Difference.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 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 /*!
21  \file Difference.cpp
22  */
23 
24 #include "../core/logger/Logger.h"
25 #include "../core/translator/Translator.h"
26 
27 #include "../dataaccess/dataset/DataSet.h"
28 #include "../dataaccess/dataset/DataSetAdapter.h"
29 #include "../dataaccess/dataset/DataSetType.h"
30 #include "../dataaccess/dataset/DataSetTypeConverter.h"
31 #include "../dataaccess/dataset/ObjectIdSet.h"
32 #include "../dataaccess/datasource/DataSource.h"
33 #include "../dataaccess/datasource/DataSourceInfo.h"
34 #include "../dataaccess/datasource/DataSourceInfoManager.h"
35 #include "../dataaccess/datasource/DataSourceCapabilities.h"
36 #include "../dataaccess/datasource/DataSourceTransactor.h"
37 
38 #include "../dataaccess/query/And.h"
39 #include "../dataaccess/query/Coalesce.h"
40 #include "../dataaccess/query/DataSetName.h"
41 #include "../dataaccess/query/EqualTo.h"
42 #include "../dataaccess/query/Expression.h"
43 #include "../dataaccess/query/Field.h"
44 #include "../dataaccess/query/Fields.h"
45 #include "../dataaccess/query/From.h"
46 #include "../dataaccess/query/GeometryType.h"
47 #include "../dataaccess/query/Insert.h"
48 #include "../dataaccess/query/LiteralString.h"
49 #include "../dataaccess/query/PropertyName.h"
50 #include "../dataaccess/query/Not.h"
51 #include "../dataaccess/query/Select.h"
52 #include "../dataaccess/query/SelectExpression.h"
53 #include "../dataaccess/query/SubSelect.h"
54 #include "../dataaccess/query/ST_Difference.h"
55 #include "../dataaccess/query/ST_Dump.h"
56 #include "../dataaccess/query/ST_Intersects.h"
57 #include "../dataaccess/query/ST_IsEmpty.h"
58 #include "../dataaccess/query/ST_Multi.h"
59 #include "../dataaccess/query/ST_Union.h"
60 #include "../dataaccess/query/Where.h"
61 
62 #include "../dataaccess/utils/Utils.h"
63 
64 #include "../datatype/Property.h"
65 #include "../datatype/SimpleData.h"
66 #include "../datatype/StringProperty.h"
67 
68 #include "../geometry/Geometry.h"
69 #include "../geometry/GeometryCollection.h"
70 #include "../geometry/GeometryProperty.h"
71 #include "../geometry/MultiLineString.h"
72 #include "../geometry/MultiPoint.h"
73 #include "../geometry/MultiPolygon.h"
74 #include "../geometry/Utils.h"
75 
76 #include "../memory/DataSet.h"
77 #include "../memory/DataSetItem.h"
78 
79 #include "AlgorithmParams.h"
80 #include "ComplexData.h"
81 #include "Difference.h"
82 #include "Exception.h"
83 #include "Utils.h"
84 
85 // BOOST
86 #include <boost/lexical_cast.hpp>
87 #include <boost/uuid/random_generator.hpp>
88 #include <boost/uuid/uuid_io.hpp>
89 
91 
93 {
95 
96  // Validating parameters
97  std::vector<te::vp::InputParams> inputParams = mainParams->getInputParams();
98 
99  if(inputParams.size() < 2)
101  "It is necessary more than one item for performing the operation."));
102 
103  te::da::DataSetType* dsType_input = inputParams[0].m_inputDataSetType;
104 
105  te::gm::GeometryProperty* inputGeomProp =
106  te::da::GetFirstGeomProperty(dsType_input);
107 
108  te::da::DataSetType* dsType_difference = inputParams[1].m_inputDataSetType;
109 
110  te::gm::GeometryProperty* differenceGeomProp =
111  te::da::GetFirstGeomProperty(dsType_difference);
112 
113  te::da::DataSet* inputDataSet = inputParams[0].m_inputDataSet;
114 
115  te::da::DataSet* differenceDataSet = inputParams[1].m_inputDataSet;
116 
117  te::da::DataSourcePtr outputDataSource = mainParams->getOutputDataSource();
118 
119  // Build output dataset type
120  std::unique_ptr<te::da::DataSetType> outputDataSetType(
121  getOutputDataSetType(mainParams));
122 
123  // Get the first geometry property from output datasettype.
124  te::gm::GeometryProperty* geomProp =
125  te::da::GetFirstGeomProperty(outputDataSetType.get());
126 
127  // Insert difference dataset in rtree.
129 
130  // Get specific params.
131  const std::map<std::string, te::dt::AbstractData*>& specificParams =
132  mainParams->getSpecificParams();
133 
134  bool isCollection = this->isCollection(specificParams);
135 
136  // Create output dataset in memory.
137  std::unique_ptr<te::mem::DataSet> outputDataSet(
138  new te::mem::DataSet(outputDataSetType.get()));
139 
140  size_t p = 0;
141  int inputSRID = inputGeomProp->getSRID();
142  int differenceSRID = differenceGeomProp->getSRID();
143 
144  std::string intupGeomName = inputGeomProp->getName();
145  std::string differenceGeomName = differenceGeomProp->getName();
146 
147  differenceDataSet->moveBeforeFirst();
148  while(differenceDataSet->moveNext())
149  {
150  try
151  {
152  if (differenceDataSet->isNull(differenceGeomName))
153  continue;
154 
155  std::unique_ptr<te::gm::Geometry> g = differenceDataSet->getGeometry(differenceGeomName);
156 
157  if(!g->isValid())
158  continue;
159 
160  rtree->insert(*g->getMBR(), p);
161 
162  ++p;
163  }
164  catch(te::common::Exception& e)
165  {
166  TE_LOG_ERROR("Vector Processing - Difference: " + e.what());
167  continue;
168  }
169  }
170 
171  std::vector<std::string> propNames = this->getPropNames(specificParams);
172 
173  inputDataSet->moveBeforeFirst();
174  while(inputDataSet->moveNext())
175  {
176  // Create DataSetItem based on output DataSet;
177  std::unique_ptr<te::mem::DataSetItem> item(
178  new te::mem::DataSetItem(outputDataSet.get()));
179 
180  // Populate item with tabular data.
181  for(std::size_t p = 0; p < propNames.size(); ++p)
182  item->setValue(propNames[p],
183  inputDataSet->getValue(propNames[p]).release());
184 
185  try
186  {
187  // Current geometry from Input Layer.
188  std::unique_ptr<te::gm::Geometry> geom =
189  inputDataSet->getGeometry(intupGeomName);
190 
191  if(!geom.get() || !geom->isValid())
192  {
193  TE_LOG_INFO("Vector Processing - Difference: Input layer has invalid geometry.");
194  continue;
195  }
196 
197  // If is different srid, transform current geom to the "difference"
198  // projection, to search in rtree the candidates.
199  if(inputSRID != differenceSRID)
200  geom->transform(differenceSRID);
201 
202  std::vector<size_t> report;
203  rtree->search(*geom->getMBR(), report);
204 
205  // If the geom SRID was changed, return to original SRID.
206  if(geom->getSRID() != inputSRID)
207  geom->transform(inputSRID);
208 
209  // Difference Operation.
210  std::vector<te::gm::Geometry*> unionVec;
211  std::unique_ptr<te::gm::Geometry> unionGeom;
212 
213  for(size_t i = 0; i < report.size(); ++i)
214  {
215  differenceDataSet->move(report[i]);
216 
217  std::unique_ptr<te::gm::Geometry> diffGeom =
218  differenceDataSet->getGeometry(differenceGeomName);
219 
220  if(diffGeom->isValid())
221  unionVec.push_back(diffGeom.release());
222  }
223 
224  // If the search is empty, insert this item into Output dataSet;
225  if(unionVec.empty())
226  {
227  // Insert the current geometry into item;
228  std::vector<te::gm::Geometry*> geomVec;
229 
230  if(isCollection)
231  geomVec.push_back(geom.release());
232  else
233  te::gm::Multi2Single(geom.get(), geomVec);
234 
235  for(std::size_t g = 0; g < geomVec.size(); ++g)
236  {
237  if(!te::gm::IsMultiType(geomVec[g]->getGeomTypeId()) && isCollection)
238  geomVec[g] = setGeomAsMulti(geomVec[g]);
239 
240  std::unique_ptr<te::mem::DataSetItem> currentItem = item->clone();
241  currentItem->setGeometry(geomProp->getName(), geomVec[g]);
242 
243  // Insert this item into Output dataSet;
244  outputDataSet->add(currentItem.release());
245  }
246 
247  continue;
248  }
249 
250  unionGeom = te::gm::GetGeometryUnion(unionVec);
251 
252  if(inputSRID != differenceSRID)
253  unionGeom->transform(inputSRID);
254 
255  geom.reset(geom->difference(unionGeom.get()));
256 
257  if(!geom->isEmpty())
258  {
259  // Insert the current geometry into item;
260  std::vector<te::gm::Geometry*> geomVec;
261 
262  if(isCollection)
263  geomVec.push_back(geom.release());
264  else
265  te::gm::Multi2Single(geom.get(), geomVec);
266 
267  for(std::size_t g = 0; g < geomVec.size(); ++g)
268  {
269  if(!te::gm::IsMultiType(geomVec[g]->getGeomTypeId()) && isCollection)
270  geomVec[g] = setGeomAsMulti(geomVec[g]);
271 
272  std::unique_ptr<te::mem::DataSetItem> currentItem = item->clone();
273  currentItem->setGeometry(geomProp->getName(), geomVec[g]);
274 
275  // Insert this item into Output dataSet;
276  outputDataSet->add(currentItem.release());
277  }
278  }
279  }
280  catch(const std::exception& e)
281  {
282  std::string str = "Vector Processing - Difference: GEOS Exception - ";
283  str += e.what();
284  TE_LOG_ERROR(str);
285 
286  continue;
287  }
288  }
289 
290  std::unique_ptr<te::da::DataSet> dataSetPrepared =
291  PrepareAdd(outputDataSet.release(), outputDataSetType.get());
292 
293  if(!dataSetPrepared.get())
294  throw te::common::Exception(
295  TE_TR("Output DataSet was not prepared to save."));
296 
297  if(dataSetPrepared->size() == 0)
298  throw te::common::Exception("The resultant layer is empty!");
299 
300  Save(outputDataSource.get(), dataSetPrepared.get(), outputDataSetType.get());
301 
302  return true;
303 }
304 
306 {
308 
309  // Validating parameters
310  std::vector<te::vp::InputParams> inputParams = mainParams->getInputParams();
311 
312  if(inputParams.size() < 2)
314  "It is necessary more than one item for performing the operation."));
315 
316  te::da::DataSetType* dsType_input = inputParams[0].m_inputDataSetType;
317 
318  te::gm::GeometryProperty* geom_input =
319  te::da::GetFirstGeomProperty(dsType_input);
320 
321  std::string aliasInput = dsType_input->getName();
322 
323  te::da::DataSetType* dsType_difference = inputParams[1].m_inputDataSetType;
324 
325  te::gm::GeometryProperty* geom_difference =
326  te::da::GetFirstGeomProperty(dsType_difference);
327 
328  std::string aliasDifference = dsType_difference->getName();
329 
330  te::da::Select* selectInput = inputParams[0].m_inputQuery;
331  te::da::SubSelect* subSelectInput =
332  new te::da::SubSelect(selectInput, "inputLayer");
333  aliasInput = subSelectInput->getAlias();
334 
335  te::da::Select* selectDifference = inputParams[1].m_inputQuery;
336  te::da::SubSelect* subSelectDifference =
337  new te::da::SubSelect(selectDifference, "differenceLayer");
338  aliasDifference = subSelectDifference->getAlias();
339 
340  // Building Difference Query.
341 
342  // Union Expression to set into Difference expression.
343  te::da::Fields* fieldsUnion = new te::da::Fields;
344 
346  aliasDifference + "." + geom_difference->getName()));
347  te::da::Field* f_union = new te::da::Field(*e_union, "c_union");
348  fieldsUnion->push_back(f_union);
349 
350  // FROM clause - This from clause is for difference layer.
351  if(!subSelectDifference)
352  throw te::common::Exception(
353  TE_TR("A problem was found. SubSelect Difference with problem."));
354 
355  te::da::From* fromUnion = new te::da::From;
356  fromUnion->push_back(subSelectDifference);
357 
358  te::da::Expression* e_intersects = new te::da::ST_Intersects(
359  new te::da::PropertyName(aliasInput + "." + geom_input->getName()),
360  new te::da::PropertyName(aliasDifference + "." +
361  geom_difference->getName()));
362 
363  te::da::Where* whereUnion = new te::da::Where(e_intersects);
364 
365  te::da::Select* selectUnion =
366  new te::da::Select(fieldsUnion, fromUnion, whereUnion);
367 
368  te::da::SelectExpression* subSelectExpression =
369  new te::da::SelectExpression(selectUnion);
370 
371  // Expressions to execute the Difference.
372  te::da::Expression* e_difference = new te::da::ST_Difference(
373  new te::da::PropertyName(aliasInput + "." + geom_input->getName()),
374  subSelectExpression);
375 
376  te::da::Fields* fieldsExpressions = new te::da::Fields;
377 
378  // Tabular attributes.
379  const std::map<std::string, te::dt::AbstractData*> specificParams =
380  mainParams->getSpecificParams();
381  std::vector<std::string> propNames = this->getPropNames(specificParams);
382 
383  for(std::size_t i = 0; i < propNames.size(); ++i)
384  {
385  te::da::Field* f_att = new te::da::Field(aliasInput + "." + propNames[i]);
386  fieldsExpressions->push_back(f_att);
387  }
388 
389  // Expression to set geometries as multigeometries.
390  te::da::Expression* e_coalesce = new te::da::Coalesce(
391  e_difference,
392  new te::da::PropertyName(aliasInput + "." + geom_input->getName()));
393 
394  bool isCollection = this->isCollection(specificParams);
395 
396  if(isCollection)
397  {
398  te::da::Expression* e_multi = new te::da::ST_Multi(*e_coalesce);
399 
400  te::da::Field* f_multi = new te::da::Field(*e_multi, "geom");
401  fieldsExpressions->push_back(f_multi);
402  }
403  else
404  {
405  te::da::Expression* e_dump = new te::da::ST_Dump(*e_coalesce);
406 
407  te::da::Field* f_dump = new te::da::Field(*e_dump, "geom");
408  fieldsExpressions->push_back(f_dump);
409  }
410 
411  // FROM clause - This from clause is for input layer.
412  if(!subSelectInput)
413  throw te::common::Exception(
414  TE_TR("A problem was found. SubSelect Input with problem."));
415 
416  te::da::From* fromDifference = new te::da::From;
417  fromDifference->push_back(subSelectInput);
418 
419  te::da::Select* selectIn =
420  new te::da::Select(fieldsExpressions, fromDifference);
421  te::da::SubSelect* subSelectIn = new te::da::SubSelect(selectIn, "result");
422 
423  // Outer Select
424  te::da::Fields* outerFields = new te::da::Fields;
425  te::da::Field* f_outer = new te::da::Field("*");
426  outerFields->push_back(f_outer);
427 
428  te::da::From* outerFrom = new te::da::From;
429  outerFrom->push_back(subSelectIn);
430 
431  te::da::Expression* e_isempty =
432  new te::da::ST_IsEmpty(subSelectIn->getAlias() + ".geom");
433  te::da::Expression* e_not = new te::da::Not(e_isempty);
434 
435 
436 
437  /*Check if the input and output dataSource are the same, if so,
438  persists the result of select query into database with insert command.*/
439  te::da::DataSourcePtr outputDataSource = mainParams->getOutputDataSource();
440 
441  te::da::DataSourceInfoPtr inDataSourceInfoPtr =
443  inputParams[0].m_inputDataSource->getId());
444 
445  te::da::DataSourceInfoPtr outDataSourceInfoPtr =
447  outputDataSource->getId());
448 
449  // Create output dataset
450  std::map<std::string, std::string> options;
451 
452  std::unique_ptr<te::da::DataSetType> outputDataSetType(
453  this->getOutputDataSetType(mainParams));
454 
455  outputDataSource->createDataSet(outputDataSetType.get(), options);
456 
457  te::da::Expression* e_geometryType = new te::da::GeometryType(subSelectIn->getAlias() + ".geom");
458 
459  te::da::DataSourcePtr outSource = mainParams->getOutputDataSource();
460  std::unique_ptr<te::da::DataSetType> outDt = outSource->getDataSetType(mainParams->getOutputDataSetName());
461 
462  te::gm::GeometryProperty* outGeomProp = te::da::GetFirstGeomProperty(outDt.get());
463 
464  std::string geometryTypeName = outSource->getGeometryTypeName(outGeomProp->getGeometryType());
465 
466  te::da::Expression* e_typeName = new te::da::LiteralString(geometryTypeName);
467 
468  te::da::Expression* e_equal = new te::da::EqualTo(e_geometryType, e_typeName);
469 
470  te::da::And* e_and = new te::da::And(e_not, e_equal);
471 
472  te::da::Where* outerWhere = new te::da::Where(e_and);
473 
474  te::da::Select* outerSelect =
475  new te::da::Select(outerFields, outerFrom, outerWhere);
476 
477  if(inDataSourceInfoPtr == nullptr)
478  throw te::common::Exception(TE_TR("Input DataSource ID not found."));
479 
480  std::string inputConnection = inDataSourceInfoPtr->getConnInfoAsString();
481 
482  std::string outputConnection;
483  if(outDataSourceInfoPtr != nullptr)
484  outputConnection = outDataSourceInfoPtr->getConnInfoAsString();
485 
486  // Execute Query
487  if(inputConnection == outputConnection)
488  {
489  te::da::Fields* insertFields = new te::da::Fields;
490 
491  for(std::size_t p = 0; p < propNames.size(); ++p)
492  {
493  te::da::Field* f_att = new te::da::Field(propNames[p]);
494  insertFields->push_back(f_att);
495  }
496 
497  te::da::Field* f_insert = new te::da::Field("geom");
498  insertFields->push_back(f_insert);
499 
501  new te::da::DataSetName(mainParams->getOutputDataSetName()),
502  insertFields, outerSelect);
503 
504  outputDataSource->execute(*insert);
505  }
506  else
507  {
508  std::unique_ptr<te::da::DataSet> dsQuery =
509  inputParams[0].m_inputDataSource->query(outerSelect);
510  dsQuery->moveBeforeFirst();
511 
512  if(dsQuery->size() == 0)
513  throw te::common::Exception("The resultant layer is empty!");
514 
515  std::string outputDsName = mainParams->getOutputDataSetName();
516 
517  dsQuery->moveBeforeFirst();
518 
519  outputDataSource->add(outputDsName, dsQuery.get(), options);
520  }
521 
522  return true;
523 }
524 
525 std::vector<std::string> te::vp::Difference::getPropNames(
526  const std::map<std::string, te::dt::AbstractData*>& specificParams)
527 {
528  std::vector<std::string> propNames;
529 
530  if(specificParams.empty())
531  return propNames;
532 
533  std::map<std::string, te::dt::AbstractData*>::const_iterator it =
534  specificParams.begin();
535 
536  while(it != specificParams.end())
537  {
538  if(it->first != "ATTRIBUTES")
539  {
540  ++it;
541  continue;
542  }
543 
546  it->second);
547 
548  if(cd)
549  propNames = cd->getValue();
550 
551  ++it;
552  }
553 
554  return propNames;
555 }
556 
558  const std::map<std::string, te::dt::AbstractData*>& specificParams)
559 {
560  bool isCollection = false;
561 
562  std::map<std::string, te::dt::AbstractData*>::const_iterator it =
563  specificParams.begin();
564 
565  while (it != specificParams.end())
566  {
567  if (it->first != "IS_COLLECTION")
568  {
569  ++it;
570  continue;
571  }
572 
575  it->second);
576 
577  if (sd)
578  isCollection = sd->getValue();
579 
580  ++it;
581  }
582 
583  return isCollection;
584 }
585 
587  te::vp::AlgorithmParams* mainParams)
588 {
589 // Get the input parameters
590  std::vector<te::vp::InputParams> inputParams = mainParams->getInputParams();
591 
592 // Get the output dataset name.
593  std::string outputDataSetName = mainParams->getOutputDataSetName();
594  te::da::DataSetType* outputDataSetType =
595  new te::da::DataSetType(outputDataSetName);
596 
597 // Set to output datasettype the primary key property.
598  if(mainParams->getOutputDataSource()->getType() != "OGR")
599  {
601  outputDataSetName + "_id", te::dt::INT32_TYPE);
602  pkProperty->setAutoNumber(true);
603  outputDataSetType->add(pkProperty);
604 
605  te::da::PrimaryKey* pk =
606  new te::da::PrimaryKey(outputDataSetName + "_pk", outputDataSetType);
607  pk->add(pkProperty);
608  outputDataSetType->setPrimaryKey(pk);
609  }
610 
611 // Get tabular attributes.
612  te::da::DataSetType* dsType = nullptr;
613  if(inputParams[0].m_inputDataSetType)
614  {
615  dsType = inputParams[0].m_inputDataSetType;
616  }
617  else
618  {
619  dsType = te::da::GetDataSetType(inputParams[0].m_inputDataSetName,
620  inputParams[0].m_inputDataSource->getId());
621  }
622 
623  const std::map<std::string, te::dt::AbstractData*> specificParams =
624  mainParams->getSpecificParams();
625  std::vector<std::string> propNames = getPropNames(specificParams);
626 
627  for (std::size_t i = 0; i < propNames.size(); ++i)
628  {
629  te::dt::Property* prop = dsType->getProperty(propNames[i])->clone();
630 
631  if (!prop)
632  continue;
633 
634  outputDataSetType->add(prop);
635  }
636 
637  // Creating the geometry property
638  te::gm::GeometryProperty* newGeomProp = new te::gm::GeometryProperty("geom");
639 
640  te::gm::GeometryProperty* intputGeomProp =
642 
643  bool isCollection = this->isCollection(specificParams);
644 
645  te::gm::GeomType type =
646  setGeomResultType(intputGeomProp->getGeometryType(), isCollection);
647  newGeomProp->setGeometryType(type);
648 
649  newGeomProp->setSRID(intputGeomProp->getSRID());
650 
651  outputDataSetType->add(newGeomProp);
652 
653  return outputDataSetType;
654 }
655 
657  const te::gm::GeomType& geomType, const bool& isCollection)
658 {
659  if (isCollection)
660  {
661  if (te::gm::IsMultiType(geomType))
662  return geomType;
663  else
664  return te::gm::GetMultiType(geomType);
665  }
666  else
667  {
668  if (te::gm::IsMultiType(geomType))
669  return te::gm::GetSimpleType(geomType);
670  else
671  return geomType;
672  }
673 }
674 
676 {
677  switch(geom->getGeomTypeId())
678  {
679  case te::gm::PointType:
680  {
681  te::gm::MultiPoint* geomColl =
683  geomColl->add(geom);
684 
685  return geomColl;
686  }
688  {
691  geomColl->add(geom);
692 
693  return geomColl;
694  }
695  case te::gm::PolygonType:
696  {
698  0, te::gm::MultiPolygonType, geom->getSRID());
699  geomColl->add(geom);
700 
701  return geomColl;
702  }
703  default:
704  break;
705  }
706 
707  return geom;
708 }
709 
An exception class for the Vector processing module.
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
Property * getProperty(std::size_t i) const
It returns the i-th property.
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
Geometric property.
TEVPEXPORT std::unique_ptr< te::da::DataSet > PrepareAdd(te::da::DataSet *ds, te::da::DataSetType *dt)
Coalesce operator.
Definition: Coalesce.h:46
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
Definition: PrimaryKey.h:123
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
void setGeometryType(GeomType t)
It sets the geometry subtype.
An atomic property like an integer or double.
Spatial intersects operator.
Definition: ST_Intersects.h:46
A class that models the name of a dataset used in a From clause.
Definition: DataSetName.h:43
boost::shared_ptr< DataSource > DataSourcePtr
A class that represents an R-tree.
A class that models the name of any property of an object.
A class that models the description of a dataset.
Definition: DataSetType.h:72
te::da::DataSetType * getOutputDataSetType(te::vp::AlgorithmParams *mainParams)
Definition: Difference.cpp:586
TEGEOMEXPORT te::gm::GeomType GetMultiType(te::gm::GeomType geomType)
Get the collection type of GeomType.
virtual const char * what() const
It outputs the exception message.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
Spatial multi operator.
Definition: ST_Multi.h:50
TEGEOMEXPORT bool IsMultiType(te::gm::GeomType geomType)
Verifies if the geomType is a collection type.
std::vector< te::vp::InputParams > getInputParams()
T getValue() const
It returns the associated value.
Definition: SimpleData.h:139
TEGEOMEXPORT std::unique_ptr< te::gm::Geometry > GetGeometryUnion(const std::vector< te::gm::Geometry * > &geomVec)
It returns the union of a geometry vector.
TEGEOMEXPORT te::gm::GeomType GetSimpleType(te::gm::GeomType geomType)
Get the simple type of GeomType.
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
Algorithm Parameters.
virtual Property * clone() const =0
It returns a clone of the object.
#define TE_LOG_INFO(message)
Use this tag in order to log a message to the TerraLib default logger with the INFO level...
Definition: Logger.h:315
The Insert object can add the return of a select object.
Definition: Insert.h:50
TEGEOMEXPORT void Multi2Single(const te::gm::Geometry *g, std::vector< te::gm::Geometry * > &geoms)
It will get a GeometryCollection and distribute in a vector.
It models a property definition.
Definition: Property.h:59
Boolean logic operator: AND.
T getValue() const
It returns the associated value.
Definition: ComplexData.h:129
This is an abstract class that models a query expression.
virtual bool move(std::size_t i)=0
It moves the dataset internal pointer to a given position.
bool executeQuery(te::vp::AlgorithmParams *mainParams)
Definition: Difference.cpp:305
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
TEVPEXPORT void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType, const bool &enableProgress=true)
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
Spatial is empty operator.
Definition: ST_IsEmpty.h:50
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
A template for complex data types.
Definition: ComplexData.h:52
int getSRID() const
It returns the spatial reference system identifier associated to this property.
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
Boolean NOT operator.
const std::string & getOutputDataSetName()
const std::string & getAlias() const
It returns the alias associated to the source item.
Definition: FromItem.cpp:47
mydialect insert("+", new te::da::BinaryOpEncoder("+"))
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Definition: Fields.h:37
Spatial difference operator.
Definition: ST_Difference.h:46
A class that can be used to model a filter expression that can be applied to a query.
Definition: Where.h:47
te::gm::Polygon * p
virtual AbstractData * clone() const =0
It returns a clone of this object.
bool isCollection(const std::map< std::string, te::dt::AbstractData * > &specificParams)
Definition: Difference.cpp:557
te::da::DataSourcePtr getOutputDataSource()
std::vector< std::string > getPropNames(const std::map< std::string, te::dt::AbstractData * > &specificParams)
Definition: Difference.cpp:525
const std::map< std::string, te::dt::AbstractData * > & getSpecificParams()
Utility functions for the data access module.
ST_Dump statistical function.
Definition: ST_Dump.h:46
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A Select models a query to be used when retrieving data from a DataSource.
Definition: Select.h:65
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Definition: From.h:37
void add(Constraint *c)
It adds a new constraint.
MultiLineString is a MultiCurve whose elements are LineStrings.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
A dataset is the unit of information manipulated by the data access module of TerraLib.
A Select can be used as a source of information in another query.
te::gm::GeomType setGeomResultType(const te::gm::GeomType &geomType, const bool &isCollection)
Definition: Difference.cpp:656
virtual std::unique_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
void add(Geometry *g)
It adds the geometry into the collection.
It models the comparison operator.
Definition: EqualTo.h:46
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
#define TE_LOG_ERROR(message)
Use this tag in order to log a message to the TerraLib default logger with the ERROR level...
Definition: Logger.h:337
bool executeMemory(te::vp::AlgorithmParams *mainParams)
Definition: Difference.cpp:92
Difference operation.
TEVPEXPORT void ValidateAlgorithmParams(AlgorithmParams *mainParams, Strategy st)
ST_Union statistical function.
Definition: ST_Union.h:46
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
TEDATAACCESSEXPORT DataSetType * GetDataSetType(const std::string &name, const std::string &datasourceId)
A template for atomic data types (integers, floats, strings and others).
Definition: SimpleData.h:59
A Select can be used as a source of information in another query.
Definition: SubSelect.h:49
te::gm::Geometry * setGeomAsMulti(te::gm::Geometry *geom)
Definition: Difference.cpp:675
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
void setPrimaryKey(PrimaryKey *pk)
It sets the primary key constraint.
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
This class models a string Literal value.
Definition: LiteralString.h:46
const std::string & getName() const
It returns the property name.
Definition: Property.h:127