VectorToVectorMemory.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 VectorToVectorMemory.h
22 
23  \brief Vector to Vector processing.
24 
25  \ingroup attributefill
26  */
27 
28 //Terralib
29 #include "../core/logger/Logger.h"
30 #include "../common/progress/TaskProgress.h"
31 #include "../common/STLUtils.h"
32 #include "../common/StringUtils.h"
33 #include "../core/translator/Translator.h"
34 #include "../dataaccess/dataset/DataSetAdapter.h"
35 #include "../dataaccess/dataset/DataSetTypeConverter.h"
36 #include "../dataaccess/datasource/DataSourceInfo.h"
37 #include "../dataaccess/datasource/DataSourceInfoManager.h"
38 #include "../dataaccess/utils/Utils.h"
39 #include "../datatype/StringProperty.h"
40 #include "../datatype/SimpleData.h"
41 #include "../geometry.h"
42 #include "../memory/DataSet.h"
43 #include "../memory/DataSetItem.h"
44 #include "../statistics/core/NumericStatisticalSummary.h"
45 #include "../statistics/core/StringStatisticalSummary.h"
46 #include "../statistics/core/SummaryFunctions.h"
47 #include "../statistics/core/Enums.h"
48 
49 #include "Config.h"
50 #include "VectorToVectorMemory.h"
51 
52 // STL
53 #include <memory>
54 
55 // Boost
56 #include <boost/algorithm/string/replace.hpp>
57 #include <boost/lexical_cast.hpp>
58 
60 {
61  std::string invalidChar;
62  bool changed;
63  if(!te::da::IsValidName(name, invalidChar))
64  {
65  name = te::common::ReplaceSpecialChars(name, changed);
66 
67  boost::replace_all(name, "/", "_");
68  boost::replace_all(name, " ", "_");
69  boost::replace_all(name, ".", "");
70  boost::replace_all(name, "'", "");
71  boost::replace_all(name, "-", "_");
72  boost::replace_all(name, "&", "e");
73  }
74 }
75 
77 
79 {
81  m_mapGeom.clear();
82 }
83 
85 {
86  TE_LOG_DEBUG("Starting VectorToVector...");
87 
88  int fromSrid = m_fromLayer->getSRID();
89  int toSrid = m_toLayer->getSRID();
90 
91  TE_LOG_DEBUG("From SRID: " + std::to_string(fromSrid) + " | To SRID: " + std::to_string(toSrid));
92 
93  std::unique_ptr<te::da::DataSetType> fromSchemaOrigin = m_fromLayer->getSchema();
94  std::unique_ptr<te::da::DataSet> fromDsOrigin = m_fromLayer->getData();
95 
96  std::unique_ptr<te::da::DataSetType> toSchemaOrigin = m_toLayer->getSchema();
97  std::unique_ptr<te::da::DataSet> toDsOrigin = m_toLayer->getData();
98 
99  te::da::DataSetTypeConverter* fromConverter = new te::da::DataSetTypeConverter(fromSchemaOrigin.get(), m_outDsrc->getCapabilities(), m_outDsrc->getEncoding());
100 
101  te::da::AssociateDataSetTypeConverterSRID(fromConverter, fromSrid, toSrid);
102 
103  std::unique_ptr<te::da::DataSetType> fromSchema(fromConverter->getResult());
104  std::unique_ptr<te::da::DataSetAdapter> fromDs(te::da::CreateAdapter(fromDsOrigin.get(), fromConverter));
105 
106  te::da::DataSetTypeConverter* toConverter = new te::da::DataSetTypeConverter(toSchemaOrigin.get(), m_outDsrc->getCapabilities(), m_outDsrc->getEncoding());
107 
108  te::da::AssociateDataSetTypeConverterSRID(toConverter, toSrid);
109 
110  std::unique_ptr<te::da::DataSetType> toSchema(toConverter->getResult());
111  std::unique_ptr<te::da::DataSet> toDs(te::da::CreateAdapter(toDsOrigin.get(), toConverter));
112 
113  te::gm::Envelope fromEnv = m_fromLayer->getExtent();
114  te::gm::Envelope toEnv = m_toLayer->getExtent();
115 
116  if (fromSrid != toSrid)
117  fromEnv.transform(fromSrid, toSrid);
118 
119  if(!fromEnv.intersects(toEnv))
120  {
121  throw te::common::Exception(TE_TR("The two layers do not intersect."));
122  }
123 
124  std::unique_ptr<te::da::DataSetType> outDst(getOutputDataSetType());
125 
126  std::unique_ptr<te::mem::DataSet> outDs(new te::mem::DataSet(outDst.get()));
127 
128  te::sam::rtree::Index<size_t, 8>* rtree = getRtree(fromDs.get());
129  KD_ADAPTATIVE_TREE* kdtree = nullptr;
130 
131  toDs->moveBeforeFirst();
132 
133  te::common::TaskProgress task("Processing Vector to Vector...");
134  task.setTotalSteps(static_cast<int>(toDs->size()));
135  task.useTimer(true);
136 
137  std::string logInfo1;
138  std::string logInfo2;
139 
140  std::vector<te::dt::Property*> outProps = outDst->getProperties();
141  std::vector<te::dt::Property*> toProps = toSchema->getProperties();
142 
143  while(toDs->moveNext())
144  {
145  try
146  {
147  te::mem::DataSetItem* item = new te::mem::DataSetItem(outDs.get());
148 
149  for(std::size_t i = 0; i < outProps.size(); ++i)
150  {
151  std::string outPropName = outProps[i]->getName();
152 
153  for(std::size_t j = 0; j < toProps.size(); ++j)
154  {
155  if(toProps[j]->getName() == outPropName)
156  {
157  if(!toDs->isNull(outPropName))
158  item->setValue(outPropName, toDs->getValue(outPropName).release());
159 
160  break;
161  }
162  }
163  }
164 
165  bool hasInvalid = false;
166  std::vector<std::size_t> intersections = getIntersections(toDs.get(), fromDs.get(), rtree, hasInvalid);
167 
168  if (hasInvalid)
169  {
170 #ifdef TERRALIB_LOGGER_ENABLED
171  te::da::PrimaryKey* toPk = toSchema->getPrimaryKey();
172  te::dt::Property* pkProp = toPk->getProperties()[0];
173 
174  std::string value = "Unknown";
175 
176  if (!toDs->isNull(pkProp->getName()))
177  value = toDs->getValue(pkProp->getName())->toString();
178 
179  std::string ex = "The \"To\" layer geometry (" + pkProp->getName() + ": " + value + ") has intersection candidate invalid!";
180  TE_LOG_INFO(ex);
181 #endif //TERRALIB_LOGGER_ENABLED
182 
183  m_hasErrors = true;
184  outDs->add(item);
185  continue;
186  }
187 
188 
189  if(intersections.empty() && !hasNoIntersectionOperations())
190  {
191  outDs->add(item);
192  continue;
193  }
194 
195  std::map<std::string, std::vector<te::attributefill::OperationType> >::iterator it = m_options.begin();
196 
197  std::vector< std::vector<te::dt::AbstractData*> > dataValues;
198 
199  dataValues = getDataValues(fromDs.get(), intersections);
200 
201  while(it != m_options.end())
202  {
203  logInfo1 = it->first;
204 
205  te::dt::Property* prop = fromSchema->getProperty(it->first);
206  std::size_t propPos = fromSchema->getPropertyPosition(it->first);
207 
210 
211  std::vector<double> numValues;
212  std::vector<std::string> strValues;
213 
214  if(prop->getType() == te::dt::STRING_TYPE)
215  {
216  strValues = getStrValues(dataValues, propPos);
217  te::stat::GetStringStatisticalSummary(strValues, ssStr, "");
218  }
219  else
220  {
221  numValues = getNumValues(dataValues, propPos);
222  te::stat::GetNumericStatisticalSummary(numValues, ssNum);
223  te::stat::Mode(numValues, ssNum);
224  }
225 
226  std::vector<te::attributefill::OperationType> funcs = it->second;
227 
228  for(std::size_t i = 0; i < funcs.size(); ++i)
229  {
230  std::string outPropName = getPropertyName(prop, funcs[i]);
231 
232  if(funcs[i] == te::attributefill::VALUE)
233  {
234  if (prop->getType() == te::dt::STRING_TYPE)
235  {
236  if(!ssStr.m_minVal.empty())
237  item->setString(outPropName, ssStr.m_minVal);
238  }
239  else
240  {
241  item->setDouble(outPropName, ssNum.m_minVal);
242  }
243  }
244  else if(funcs[i] == te::attributefill::HIGHEST_INTERSECTION)
245  {
246  te::dt::AbstractData* value = getClassWithHighestIntersectionArea(toDs.get(), static_cast<size_t>(toSrid), fromDs.get(), static_cast<size_t>(fromSrid), intersections, prop->getName(), dataValues);
247 
248  item->setValue(outPropName, value);
249  }
250  else if(funcs[i] == te::attributefill::HIGHEST_OCCURRENCE)
251  {
252  te::dt::AbstractData* value = getClassWithHighestOccurrence(fromDs.get(), intersections, prop->getName(), dataValues);
253  if (value)
254  item->setValue(outPropName, value);
255  }
256  else if(funcs[i] == te::attributefill::PERCENT_CLASS)
257  {
258  std::map<std::string, double> result = getPercentagePerClass(fromDs.get(), intersections, prop->getName(), dataValues);
259 
260  std::map<std::string, double>::iterator itAux = result.begin();
261  while(itAux != result.end())
262  {
263  std::string className = itAux->first;
264  normalizeClassName(className);
265  std::string newPropName = prop->getName() + "_" + className;
266 
267  item->setDouble(newPropName, itAux->second);
268 
269  ++itAux;
270  }
271  }
272  else if(funcs[i] == te::attributefill::PRESENCE)
273  {
274  if(intersections.size() > 0)
275  {
276  item->setInt32(outPropName, 1);
277  }
278  else
279  {
280  item->setInt32(outPropName, 0);
281  }
282  }
283  else if(funcs[i] == te::attributefill::PERCENT_TOTAL_AREA)
284  {
285  double area = getPercentageOfTotalArea(toDs.get(), static_cast<size_t>(toSrid), fromDs.get(), static_cast<size_t>(fromSrid), intersections, prop->getName(), dataValues);
286 
287  item->setDouble(outPropName, area);
288  }
289  else if(funcs[i] == te::attributefill::PERCENT_EACH_CLASS)
290  {
291  std::map<std::string, double> result = getPercentageOfEachClassByArea(toDs.get(), static_cast<size_t>(toSrid), fromDs.get(), static_cast<size_t>(fromSrid), intersections, prop->getName(), dataValues);
292 
293  std::map<std::string, double>::iterator itAux = result.begin();
294  while(itAux != result.end())
295  {
296  std::string className = itAux->first;
297  normalizeClassName(className);
298  std::string newPropName = prop->getName() + "_" + className;
299 
300  item->setDouble(newPropName, itAux->second);
301 
302  ++itAux;
303  }
304  }
305  else if(funcs[i] == te::attributefill::WEIGHTED)
306  {
307  double weigh = getWeightedByArea(toDs.get(), static_cast<size_t>(toSrid), fromDs.get(), static_cast<size_t>(fromSrid), intersections, prop->getName(), dataValues);
308 
309  item->setDouble(outPropName, weigh);
310  }
311  else if(funcs[i] == te::attributefill::WEIGHTED_SUM)
312  {
313  double weigh = getWeightedSumByArea(toDs.get(), static_cast<size_t>(toSrid), fromDs.get(), static_cast<size_t>(fromSrid), intersections, prop->getName(), dataValues);
314 
315  item->setDouble(outPropName, weigh);
316  }
317  else if(funcs[i] == te::attributefill::MIN_DISTANCE)
318  {
319  double result = 0;
320 
321  if(intersections.empty())
322  {
323  if(!kdtree)
324  kdtree = getKDtree(fromDs.get(), static_cast<size_t>(toSrid));
325 
326  result = getMinimumDistance(toDs.get(), static_cast<size_t>(toSrid), fromDs.get(), static_cast<size_t>(fromSrid), kdtree);
327  }
328 
329  item->setDouble(outPropName, result);
330  }
331  else if (funcs[i] == te::attributefill::MIN_DISTANCE_CENTROID)
332  {
333  double result = 0;
334 
335  if (!kdtree)
336  kdtree = getKDtree(fromDs.get(), static_cast<size_t>(toSrid));
337 
338  result = getMinimumDistanceFromCentroid(toDs.get(), static_cast<size_t>(toSrid), fromDs.get(), static_cast<size_t>(fromSrid), kdtree, rtree);
339 
340  item->setDouble(outPropName, result);
341  }
342  else if(isStatistical(funcs[i]))
343  {
344  if(prop->getType() == te::dt::STRING_TYPE)
345  {
346  std::string value = getValue(ssStr, funcs[i]);
347  if (!value.empty())
348  item->setString(outPropName, value);
349  }
350  else
351  {
352  if(funcs[i] == te::attributefill::MODE)
353  {
354  std::string value = getModeValue(ssNum);
355  if(!value.empty())
356  item->setString(outPropName, value);
357  }
358  else
359  {
360  double value = getValue(ssNum, funcs[i]);
361  item->setDouble(outPropName, value);
362  }
363  }
364  }
365  else if (funcs[i] == te::attributefill::COUNT_DISTINCT)
366  {
367  int value = getTotalNumberOfDistinctValues(fromDs.get(), prop->getName(), dataValues);
368  item->setInt32(outPropName, value);
369  }
370  }
371 
372  ++it;
373  }
374 
375  for (std::size_t a = 0; a < dataValues.size(); ++a)
376  te::common::FreeContents(dataValues[a]);
377 
378  dataValues.clear();
379 
380  outDs->add(item);
381 
382  if (task.isActive() == false)
383  throw te::common::Exception(TE_TR("Operation canceled!"), 1);
384 
385  task.pulse();
386  }
387  catch(te::common::Exception& e)
388  {
389  if(e.code() == 1)
390  {
391  throw e;
392  }
393 
394 #ifdef TERRALIB_LOGGER_ENABLED
395  std::string ex = e.what();
396  ex += " | Ref: " + logInfo1 + " : " + logInfo2;
397  TE_LOG_INFO(ex);
398 #endif //TERRALIB_LOGGER_ENABLED
399 
400  m_hasErrors = true;
401  }
402  catch(std::exception& e)
403  {
404 #ifdef TERRALIB_LOGGER_ENABLED
405  std::string ex = e.what();
406  ex += " | Ref: " + logInfo1 + " : " + logInfo2;
407  TE_LOG_INFO(ex);
408 #endif //TERRALIB_LOGGER_ENABLED
409  m_hasErrors = true;
410  }
411  }
412 
413  if (!outDs->isEmpty())
414  {
415  save(std::move(outDs), std::move(outDst));
416  m_outDsrc->close();
417  }
418 
419  if(rtree)
420  delete rtree;
421 
422  if(kdtree)
423  delete kdtree;
424 
425  return true;
426 }
427 
429 {
430  std::string id = m_toLayer->getDataSourceId();
431 
432  std::string type = te::da::DataSourceInfoManager::getInstance().get(id)->getType();
433 
434  if (type == "OGR")
435  return true;
436  else
437  return false;
438 }
439 
441 {
442  std::unique_ptr<te::da::DataSetType> fromSchemaOrigin = m_fromLayer->getSchema();
443  std::unique_ptr<te::da::DataSet> fromDsOrigin = m_fromLayer->getData();
444 
445  std::unique_ptr<te::da::DataSetType> toSchemaOrigin = m_toLayer->getSchema();
446  std::unique_ptr<te::da::DataSet> toDsOrigin = m_toLayer->getData();
447 
448  te::da::DataSetTypeConverter* fromConverter = new te::da::DataSetTypeConverter(fromSchemaOrigin.get(), m_outDsrc->getCapabilities(), m_outDsrc->getEncoding());
449 
450  te::da::AssociateDataSetTypeConverterSRID(fromConverter, m_fromLayer->getSRID(), m_toLayer->getSRID());
451 
452  std::unique_ptr<te::da::DataSetType> fromSchema(fromConverter->getResult());
453  std::unique_ptr<te::da::DataSetAdapter> fromDs(te::da::CreateAdapter(fromDsOrigin.get(), fromConverter));
454 
455  te::da::DataSetTypeConverter* toConverter = new te::da::DataSetTypeConverter(toSchemaOrigin.get(), m_outDsrc->getCapabilities(), m_outDsrc->getEncoding());
456 
457  te::da::AssociateDataSetTypeConverterSRID(toConverter, m_toLayer->getSRID());
458 
459  std::unique_ptr<te::da::DataSetType> toSchema(toConverter->getResult());
460  std::unique_ptr<te::da::DataSetAdapter> toDs(te::da::CreateAdapter(toDsOrigin.get(), toConverter));
461 
462  te::da::DataSetType* dst = new te::da::DataSetType(*toSchema.get());
463  dst->setName(m_outDset);
464  dst->setTitle(m_outDset);
465 
466  std::vector<te::dt::Property*> outProps = dst->getProperties();
467 
468  te::da::PrimaryKey* pk = dst->getPrimaryKey();
469 
470  std::vector<te::dt::Property*> pkProps;
471 
472  if (pk)
473  pkProps = dst->getPrimaryKey()->getProperties();
474 
475  // Keep only the properties that the user selected
476  for(std::size_t i = 0; i < outProps.size(); ++i)
477  {
478  bool isPk = false;
479  for(std::size_t j = 0; j < pkProps.size(); ++j)
480  {
481  if(outProps[i]->getName() == pkProps[j]->getName())
482  {
483  isPk = true;
484  break;
485  }
486  }
487 
488  if(outProps[i]->getType() != te::dt::GEOMETRY_TYPE && !isPk)
489  {
490  std::string name = outProps[i]->getName();
491  if(std::find(m_toLayerProps.begin(), m_toLayerProps.end(), name) == m_toLayerProps.end())
492  dst->remove(outProps[i]);
493  }
494  }
495 
496  std::map<std::string, std::vector<te::attributefill::OperationType> >::iterator it = m_options.begin();
497 
498  while(it != m_options.end())
499  {
500  te::dt::Property* currentProperty = fromSchema->getProperty(it->first);
501 
502  std::vector<te::attributefill::OperationType> funcs = it->second;
503 
504  for(std::size_t i = 0; i < funcs.size(); ++i)
505  {
506  te::dt::SimpleProperty* newProp = nullptr;
507 
508  std::string newName = getPropertyName(currentProperty, static_cast<te::attributefill::OperationType>(funcs[i]));
509 
510  if(funcs[i] == te::attributefill::VALUE)
511  {
512  if(currentProperty->getType() == te::dt::STRING_TYPE)
513  newProp = new te::dt::StringProperty(newName);
514  else
515  newProp = new te::dt::SimpleProperty(newName, te::dt::DOUBLE_TYPE);
516  }
517  else if(funcs[i] == te::attributefill::HIGHEST_OCCURRENCE ||
519  {
520  newProp = dynamic_cast<te::dt::SimpleProperty*>(currentProperty->clone());
521  newProp->setRequired(false);
522  newProp->setAutoNumber(false);
523  newProp->setDefaultValue(nullptr);
524  newProp->setName(newName);
525  }
527  {
528  continue;//Sera feito fora do for
529  }
530  else if(funcs[i] == te::attributefill::PRESENCE ||
532  {
533  newProp = new te::dt::SimpleProperty(newName, te::dt::INT32_TYPE);
534  }
535  else if(funcs[i] == te::attributefill::PERCENT_TOTAL_AREA ||
536  funcs[i] == te::attributefill::MIN_DISTANCE ||
538  {
539  newProp = new te::dt::SimpleProperty(newName, te::dt::DOUBLE_TYPE);
540  }
541  else if(currentProperty->getType() == te::dt::STRING_TYPE || funcs[i] == te::attributefill::MODE)
542  {
543  newProp = new te::dt::StringProperty(newName);
544  }
545  else
546  {
547  newProp = new te::dt::SimpleProperty(newName, te::dt::DOUBLE_TYPE);
548  }
549 
550  dst->add(newProp);
551  }
552 
553  if(std::find(funcs.begin(), funcs.end(), te::attributefill::PERCENT_CLASS) != funcs.end() ||
554  std::find(funcs.begin(), funcs.end(), te::attributefill::PERCENT_EACH_CLASS) != funcs.end())
555  {
556  std::vector<std::string> strClasses = getDistinctClasses(fromDs.get(), currentProperty->getName());
557 
558  for(std::size_t i = 0; i < strClasses.size(); ++i)
559  {
560  std::string className = strClasses[i];
561 
562  normalizeClassName(className);
563 
564  std::string newPropName = currentProperty->getName() + "_" + className;
565 
567 
568  dst->add(newProp);
569  }
570  }
571 
572  ++it;
573  }
574 
575  return dst;
576 }
577 
579  const std::string& propertyName)
580 {
581  std::vector<std::string> result;
582 
583  fromDs->moveBeforeFirst();
584 
585  while(fromDs->moveNext())
586  {
587  if (fromDs->isNull(propertyName))
588  continue;
589 
590  std::string strClass = fromDs->getAsString(propertyName, 9);
591 
592  if(std::find(result.begin(), result.end(), strClass) == result.end())
593  {
594  result.push_back(strClass);
595  }
596  }
597 
598  return result;
599 }
600 
602 {
604 
605  std::size_t geomPos = te::da::GetFirstSpatialPropertyPos(data);
606 
607  data->moveBeforeFirst();
608 
609  int count = 0;
610 
612  m_mapGeom.clear();
613 
614  while(data->moveNext())
615  {
616  if (data->isNull(geomPos))
617  continue;
618 
619  std::unique_ptr<te::gm::Geometry> geom = data->getGeometry(geomPos);
620 
621  rtree->insert(*geom->getMBR(), static_cast<unsigned long>(count));
622 
623  m_mapGeom.insert(std::map<int, te::gm::Geometry*>::value_type(count, geom.release()));
624 
625  ++count;
626  }
627 
628  return rtree;
629 }
630 
632 {
633  std::string name = te::common::Convert2LCase(prop->getName());
634 
635  std::string newName = name + "_";
636 
637  if(func == te::attributefill::VALUE)
638  newName += "value";
639  else if(func == te::attributefill::MIN_VALUE)
640  newName += "min_val";
641  else if(func == te::attributefill::MAX_VALUE)
642  newName += "max_val";
643  else if(func == te::attributefill::MEAN)
644  newName += "mean";
645  else if(func == te::attributefill::SUM)
646  newName += "sum_values";
647  else if(func == te::attributefill::COUNT)
648  newName += "total_values";
649  else if(func == te::attributefill::VALID_COUNT)
650  newName += "total_notnull_values";
651  else if (func == te::attributefill::COUNT_DISTINCT)
652  newName += "total_distinct";
654  newName += "stand_dev";
655  else if(func == te::attributefill::VARIANCE)
656  newName += "variance";
657  else if(func == te::attributefill::SKEWNESS)
658  newName += "skewness";
659  else if(func == te::attributefill::KURTOSIS)
660  newName += "kurtosis";
661  else if(func == te::attributefill::AMPLITUDE)
662  newName += "amplitude";
663  else if(func == te::attributefill::MEDIAN)
664  newName += "median";
665  else if(func == te::attributefill::VAR_COEFF)
666  newName += "coeff_variation";
667  else if(func == te::attributefill::MODE)
668  newName += "mode";
670  newName += "class_high_occurrence";
672  newName += "class_high_area";
673  else if(func == te::attributefill::MIN_DISTANCE)
674  newName += "min_distance";
676  newName += "dis_cent";
677  else if(func == te::attributefill::PRESENCE)
678  newName += "presence";
680  newName += "percent_of_total_area";
682  newName += "percent_area_class";
683  else if(func == te::attributefill::WEIGHTED)
684  newName += "weigh_area";
685  else if(func == te::attributefill::WEIGHTED_SUM)
686  newName += "weigh_sum_area";
687  else if(func == te::attributefill::PERCENT_CLASS)
688  newName += "percent_class";
689 
690  return newName;
691 }
692 
696  bool& hasInvalid)
697 {
698  std::size_t toSpatialPos = te::da::GetFirstSpatialPropertyPos(toDs);
699 
700  std::unique_ptr<te::gm::Geometry> geom = toDs->getGeometry(toSpatialPos);
701 
702  std::vector<size_t> report;
703  rtree->search(*geom->getMBR(), report);
704 
705  std::vector<std::size_t> interVec;
706  for(std::size_t i = 0; i < report.size(); ++i)
707  {
708  //fromDs->move(report[i]);
709 
710  te::gm::Geometry* g = m_mapGeom[report[i]];//fromDs->getGeometry(fromSpatialPos);
711 
712  if (!g->isValid())
713  hasInvalid = true;
714 
715  if(geom->intersects(g) && !geom->touches(g))
716  {
717  interVec.push_back(report[i]);
718  }
719  }
720  return interVec;
721 }
722 
723 std::vector<double> te::attributefill::VectorToVectorMemory::getNumValues(std::vector< std::vector<te::dt::AbstractData*> > dataValues, std::size_t pos)
724 {
725  std::vector<double> result;
726 
727  for (std::size_t t = 0; t < dataValues.size(); ++t)
728  {
729  std::vector<te::dt::AbstractData*> data = dataValues[t];
730 
731  if (!data[pos])
732  {
733  result.push_back(double(0.0f));
734  continue;
735  }
736 
737  if (data[pos]->getTypeCode() == te::dt::INT16_TYPE ||
738  data[pos]->getTypeCode() == te::dt::UINT16_TYPE ||
739  data[pos]->getTypeCode() == te::dt::INT32_TYPE ||
740  data[pos]->getTypeCode() == te::dt::UINT32_TYPE ||
741  data[pos]->getTypeCode() == te::dt::INT64_TYPE ||
742  data[pos]->getTypeCode() == te::dt::UINT64_TYPE ||
743  data[pos]->getTypeCode() == te::dt::FLOAT_TYPE ||
744  data[pos]->getTypeCode() == te::dt::DOUBLE_TYPE ||
745  data[pos]->getTypeCode() == te::dt::CINT16_TYPE ||
746  data[pos]->getTypeCode() == te::dt::CINT32_TYPE ||
747  data[pos]->getTypeCode() == te::dt::CFLOAT_TYPE ||
748  data[pos]->getTypeCode() == te::dt::CDOUBLE_TYPE)
749  {
750  std::string strValue = data[pos]->toString();
751 
752  result.push_back(boost::lexical_cast<double>(strValue));
753  }
754  }
755 
756  return result;
757 }
758 
759 std::vector<std::string> te::attributefill::VectorToVectorMemory::getStrValues(std::vector< std::vector<te::dt::AbstractData*> > dataValues, std::size_t pos)
760 {
761  std::vector<std::string> result;
762 
763  for (std::size_t t = 0; t < dataValues.size(); ++t)
764  {
765  std::vector<te::dt::AbstractData*> data = dataValues[t];
766 
767  if (!data[pos])
768  {
769  result.push_back("");
770  continue;
771  }
772 
773  if (data[pos]->getTypeCode() == te::dt::STRING_TYPE)
774  result.push_back(data[pos]->toString());
775 
776  }
777 
778  return result;
779 }
780 
782  const std::string& propertyName,
783  std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
784 {
785  std::set<std::string> aux;
786 
787  for (auto v : dataValues)
788  {
789  int propIndex = te::da::GetPropertyIndex(fromDs, propertyName);
790 
791  if(v[propIndex])
792  aux.insert(v[propIndex]->toString());
793  }
794 
795  return (int)aux.size();
796 }
797 
799 {
800  if(type == te::attributefill::MIN_VALUE ||
802  type == te::attributefill::MEAN ||
803  type == te::attributefill::SUM ||
804  type == te::attributefill::COUNT ||
807  type == te::attributefill::VARIANCE ||
808  type == te::attributefill::SKEWNESS ||
809  type == te::attributefill::KURTOSIS ||
811  type == te::attributefill::MEDIAN ||
813  type == te::attributefill::MODE)
814  {
815  return true;
816  }
817 
818  return false;
819 }
820 
822 {
823  if(type == te::attributefill::AMPLITUDE)
824  return ss.m_amplitude;
825  else if(type == te::attributefill::COUNT)
826  return ss.m_count;
827  else if(type == te::attributefill::KURTOSIS)
828  return ss.m_kurtosis;
829  else if(type == te::attributefill::MAX_VALUE)
830  return ss.m_maxVal;
831  else if(type == te::attributefill::MEAN)
832  return ss.m_mean;
833  else if(type == te::attributefill::MEDIAN)
834  return ss.m_median;
835  else if(type == te::attributefill::MIN_VALUE)
836  return ss.m_minVal;
837  else if(type == te::attributefill::SKEWNESS)
838  return ss.m_skewness;
840  return ss.m_stdDeviation;
841  else if(type == te::attributefill::SUM)
842  return ss.m_sum;
843  else if(type == te::attributefill::VALID_COUNT)
844  return ss.m_validCount;
845  else if(type == te::attributefill::VAR_COEFF)
846  return ss.m_varCoeff;
847  else if(type == te::attributefill::VARIANCE)
848  return ss.m_variance;
849  else
850  return -1;
851 }
852 
854 {
855  if(type == te::attributefill::MAX_VALUE)
856  return ss.m_maxVal;
857  else if(type == te::attributefill::MIN_VALUE)
858  return ss.m_minVal;
859  else if(type == te::attributefill::MODE)
860  return ss.m_mode;
861  else if(type == te::attributefill::COUNT)
862  return boost::lexical_cast<std::string>(ss.m_count);
863  else if(type == te::attributefill::VALID_COUNT)
864  return boost::lexical_cast<std::string>(ss.m_validCount);
865  else
866  return "null";
867 }
868 
870 {
871  std::string result;
872  std::vector<double> values = ss.m_mode;
873  for(std::size_t i = 0; i < values.size(); ++i)
874  {
875  if(i == 0)
876  result += boost::lexical_cast<std::string>(values[i]);
877  else
878  result += ", " + boost::lexical_cast<std::string>(values[i]);
879  }
880 
881  return result;
882 }
883 
884 std::vector<std::vector<te::dt::AbstractData*> > te::attributefill::VectorToVectorMemory::getDataValues(te::da::DataSet* fromDs,
885  std::vector<std::size_t> dsPos)
886 {
887  std::vector<std::vector<te::dt::AbstractData*> > result;
888 
889  for(std::size_t i = 0; i < dsPos.size(); ++i)
890  {
891  std::vector<te::dt::AbstractData*> resultItem;
892 
893  fromDs->move(dsPos[i]);
894 
895  for (std::size_t t = 0; t < fromDs->getNumProperties(); ++t)
896  {
897  if (fromDs->isNull(t))
898  resultItem.push_back(nullptr);
899  else
900  resultItem.push_back(fromDs->getValue(t).release());
901  }
902  result.push_back(resultItem);
903  }
904 
905  return result;
906 }
907 
909  std::vector<std::size_t> dsPos,
910  const std::string& propertyName,
911  std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
912 {
913  int propIndex = te::da::GetPropertyIndex(fromDs, propertyName);
914  int propType = fromDs->getPropertyDataType(static_cast<size_t>(propIndex));
915 
916  std::size_t highOccur = 0;
917  std::vector<std::string> highValues;
918 
919  std::map<std::string, std::size_t> counter;
920  for (std::size_t i = 0; i < dsPos.size(); ++i)
921  {
922  if (!dataValues[i][static_cast<size_t>(propIndex)])
923  continue;
924 
925  std::string value = dataValues[i][static_cast<size_t>(propIndex)]->toString();
926 
927  if (counter.find(value) == counter.end())
928  {
929  counter[value] = 1;
930 
931  if(highOccur == 0)
932  highOccur = 1;
933  }
934  else
935  {
936  std::size_t aux = counter[value] + 1;
937  counter[value] = aux;
938 
939  if (aux > highOccur)
940  highOccur = aux;
941  }
942  }
943 
944  std::map<std::string, std::size_t>::iterator it = counter.begin();
945  while (it != counter.end())
946  {
947  if (it->second == highOccur)
948  highValues.push_back(it->first);
949  ++it;
950  }
951 
952  if (highValues.size() > 1)
953  {
954  std::vector<double> intVec;
955 
956  if (propType == te::dt::STRING_TYPE)
957  {
959  te::stat::GetStringStatisticalSummary(highValues, ssStr);
960 
961  return getDataBasedOnType(ssStr.m_minVal, propType);
962  }
963  else
964  {
965  for (std::size_t i = 0; i < highValues.size(); ++i)
966  {
967  intVec.push_back(boost::lexical_cast<double>(highValues[i]));
968  }
969 
972  te::stat::Mode(intVec, ssNum);
973  std::string strVal = boost::lexical_cast<std::string>(ssNum.m_minVal);
974  return getDataBasedOnType(strVal, propType);
975  }
976  }
977  else if (!highValues.empty())
978  return getDataBasedOnType(highValues[0], propType);
979  else
980  return nullptr;
981 }
982 
984  std::size_t toSrid,
985  te::da::DataSet* fromDs,
986  std::size_t,
987  std::vector<std::size_t> dsPos,
988  const std::string& propertyName,
989  std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
990 {
991  std::size_t toGeomPos = te::da::GetFirstSpatialPropertyPos(toDs);
992 
993  int propIndex = te::da::GetPropertyIndex(fromDs, propertyName);
994  int propType = fromDs->getPropertyDataType(static_cast<size_t>(propIndex));
995 
996  std::unique_ptr<te::gm::Geometry> toGeom = toDs->getGeometry(toGeomPos);
997  if(toGeom->getSRID() <= 0)
998  toGeom->setSRID(static_cast<int>(toSrid));
999 
1000  std::map<std::string, double> classAreaMap;
1001  for(std::size_t i = 0; i < dsPos.size(); ++i)
1002  {
1003  if (!dataValues[i][static_cast<size_t>(propIndex)])
1004  continue;
1005 
1006  te::gm::Geometry* fromGeom = m_mapGeom[dsPos[i]];
1007 
1008  std::unique_ptr<te::gm::Geometry> interGeom;
1009 
1010  if(!checkGeometries(fromGeom, dsPos[i], toGeom.get()))
1011  {
1012  m_hasErrors = true;
1013  continue;
1014  }
1015 
1016  try
1017  {
1018  interGeom.reset(toGeom->intersection(fromGeom));
1019  }
1020  catch(const std::exception &e)
1021  {
1022 #ifdef TERRALIB_LOGGER_ENABLED
1023  std::string ex = e.what();
1024  TE_LOG_INFO(ex);
1025 #endif //TERRALIB_LOGGER_ENABLED
1026  m_hasErrors = true;
1027  continue;
1028  }
1029 
1030  std::string value = dataValues[i][static_cast<size_t>(propIndex)]->toString();
1031 
1032  double area = getArea(interGeom.get());
1033 
1034  if(classAreaMap.find(value) == classAreaMap.end())
1035  {
1036  classAreaMap[value] = area;
1037  }
1038  else
1039  {
1040  double aux = classAreaMap[value];
1041  classAreaMap[value] = aux + area;
1042  }
1043  }
1044 
1045  std::map<std::string, double>::iterator it = classAreaMap.begin();
1046  std::string value;
1047  double aux = 0;
1048  while(it != classAreaMap.end())
1049  {
1050  if(aux < it->second)
1051  {
1052  aux = it->second;
1053  value = it->first;
1054  }
1055 
1056  ++it;
1057  }
1058 
1059  te::dt::AbstractData* data = getDataBasedOnType(value, propType);
1060 
1061  return data;
1062 }
1063 
1065  std::vector<std::size_t> dsPos,
1066  const std::string& propertyName,
1067  std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
1068 {
1069  int propIndex = te::da::GetPropertyIndex(fromDs, propertyName);
1070 
1071  std::map<std::string, double> result;
1072 
1073  std::map<std::string, std::size_t> aux;
1074  for(std::size_t i = 0; i < dsPos.size(); ++i)
1075  {
1076  if (dataValues[i][static_cast<size_t>(propIndex)] == nullptr)
1077  continue;
1078 
1079  std::string value = dataValues[i][static_cast<size_t>(propIndex)]->toString();
1080 
1081  if(aux.find(value) == aux.end())
1082  {
1083  aux[value] = 1;
1084  }
1085  else
1086  {
1087  aux[value] += 1;
1088  }
1089  }
1090 
1091  std::size_t total = 0;
1092  std::map<std::string, std::size_t>::iterator it = aux.begin();
1093  while(it != aux.end())
1094  {
1095  total += it->second;
1096 
1097  ++it;
1098  }
1099 
1100  it = aux.begin();
1101  while(it != aux.end())
1102  {
1103  std::string normName = it->first;
1104  normalizeClassName(normName);
1105  result[normName] = (static_cast<double>(it->second / total));
1106 
1107  ++it;
1108  }
1109 
1110  return result;
1111 }
1112 
1114  std::size_t toSrid,
1115  te::da::DataSet*,
1116  std::size_t,
1117  std::vector<std::size_t> dsPos,
1118  const std::string&,
1119  std::vector< std::vector<te::dt::AbstractData*> >&)
1120 {
1121  std::size_t toGeomPos = te::da::GetFirstSpatialPropertyPos(toDs);
1122 
1123  std::unique_ptr<te::gm::Geometry> toGeom = toDs->getGeometry(toGeomPos);
1124  if(toGeom->getSRID() <= 0)
1125  toGeom->setSRID(static_cast<int>(toSrid));
1126 
1127  double classArea = 0;
1128  for(std::size_t i = 0; i < dsPos.size(); ++i)
1129  {
1130  //dataValues[i][propIndex];//fromDs->move(dsPos[i]);
1131 
1132  te::gm::Geometry* fromGeom = m_mapGeom[dsPos[i]];//fromDs->getGeometry(fromGeomPos);
1133 
1134  if(!checkGeometries(fromGeom, dsPos[i], toGeom.get()))
1135  {
1136  m_hasErrors = true;
1137  continue;
1138  }
1139 
1140  std::unique_ptr<te::gm::Geometry> interGeom(toGeom->intersection(fromGeom));
1141 
1142  classArea += getArea(interGeom.get());
1143  }
1144 
1145  double polArea = getArea(toGeom.get());
1146 
1147  return classArea/polArea;
1148 }
1149 
1151  std::size_t toSrid,
1152  te::da::DataSet* fromDs,
1153  std::size_t,
1154  std::vector<std::size_t> dsPos,
1155  const std::string& propertyName,
1156  std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
1157 {
1158  std::map<std::string, double> result;
1159 
1160  std::size_t toGeomPos = te::da::GetFirstSpatialPropertyPos(toDs);
1161 
1162  int propIndex = te::da::GetPropertyIndex(fromDs, propertyName);
1163 
1164  std::unique_ptr<te::gm::Geometry> toGeom = toDs->getGeometry(toGeomPos);
1165  if(toGeom->getSRID() <= 0)
1166  toGeom->setSRID(static_cast<int>(toSrid));
1167 
1168  double toGeomArea = getArea(toGeom.get());
1169 
1170  for(std::size_t i = 0; i < dsPos.size(); ++i)
1171  {
1172  if (dataValues[i][static_cast<size_t>(propIndex)] == nullptr)
1173  continue;
1174 
1175  te::gm::Geometry* fromGeom = m_mapGeom[dsPos[i]];
1176 
1177  if(!checkGeometries(fromGeom, dsPos[i], toGeom.get()))
1178  {
1179  m_hasErrors = true;
1180  continue;
1181  }
1182 
1183  std::unique_ptr<te::gm::Geometry> interGeom(toGeom->intersection(fromGeom));
1184 
1185  std::string value = dataValues[i][static_cast<size_t>(propIndex)]->toString();
1186 
1187  double area = getArea(interGeom.get());
1188 
1189  if(result.find(value) == result.end())
1190  {
1191  result[value] = area/toGeomArea;
1192  }
1193  else
1194  {
1195  result[value] += area/toGeomArea;
1196  }
1197  }
1198 
1199  return result;
1200 }
1201 
1203  std::size_t toSrid,
1204  te::da::DataSet* fromDs,
1205  std::size_t,
1206  std::vector<std::size_t> dsPos,
1207  const std::string& propertyName,
1208  std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
1209 {
1210  std::size_t toGeomPos = te::da::GetFirstSpatialPropertyPos(toDs);
1211 
1212  int propIndex = te::da::GetPropertyIndex(fromDs, propertyName);
1213 
1214  std::unique_ptr<te::gm::Geometry> toGeom = toDs->getGeometry(toGeomPos);
1215  if(toGeom->getSRID() <= 0)
1216  toGeom->setSRID(static_cast<int>(toSrid));
1217 
1218  double toGeomArea = getArea(toGeom.get());
1219 
1220  double weigh = 0;
1221 
1222  for(std::size_t i = 0; i < dsPos.size(); ++i)
1223  {
1224  if (dataValues[i][static_cast<size_t>(propIndex)] == nullptr)
1225  continue;
1226 
1227  te::gm::Geometry* fromGeom = m_mapGeom[dsPos[i]];
1228 
1229  if(!checkGeometries(fromGeom, dsPos[i], toGeom.get()))
1230  {
1231  m_hasErrors = true;
1232  continue;
1233  }
1234 
1235  std::unique_ptr<te::gm::Geometry> interGeom(toGeom->intersection(fromGeom));
1236 
1237  double value_num = 0;
1238 
1239  std::string value = dataValues[i][static_cast<size_t>(propIndex)]->toString();
1240  value_num = boost::lexical_cast<double>(value);
1241 
1242  double intersectionArea = getArea(interGeom.get());
1243 
1244  weigh += value_num*(intersectionArea/toGeomArea);
1245  }
1246 
1247  return weigh;
1248 }
1249 
1251  std::size_t toSrid,
1252  te::da::DataSet* fromDs,
1253  std::size_t,
1254  std::vector<std::size_t> dsPos,
1255  const std::string& propertyName,
1256  std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
1257 {
1258  std::size_t toGeomPos = te::da::GetFirstSpatialPropertyPos(toDs);
1259 
1260  int propIndex = te::da::GetPropertyIndex(fromDs, propertyName);
1261 
1262  std::unique_ptr<te::gm::Geometry> toGeom = toDs->getGeometry(toGeomPos);
1263  if(toGeom->getSRID() <= 0)
1264  toGeom->setSRID(static_cast<int>(toSrid));
1265 
1266  double weigh = 0;
1267 
1268  for(std::size_t i = 0; i < dsPos.size(); ++i)
1269  {
1270  if (dataValues[i][static_cast<size_t>(propIndex)] == nullptr)
1271  continue;
1272 
1273  te::gm::Geometry* fromGeom = m_mapGeom[dsPos[i]];
1274 
1275  double fromGeomArea = getArea(fromGeom);
1276 
1277  if(!checkGeometries(fromGeom, dsPos[i], toGeom.get()))
1278  {
1279  m_hasErrors = true;
1280  continue;
1281  }
1282 
1283  std::unique_ptr<te::gm::Geometry> interGeom(toGeom->intersection(fromGeom));
1284 
1285  double value_num = 0;
1286 
1287  std::string value = dataValues[i][static_cast<size_t>(propIndex)]->toString();
1288  value_num = boost::lexical_cast<double>(value);
1289 
1290  double intersectionArea = getArea(interGeom.get());
1291 
1292  weigh += value_num*(intersectionArea/fromGeomArea);
1293  }
1294 
1295  return weigh;
1296 }
1297 
1299 {
1300  if(type == te::gm::PolygonType ||
1301  type == te::gm::PolygonZType ||
1302  type == te::gm::PolygonMType ||
1303  type == te::gm::PolygonZMType)
1304  return true;
1305 
1306  return false;
1307 }
1308 
1310 {
1311  if(type == te::gm::LineStringType ||
1312  type == te::gm::LineStringMType ||
1313  type == te::gm::LineStringZMType ||
1314  type == te::gm::LineStringZType)
1315  return true;
1316 
1317  return false;
1318 }
1319 
1321 {
1322  if(type == te::gm::PointType ||
1323  type == te::gm::PointZType ||
1324  type == te::gm::PointMType ||
1325  type == te::gm::PointZMType)
1326  return true;
1327 
1328  return false;
1329 }
1330 
1332 {
1333  if(type == te::gm::MultiPolygonType ||
1334  type == te::gm::MultiPolygonZType ||
1335  type == te::gm::MultiPolygonMType ||
1337  return true;
1338 
1339  return false;
1340 }
1341 
1343 {
1344  if(type == te::gm::MultiLineStringMType ||
1345  type == te::gm::MultiLineStringType ||
1348  return true;
1349 
1350  return false;
1351 }
1352 
1354 {
1355  if(type == te::gm::MultiPointType ||
1356  type == te::gm::MultiPointZType ||
1357  type == te::gm::MultiPointMType ||
1358  type == te::gm::MultiPointZMType)
1359  return true;
1360 
1361  return false;
1362 }
1363 
1365 {
1366  te::gm::GeomType geomType = geom->getGeomTypeId();
1367 
1368  double area = 0;
1369 
1370  switch(geomType)
1371  {
1372  case te::gm::PolygonType:
1373  case te::gm::PolygonZType:
1374  case te::gm::PolygonMType:
1375  case te::gm::PolygonZMType:
1376  {
1377  te::gm::Polygon* g = dynamic_cast<te::gm::Polygon*>(geom);
1378  area = g->getArea();
1379  break;
1380  }
1381 
1386  {
1387  te::gm::MultiPolygon* g = dynamic_cast<te::gm::MultiPolygon*>(geom);
1388  area = g->getArea();
1389  break;
1390  }
1391 
1396  {
1397  te::gm::MultiSurface* col = dynamic_cast<te::gm::MultiSurface*>(geom);
1398  for (std::size_t j = 0; j < col->getNumGeometries(); ++j)
1399  {
1400  te::gm::Geometry* auxGeom = col->getGeometryN(j);
1401  if (isPolygon(auxGeom->getGeomTypeId()))
1402  {
1403  area += dynamic_cast<te::gm::Polygon*>(auxGeom)->getArea();
1404  }
1405  else if (isMultiPolygon(auxGeom->getGeomTypeId()))
1406  {
1407  area += dynamic_cast<te::gm::MultiPolygon*>(auxGeom)->getArea();
1408  }
1409  }
1410 
1411  break;
1412  }
1417  {
1419  for(std::size_t j = 0; j < col->getNumGeometries(); ++j)
1420  {
1421  te::gm::Geometry* auxGeom = col->getGeometryN(j);
1422  if(isPolygon(auxGeom->getGeomTypeId()))
1423  {
1424  area += dynamic_cast<te::gm::Polygon*>(auxGeom)->getArea();
1425  }
1426  else if(isMultiPolygon(auxGeom->getGeomTypeId()))
1427  {
1428  area += dynamic_cast<te::gm::MultiPolygon*>(auxGeom)->getArea();
1429  }
1430  }
1431 
1432  break;
1433  }
1434  default:
1435  {
1436  throw te::common::Exception(TE_TR("Unexpected geometry type!"));
1437  }
1438  }
1439 
1440  return area;
1441 }
1442 
1444 {
1445  te::dt::AbstractData* data = nullptr;
1446 
1447  switch(type)
1448  {
1449  case te::dt::STRING_TYPE:
1450  {
1452  break;
1453  }
1454  case te::dt::INT16_TYPE:
1455  {
1456  int16_t v = boost::lexical_cast<int16_t>(strValue);
1458  break;
1459  }
1460  case te::dt::INT32_TYPE:
1461  {
1462  int32_t v = boost::lexical_cast<int32_t>(strValue);
1464  break;
1465  }
1466  case te::dt::INT64_TYPE:
1467  {
1468  int64_t v = boost::lexical_cast<int64_t>(strValue);
1470  break;
1471  }
1472  case te::dt::UINT16_TYPE:
1473  {
1474  uint16_t v = boost::lexical_cast<uint16_t>(strValue);
1476  break;
1477  }
1478  case te::dt::UINT32_TYPE:
1479  {
1480  uint32_t v = boost::lexical_cast<uint32_t>(strValue);
1482  break;
1483  }
1484  case te::dt::UINT64_TYPE:
1485  {
1486  uint64_t v = boost::lexical_cast<uint64_t>(strValue);
1488  break;
1489  }
1490  default:
1491  {
1492  throw te::common::Exception(TE_TR("Unexpected data type!"));
1493  }
1494  }
1495 
1496  return data;
1497 }
1498 
1500 {
1501  std::size_t geomPos = te::da::GetFirstSpatialPropertyPos(data);
1502 
1503  KD_ADAPTATIVE_TREE* kdtree = new KD_ADAPTATIVE_TREE(*data->getExtent(geomPos).release(), 5);
1504 
1505  std::vector<std::pair<te::gm::Coord2D, te::gm::Point> > kdset;
1506 
1507  data->moveBeforeFirst();
1508 
1509  while(data->moveNext())
1510  {
1511  std::unique_ptr<te::gm::Geometry> geom = data->getGeometry(geomPos);
1512 
1513  std::vector<te::gm::Point*> allPoints = getAllPointsOfGeometry(geom.get());
1514 
1515  for(std::size_t i = 0; i < allPoints.size(); ++i)
1516  {
1517  te::gm::Point* p = allPoints[i];
1518 
1519  if(p->getSRID() != static_cast<int>(toSrid))
1520  {
1521  p->transform(static_cast<int>(toSrid));
1522  }
1523 
1524  te::gm::Coord2D coord(p->getX(), p->getY());
1525  te::gm::Point point(*p);
1526  kdset.push_back(std::pair<te::gm::Coord2D, te::gm::Point>(coord, point));
1527  }
1528 
1529  te::common::FreeContents(allPoints);
1530  }
1531 
1532  kdtree->build(kdset);
1533 
1534  return kdtree;
1535 }
1536 
1538  std::size_t,
1539  te::da::DataSet*,
1540  std::size_t,
1541  KD_ADAPTATIVE_TREE* kdtree)
1542 {
1543  std::size_t toGeomPos = te::da::GetFirstSpatialPropertyPos(toDs);
1544  std::unique_ptr<te::gm::Geometry> toGeom = toDs->getGeometry(toGeomPos);
1545 
1546  std::vector<te::gm::Point*> allPoints = getAllPointsOfGeometry(toGeom.get());
1547 
1548  std::vector<double> distances;
1549 
1550  for (std::size_t i = 0; i < allPoints.size(); ++i)
1551  {
1552  te::gm::Point* p = allPoints[i];
1553  te::gm::Coord2D key = te::gm::Coord2D(p->getX(), p->getY());
1554  std::vector<te::gm::Point> points;
1555  points.push_back(te::gm::Point(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
1556  std::vector<double> sqrDists;
1557 
1558  kdtree->nearestNeighborSearch(key, points, sqrDists, 1);
1559 
1560  distances.push_back(sqrDists[0]);
1561  }
1562 
1563  te::common::FreeContents(allPoints);
1564 
1565  double finalResult = std::numeric_limits<double>::max();
1566  for (std::size_t i = 0; i < distances.size(); ++i)
1567  {
1568  if (distances[i] < finalResult)
1569  finalResult = distances[i];
1570  }
1571 
1572  return sqrt(finalResult);
1573 }
1574 
1576  std::size_t toSrid,
1577  te::da::DataSet* /*fromDs*/,
1578  std::size_t fromSrid,
1579  KD_ADAPTATIVE_TREE* kdtree,
1581 {
1582  std::size_t toGeomPos = te::da::GetFirstSpatialPropertyPos(toDs);
1583  std::unique_ptr<te::gm::Geometry> toGeom = toDs->getGeometry(toGeomPos);
1584 
1585  te::gm::Coord2D centroid = toGeom->getCentroid();
1586  te::gm::Point aux(centroid.x, centroid.y);
1587  aux.setSRID(static_cast<int>(toSrid));
1588 
1589  // Verify if the centroid intersects the a geometry of from layer
1590  std::vector<size_t> report;
1591  rtree->search(*aux.getMBR(), report);
1592 
1593  for (std::size_t i : report)
1594  {
1595  te::gm::Geometry* g = m_mapGeom[i];
1596 
1597  if (g->getSRID() != aux.getSRID())
1598  aux.transform(g->getSRID());
1599 
1600  if (g->contains(&aux) || g->intersects(&aux))
1601  return 0;
1602  }
1603 
1604  std::vector<te::gm::Point> points;
1605  points.push_back(te::gm::Point(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
1606  std::vector<double> sqrDists;
1607 
1608  kdtree->nearestNeighborSearch(centroid, points, sqrDists, 1);
1609 
1610  if (fromSrid != static_cast<size_t>(aux.getSRID()))
1611  aux.transform(static_cast<int>(fromSrid));
1612 
1613  // Por algum motivo o sqrDists nao esta com a distancia correta
1614  double distance = points[0].distance(&aux);
1615 
1616  return distance;
1617 }
1618 
1620 {
1621  std::size_t geomType = geom->getGeomTypeId();
1622 
1623  std::vector<te::gm::Point*> result;
1624 
1625  switch(geomType)
1626  {
1627  case te::gm::PointType:
1628  case te::gm::PointZType:
1629  case te::gm::PointMType:
1630  case te::gm::PointZMType:
1631  {
1632  te::gm::Point* g = dynamic_cast<te::gm::Point*>(geom);
1633  result.push_back(new te::gm::Point(*g));
1634  break;
1635  }
1640  {
1641  te::gm::MultiPoint* g = dynamic_cast<te::gm::MultiPoint*>(geom);
1642  for(std::size_t i = 0; i < g->getNumGeometries(); ++i)
1643  {
1644  te::gm::Geometry* gAux = g->getGeometryN(i);
1645 
1646  std::vector<te::gm::Point*> vec = getAllPointsOfGeometry(gAux);
1647  result.insert(result.end(), vec.begin(), vec.end());
1648  }
1649  break;
1650  }
1651  case te::gm::PolygonType:
1652  case te::gm::PolygonZType:
1653  case te::gm::PolygonMType:
1654  case te::gm::PolygonZMType:
1655  {
1656  te::gm::Polygon* g = dynamic_cast<te::gm::Polygon*>(geom);
1657 
1658  for(std::size_t i = 0; i < g->getNumRings(); ++i)
1659  {
1660 
1661  te::gm::Curve* c = g->getRingN(i);
1662 
1663  te::gm::LinearRing* lr = dynamic_cast<te::gm::LinearRing*>(c);
1664 
1665  for(std::size_t j = 0; j < lr->getNPoints(); ++j)
1666  {
1667  result.push_back(lr->getPointN(j).release());
1668  }
1669  }
1670 
1671  break;
1672  }
1677  {
1678  te::gm::MultiPolygon* g = dynamic_cast<te::gm::MultiPolygon*>(geom);
1679 
1680  for(std::size_t i = 0; i < g->getNumGeometries(); ++i)
1681  {
1682  te::gm::Geometry* gAux = g->getGeometryN(i);
1683 
1684  std::vector<te::gm::Point*> vec = getAllPointsOfGeometry(gAux);
1685  result.insert(result.end(), vec.begin(), vec.end());
1686  }
1687  break;
1688  }
1693  {
1694  te::gm::LineString* g = dynamic_cast<te::gm::LineString*>(geom);
1695 
1696  for(std::size_t i = 0; i < g->getNPoints(); ++i)
1697  {
1698  result.push_back(g->getPointN(i).release());
1699  }
1700 
1701  break;
1702  }
1707  {
1708  te::gm::MultiLineString* g = dynamic_cast<te::gm::MultiLineString*>(geom);
1709 
1710  for(std::size_t i = 0; i < g->getNumGeometries(); ++i)
1711  {
1712  te::gm::Geometry* gAux = g->getGeometryN(i);
1713 
1714  std::vector<te::gm::Point*> vec = getAllPointsOfGeometry(gAux);
1715  result.insert(result.end(), vec.begin(), vec.end());
1716  }
1717 
1718  break;
1719  }
1720  default:
1721  {
1722  return std::vector<te::gm::Point*>();
1723  }
1724  }
1725 
1726  return result;
1727 }
1728 
1730 {
1731  std::map<std::string, std::vector<te::attributefill::OperationType> >::iterator it = m_options.begin();
1732 
1733  while(it != m_options.end())
1734  {
1735  std::vector<te::attributefill::OperationType> ops = it->second;
1736 
1737  for(std::size_t i = 0; i < ops.size(); ++i)
1738  {
1739  if(ops[i] == te::attributefill::MIN_DISTANCE ||
1741  ops[i] == te::attributefill::PRESENCE)
1742  return true;
1743  }
1744  ++it;
1745  }
1746 
1747  return false;
1748 }
1749 
1751 {
1752  if(!fromGeom->isValid())
1753  {
1754 #ifdef TERRALIB_LOGGER_ENABLED
1755  std::string ex = TE_TR("\"From\" layer geometry at position ");
1756  ex += boost::lexical_cast<std::string>(fromPos);
1757  ex += TE_TR(" is invalid.");
1758  TE_LOG_INFO(ex);
1759 #endif //TERRALIB_LOGGER_ENABLED
1760 
1761  return false;
1762  }
1763  else if(!toGeom->isValid())
1764  {
1765 #ifdef TERRALIB_LOGGER_ENABLED
1766  std::string ex = TE_TR("\"To\" layer geometry is invalid.");
1767  TE_LOG_INFO(ex);
1768 #endif //TERRALIB_LOGGER_ENABLED
1769 
1770  return false;
1771  }
1772 
1773  return true;
1774 }
std::vector< te::gm::Point * > getAllPointsOfGeometry(te::gm::Geometry *geom)
It get all points of a geometry.
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
double getValue(te::stat::NumericStatisticalSummary ss, te::attributefill::OperationType type)
It get the value of required operation type from numeric statistical summary.
std::size_t getNumRings() const
It returns the number of rings in this CurvePolygon.
Definition: CurvePolygon.h:153
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
void setTitle(const std::string &title)
It sets a human descriptive title for the DataSetType.
Definition: DataSetType.h:137
bool save(std::unique_ptr< te::mem::DataSet > result, std::unique_ptr< te::da::DataSetType > outDsType)
std::vector< std::string > m_toLayerProps
bool isStatistical(te::attributefill::OperationType type)
It verify if the operation is a statistical operation.
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
A structure to hold the set of statistics from a set of numerical values.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
double y
y-coordinate.
Definition: Coord2D.h:114
void setDouble(std::size_t i, double value)
It sets the value of the i-th property.
void setSRID(int srid) _NOEXCEPT_OP(true)
It sets the Spatial Reference System ID of the Point.
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
An atomic property like an integer or double.
te::map::AbstractLayerPtr m_toLayer
std::vector< double > getNumValues(std::vector< std::vector< te::dt::AbstractData * > > dataValues, std::size_t pos)
It get the numeric values of a vector of abstract data.
std::string Convert2LCase(const std::string &value)
It converts a string to lower case.
Definition: StringUtils.h:202
TEDATAACCESSEXPORT void AssociateDataSetTypeConverterSRID(DataSetTypeConverter *converter, const int &inputSRID, const int &outputSRID=TE_UNKNOWN_SRS)
double x
x-coordinate.
Definition: Coord2D.h:113
A class that represents an R-tree.
A class that models the description of a dataset.
Definition: DataSetType.h:72
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
Definition: Curve.h:58
virtual const char * what() const
It outputs the exception message.
void useTimer(bool flag)
Used to define if task use progress timer information.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
std::map< std::string, std::vector< te::attributefill::OperationType > > m_options
te::dt::AbstractData * getDataBasedOnType(const std::string &strValue, const int type)
It get a abstract data with the value based on the type.
A class that represents a two dimensional K-d Tree (2-d Tree) that store data-elements into the leafs...
This class can be used to inform the progress of a task.
Definition: TaskProgress.h:53
std::vector< std::size_t > getIntersections(te::da::DataSet *toDs, te::da::DataSet *fromDs, te::sam::rtree::Index< size_t, 8 > *rtree, bool &hasInvalid)
It verify all intersection between the "From" and "To" data sets.
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property.
std::unique_ptr< Point > getPointN(std::size_t i) const
It returns the specified point in this LineString.
PrimaryKey * getPrimaryKey() const
It returns the primary key associated to the dataset type.
Definition: DataSetType.h:214
std::map< std::string, double > getPercentageOfEachClassByArea(te::da::DataSet *toDs, std::size_t toSrid, te::da::DataSet *fromDs, std::size_t fromSrid, std::vector< std::size_t > dsPos, const std::string &propertyName, std::vector< std::vector< te::dt::AbstractData * > > &dataValues)
It get the percentage of each class intersection area in the total area.
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
bool checkGeometries(te::gm::Geometry *fromGeom, std::size_t fromPos, te::gm::Geometry *toGeom)
#define TE_TR(message)
It marks a string in order to get translated.
Definition: Translator.h:242
virtual bool intersects(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns true if the geometry object spatially intersects rhs geometry.
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
std::string ReplaceSpecialChars(const std::string &str, bool &changed)
It replace special characters of a string.
Definition: StringUtils.h:376
It models a property definition.
Definition: Property.h:59
TEDATAACCESSEXPORT int GetPropertyIndex(te::da::DataSet *dataSet, const std::string propName)
bool isActive() const
Verify if the task is active.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the primary key.
Definition: PrimaryKey.h:109
void setDefaultValue(std::string *d)
It sets the default value associated to the property, or NULL if none is associated.
virtual bool move(std::size_t i)=0
It moves the dataset internal pointer to a given position.
void setTotalSteps(int value)
Set the task total stepes.
std::string getPropertyName(te::dt::Property *prop, te::attributefill::OperationType func)
It return a name based on original property name and the selected operation.
An converter for DataSetType.
Vector to Vector processing.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
virtual int code() const
It gets the exception code.
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
double getPercentageOfTotalArea(te::da::DataSet *toDs, std::size_t toSrid, te::da::DataSet *fromDs, std::size_t fromSrid, std::vector< std::size_t > dsPos, const std::string &propertyName, std::vector< std::vector< te::dt::AbstractData * > > &dataValues)
It get the percentage of intersection area in the total area.
void remove(Constraint *c)
It removes the constraint.
TEDATAACCESSEXPORT std::size_t GetFirstSpatialPropertyPos(const te::da::DataSet *dataset)
It returns the first dataset spatial property or NULL if none is found.
const std::vector< Property * > & getProperties() const
It returns the list of properties describing the CompositeProperty.
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
bool isMultiPoint(te::gm::GeomType type)
It verify if the geometry is a multi point.
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:152
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
A point with x and y coordinate values.
Definition: Point.h:50
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
virtual bool isValid() const _NOEXCEPT_OP(false)
It tells if the geometry is well formed.
An Envelope defines a 2D rectangular region.
void build(std::vector< std::pair< kdKey, kdDataItem > > &dataSet)
It inserts the data set into the tree.
te::sam::kdtree::AdaptativeIndex< KD_ADAPTATIVE_NODE > KD_ADAPTATIVE_TREE
void transform(int srid) _NOEXCEPT_OP(false)
It converts the coordinate values of the point to the new spatial reference system.
bool hasNoIntersectionOperations()
Verify if has operations that don&#39;t need the intersections.
TESTATEXPORT void GetNumericStatisticalSummary(std::vector< double > &values, te::stat::NumericStatisticalSummary &ss, double nullValue)
te::gm::Polygon * p
KD_ADAPTATIVE_TREE * getKDtree(te::da::DataSet *data, std::size_t toSrid)
It return a KDTree.
std::size_t getNPoints() const
It returns the number of points (vertexes) in the linestring.
Definition: LineString.h:193
virtual bool contains(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns true if this geometry object spatially contains rhs geometry.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
virtual std::string getAsString(std::size_t i, int precision=0) const
Method for retrieving a data value as a string plain representation.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
te::dt::AbstractData * getClassWithHighestOccurrence(te::da::DataSet *fromDs, std::vector< std::size_t > dsPos, const std::string &propertyName, std::vector< std::vector< te::dt::AbstractData * > > &dataValues)
It get the class with highest occurrence from "From" data set in "To" data set.
double getWeightedSumByArea(te::da::DataSet *toDs, std::size_t toSrid, te::da::DataSet *fromDs, std::size_t fromSrid, std::vector< std::size_t > dsPos, const std::string &propertyName, std::vector< std::vector< te::dt::AbstractData * > > &dataValues)
It get the sum of weighted average if intersections values.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
std::string getModeValue(te::stat::NumericStatisticalSummary ss)
It get a string with the mode operation format.
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
te::dt::AbstractData * getClassWithHighestIntersectionArea(te::da::DataSet *toDs, std::size_t toSrid, te::da::DataSet *fromDs, std::size_t fromSrid, std::vector< std::size_t > dsPos, const std::string &propertyName, std::vector< std::vector< te::dt::AbstractData * > > &dataValues)
It get the class with highest intersection area from "From" data set in "To" data set...
std::vector< std::string > getDistinctClasses(te::da::DataSet *fromDs, const std::string &propertyName)
It return distincts values of a property from the "From" data set.
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.
Configuration flags for the Attribute Fill module of TerraLib.
double getArea() const
It returns the area of this surface, as measured in the spatial reference system of this surface...
int getTotalNumberOfDistinctValues(te::da::DataSet *fromDs, const std::string &propertyName, std::vector< std::vector< te::dt::AbstractData * > > &dataValues)
Geometry * getGeometryN(std::size_t i) const
It returns the n-th geometry in this GeometryCollection.
int getType() const
It returns the property data type.
Definition: Property.h:161
void add(Constraint *c)
It adds a new constraint.
MultiLineString is a MultiCurve whose elements are LineStrings.
TESTATEXPORT void GetStringStatisticalSummary(std::vector< std::string > &values, te::stat::StringStatisticalSummary &ss, const std::string &nullValue)
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.
bool run()
It execute the operations.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
double getArea() const
It returns the area of this MultiSurface, as measured in the spatial reference system of this multisu...
bool isLine(te::gm::GeomType type)
It verify if the geometry is a line.
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
MultiSurface is a class that represents a 2-dimensional GeometryCollection whose elements are surface...
Definition: MultiSurface.h:54
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.
A structure to hold the set of statistics from a set of categorical (sample) values.
It describes a primary key (pk) constraint.
Definition: PrimaryKey.h:52
std::vector< std::vector< te::dt::AbstractData * > > getDataValues(te::da::DataSet *fromDs, std::vector< std::size_t > dsPos)
It get the value of all positions in "To" data set that has intersection with a position of "From" da...
TEDATAACCESSEXPORT bool IsValidName(const std::string &name, std::string &invalidChar)
It checks if the name is not valid as the existence of invalid characters, reserved words...
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.
bool isPolygon(te::gm::GeomType type)
It verify if the geometry is a polygon.
#define TE_LOG_DEBUG(message)
Use this tag in order to log a message to the TerraLib default logger with the DEBUG level...
Definition: Logger.h:304
std::map< std::size_t, te::gm::Geometry * > m_mapGeom
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
te::da::DataSetType * getOutputDataSetType()
It create a data set type based on selecteds properties and operations.
bool isMultiLine(te::gm::GeomType type)
It verify if the geometry is a multi line.
A template for atomic data types (integers, floats, strings and others).
Definition: SimpleData.h:59
void setString(std::size_t i, const std::string &value)
It sets the value of the i-th property.
bool isPoint(te::gm::GeomType type)
It verify if the geometry is a point.
double getMinimumDistanceFromCentroid(te::da::DataSet *toDs, std::size_t toSrid, te::da::DataSet *fromDs, std::size_t fromSrid, KD_ADAPTATIVE_TREE *kdtree, te::sam::rtree::Index< size_t, 8 > *rtree)
It get the minimum distance of objects centroid that not intersect.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
It is a collection of other geometric objects.
te::map::AbstractLayerPtr m_fromLayer
double getMinimumDistance(te::da::DataSet *toDs, std::size_t toSrid, te::da::DataSet *fromDs, std::size_t fromSrid, KD_ADAPTATIVE_TREE *kdtree)
It get the minimum distance of objects that not intersect.
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
void nearestNeighborSearch(const kdKey &key, std::vector< kdDataItem > &report, std::vector< double > &sqrDists, const std::size_t &k) const
It searches the nearest data in nodes: you must pass an array of kdDataItem of size "k" with coordina...
virtual std::unique_ptr< te::gm::Envelope > getExtent(std::size_t i)=0
It computes the bounding rectangle for a spatial property of the dataset.
double getArea(te::gm::Geometry *geom)
It get the area of a geometry.
OperationType
Define grouping operations type.
void transform(int oldsrid, int newsrid)
It will transform the coordinates of the Envelope from the old SRS to the new one.
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
std::vector< std::string > getStrValues(std::vector< std::vector< te::dt::AbstractData * > > dataValues, std::size_t pos)
It get the string values of a vector of abstract data.
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:138
unsigned int col
std::map< std::string, double > getPercentagePerClass(te::da::DataSet *fromDs, std::vector< std::size_t > dsPos, const std::string &propertyName, std::vector< std::vector< te::dt::AbstractData * > > &dataValues)
It get the percent per class from "From" data set in "To" data set.
TESTATEXPORT void Mode(const std::vector< double > &values, te::stat::NumericStatisticalSummary &ss)
bool isMultiPolygon(te::gm::GeomType type)
It verify if the geometry is a multi polygon.
double getWeightedByArea(te::da::DataSet *toDs, std::size_t toSrid, te::da::DataSet *fromDs, std::size_t fromSrid, std::vector< std::size_t > dsPos, const std::string &propertyName, std::vector< std::vector< te::dt::AbstractData * > > &dataValues)
It get the weighted average if intersections values.
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
Definition: CurvePolygon.h:193
const std::string & getName() const
It returns the property name.
Definition: Property.h:127
te::sam::rtree::Index< size_t, 8 > * getRtree(te::da::DataSet *data)
It return a RTree with data set iterator position information.