29 #include "../BuildConfig.h"
30 #include "../common/Logger.h"
31 #include "../common/progress/TaskProgress.h"
32 #include "../common/STLUtils.h"
33 #include "../common/StringUtils.h"
34 #include "../common/Translator.h"
35 #include "../dataaccess/dataset/DataSetAdapter.h"
36 #include "../dataaccess/dataset/DataSetTypeConverter.h"
37 #include "../dataaccess/utils/Utils.h"
38 #include "../datatype/StringProperty.h"
39 #include "../datatype/SimpleData.h"
40 #include "../geometry.h"
41 #include "../memory/DataSet.h"
42 #include "../memory/DataSetItem.h"
43 #include "../statistics/core/NumericStatisticalSummary.h"
44 #include "../statistics/core/StringStatisticalSummary.h"
45 #include "../statistics/core/SummaryFunctions.h"
46 #include "../statistics/core/Enums.h"
55 #include <boost/algorithm/string/replace.hpp>
56 #include <boost/lexical_cast.hpp>
60 std::string invalidChar;
66 boost::replace_all(name,
"/",
"_");
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,
"&",
"e");
88 int fromSrid = m_fromLayer->getSRID();
89 int toSrid = m_toLayer->getSRID();
91 std::auto_ptr<te::da::DataSetType> fromSchemaOrigin = m_fromLayer->getSchema();
97 std::auto_ptr<te::da::DataSetType> fromSchema(converter->
getResult());
99 std::auto_ptr<te::da::DataSet> fromDsOrigin = m_fromLayer->getData();
106 std::auto_ptr<te::da::DataSet> toDs = m_toLayer->getData();
107 std::auto_ptr<te::da::DataSetType> toSchema = m_toLayer->getSchema();
109 if (fromSrid != toSrid)
117 std::auto_ptr<te::da::DataSetType> outDst(getOutputDataSetType());
124 toDs->moveBeforeFirst();
130 std::string logInfo1 =
"";
131 std::string logInfo2 =
"";
133 std::vector<te::dt::Property*> outProps = outDst->getProperties();
134 std::vector<te::dt::Property*> toProps = toSchema->getProperties();
136 while(toDs->moveNext())
142 for(std::size_t i = 0; i < outProps.size(); ++i)
144 std::string outPropName = outProps[i]->getName();
146 for(std::size_t j = 0; j < toProps.size(); ++j)
148 if(toProps[j]->getName() == outPropName)
150 item->
setValue(outPropName, toDs->getValue(outPropName).release());
156 bool hasInvalid =
false;
157 std::vector<std::size_t> intersections = getIntersections(toDs.get(), fromDs.get(), rtree, hasInvalid);
161 #ifdef TERRALIB_LOGGER_ENABLED
165 std::string ex =
"The \"To\" layer geometry (" + pkProp->
getName() +
": " + toDs->getValue(pkProp->
getName())->toString() +
") has intersection candidate invalid!";
166 te::common::Logger::logDebug(
"attributefill", ex.c_str());
167 #endif //TERRALIB_LOGGER_ENABLED
175 if(intersections.empty() && !hasNoIntersectionOperations())
181 std::map<std::string, std::vector<te::attributefill::OperationType> >::iterator it = m_options.begin();
183 std::vector< std::vector<te::dt::AbstractData*> > dataValues;
185 dataValues = getDataValues(fromDs.get(), intersections);
187 while(it != m_options.end())
189 logInfo1 = it->first;
192 std::size_t propPos = fromSchema->getPropertyPosition(it->first);
197 std::vector<double> numValues;
198 std::vector<std::string> strValues;
202 strValues = getStrValues(dataValues, propPos);
207 numValues = getNumValues(dataValues, propPos);
211 std::vector<te::attributefill::OperationType> funcs = it->second;
213 for(std::size_t i = 0; i < funcs.size(); ++i)
215 std::string outPropName = getPropertyName(prop, funcs[i]);
226 te::dt::AbstractData* value = getClassWithHighestIntersectionArea(toDs.get(), toSrid, fromDs.get(), fromSrid, intersections, prop->
getName(), dataValues);
238 std::map<std::string, double> result = getPercentagePerClass(fromDs.get(), intersections, prop->
getName(), dataValues);
240 std::map<std::string, double>::iterator itAux = result.begin();
241 while(itAux != result.end())
243 std::string className = itAux->first;
244 normalizeClassName(className);
245 std::string newPropName = prop->
getName() +
"_" + className;
247 item->
setDouble(newPropName, itAux->second);
254 if(intersections.size() > 0)
265 double area = getPercentageOfTotalArea(toDs.get(), toSrid, fromDs.get(), fromSrid, intersections, prop->
getName(), dataValues);
271 std::map<std::string, double> result = getPercentageOfEachClassByArea(toDs.get(), toSrid, fromDs.get(), fromSrid, intersections, prop->
getName(), dataValues);
273 std::map<std::string, double>::iterator itAux = result.begin();
274 while(itAux != result.end())
276 std::string className = itAux->first;
277 normalizeClassName(className);
278 std::string newPropName = prop->
getName() +
"_" + className;
280 item->
setDouble(newPropName, itAux->second);
287 double weigh = getWeightedByArea(toDs.get(), toSrid, fromDs.get(), fromSrid, intersections, prop->
getName(), dataValues);
293 double weigh = getWeightedSumByArea(toDs.get(), toSrid, fromDs.get(), fromSrid, intersections, prop->
getName(), dataValues);
301 if(intersections.empty())
304 kdtree = getKDtree(fromDs.get(), toSrid);
306 result = getMinimumDistance(toDs.get(), toSrid, fromDs.get(), fromSrid, kdtree);
311 else if(isStatistical(funcs[i]))
315 std::string value = getValue(ssStr, funcs[i]);
322 std::string value = getModeValue(ssNum);
327 double value = getValue(ssNum, funcs[i]);
337 for (std::size_t a = 0; a < dataValues.size(); ++a)
356 #ifdef TERRALIB_LOGGER_ENABLED
357 std::string ex = e.
what();
358 ex +=
" | Ref: " + logInfo1 +
" : " + logInfo2;
359 te::common::Logger::logDebug(
"attributefill", ex.c_str());
360 #endif //TERRALIB_LOGGER_ENABLED
364 catch(std::exception& e)
366 #ifdef TERRALIB_LOGGER_ENABLED
367 std::string ex = e.what();
368 ex +=
" | Ref: " + logInfo1 +
" : " + logInfo2;
369 te::common::Logger::logDebug(
"attributefill", ex.c_str());
370 #endif //TERRALIB_LOGGER_ENABLED
375 if (!outDs->isEmpty())
389 std::auto_ptr<te::da::DataSet> fromDs = m_fromLayer->getData();
390 std::auto_ptr<te::da::DataSetType> fromSchema = m_fromLayer->getSchema();
392 std::auto_ptr<te::da::DataSetType> toScheme = m_toLayer->getSchema();
398 std::vector<te::dt::Property*> outProps = dst->
getProperties();
402 for(std::size_t i = 0; i < outProps.size(); ++i)
405 for(std::size_t j = 0; j < pkProps.size(); ++j)
407 if(outProps[i]->getName() == pkProps[j]->getName())
416 std::string name = outProps[i]->getName();
417 if(std::find(m_toLayerProps.begin(), m_toLayerProps.end(), name) == m_toLayerProps.end())
422 std::map<std::string, std::vector<te::attributefill::OperationType> >::iterator it = m_options.begin();
424 while(it != m_options.end())
428 std::vector<te::attributefill::OperationType> funcs = it->second;
430 for(std::size_t i = 0; i < funcs.size(); ++i)
480 std::vector<std::string> strClasses = getDistinctClasses(fromDs.get(), currentProperty->
getName());
482 for(std::size_t i = 0; i < strClasses.size(); ++i)
484 std::string className = strClasses[i];
486 normalizeClassName(className);
488 std::string newPropName = currentProperty->
getName() +
"_" + className;
503 const std::string& propertyName)
505 std::vector<std::string> result;
511 std::string strClass = fromDs->
getAsString(propertyName, 9);
513 if(std::find(result.begin(), result.end(), strClass) == result.end())
515 result.push_back(strClass);
537 std::auto_ptr<te::gm::Geometry> geom = data->
getGeometry(geomPos);
539 rtree->
insert(*geom->getMBR(), count);
541 m_mapGeom.insert(std::map<int, te::gm::Geometry*>::value_type(count, geom.release()));
553 std::string newName = name +
"_";
558 newName +=
"min_val";
560 newName +=
"max_val";
564 newName +=
"sum_values";
566 newName +=
"total_values";
568 newName +=
"total_notnull_values";
570 newName +=
"stand_dev";
572 newName +=
"variance";
574 newName +=
"skewness";
576 newName +=
"kurtosis";
578 newName +=
"amplitude";
582 newName +=
"coeff_variation";
586 newName +=
"class_high_occurrence";
588 newName +=
"class_high_area";
590 newName +=
"min_distance";
592 newName +=
"presence";
594 newName +=
"percent_of_total_area";
596 newName +=
"percent_area_class";
598 newName +=
"weigh_area";
600 newName +=
"weigh_sum_area";
602 newName +=
"percent_class";
614 std::auto_ptr<te::gm::Geometry> geom = toDs->
getGeometry(toSpatialPos);
616 std::vector<size_t> report;
617 rtree->
search(*geom->getMBR(), report);
619 std::vector<std::size_t> interVec;
620 for(std::size_t i = 0; i < report.size(); ++i)
629 if(geom->intersects(g))
631 interVec.push_back(report[i]);
639 std::vector<double> result;
641 for (std::size_t t = 0; t < dataValues.size(); ++t)
643 std::vector<te::dt::AbstractData*> data = dataValues[t];
647 result.push_back(0.0f);
664 std::string strValue = data[pos]->toString();
666 result.push_back(boost::lexical_cast<double>(strValue));
675 std::vector<std::string> result;
677 for (std::size_t t = 0; t < dataValues.size(); ++t)
679 std::vector<te::dt::AbstractData*> data = dataValues[t];
683 result.push_back(
"");
688 result.push_back(data[pos]->toString());
759 return boost::lexical_cast<std::string>(ss.
m_count);
761 return boost::lexical_cast<std::string>(ss.
m_validCount);
768 std::string result =
"";
769 std::vector<double> values = ss.
m_mode;
770 for(std::size_t i = 0; i < values.size(); ++i)
773 result += boost::lexical_cast<std::string>(values[i]);
775 result +=
", " + boost::lexical_cast<std::string>(values[i]);
782 std::vector<std::size_t> dsPos)
784 std::vector<std::vector<te::dt::AbstractData*> > result;
786 for(std::size_t i = 0; i < dsPos.size(); ++i)
788 std::vector<te::dt::AbstractData*> resultItem;
790 fromDs->
move(dsPos[i]);
795 resultItem.push_back(0);
797 resultItem.push_back(fromDs->
getValue(t).release());
799 result.push_back(resultItem);
806 std::vector<std::size_t> dsPos,
807 const std::string& propertyName,
808 std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
813 std::size_t highOccur = 0;
814 std::vector<std::string> highValues;
816 std::map<std::string, std::size_t> counter;
817 for (std::size_t i = 0; i < dsPos.size(); ++i)
821 if (!dataValues[i][propIndex])
824 std::string value = dataValues[i][propIndex]->toString();
826 if (counter.find(value) == counter.end())
833 std::size_t aux = counter[value] + 1;
834 counter[value] = aux;
841 std::map<std::string, std::size_t>::iterator it = counter.begin();
842 while (it != counter.end())
844 if (it->second == highOccur)
845 highValues.push_back(it->first);
849 if (highValues.size() > 1)
851 std::vector<double> intVec;
858 return getDataBasedOnType(ssStr.
m_minVal, propType);
862 for (std::size_t i = 0; i < highValues.size(); ++i)
864 intVec.push_back(boost::lexical_cast<double>(highValues[i]));
869 std::string strVal = boost::lexical_cast<std::string>(ssNum.
m_minVal);
870 return getDataBasedOnType(strVal, propType);
873 else if (!highValues.empty())
874 return getDataBasedOnType(highValues[0], propType);
883 std::vector<std::size_t> dsPos,
884 const std::string& propertyName,
885 std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
892 std::auto_ptr<te::gm::Geometry> toGeom = toDs->
getGeometry(toGeomPos);
893 if(toGeom->getSRID() <= 0)
894 toGeom->setSRID((
int)toSrid);
896 std::map<std::string, double> classAreaMap;
897 for(std::size_t i = 0; i < dsPos.size(); ++i)
901 if (!dataValues[i][propIndex])
906 std::auto_ptr<te::gm::Geometry> interGeom;
908 if(!checkGeometries(fromGeom, dsPos[i], toGeom.get()))
916 interGeom.reset(toGeom->intersection(fromGeom));
918 catch(
const std::exception &e)
920 #ifdef TERRALIB_LOGGER_ENABLED
921 std::string ex = e.what();
922 te::common::Logger::logDebug(
"attributefill", ex.c_str());
923 #endif //TERRALIB_LOGGER_ENABLED
928 std::string value = dataValues[i][propIndex]->
toString();
930 double area = getArea(interGeom.get());
932 if(classAreaMap.find(value) == classAreaMap.end())
934 classAreaMap[value] = area;
938 double aux = classAreaMap[value];
939 classAreaMap[value] = aux + area;
943 std::map<std::string, double>::iterator it = classAreaMap.begin();
946 while(it != classAreaMap.end())
963 std::vector<std::size_t> dsPos,
964 const std::string& propertyName,
965 std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
969 std::map<std::string, double> result;
971 std::map<std::string, std::size_t> aux;
972 for(std::size_t i = 0; i < dsPos.size(); ++i)
976 std::string value = dataValues[i][propIndex]->toString();
978 if(aux.find(value) == aux.end())
988 std::size_t total = 0;
989 std::map<std::string, std::size_t>::iterator it = aux.begin();
990 while(it != aux.end())
998 while(it != aux.end())
1000 std::string normName = it->first;
1001 normalizeClassName(normName);
1002 result[normName] = ((double)it->second / total);
1014 std::vector<std::size_t> dsPos,
1016 std::vector< std::vector<te::dt::AbstractData*> >&)
1020 std::auto_ptr<te::gm::Geometry> toGeom = toDs->
getGeometry(toGeomPos);
1021 if(toGeom->getSRID() <= 0)
1022 toGeom->setSRID((
int)toSrid);
1024 double classArea = 0;
1025 for(std::size_t i = 0; i < dsPos.size(); ++i)
1031 if(!checkGeometries(fromGeom, dsPos[i], toGeom.get()))
1037 std::auto_ptr<te::gm::Geometry> interGeom(toGeom->intersection(fromGeom));
1039 classArea += getArea(interGeom.get());
1042 double polArea = getArea(toGeom.get());
1044 return classArea/polArea;
1051 std::vector<std::size_t> dsPos,
1052 const std::string& propertyName,
1053 std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
1055 std::map<std::string, double> result;
1061 std::auto_ptr<te::gm::Geometry> toGeom = toDs->
getGeometry(toGeomPos);
1062 if(toGeom->getSRID() <= 0)
1063 toGeom->setSRID((
int)toSrid);
1065 double toGeomArea = getArea(toGeom.get());
1067 for(std::size_t i = 0; i < dsPos.size(); ++i)
1073 if(!checkGeometries(fromGeom, dsPos[i], toGeom.get()))
1079 std::auto_ptr<te::gm::Geometry> interGeom(toGeom->intersection(fromGeom));
1081 std::string value = dataValues[i][propIndex]->
toString();
1083 double area = getArea(interGeom.get());
1085 if(result.find(value) == result.end())
1087 result[value] = area/toGeomArea;
1091 result[value] += area/toGeomArea;
1102 std::vector<std::size_t> dsPos,
1103 const std::string& propertyName,
1104 std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
1110 std::auto_ptr<te::gm::Geometry> toGeom = toDs->
getGeometry(toGeomPos);
1111 if(toGeom->getSRID() <= 0)
1112 toGeom->setSRID((
int)toSrid);
1114 double toGeomArea = getArea(toGeom.get());
1118 for(std::size_t i = 0; i < dsPos.size(); ++i)
1124 if(!checkGeometries(fromGeom, dsPos[i], toGeom.get()))
1130 std::auto_ptr<te::gm::Geometry> interGeom(toGeom->intersection(fromGeom));
1132 double value_num = 0;
1134 if(!fromDs->
isNull(propertyName))
1136 std::string value = dataValues[i][propIndex]->
toString();
1137 value_num = boost::lexical_cast<
double>(value);
1140 double intersectionArea = getArea(interGeom.get());
1142 weigh += value_num*(intersectionArea/toGeomArea);
1152 std::vector<std::size_t> dsPos,
1153 const std::string& propertyName,
1154 std::vector< std::vector<te::dt::AbstractData*> >& dataValues)
1160 std::auto_ptr<te::gm::Geometry> toGeom = toDs->
getGeometry(toGeomPos);
1161 if(toGeom->getSRID() <= 0)
1162 toGeom->setSRID((
int)toSrid);
1166 for(std::size_t i = 0; i < dsPos.size(); ++i)
1172 double fromGeomArea = getArea(fromGeom);
1174 if(!checkGeometries(fromGeom, dsPos[i], toGeom.get()))
1180 std::auto_ptr<te::gm::Geometry> interGeom(toGeom->intersection(fromGeom));
1182 double value_num = 0;
1184 if (!dataValues[i][propIndex])
1186 std::string value = dataValues[i][propIndex]->toString();
1187 value_num = boost::lexical_cast<
double>(value);
1190 double intersectionArea = getArea(interGeom.get());
1192 weigh += value_num*(intersectionArea/fromGeomArea);
1324 int16_t v = boost::lexical_cast<int16_t>(strValue);
1330 int32_t v = boost::lexical_cast<int32_t>(strValue);
1336 int64_t v = boost::lexical_cast<int64_t>(strValue);
1342 uint16_t v = boost::lexical_cast<uint16_t>(strValue);
1348 uint32_t v = boost::lexical_cast<uint32_t>(strValue);
1354 uint64_t v = boost::lexical_cast<uint64_t>(strValue);
1373 std::vector<std::pair<te::gm::Coord2D, te::gm::Point> > kdset;
1379 std::auto_ptr<te::gm::Geometry> geom = data->
getGeometry(geomPos);
1381 std::vector<te::gm::Point*> allPoints = getAllPointsOfGeometry(geom.get());
1383 for(std::size_t i = 0; i < allPoints.size(); ++i)
1393 kdset.push_back(std::pair<te::gm::Coord2D, te::gm::Point>(coord, *p));
1397 kdtree->
build(kdset);
1409 std::auto_ptr<te::gm::Geometry> toGeom = toDs->
getGeometry(toGeomPos);
1411 std::vector<te::gm::Point*> allPoints = getAllPointsOfGeometry(toGeom.get());
1413 std::vector<double> distances;
1415 for(std::size_t i = 0; i < allPoints.size(); ++i)
1419 std::vector<te::gm::Point> points;
1420 points.push_back(
te::gm::Point(std::numeric_limits<double>::max(), std::numeric_limits<double>::max()));
1421 std::vector<double> sqrDists;
1425 distances.push_back(sqrDists[0]);
1428 double finalResult = std::numeric_limits<double>::max();
1429 for(std::size_t i = 0; i < distances.size(); ++i)
1431 if(distances[i] < finalResult)
1432 finalResult = distances[i];
1435 return sqrt(finalResult);
1442 std::vector<te::gm::Point*> result;
1449 result.push_back(g);
1459 std::vector<te::gm::Point*> vec = getAllPointsOfGeometry(gAux);
1460 result.insert(result.end(), vec.begin(), vec.end());
1475 for(std::size_t j = 0; j < lr->
getNPoints(); ++j)
1491 std::vector<te::gm::Point*> vec = getAllPointsOfGeometry(gAux);
1492 result.insert(result.end(), vec.begin(), vec.end());
1500 for(std::size_t i = 0; i < g->
getNPoints(); ++i)
1515 std::vector<te::gm::Point*> vec = getAllPointsOfGeometry(gAux);
1516 result.insert(result.end(), vec.begin(), vec.end());
1523 return std::vector<te::gm::Point*>();
1532 std::map<std::string, std::vector<te::attributefill::OperationType> >::iterator it = m_options.begin();
1534 while(it != m_options.end())
1536 std::vector<te::attributefill::OperationType> ops = it->second;
1538 for(std::size_t i = 0; i < ops.size(); ++i)
1554 #ifdef TERRALIB_LOGGER_ENABLED
1555 std::string ex =
TE_TR(
"\"From\" layer geometry at position ");
1556 ex += boost::lexical_cast<std::string>(fromPos);
1557 ex +=
TE_TR(
" is invalid.");
1558 te::common::Logger::logDebug(
"attributefill", ex.c_str());
1559 #endif //TERRALIB_LOGGER_ENABLED
1565 #ifdef TERRALIB_LOGGER_ENABLED
1566 std::string ex =
TE_TR(
"\"To\" layer geometry is invalid.");
1567 te::common::Logger::logDebug(
"attributefill", ex.c_str());
1568 #endif //TERRALIB_LOGGER_ENABLED
void normalizeClassName(std::string &name)
VectorToVectorMemory()
Constructor.
TESTATEXPORT void GetNumericStatisticalSummary(std::vector< double > &values, te::stat::NumericStatisticalSummary &ss, double nullVal)
std::vector< te::gm::Point * > getAllPointsOfGeometry(te::gm::Geometry *geom)
It get all points of a geometry.
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.
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.
void transform(int srid)
It converts the coordinate values of the point to the new spatial reference system.
bool isStatistical(te::attributefill::OperationType type)
It verify if the operation is a statistical operation.
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
MultiPolygon is a MultiSurface whose elements are Polygons.
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.
Configuration flags for the Attribute Fill module of TerraLib.
void setDouble(std::size_t i, double value)
It sets the value of the i-th property.
bool intersects(const Envelope &rhs) const
It returns true if the envelopes "spatially intersects".
An atomic property like an integer or double.
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.
TEDATAACCESSEXPORT void AssociateDataSetTypeConverterSRID(DataSetTypeConverter *converter, const int &inputSRID, const int &outputSRID=TE_UNKNOWN_SRS)
A class that represents an R-tree.
A class that models the description of a dataset.
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
virtual const char * what() const
It outputs the exception message.
void useTimer(bool flag)
Used to define if task use progress timer information.
te::dt::AbstractData * getDataBasedOnType(const std::string &strValue, const int type)
It get a abstract data with the value based on the type.
Point * getPointN(std::size_t i) const
It returns the specified point in this LineString.
DataSetType * getResult() const
A class that represents a two dimensional K-d Tree (2-d Tree) that store data-elements into the leafs...
virtual Property * clone() const =0
It returns a clone of the object.
This class can be used to inform the progress of a task.
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::vector< double > m_mode
PrimaryKey * getPrimaryKey() const
It returns the primary key associated to the dataset type.
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.
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.
TECOMMONEXPORT std::string ReplaceSpecialChars(const std::string &str, bool &changed)
It replace special characters of a string.
It models a property definition.
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.
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.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
virtual int code() const
It gets the exception code.
void setName(const std::string &name)
It sets the property name.
MultiPoint is a GeometryCollection whose elements are restricted to points.
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.
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.
A point with x and y coordinate values.
An Envelope defines a 2D rectangular region.
void build(std::vector< std::pair< kdKey, kdDataItem > > &dataSet)
It inserts the data set into the tree.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
te::sam::kdtree::AdaptativeIndex< KD_ADAPTATIVE_NODE > KD_ADAPTATIVE_TREE
bool hasNoIntersectionOperations()
Verify if has operations that don't need the intersections.
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.
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.
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.
virtual bool isValid() const
It tells if the geometry is well formed.
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...
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
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.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
TESTATEXPORT void GetStringStatisticalSummary(std::vector< std::string > &values, te::stat::StringStatisticalSummary &ss)
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.
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
double getArea() const
It returns the area of this surface, as measured in the spatial reference system of this surface...
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.
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.
bool run()
It execute the operations.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
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.
A structure to hold the set of statistics from a set of categorical (sample) values.
It describes a primary key (pk) constraint.
virtual std::auto_ptr< te::gm::Envelope > getExtent(std::size_t i)=0
It computes the bounding rectangle for a spatial property of the dataset.
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.
std::string toString() const
It returns the data value in a WKT representation.
bool isPolygon(te::gm::GeomType type)
It verify if the geometry is a polygon.
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).
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.
It is a collection of other geometric objects.
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)
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
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...
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...
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.
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.
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.
virtual std::auto_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
Curve * getRingN(std::size_t i) const
It returns the n-th ring for this curve polygon as a curve.
const std::string & getName() const
It returns the property name.
te::sam::rtree::Index< size_t, 8 > * getRtree(te::da::DataSet *data)
It return a RTree with data set iterator position information.