All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AddProperty.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2001-2011 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 // TerraLib
21 #include "AddProperty.h"
22 #include "../../../dataaccess.h"
23 #include "../../../datatype.h"
24 #include "../../../geometry/Coord2D.h"
25 #include "../../../geometry/Envelope.h"
26 #include "../../../geometry/Geometry.h"
27 #include "../../../geometry/GeometryProperty.h"
28 #include "../../../raster/Grid.h"
29 #include "../../../raster/BandProperty.h"
30 #include "../../../raster/RasterProperty.h"
31 
32 // Qt
33 #include <QtGui/QtGui>
34 #include <QtGui/QComboBox>
35 #include <QtGui/QMessageBox>
36 
38  : QDialog(parent),
39  m_ds(ds),
40  m_property(0),
41  m_defaultValue(0)
42 {
43  if(m_ds == 0)
44  QMessageBox::critical(this, tr("Missing a Valid Data Source"), tr("Provide a valid data source!"));
45 
46  setupUi(this);
47 
48  layout()->setSizeConstraint(QLayout::SetFixedSize);
49 
50  // Get the dataset names of the data source
51  std::vector<std::string> datasetNames = m_ds->getDataSetNames();
52 
53  // Fill alphabetically the dataSetCombobox with the dataset names of the data source
54  QStringList dataSetList;
55 
56  size_t numDataSets = datasetNames.size();
57  for (size_t i = 0; i < numDataSets; ++i)
58  dataSetList << (datasetNames[i]).c_str();
59 
60  dataSetList.sort();
61  dataSetComboBox->addItems(dataSetList);
62 
63  // Fill the dataTypeComboBox with the data types available
64  // according the data source capabilities
67 
68  if(dataTypeCapabilities.supportsArray())
69  dataTypeComboBox->addItem("ARRAY");
70 
71  if(dataTypeCapabilities.supportsBit())
72  dataTypeComboBox->addItem("BIT");
73 
74  if(dataTypeCapabilities.supportsBoolean())
75  dataTypeComboBox->addItem("BOOLEAN");
76 
77  if(dataTypeCapabilities.supportsByteArray())
78  dataTypeComboBox->addItem("BYTE_ARRAY");
79 
80  if(dataTypeCapabilities.supportsChar())
81  dataTypeComboBox->addItem("CHAR");
82 
83  if(dataTypeCapabilities.supportsComposite())
84  dataTypeComboBox->addItem("COMPOSITE");
85 
86  if(dataTypeCapabilities.supportsDataset())
87  dataTypeComboBox->addItem("DATASET");
88 
89  if(dataTypeCapabilities.supportsDateTime())
90  dataTypeComboBox->addItem("DATETIME");
91 
92  if(dataTypeCapabilities.supportsDouble())
93  dataTypeComboBox->addItem("DOUBLE");
94 
95  if(dataTypeCapabilities.supportsFloat())
96  dataTypeComboBox->addItem("FLOAT");
97 
98  if(dataTypeCapabilities.supportsGeometry())
99  dataTypeComboBox->addItem("GEOMETRY");
100 
101  if(dataTypeCapabilities.supportsInt16())
102  dataTypeComboBox->addItem("INT16");
103 
104  if(dataTypeCapabilities.supportsInt32())
105  dataTypeComboBox->addItem("INT32");
106 
107  if(dataTypeCapabilities.supportsInt64())
108  dataTypeComboBox->addItem("INT64");
109 
110  if(dataTypeCapabilities.supportsNumeric())
111  dataTypeComboBox->addItem("NUMERIC");
112 
113  if(dataTypeCapabilities.supportsRaster())
114  dataTypeComboBox->addItem("RASTER");
115 
116  if(dataTypeCapabilities.supportsString())
117  dataTypeComboBox->addItem("STRING");
118 
119  if(dataTypeCapabilities.supportsUChar())
120  dataTypeComboBox->addItem("UCHAR");
121 
122  if(dataTypeCapabilities.supportsUInt16())
123  dataTypeComboBox->addItem("UINT16");
124 
125  if(dataTypeCapabilities.supportsUInt32())
126  dataTypeComboBox->addItem("UINT32");
127 
128  if(dataTypeCapabilities.supportsUInt64())
129  dataTypeComboBox->addItem("UINT64");
130 
131  // Connect the signals/slots
132  connect(dataSetComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(dataSetComboBoxChanged(const QString&)));
133  connect(autoNumberCheckBox, SIGNAL(clicked(bool)), this, SLOT(autoNumberCheckBoxClicked(bool)));
134  connect(dataTypeComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(dataTypeComboBoxChanged(const QString&)));
135  connect(requiredCheckBox, SIGNAL(clicked(bool)), this, SLOT(requiredCheckBoxClicked(bool)));
136  connect(arrayElementDataTypeComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(arrayElementDataTypeComboBoxChanged(const QString&)));
137  connect(stringTypeComboBox, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(stringTypeComboBoxChanged(const QString&)));
138  connect(okPushButton, SIGNAL(clicked()), this, SLOT(okPushButtonClicked()));
139  connect(cancelPushButton, SIGNAL(clicked()), this, SLOT(cancelPushButtonClicked()));
140  connect(helpPushButton, SIGNAL(clicked()), this, SLOT(helpPushButtonClicked()));
141 
142  dataSetComboBoxChanged(dataSetComboBox->currentText());
143  dataTypeComboBoxChanged(dataTypeComboBox->currentText());
144 }
145 
147 {
148 }
149 
151 {
152  propertiesComboBox->clear();
153 
154  std::vector<std::string> pNames = m_ds->getPropertyNames(dataSetName.toStdString());
155 
156  for (size_t i = 0; i < pNames.size(); ++i)
157  propertiesComboBox->addItem(pNames[i].c_str());
158 }
159 
161 {
162  autoNumberCheckBox->setEnabled(false);
163  autoNumberCheckBox->setChecked(false);
164 
165  requiredCheckBox->setEnabled(true);
166  requiredCheckBox->setChecked(false);
167 
168  defaultValueLineEdit->clear();
169  defaultValueLineEdit->setEnabled(false);
170 
171  dataTypeStackedWidget->setVisible(true);
172 
173  if(dataType == "ARRAY")
174  setArrayPropertyParams();
175  else if(dataType == "COMPOSITE")
176  {
177  requiredCheckBox->setEnabled(false);
178  dataTypeStackedWidget->setCurrentWidget(compositePage);
179  }
180  else if(dataType == "DATETIME")
181  setDateTimePropertyParams();
182  else if(dataType == "GEOMETRY")
183  setGeometryPropertyParams();
184  else if(dataType == "NUMERIC")
185  dataTypeStackedWidget->setCurrentWidget(numericPage);
186  else if(dataType == "RASTER")
187  {
188  requiredCheckBox->setEnabled(false);
189  dataTypeStackedWidget->setCurrentWidget(rasterPage);
190  }
191  else if(dataType == "STRING")
192  setStringPropertyParams();
193  else
194  {
195  dataTypeStackedWidget->setVisible(false);
196 
197  if(dataType == "INT32" || dataType == "INT64")
198  autoNumberCheckBox->setEnabled(true);
199  }
200 }
201 
203 {
204  requiredCheckBox->setEnabled(true);
205  defaultValueLineEdit->setEnabled(true);
206  requiredCheckBox->setChecked(false);
207  defaultValueLineEdit->clear();
208 
209  if(checked)
210  {
211  requiredCheckBox->setEnabled(false);
212  defaultValueLineEdit->setEnabled(false);
213  requiredCheckBox->setChecked(true);
214  }
215 }
216 
218 {
219  defaultValueLineEdit->clear();
220  if(checked == true)
221  defaultValueLineEdit->setEnabled(true);
222  else
223  defaultValueLineEdit->setEnabled(false);
224 }
225 
227 {
228  if(arrayElementDataType == "NUMERIC")
229  {
230  arrayElementStackedWidget->setVisible(true);
231  arrayElementStackedWidget->setCurrentWidget(arrayElementNumericPage);
232  }
233  else if(arrayElementDataType == "STRING")
234  {
235  arrayElementStackedWidget->setVisible(true);
236  arrayElementStackedWidget->setCurrentWidget(arrayElementStringPage);
237  }
238  else
239  arrayElementStackedWidget->setVisible(false);
240 }
241 
242 
244 {
245  stringSizeLineEdit->setEnabled(true);
246 
247  if(stringType == "STRING")
248  {
249  stringSizeLineEdit->clear();
250  stringSizeLineEdit->setEnabled(false);
251  }
252 }
253 
255 {
256  // Get the property name
257  if(propertyNameLineEdit->text().isEmpty())
258  {
259  QMessageBox::information(this, tr("Missing the Property Name"),
260  tr("Set the name of the new property!"));
261  return;
262  }
263 
264  m_propertyName = propertyNameLineEdit->text().toStdString();
265 
266  // Get the default value
267  if(defaultValueLineEdit->text().isEmpty())
268  m_defaultValue = 0;
269  else
270  m_defaultValue = new std::string(defaultValueLineEdit->text().toStdString());
271 
272  // Build the property
273  QString dataType = dataTypeComboBox->currentText();
274 
275  m_property = buildProperty(dataType);
276 
277  if(m_property == 0)
278  return;
279 
280  accept();
281 }
282 
284 {
285  reject();
286 }
287 
289 {
290 }
291 
293 {
294  dataTypeStackedWidget->setCurrentWidget(arrayPage);
295 
296  // Fill the arrayElementDataTypeComboBox with the
297  // array element types currently supported
298  if(arrayElementDataTypeComboBox->count() == 0)
299  {
300  for(int i = 0; i < dataTypeComboBox->count(); ++i)
301  {
302  QString dataType = dataTypeComboBox->itemText(i);
303 
304  if(dataType == "ARRAY" || dataType == "COMPOSITE" ||
305  dataType == "GEOMETRY" || dataType == "RASTER")
306  continue;
307 
308  arrayElementDataTypeComboBox->addItem(dataType);
309  }
310  }
311 
312  // Fill the arrayElementStringTypeComboBox with the string types
313  if (arrayElementStringTypeComboBox->count() == 0)
314  {
315  arrayElementStringTypeComboBox->addItem("FIXED_STRING");
316  arrayElementStringTypeComboBox->addItem("VAR_STRING");
317  arrayElementStringTypeComboBox->addItem("STRING");
318  }
319 }
320 
322 {
323  dataTypeStackedWidget->setCurrentWidget(dateTimePage);
324 
325  // Fill the dateTimeTypeComboBox with the datetime types
326  if (dateTimeTypeComboBox->count() == 0)
327  {
328  dateTimeTypeComboBox->addItem("DATE");
329  dateTimeTypeComboBox->addItem("DATE_PERIOD");
330  dateTimeTypeComboBox->addItem("DATE_DURATION");
331  dateTimeTypeComboBox->addItem("TIME_DURATION");
332  dateTimeTypeComboBox->addItem("TIME_INSTANT");
333  dateTimeTypeComboBox->addItem("TIME_PERIOD");
334  dateTimeTypeComboBox->addItem("TIME_INSTANT_TZ");
335  dateTimeTypeComboBox->addItem("TIME_PERIOD_TZ");
336  }
337 
338  QMessageBox::warning(this, tr("Add Operation Not Implemented"),
339  tr("The add operation for the datetime property was not implemented yet!"));
340 }
341 
343 {
344  dataTypeStackedWidget->setCurrentWidget(geometryPage);
345 
346  // Fill the geometryTypeComboBox with the geometry types
347  if (geometryTypeComboBox->count() == 0)
348  {
349  geometryTypeComboBox->addItem("GEOMETRY");
350  geometryTypeComboBox->addItem("GEOMETRYZ");
351  geometryTypeComboBox->addItem("GEOMETRYM");
352  geometryTypeComboBox->addItem("GEOMETRYZM");
353  geometryTypeComboBox->addItem("POINT");
354  geometryTypeComboBox->addItem("POINTZ");
355  geometryTypeComboBox->addItem("POINTM");
356  geometryTypeComboBox->addItem("POINTZM");
357  geometryTypeComboBox->addItem("LINESTRING");
358  geometryTypeComboBox->addItem("LINESTRINGZ");
359  geometryTypeComboBox->addItem("LINESTRINGM");
360  geometryTypeComboBox->addItem("LINESTRINGZM");
361  geometryTypeComboBox->addItem("POLYGON");
362  geometryTypeComboBox->addItem("POLYGONZ");
363  geometryTypeComboBox->addItem("POLYGONM");
364  geometryTypeComboBox->addItem("POLYGONZM");
365  geometryTypeComboBox->addItem("GEOMETRYCOLLECTION");
366  geometryTypeComboBox->addItem("GEOMETRYCOLLECTIONZ");
367  geometryTypeComboBox->addItem("GEOMETRYCOLLECTIONM");
368  geometryTypeComboBox->addItem("GEOMETRYCOLLECTIONZM");
369  geometryTypeComboBox->addItem("MULTIPOINT");
370  geometryTypeComboBox->addItem("MULTIPOINTZ");
371  geometryTypeComboBox->addItem("MULTIPOINTM");
372  geometryTypeComboBox->addItem("MULTIPOINTZM");
373  geometryTypeComboBox->addItem("MULTILINESTRING");
374  geometryTypeComboBox->addItem("MULTILINESTRINGZ");
375  geometryTypeComboBox->addItem("MULTILINESTRINGM");
376  geometryTypeComboBox->addItem("MULTILINESTRINGZM");
377  geometryTypeComboBox->addItem("MULTIPOLYGON");
378  geometryTypeComboBox->addItem("MULTIPOLYGONZ");
379  geometryTypeComboBox->addItem("MULTIPOLYGONM");
380  geometryTypeComboBox->addItem("MULTIPOLYGONZM");
381  geometryTypeComboBox->addItem("UNKNOWNGEOMETRY");
382  }
383 }
384 
386 {
387  dataTypeStackedWidget->setCurrentWidget(stringPage);
388 
389  // Fill the stringTypeComboBox with the string types
390  if (stringTypeComboBox->count() == 0)
391  {
392  stringTypeComboBox->addItem("FIXED_STRING");
393  stringTypeComboBox->addItem("VAR_STRING");
394  stringTypeComboBox->addItem("STRING");
395  }
396 }
397 
399 {
400  if(dataType == "ARRAY")
401  return buildArrayProperty();
402  else if(dataType == "BIT")
403  return buildBitProperty();
404  else if(dataType == "BOOLEAN")
405  return buildBooleanProperty();
406  else if(dataType == "BYTE_ARRAY")
407  return buildByteArrayProperty();
408  else if(dataType == "CHAR")
409  return buildCharProperty();
410  else if(dataType == "COMPOSITE")
411  return buildCompositeProperty();
412  else if(dataType == "DATETIME")
413  return buildDateTimeProperty();
414  else if(dataType == "DOUBLE")
415  return buildDoubleProperty();
416  else if(dataType == "FLOAT")
417  return buildFloatProperty();
418  else if(dataType == "GEOMETRY")
419  return buildGeometryProperty();
420  else if(dataType == "INT16")
421  return buildInt16Property();
422  else if (dataType == "INT32")
423  return buildInt32Property();
424  else if(dataType == "INT64")
425  return buildInt64Property();
426  else if(dataType == "NUMERIC")
427  return buildNumericProperty();
428  else if(dataType == "RASTER")
429  return buildRasterProperty();
430  else if(dataType == "STRING")
431  return buildStringProperty();
432  else if(dataType == "UCHAR")
433  return buildUcharProperty();
434  else if(dataType == "UINT16")
435  return buildUint16Property();
436  else if(dataType == "UINT32")
437  return buildUint32Property();
438  else if(dataType == "UINT64")
439  return buildUint64Property();
440  else if(dataType == "UNKNOWN")
441  return buildUnknownProperty();
442  else if(dataType == "VOID")
443  return buildVoidProperty();
444 
445  return 0;
446 }
447 
449 {
450  // Get the dimension
451  unsigned int dimension = 1;
452  if(arrayDimensionLineEdit->text().isEmpty() == false)
453  {
454  bool ok;
455  dimension = arrayDimensionLineEdit->text().toUInt(&ok);
456  if(ok == false)
457  {
458  QMessageBox::warning(this, tr("Invalid Value"),
459  tr("The array dimension must be an unsigned int value!"));
460  return 0;
461  }
462  }
463 
464  // Build the array element property
465  te::dt::SimpleProperty* arrayElementProperty;
466 
467  QString arrayElementDataType = arrayElementDataTypeComboBox->currentText();
468 
469  std::string tempPropertyName = m_propertyName;
470  m_propertyName = std::string();
471 
472  std::string* tempDefaultValue = m_defaultValue;
473  m_defaultValue = 0;
474 
475  arrayElementProperty = static_cast<te::dt::SimpleProperty*>(buildProperty(arrayElementDataType));
476  arrayElementProperty->setAutoNumber(false);
477  arrayElementProperty->setRequired(false);
478 
479  m_propertyName = tempPropertyName;
480  m_defaultValue = tempDefaultValue;
481 
482  if(dimension != 1)
483  {
484  te::dt::SimpleProperty* simpleP = arrayElementProperty;
485 
486  arrayElementProperty = 0;
487 
488  for(unsigned int i = 0; i < dimension - 2; ++i)
489  arrayElementProperty = new te::dt::ArrayProperty(std::string(), arrayElementProperty);
490 
491  arrayElementProperty = new te::dt::ArrayProperty(std::string(), simpleP);
492  }
493 
494  return new te::dt::ArrayProperty(m_propertyName, arrayElementProperty,
495  requiredCheckBox->isChecked(), m_defaultValue);
496 }
497 
499 {
500  if(m_defaultValue != 0)
501  {
502  for(size_t i = 0; i < m_defaultValue->size(); ++i)
503  {
504  if(m_defaultValue->operator[](i) == '0' || m_defaultValue->operator[](i) == '1')
505  {
506  QMessageBox::warning(this, tr("Default Value Error"),
507  tr("The default value contents for the BIT property can only contains 0's or 1's!"));
508  return 0;
509  }
510  }
511  }
512 
513  return new te::dt::SimpleProperty(m_propertyName, te::dt::BIT_TYPE,
514  requiredCheckBox->isChecked(), m_defaultValue);
515 }
516 
518 {
519  if(m_defaultValue != 0)
520  {
521  QString qs = defaultValueLineEdit->text().toUpper();
522 
523  if(qs != "TRUE" && qs != "FALSE")
524  {
525  QMessageBox::warning(this, tr("Default Value Error"),
526  tr("The default value for the BOOLEAN property can only be: true, TRUE, false, or FALSE"));
527  return 0;
528  }
529  }
530 
531  return new te::dt::SimpleProperty(m_propertyName, te::dt::BOOLEAN_TYPE,
532  requiredCheckBox->isChecked(), m_defaultValue);
533 }
534 
536 {
537  return new te::dt::SimpleProperty(m_propertyName, te::dt::BYTE_ARRAY_TYPE,
538  requiredCheckBox->isChecked(), m_defaultValue);
539 }
540 
541 
543 {
544  if(m_defaultValue != 0)
545  {
546  bool ok;
547  int val = defaultValueLineEdit->text().toInt(&ok);
548 
549  if(ok == false || val <-128 || val > 127)
550  {
551  QMessageBox::warning(this, tr("Default Value Error"),
552  tr("The default value must be a char value >= -128 and <= 127!"));
553  return 0;
554  }
555  }
556 
557  return new te::dt::SimpleProperty(m_propertyName, te::dt::CHAR_TYPE,
558  requiredCheckBox->isChecked(), m_defaultValue);
559 }
560 
562 {
563  std::string cname = std::string();
564 
565  if(compositeNameLineEdit->text().isEmpty() == false)
566  cname = compositeNameLineEdit->text().toStdString();
567 
568  return new te::dt::CompositeProperty(cname, m_propertyName);
569 }
570 
572 {
573  // Get the DateTime type
574  te::dt::DateTimeType dateTimeType =
575  static_cast<te::dt::DateTimeType>(dateTimeTypeComboBox->currentIndex());
576 
577  // Build the DateTime property
578  te::dt::Property* dateTimeProperty = new te::dt::DateTimeProperty(m_propertyName,
579  dateTimeType, te::dt::SECOND, requiredCheckBox->isChecked(), m_defaultValue);
580 
581  return dateTimeProperty;
582  }
583 
585 {
586  if(m_defaultValue != 0)
587  {
588  bool ok;
589 
590  defaultValueLineEdit->text().toDouble(&ok);
591  if(ok == false)
592  {
593  QMessageBox::warning(this, tr("Default Value Error"),
594  tr("The default value must be a double number!"));
595  return 0;
596  }
597  }
598 
599  return new te::dt::SimpleProperty(m_propertyName, te::dt::DOUBLE_TYPE,
600  requiredCheckBox->isChecked(), m_defaultValue);
601 }
602 
604 {
605  if(m_defaultValue != 0)
606  {
607  bool ok;
608 
609  defaultValueLineEdit->text().toFloat(&ok);
610  if(ok == false)
611  {
612  QMessageBox::warning(this, tr("Default Value Error"),
613  tr("The default value must be a float number!"));
614  return 0;
615  }
616  }
617 
618  return new te::dt::SimpleProperty(m_propertyName, te::dt::FLOAT_TYPE,
619  requiredCheckBox->isChecked(), m_defaultValue);
620 }
621 
623 {
624  // Get the geometry subtype
625  std::string gTypeStr = geometryTypeComboBox->currentText().toStdString();
627 
628  // Get the srid
629  int srid = 0;
630  if (geometrySRIDLineEdit->text().isEmpty() == false)
631  {
632  bool ok;
633  srid = geometrySRIDLineEdit->text().toInt(&ok);
634  if(ok == false)
635  {
636  QMessageBox::warning(this, tr("Invalid SRID"),
637  tr("The SRID for the GEOMETRY property must be an integer number!"));
638  return 0;
639  }
640  }
641 
642  return new te::gm::GeometryProperty(m_propertyName, srid, gType,
643  requiredCheckBox->isChecked(), m_defaultValue);
644 }
645 
647 {
648  if(m_defaultValue != 0)
649  {
650  bool ok;
651 
652  defaultValueLineEdit->text().toShort(&ok);
653  if(ok == false)
654  {
655  QMessageBox::warning(this, tr("Default Value Error"),
656  tr("The default value must be a short value!"));
657  return 0;
658  }
659  }
660 
661  return new te::dt::SimpleProperty(m_propertyName, te::dt::INT16_TYPE,
662  requiredCheckBox->isChecked(), m_defaultValue);
663 }
664 
666 {
667  if(m_defaultValue != 0)
668  {
669  bool ok;
670 
671  defaultValueLineEdit->text().toInt(&ok);
672  if(ok == false)
673  {
674  QMessageBox::warning(this, tr("Default Value Error"),
675  tr("The default value must be an integer value!"));
676  return 0;
677  }
678  }
679 
681  requiredCheckBox->isChecked(), m_defaultValue);
682 
683  p->setAutoNumber(autoNumberCheckBox->isChecked());
684 
685  return p;
686 }
687 
689 {
690  if(m_defaultValue != 0)
691  {
692  bool ok;
693 
694  defaultValueLineEdit->text().toLongLong(&ok);
695  if(ok == false)
696  {
697  QMessageBox::warning(this, tr("Default Value Error"),
698  tr("The default value must be a long long value!"));
699  return 0;
700  }
701  }
702 
704  requiredCheckBox->isChecked(), m_defaultValue);
705 
706  p->setAutoNumber(autoNumberCheckBox->isChecked());
707 
708  return p;
709 }
710 
712 {
713  bool ok = false;
714 
715  // Check the default value
716  if(dataTypeComboBox->currentText() == "NUMERIC")
717  {
718  if(m_defaultValue != 0)
719  {
720  defaultValueLineEdit->text().toDouble(&ok);
721  if(ok == false)
722  {
723  QMessageBox::warning(this, tr("Default Value Error"),
724  tr("The default value must be a numeric value!"));
725  return 0;
726  }
727  }
728  }
729 
730  // Get the precision value
731  unsigned int precision = 0;
732 
733  if(dataTypeComboBox->currentText() == "NUMERIC")
734  {
735  if(precisionLineEdit->text().isEmpty() == false)
736  precision = precisionLineEdit->text().toUInt(&ok);
737  }
738  else
739  {
740  if(arrayElementPrecisionLineEdit->text().isEmpty() == false)
741  precision = arrayElementPrecisionLineEdit->text().toUInt(&ok);
742  }
743 
744  if(ok == false)
745  {
746  QMessageBox::warning(this, tr("Invalid Value"),
747  tr("The precision must be an unsigned int value!"));
748  return 0;
749  }
750 
751  // Get the scale value
752  unsigned int scale = 0;
753 
754  if(dataTypeComboBox->currentText() == "NUMERIC")
755  {
756  if(scaleLineEdit->text().isEmpty() == false)
757  scale = scaleLineEdit->text().toUInt(&ok);
758  }
759  else
760  {
761  if(arrayElementScaleLineEdit->text().isEmpty() == false)
762  scale = arrayElementScaleLineEdit->text().toUInt(&ok);
763  }
764 
765  if(ok == false)
766  {
767  QMessageBox::warning(this, tr("Invalid Value"),
768  tr("The scale must be an unsigned int value!"));
769  return 0;
770  }
771 
772  return new te::dt::NumericProperty(m_propertyName,
773  precision, scale, requiredCheckBox->isChecked(), m_defaultValue);
774 }
775 
777 {
778  bool ok = false;
779 
780  // Get the srid
781  int srid = 0;
782  if (rasterSRIDLineEdit->text().isEmpty() == false)
783  {
784  srid = rasterSRIDLineEdit->text().toInt(&ok);
785  if(ok == false)
786  {
787  QMessageBox::warning(this, tr("Invalid Value"),
788  tr("The SRID must be an integer value!"));
789  return 0;
790  }
791  }
792 
793  // Get the number of columns
794  unsigned int nCols = 0;
795  if (nColsLineEdit->text().isEmpty() == false)
796  {
797  nCols = nColsLineEdit->text().toUInt(&ok);
798  if(ok == false)
799  {
800  QMessageBox::warning(this, tr("Invalid Value"),
801  tr("The number of columns must be an unsigned integer value!"));
802  return 0;
803  }
804  }
805 
806  // Get the number of lines
807  unsigned int nLines = 0;
808  if (nLinesLineEdit->text().isEmpty() == false)
809  {
810  nLines = nLinesLineEdit->text().toUInt();
811  if(ok == false)
812  {
813  QMessageBox::warning(this, tr("Invalid Value"),
814  tr("The number of lines must be an unsigned integer value!"));
815  return 0;
816  }
817  }
818 
819  // Get the X resolution
820  float resX = 0.;
821  if (resxLineEdit->text().isEmpty() == false)
822  {
823  resX = resxLineEdit->text().toFloat(&ok);
824  if(ok == false)
825  {
826  QMessageBox::warning(this, tr("Invalid Value"),
827  tr("The X resolution must be a float value!"));
828  return 0;
829  }
830  }
831 
832  // Get the Y resolution
833  float resY = 0.;
834  if (resyLineEdit->text().isEmpty() == false)
835  {
836  resY = resyLineEdit->text().toFloat();
837  if(ok == false)
838  {
839  QMessageBox::warning(this, tr("Invalid Value"),
840  tr("The Y resolution must be a float value!"));
841  return 0;
842  }
843  }
844 
845  // Get the envelope
846  double llx = 0.0;
847  double lly = 0.0;
848  double urx = 0.0;
849  double ury = 0.0;
850 
851  if(rasterLLXLineEdit->text().isEmpty() == false)
852  {
853  llx = rasterLLXLineEdit->text().toDouble(&ok);
854  if(ok == false)
855  {
856  QMessageBox::warning(this, tr("Invalid Value"),
857  tr("The LLX coordinate must be a double value!"));
858  return 0;
859  }
860  }
861 
862  if(rasterLLYLineEdit->text().isEmpty() == false)
863  {
864  lly = rasterLLYLineEdit->text().toDouble(&ok);
865  if(ok == false)
866  {
867  QMessageBox::warning(this, tr("Invalid Value"),
868  tr("The LLY coordinate must be a double value!"));
869  return 0;
870  }
871  }
872 
873  if(rasterURXLineEdit->text().isEmpty() == false)
874  {
875  urx = rasterURXLineEdit->text().toDouble(&ok);
876  if(ok == false)
877  {
878  QMessageBox::warning(this, tr("Invalid Value"),
879  tr("The URX coordinate must be a double value!"));
880  return 0;
881  }
882  }
883 
884  if(rasterURYLineEdit->text().isEmpty() == false)
885  {
886  ury = rasterURYLineEdit->text().toDouble(&ok);
887  if(ok == false)
888  {
889  QMessageBox::warning(this, tr("Invalid Value"),
890  tr("The URY coordinate must be a double value!"));
891  return 0;
892  }
893  }
894 
895  // Get the number of bands
896  unsigned int nBands = 0;
897 
898  if (nBandsLineEdit->text().isEmpty() == false)
899  {
900  nBands = nBandsLineEdit->text().toUInt(&ok);
901  if(ok == false)
902  {
903  QMessageBox::warning(this, tr("Invalid Value"),
904  tr("The number of bands must be an unsigned integer value!"));
905  return 0;
906  }
907  }
908 
909  // Build the raster property
910  te::rst::Grid* grid = new te::rst::Grid(nCols,nLines);
911  grid->setGeoreference(te::gm::Coord2D(llx, ury), srid, resX, resY);
912 
913  std::map<std::string, std::string> rinfo;
914 
915  // how to retrieve the band data type?
916  std::vector<te::rst::BandProperty*> bprops;
917  for (unsigned b = 0; b < nBands; b++)
918  bprops.push_back(new te::rst::BandProperty(b, te::dt::CHAR_TYPE));
919 
920  te::rst::RasterProperty* rp = new te::rst::RasterProperty(grid, bprops, rinfo, requiredCheckBox->isChecked());
921 
922  return rp;
923 }
924 
926 {
927  // Get the string type and the string size
928  te::dt::StringType stringType;
929  size_t stringSize = 0;
930  bool ok = false;
931 
932  if(dataTypeComboBox->currentText() == "STRING")
933  {
934  stringType = static_cast<te::dt::StringType>(stringTypeComboBox->currentIndex());
935 
936  if(stringSizeLineEdit->text().isEmpty() == false)
937  stringSize = stringSizeLineEdit->text().toUInt(&ok);
938  }
939  else
940  {
941  stringType = static_cast<te::dt::StringType>(arrayElementStringTypeComboBox->currentIndex());
942 
943  if(arrayElementStringSizeLineEdit->text().isEmpty() == false)
944  stringSize = arrayElementStringSizeLineEdit->text().toUInt(&ok);
945  }
946 
947  if(ok == false)
948  {
949  QMessageBox::warning(this, tr("Invalid Value"),
950  tr("The string size must be an unsigned int value!"));
951  return 0;
952  }
953 
954  te::dt::Property* stringProperty = new te::dt::StringProperty(m_propertyName,
955  stringType, stringSize, requiredCheckBox->isChecked(), m_defaultValue);
956 
957  return stringProperty;
958 }
959 
961 {
962  if(m_defaultValue != 0)
963  {
964  bool ok;
965 
966  unsigned int val = defaultValueLineEdit->text().toUShort(&ok);
967  if(ok == false || val > 255)
968  {
969  QMessageBox::warning(this, tr("Default Value Error"),
970  tr("The default value must be an unsigned char value!"));
971  return 0;
972  }
973  }
974 
975  return new te::dt::SimpleProperty(m_propertyName, te::dt::UCHAR_TYPE,
976  requiredCheckBox->isChecked(), m_defaultValue);
977 }
978 
980 {
981  if(m_defaultValue != 0)
982  {
983  bool ok;
984 
985  defaultValueLineEdit->text().toUShort(&ok);
986  if(ok == false)
987  {
988  QMessageBox::warning(this, tr("Default Value Error"),
989  tr("The default value must be an unsigned short value!"));
990  return 0;
991  }
992  }
993 
994  return new te::dt::SimpleProperty(m_propertyName, te::dt::UINT32_TYPE,
995  requiredCheckBox->isChecked(), m_defaultValue);
996 }
997 
999 {
1000  if(m_defaultValue != 0)
1001  {
1002  bool ok;
1003 
1004  defaultValueLineEdit->text().toUInt(&ok);
1005  if(ok == false)
1006  {
1007  QMessageBox::warning(this, tr("Default Value Error"),
1008  tr("The default value must be an unsigned integer value!"));
1009  return 0;
1010  }
1011  }
1012 
1013  return new te::dt::SimpleProperty(m_propertyName, te::dt::UINT32_TYPE,
1014  requiredCheckBox->isChecked(), m_defaultValue);
1015 }
1016 
1018 {
1019  if(m_defaultValue != 0)
1020  {
1021  bool ok;
1022 
1023  defaultValueLineEdit->text().toULongLong(&ok);
1024  if(ok == false)
1025  {
1026  QMessageBox::warning(this, tr("Default Value Error"),
1027  tr("The default value must be an unsigned long long value!"));
1028  return 0;
1029  }
1030  }
1031 
1032  return new te::dt::SimpleProperty(m_propertyName, te::dt::UINT64_TYPE,
1033  requiredCheckBox->isChecked(), m_defaultValue);
1034 }
1035 
1037 {
1038  return new te::dt::SimpleProperty(m_propertyName, te::dt::UNKNOWN_TYPE,
1039  false, 0);
1040 }
1041 
1043 {
1044  return new te::dt::SimpleProperty(m_propertyName, te::dt::VOID_TYPE,
1045  false, 0);
1046 }
1047 
1049 {
1050 }
te::dt::Property * buildCharProperty()
te::dt::Property * buildNumericProperty()
void setRequired(bool r)
It tells if the property is required or not.
te::da::DataTypeCapabilities dataTypeCapabilities
The type for variable-length multidimensional arrays.
Definition: ArrayProperty.h:45
te::dt::Property * buildRasterProperty()
void arrayElementDataTypeComboBoxChanged(const QString &arrayElementDataType)
te::dt::Property * buildStringProperty()
void autoNumberCheckBoxClicked(bool checked)
void stringTypeComboBoxChanged(const QString &stringType)
An atomic property like an integer or double.
virtual std::vector< std::string > getDataSetNames()
It gets the dataset names available in the data source.
Definition: DataSource.cpp:143
te::dt::Property * buildDateTimeProperty()
te::dt::Property * buildUint64Property()
virtual const DataSourceCapabilities & getCapabilities() const =0
It returns the known capabilities of the data source.
void requiredCheckBoxClicked(bool checked)
The type for date and time types: date, date period, date duration, time duration, time instant, time period, time instant with time zone or time period with time zone.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
It adds a property to a data set.
void closeEvent(QCloseEvent *e)
void dataSetComboBoxChanged(const QString &dataSetName)
te::dt::Property * buildVoidProperty()
te::dt::Property * buildInt64Property()
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
te::dt::Property * buildUint16Property()
te::dt::Property * buildInt32Property()
void setGeoreference(const te::gm::Coord2D &ulLocation, int srid, double resX, double resY)
Sets the information needed to georeference the grid.
Definition: Grid.cpp:220
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
te::da::DataSource * m_ds
Definition: AddProperty.h:105
te::dt::Property * buildFloatProperty()
te::dt::Property * buildByteArrayProperty()
A rectified grid is the spatial support for raster data.
Definition: Grid.h:55
te::dt::Property * buildBitProperty()
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
te::dt::Property * buildCompositeProperty()
AddProperty(te::da::DataSource *ds, QWidget *parent=0)
Definition: AddProperty.cpp:37
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
Definition: Geometry.h:178
te::dt::Property * buildUint32Property()
const DataTypeCapabilities & getDataTypeCapabilities() const
DateTimeType
The subtype of date and time type.
Definition: Enums.h:38
te::dt::Property * buildArrayProperty()
te::dt::Property * buildInt16Property()
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:116
A raster band description.
Definition: BandProperty.h:61
StringType
The subtype of string property.
Definition: Enums.h:107
te::dt::Property * buildUcharProperty()
Raster property.
It models a property definition.
Definition: Property.h:59
A base class for a compound property (non-atomic properties).
te::dt::Property * buildUnknownProperty()
te::dt::Property * buildGeometryProperty()
void dataTypeComboBoxChanged(const QString &dataType)
The type for arbitrary precison numbers, like numeric(p, q).
te::dt::Property * buildDoubleProperty()
A class that represents the supported data types of a specific data source.
te::dt::Property * buildBooleanProperty()
Geometric property.
te::da::DataSourceCapabilities capabilities
te::dt::Property * buildProperty(const QString &dataType)