src/terralib/vp/Union.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 Union.cpp
22 */
23 
24 #include "../core/translator/Translator.h"
25 #include "../core/logger/Logger.h"
26 #include "../common/STLUtils.h"
27 #include "../dataaccess/utils/Utils.h"
28 #include "../datatype/SimpleData.h"
29 #include "../geometry/Geometry.h"
30 #include "../geometry/GeometryProperty.h"
31 #include "../geometry/MultiLineString.h"
32 #include "../geometry/MultiPoint.h"
33 #include "../geometry/MultiPolygon.h"
34 #include "../geometry/Utils.h"
35 #include "ComplexData.h"
36 #include "Union.h"
37 #include "Utils.h"
38 
39 te::vp::Union::Union() = default;
40 
42 {
44 
45 
46  std::vector<te::vp::InputParams> inputParams = mainParams->getInputParams();
47 
48  te::da::DataSetType* firstDt = inputParams[0].m_inputDataSetType;
49  te::da::DataSet* firstDs = inputParams[0].m_inputDataSet;
50  te::gm::GeometryProperty* firstGeomProp =
51  dynamic_cast<te::gm::GeometryProperty*>(
53 
54 
55  te::da::DataSetType* secondDt = inputParams[1].m_inputDataSetType;
56  te::da::DataSet* secondDs = inputParams[1].m_inputDataSet;
57  te::gm::GeometryProperty* secondGeomProp =
58  dynamic_cast<te::gm::GeometryProperty*>(
60 
61 
62  std::map<std::string, te::dt::AbstractData*> specificParams = mainParams->getSpecificParams();
63 
65 
66  std::unique_ptr<te::da::DataSetType> outputDataSetType(getOutputDataSetType(mainParams));
67 
68  std::unique_ptr<te::mem::DataSet> outputDataSet(new te::mem::DataSet(outputDataSetType.get()));
69 
70  te::gm::GeometryProperty* outputGeometryProperty = te::da::GetFirstGeomProperty(outputDataSetType.get());
71 
72  te::da::DataSourcePtr outputSource = mainParams->getOutputDataSource();
73 
74  bool isCollection = this->isCollection(specificParams);
75 
76 
77  firstDs->moveBeforeFirst();
78 
79  while (firstDs->moveNext())
80  {
81  try
82  {
83  std::unique_ptr<te::mem::DataSetItem> mainItem(new te::mem::DataSetItem(outputDataSet.get()));
84 
85  for(auto it : m_firstAttrNameMap)
86  {
87  if (!firstDs->isNull(it.second))
88  mainItem->setValue(it.first, firstDs->getValue(it.second).release());
89  }
90 
91  if (firstDs->isNull(firstGeomProp->getName()))
92  {
93  outputDataSet->add(mainItem.release());
94  continue;
95  }
96 
97  std::unique_ptr<te::gm::Geometry> firstCurrGeom = firstDs->getGeometry(firstGeomProp->getName());
98 
99  if(!firstCurrGeom->isValid())
100  {
101  TE_LOG_ERROR("Vector Processing - Union - Input layer with invalid geometry.");
102  continue;
103  }
104 
105  // Add all geometries that intersects reference geometry.
106  std::vector<te::gm::Geometry*> vectorToDiff;
107 
108  std::vector<std::size_t> report;
109  rtreeSecond->search(*firstCurrGeom->getMBR(), report);
110 
111  for (auto i : report)
112  {
113  secondDs->move(i);
114 
115  if (secondDs->isNull(secondGeomProp->getName()))
116  continue;
117 
118  std::unique_ptr<te::gm::Geometry> secondCurrGeom = secondDs->getGeometry(secondGeomProp->getName());
119 
120  if(!secondCurrGeom->isValid())
121  {
122  TE_LOG_ERROR("Vector Processing - Union - Overlay layer with invalid geometry.");
123  continue;
124  }
125 
126  if(firstCurrGeom->intersects(secondCurrGeom.get()) &&
127  !firstCurrGeom->touches(secondCurrGeom.get()))
128  {
129  std::unique_ptr<te::gm::Geometry> intersectionGeometry(firstCurrGeom->intersection(secondCurrGeom.get()));
130 
131  if(!intersectionGeometry->isEmpty())
132  {
133  vectorToDiff.push_back(static_cast<te::gm::Geometry*>(secondCurrGeom->clone()));
134 
135  std::unique_ptr<te::mem::DataSetItem> clonedItem = mainItem->clone();
136 
137  for(auto it : m_secondAttrNameMap)
138  {
139  if (!secondDs->isNull(it.second))
140  clonedItem->setValue(it.first, secondDs->getValue(it.second).release());
141  }
142 
143  if(!isCollection)
144  {
145  std::vector<te::gm::Geometry*> singleGeometries;
146  te::gm::Multi2Single(intersectionGeometry.get(), singleGeometries);
147 
148  for(auto g : singleGeometries)
149  {
150  if(g->getGeomTypeId() == outputGeometryProperty->getGeometryType())
151  {
152  std::unique_ptr<te::mem::DataSetItem> singleItem = clonedItem->clone();
153  singleItem->setGeometry(outputGeometryProperty->getName(), g);
154  outputDataSet->add(singleItem.release());
155  }
156  }
157  }
158  else
159  {
160  if(!te::gm::IsMultiType(intersectionGeometry->getGeomTypeId()))
161  intersectionGeometry.reset(te::vp::SetGeomAsMulti(*intersectionGeometry.get()));
162 
163  if(intersectionGeometry->getGeomTypeId() == outputGeometryProperty->getGeometryType())
164  {
165  clonedItem->setGeometry(outputGeometryProperty->getName(), intersectionGeometry.release());
166  outputDataSet->add(clonedItem.release());
167  }
168  }
169  }
170  }
171  }
172 
173  std::unique_ptr<te::gm::Geometry> unionGeometry(nullptr);
174  if(!vectorToDiff.empty())
175  {
176  unionGeometry = std::move(te::gm::GetGeometryUnion(vectorToDiff));
177  te::common::FreeContents(vectorToDiff);
178  }
179 
180  std::unique_ptr<te::gm::Geometry> differenceGeometry(nullptr);
181  if(unionGeometry != nullptr && !unionGeometry->isEmpty())
182  differenceGeometry.reset(firstCurrGeom->difference(unionGeometry.get()));
183  else
184  differenceGeometry.reset(firstCurrGeom.release());
185 
186  if(!differenceGeometry->isEmpty())
187  {
188  if(!isCollection)
189  {
190  std::vector<te::gm::Geometry*> singleGeometries;
191  te::gm::Multi2Single(differenceGeometry.get(), singleGeometries);
192 
193  for(auto g : singleGeometries)
194  {
195  if(g->getGeomTypeId() == outputGeometryProperty->getGeometryType())
196  {
197  std::unique_ptr<te::mem::DataSetItem> singleItem = mainItem->clone();
198  singleItem->setGeometry(outputGeometryProperty->getName(), g);
199  outputDataSet->add(singleItem.release());
200  }
201  }
202  }
203  else
204  {
205  if(!te::gm::IsMultiType(differenceGeometry->getGeomTypeId()))
206  differenceGeometry.reset(te::vp::SetGeomAsMulti(*differenceGeometry.get()));
207 
208  if(differenceGeometry->getGeomTypeId() == outputGeometryProperty->getGeometryType())
209  {
210  mainItem->setGeometry(outputGeometryProperty->getName(), differenceGeometry.release());
211  outputDataSet->add(mainItem.release());
212  }
213  }
214  }
215  }
216  catch(te::common::Exception& e)
217  {
218  TE_LOG_ERROR("Vector Processing - Union - Input Layer: " + e.what());
219  continue;
220  }
221  }
222 
224 
225  secondDs->moveBeforeFirst();
226  while (secondDs->moveNext())
227  {
228  try
229  {
230  std::unique_ptr<te::mem::DataSetItem> mainItem(new te::mem::DataSetItem(outputDataSet.get()));
231 
232  for(auto it : m_secondAttrNameMap)
233  {
234  if (!secondDs->isNull(it.second))
235  mainItem->setValue(it.first, secondDs->getValue(it.second).release());
236  }
237 
238  if (secondDs->isNull(firstGeomProp->getName()))
239  {
240  outputDataSet->add(mainItem.release());
241  continue;
242  }
243 
244  std::unique_ptr<te::gm::Geometry> secondCurrGeom = secondDs->getGeometry(secondGeomProp->getName());
245 
246  if(!secondCurrGeom->isValid())
247  {
248  TE_LOG_ERROR("Vector Processing - Union - Overlay layer with invalid geometry.");
249  continue;
250  }
251 
252  // Add all geometries that intersects reference geometry.
253  std::vector<te::gm::Geometry*> vectorToDiff;
254 
255  std::vector<std::size_t> report;
256  rtreeFirst->search(*secondCurrGeom->getMBR(), report);
257 
258  for (auto i : report)
259  {
260  firstDs->move(i);
261 
262  std::unique_ptr<te::gm::Geometry> firstCurrGeom = firstDs->getGeometry(firstGeomProp->getName());
263 
264  if(!firstCurrGeom->isValid())
265  continue;
266 
267  if(secondCurrGeom->intersects(firstCurrGeom.get()) &&
268  !secondCurrGeom->touches(firstCurrGeom.get()))
269  vectorToDiff.push_back(static_cast<te::gm::Geometry*>(firstCurrGeom->clone()));
270  }
271 
272  std::unique_ptr<te::gm::Geometry> unionGeometry(nullptr);
273  if(!vectorToDiff.empty())
274  {
275  unionGeometry = std::move(te::gm::GetGeometryUnion(vectorToDiff));
276  te::common::FreeContents(vectorToDiff);
277  }
278 
279  std::unique_ptr<te::gm::Geometry> differenceGeometry(nullptr);
280 
281  if(unionGeometry != nullptr && !unionGeometry->isEmpty())
282  differenceGeometry.reset(secondCurrGeom->difference(unionGeometry.get()));
283  else
284  differenceGeometry.reset(secondCurrGeom.release());
285 
286  if(!differenceGeometry->isEmpty())
287  {
288  if(!isCollection)
289  {
290  std::vector<te::gm::Geometry*> singleGeometries;
291  te::gm::Multi2Single(differenceGeometry.get(), singleGeometries);
292 
293  for(auto g : singleGeometries)
294  {
295  std::unique_ptr<te::mem::DataSetItem> singleItem = mainItem->clone();
296 
297  singleItem->setGeometry(outputGeometryProperty->getName(), g);
298  outputDataSet->add(singleItem.release());
299  }
300  }
301  else
302  {
303  if(!te::gm::IsMultiType(differenceGeometry->getGeomTypeId()))
304  differenceGeometry.reset(te::vp::SetGeomAsMulti(*differenceGeometry.get()));
305 
306  mainItem->setGeometry(outputGeometryProperty->getName(), differenceGeometry.release());
307  outputDataSet->add(mainItem.release());
308  }
309  }
310  }
311  catch(te::common::Exception& e)
312  {
313  TE_LOG_ERROR("Vector Processing - Union - Overlay Layer: " + e.what());
314  continue;
315  }
316  }
317 
318  outputDataSet->moveBeforeFirst();
319 
320  std::unique_ptr<te::da::DataSet> dataSetPrepared = PrepareAdd(outputDataSet.release(), outputDataSetType.get());
321 
322  if (!dataSetPrepared.get())
323  throw te::common::Exception(
324  TE_TR("Output DataSet was not prepared to save."));
325 
326  if (dataSetPrepared->size() == 0)
327  throw te::common::Exception(TE_TR("The resultant layer is empty!"));
328 
329  te::vp::Save(outputSource.get(), dataSetPrepared.get(),
330  outputDataSetType.get());
331 
332  return true;
333 }
334 
336  const std::map<std::string, te::dt::AbstractData*>& specificParams)
337 {
338  bool isCollection = false;
339 
340  for(std::map<std::string, te::dt::AbstractData*>::const_iterator it =
341  specificParams.begin();
342  it != specificParams.end(); ++it)
343  {
344  if(it->first != "IS_COLLECTION")
345  {
346  continue;
347  }
348 
351  it->second);
352 
353  if(sd)
354  isCollection = sd->getValue();
355  }
356 
357  return isCollection;
358 }
359 
360 std::vector<std::pair<std::string, std::string> > te::vp::Union::getProperties(
361  const std::map<std::string, te::dt::AbstractData*>& specificParams)
362 {
363  std::map<std::string, te::dt::AbstractData*>::const_iterator it =
364  specificParams.begin();
365 
366  std::vector<std::pair<std::string, std::string> > propNames;
367 
368  while(it != specificParams.end())
369  {
370  if(it->first != "ATTRIBUTES")
371  {
372  ++it;
373  continue;
374  }
375 
376  te::dt::AbstractData* abData = it->second;
377 
379  cd = dynamic_cast<te::vp::ComplexData<
380  std::vector<std::pair<std::string, std::string> > >*>(abData);
381 
382  if(cd)
383  propNames = cd->getValue();
384 
385  ++it;
386  }
387 
388  return propNames;
389 }
390 
392 {
393  return false;
394 }
395 
397  te::vp::AlgorithmParams* mainParams)
398 {
399  te::vp::InputParams firstInputParams = mainParams->getInputParams()[0];
400  te::vp::InputParams secondInputParams = mainParams->getInputParams()[1];
401 
402  std::string outputDataSetName = mainParams->getOutputDataSetName();
403 
404  const std::map<std::string, te::dt::AbstractData*> specificParams =
405  mainParams->getSpecificParams();
406 
407  bool isCollection = this->isCollection(specificParams);
408 
409  te::da::DataSetType* firstDataSetType = firstInputParams.m_inputDataSetType;
410 
411  te::gm::GeometryProperty* firstGeometryProperty =
412  te::da::GetFirstGeomProperty(firstDataSetType);
413 
414  te::da::DataSetType* secondDataSetType = secondInputParams.m_inputDataSetType;
415 
416  te::gm::GeometryProperty* secondGeometryProperty =
417  te::da::GetFirstGeomProperty(secondDataSetType);
418 
419  std::vector<te::dt::Property*> firstSelectedProperties =
420  getFirstSelectedProperties(firstDataSetType, specificParams);
421 
422  std::vector<te::dt::Property*> secondSelectedProperties =
423  getSecondSelectedProperties(secondDataSetType, specificParams);
424 
425  te::da::DataSetType* outputDataSetType =
426  new te::da::DataSetType(outputDataSetName);
427 
428  std::vector<std::string> attrNamesAux;
429 
430  if(mainParams->getOutputDataSource()->getType() != "OGR")
431  {
433  outputDataSetName + "_id", te::dt::INT32_TYPE);
434  pkProperty->setAutoNumber(true);
435  outputDataSetType->add(pkProperty);
436 
437  te::da::PrimaryKey* pk =
438  new te::da::PrimaryKey(outputDataSetName + "_pk", outputDataSetType);
439  pk->add(pkProperty);
440  outputDataSetType->setPrimaryKey(pk);
441  }
442 
443  for(std::size_t i = 0; i < firstSelectedProperties.size(); ++i)
444  {
445  te::dt::Property* clonedProperty = firstSelectedProperties[i]->clone();
446 
447  te::dt::SimpleProperty* spAux =
448  dynamic_cast<te::dt::SimpleProperty*>(clonedProperty);
449 
450  if(spAux)
451  {
452  spAux->setRequired(false);
453  }
454 
455  std::string pName = clonedProperty->getName();
456 
457  if(mainParams->getOutputDataSource()->getType() == "OGR")
458  pName = GetDistinctName(pName, attrNamesAux, 10);
459  else
460  pName = GetDistinctName(pName, attrNamesAux);
461 
462  m_firstAttrNameMap[pName] = clonedProperty->getName();
463 
464  clonedProperty->setName(pName);
465 
466  outputDataSetType->add(clonedProperty);
467 
468  attrNamesAux.push_back(clonedProperty->getName());
469  }
470 
471  for(std::size_t i = 0; i < secondSelectedProperties.size(); ++i)
472  {
473  te::dt::Property* clonedProperty = secondSelectedProperties[i]->clone();
474 
475  te::dt::SimpleProperty* spAux =
476  dynamic_cast<te::dt::SimpleProperty*>(clonedProperty);
477 
478  if(spAux)
479  {
480  spAux->setRequired(false);
481  }
482 
483  std::string pName = clonedProperty->getName();
484 
485  if(mainParams->getOutputDataSource()->getType() == "OGR")
486  pName = GetDistinctName(pName, attrNamesAux, 10);
487  else
488  pName = GetDistinctName(pName, attrNamesAux);
489 
490  m_secondAttrNameMap[pName] = clonedProperty->getName();
491 
492  clonedProperty->setName(pName);
493 
494  outputDataSetType->add(clonedProperty);
495 
496  attrNamesAux.push_back(clonedProperty->getName());
497  }
498 
499  te::gm::GeometryProperty* newGeometryProperty =
500  new te::gm::GeometryProperty("geom");
501 
503  firstGeometryProperty->getGeometryType(),
504  secondGeometryProperty->getGeometryType(), isCollection);
505  newGeometryProperty->setGeometryType(type);
506 
507  newGeometryProperty->setSRID(firstGeometryProperty->getSRID());
508 
509  outputDataSetType->add(newGeometryProperty);
510 
511  return outputDataSetType;
512 }
513 
515  const te::gm::GeomType& firstGeom, const te::gm::GeomType& secondGeom,
516  const bool& isCollection)
517 {
518  te::gm::GeomType geomType;
519 
520  if ((firstGeom == te::gm::PointType) ||
521  (firstGeom == te::gm::PointZType) ||
522  (firstGeom == te::gm::PointMType) ||
523  (firstGeom == te::gm::PointZMType) ||
524  (firstGeom == te::gm::PointKdType) ||
525 
526  (secondGeom == te::gm::PointType) ||
527  (secondGeom == te::gm::PointZType) ||
528  (secondGeom == te::gm::PointMType) ||
529  (secondGeom == te::gm::PointZMType) ||
530  (secondGeom == te::gm::PointKdType) ||
531 
532  (firstGeom == te::gm::MultiPointType) ||
533  (firstGeom == te::gm::MultiPointZType) ||
534  (firstGeom == te::gm::MultiPointMType) ||
535  (firstGeom == te::gm::MultiPointZMType) ||
536 
537  (secondGeom == te::gm::MultiPointType) ||
538  (secondGeom == te::gm::MultiPointZType) ||
539  (secondGeom == te::gm::MultiPointMType) ||
540  (secondGeom == te::gm::MultiPointZMType))
541  {
542  geomType = te::gm::MultiPointType;
543  }
544  else if ((firstGeom == te::gm::LineStringType) ||
545  (firstGeom == te::gm::LineStringZType) ||
546  (firstGeom == te::gm::LineStringMType) ||
547  (firstGeom == te::gm::LineStringZMType) ||
548 
549  (secondGeom == te::gm::LineStringType) ||
550  (secondGeom == te::gm::LineStringZType) ||
551  (secondGeom == te::gm::LineStringMType) ||
552  (secondGeom == te::gm::LineStringZMType) ||
553 
554  (firstGeom == te::gm::MultiLineStringType) ||
555  (firstGeom == te::gm::MultiLineStringZType) ||
556  (firstGeom == te::gm::MultiLineStringMType) ||
557  (firstGeom == te::gm::MultiLineStringZMType) ||
558 
559  (secondGeom == te::gm::MultiLineStringType) ||
560  (secondGeom == te::gm::MultiLineStringZType) ||
561  (secondGeom == te::gm::MultiLineStringMType) ||
562  (secondGeom == te::gm::MultiLineStringZMType))
563  {
564  geomType = te::gm::MultiLineStringType;
565  }
566  else
567  geomType = te::gm::MultiPolygonType;
568 
569  if (isCollection)
570  {
571  if (te::gm::IsMultiType(geomType))
572  return geomType;
573  else
574  return te::gm::GetMultiType(geomType);
575  }
576  else
577  {
578  if (te::gm::IsMultiType(geomType))
579  return te::gm::GetSimpleType(geomType);
580  else
581  return geomType;
582  }
583 }
584 
585 std::vector<te::dt::Property*> te::vp::Union::getFirstSelectedProperties(
586  const te::da::DataSetType* dataSetType,
587  const std::map<std::string, te::dt::AbstractData*>& specificParams)
588 {
589  std::vector<te::dt::Property*> result;
590 
591  std::vector<std::pair<std::string, std::string> > selectedProperties =
592  getProperties(specificParams);
593 
594  for(std::size_t i = 0; i < selectedProperties.size(); ++i)
595  {
596  if(selectedProperties[i].first == "FIRST")
597  {
598  result.push_back(dataSetType->getProperty(selectedProperties[i].second));
599  }
600  }
601 
602  return result;
603 }
604 
605 std::vector<te::dt::Property*> te::vp::Union::getSecondSelectedProperties(
606  const te::da::DataSetType* dataSetType,
607  const std::map<std::string, te::dt::AbstractData*>& specificParams)
608 {
609  std::vector<te::dt::Property*> result;
610 
611  std::vector<std::pair<std::string, std::string> > selectedProperties =
612  getProperties(specificParams);
613 
614  for(std::size_t i = 0; i < selectedProperties.size(); ++i)
615  {
616  if(selectedProperties[i].first == "SECOND")
617  {
618  result.push_back(dataSetType->getProperty(selectedProperties[i].second));
619  }
620  }
621 
622  return result;
623 }
624 
626 {
627  // note that this has effect only in Points, Lines and Polygons
628  switch(geom->getGeomTypeId())
629  {
630  case te::gm::PointType:
631  {
632  te::gm::MultiPoint* geomColl =
634  geomColl->add(geom);
635 
636  return geomColl;
637  }
639  {
642  geomColl->add(geom);
643 
644  return geomColl;
645  }
646  case te::gm::PolygonType:
647  {
649  0, te::gm::MultiPolygonType, geom->getSRID());
650  geomColl->add(geom);
651 
652  return geomColl;
653  }
654  default:
655  return geom;
656  }
657 }
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
std::vector< te::dt::Property * > getSecondSelectedProperties(const te::da::DataSetType *dataSetType, const std::map< std::string, te::dt::AbstractData * > &specificParams)
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
std::vector< std::pair< std::string, std::string > > getProperties(const std::map< std::string, te::dt::AbstractData * > &specificParams)
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
bool executeQuery(te::vp::AlgorithmParams *mainParams)
Geometric property.
TEVPEXPORT std::unique_ptr< te::da::DataSet > PrepareAdd(te::da::DataSet *ds, te::da::DataSetType *dt)
A structure to hold the input parameters of vector processing.
Definition: InputParams.h:50
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.
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
void setGeometryType(GeomType t)
It sets the geometry subtype.
bool isCollection(const std::map< std::string, te::dt::AbstractData * > &specificParams)
An atomic property like an integer or double.
boost::shared_ptr< DataSource > DataSourcePtr
A class that models the description of a dataset.
Definition: DataSetType.h:72
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.
std::map< std::string, std::string > m_firstAttrNameMap
std::vector< te::dt::Property * > getFirstSelectedProperties(const te::da::DataSetType *dataSetType, const std::map< std::string, te::dt::AbstractData * > &specificParams)
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.
TEVPEXPORT te::sam::rtree::Index< size_t, 8 > * GetRtree(te::da::DataSet *data)
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
virtual Property * clone() const =0
It returns a clone of the object.
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
T getValue() const
It returns the associated value.
Definition: ComplexData.h:129
virtual bool move(std::size_t i)=0
It moves the dataset internal pointer to a given position.
std::map< std::string, std::string > m_secondAttrNameMap
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.
void setName(const std::string &name)
It sets the property name.
Definition: Property.h:137
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.
const std::string & getOutputDataSetName()
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
te::da::DataSourcePtr getOutputDataSource()
te::da::DataSetType * m_inputDataSetType
Is required.
Definition: InputParams.h:82
const std::map< std::string, te::dt::AbstractData * > & getSpecificParams()
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
Utility functions for the data access module.
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.
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.
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.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
void setRequired(bool r)
It tells if the property is required or not.
#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
TEVPEXPORT void ValidateAlgorithmParams(AlgorithmParams *mainParams, Strategy st)
bool executeMemory(te::vp::AlgorithmParams *mainParams)
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
TEVPEXPORT std::string GetDistinctName(const std::string &name, std::vector< std::string > names, std::size_t maxSize=0)
A template for atomic data types (integers, floats, strings and others).
Definition: SimpleData.h:59
te::da::DataSetType * getOutputDataSetType(te::vp::AlgorithmParams *mainParams)
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
Definition: BoostUtils.h:55
TEVPEXPORT te::gm::Geometry * SetGeomAsMulti(const te::gm::Geometry &geom)
te::gm::GeomType getGeomResultType(const te::gm::GeomType &firstGeom, const te::gm::GeomType &secondGeom, const bool &isCollection)
TEDATAACCESSEXPORT te::dt::Property * GetFirstSpatialProperty(const DataSetType *dt)
void setPrimaryKey(PrimaryKey *pk)
It sets the primary key constraint.
te::gm::Geometry * setGeomAsMulti(te::gm::Geometry *geom)
const std::string & getName() const
It returns the property name.
Definition: Property.h:127