29 #include "../common/progress/TaskProgress.h" 30 #include "../core/logger/Logger.h" 31 #include "../core/translator/Translator.h" 33 #include "../dataaccess/dataset/DataSet.h" 34 #include "../dataaccess/dataset/DataSetAdapter.h" 36 #include "../dataaccess/query/DataSetName.h" 37 #include "../dataaccess/query/Expression.h" 38 #include "../dataaccess/query/Field.h" 39 #include "../dataaccess/query/Fields.h" 40 #include "../dataaccess/query/From.h" 41 #include "../dataaccess/query/FromItem.h" 42 #include "../dataaccess/query/GroupBy.h" 43 #include "../dataaccess/query/GroupByItem.h" 44 #include "../dataaccess/query/LiteralInt32.h" 45 #include "../dataaccess/query/PropertyName.h" 46 #include "../dataaccess/query/Select.h" 47 #include "../dataaccess/query/ST_Area.h" 48 #include "../dataaccess/query/ST_Centroid.h" 49 #include "../dataaccess/query/ST_ConvexHull.h" 50 #include "../dataaccess/query/ST_Envelope.h" 51 #include "../dataaccess/query/ST_Length.h" 52 #include "../dataaccess/query/ST_Perimeter.h" 53 #include "../dataaccess/query/ST_SetSRID.h" 54 #include "../dataaccess/query/ST_Transform.h" 55 #include "../dataaccess/query/ST_Union.h" 56 #include "../dataaccess/utils/Utils.h" 58 #include "../geometry/Geometry.h" 59 #include "../geometry/GeometryCollection.h" 60 #include "../geometry/GeometryProperty.h" 62 #include "../memory/DataSet.h" 63 #include "../memory/DataSetItem.h" 75 std::vector<int> opGeom;
76 std::vector<int> opTab;
77 std::vector<te::da::DataSetType*> dsTypeVec;
104 "Vector Processing - Geometric Operation - The operation is not " 110 bool hasMultiGeomColumns =
false;
117 if(hasMultiGeomColumns)
125 if(opGeom.size() > 0)
127 for(std::size_t i = 0; i < opGeom.size(); ++i)
138 for(std::size_t dsTypePos = 0; dsTypePos < dsTypeVec.size(); ++dsTypePos)
142 std::unique_ptr<te::da::DataSetType> outDataSetType(
143 dsTypeVec[dsTypePos]);
144 std::unique_ptr<te::mem::DataSet> outDataSet(
157 if(hasMultiGeomColumns)
165 if(opGeom.size() > 0)
167 for(std::size_t i = 0; i < opGeom.size(); ++i)
178 for(std::size_t dsTypePos = 0; dsTypePos < dsTypeVec.size(); ++dsTypePos)
182 std::unique_ptr<te::da::DataSetType> outDataSetType(
183 dsTypeVec[dsTypePos]);
184 std::unique_ptr<te::mem::DataSet> outDataSet(
202 if(hasMultiGeomColumns)
210 if(opGeom.size() > 0)
212 for(std::size_t i = 0; i < opGeom.size(); ++i)
223 for(std::size_t dsTypePos = 0; dsTypePos < dsTypeVec.size(); ++dsTypePos)
227 std::unique_ptr<te::da::DataSetType> outDataSetType(
228 dsTypeVec[dsTypePos]);
229 std::unique_ptr<te::mem::DataSet> outDataSet(
247 TE_LOG_INFO(
"Vector Processing - Geometric Operation - Strategy Not found!");
257 std::vector<int> geoVec)
263 std::string name = geomProperty->
getName();
269 for(std::size_t prop_pos = 0; prop_pos <
m_selectedProps.size(); ++prop_pos)
272 fields->push_back(f_prop);
276 if(tabVec.size() > 0)
278 for(std::size_t tabPos = 0; tabPos < tabVec.size(); ++tabPos)
283 switch(tabVec[tabPos])
298 fields->push_back(f);
314 fields->push_back(f);
329 fields->push_back(f);
335 "Vector Processing - Geometric Operation - Invalid field to add " 342 std::unique_ptr<te::da::DataSetType> dsTypeSource(
350 if(geoVec.size() > 0)
352 for(std::size_t geoPos = 0; geoPos < geoVec.size(); ++geoPos)
358 switch(geoVec[geoPos])
363 if(pos < outDSet->getNumProperties() && pos > 0)
365 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
379 fields->push_back(f_geom);
386 if(pos < outDSet->getNumProperties() && pos > 0)
388 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
402 fields->push_back(f_geom);
409 if(pos < outDSet->getNumProperties() && pos > 0)
411 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
425 fields->push_back(f_geom);
432 "Vector Processing - Geometric Operation - Invalid field to add " 442 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
454 fields->push_back(f_prop);
460 from->push_back(fromItem);
464 std::unique_ptr<te::da::DataSet> dsQuery =
m_inDsrc->query(select);
466 if(dsQuery->isEmpty())
471 return outDSet.release();
476 std::vector<int> geoVec)
482 std::string name = geomProperty->
getName();
486 if(tabVec.size() > 0)
488 for(std::size_t tabPos = 0; tabPos < tabVec.size(); ++tabPos)
493 switch(tabVec[tabPos])
509 fields->push_back(f);
526 fields->push_back(f);
543 fields->push_back(f);
549 "Vector Processing - Geometric Operation - Invalid field to add " 556 std::unique_ptr<te::da::DataSetType> dsTypeSource(
564 if(geoVec.size() > 0)
566 for(std::size_t geoPos = 0; geoPos < geoVec.size(); ++geoPos)
572 switch(geoVec[geoPos])
577 if(pos < outDSet->getNumProperties() && pos > 0)
579 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
594 fields->push_back(f_geom);
601 if(pos < outDSet->getNumProperties() && pos > 0)
603 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
618 fields->push_back(f_geom);
625 if(pos < outDSet->getNumProperties() && pos > 0)
627 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
642 fields->push_back(f_geom);
649 "Vector Processing - Geometric Operation - Invalid field to add " 659 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
672 fields->push_back(f_prop);
678 from->push_back(fromItem);
682 std::unique_ptr<te::da::DataSet> dsQuery =
m_inDsrc->query(select);
684 if(dsQuery->isEmpty())
689 return outDSet.release();
694 std::vector<int> geoVec)
700 std::string name = geomProperty->
getName();
705 fields->push_back(f_aggreg);
707 if(tabVec.size() > 0)
709 for(std::size_t tabPos = 0; tabPos < tabVec.size(); ++tabPos)
714 switch(tabVec[tabPos])
731 fields->push_back(f);
749 fields->push_back(f);
767 fields->push_back(f);
773 "Vector Processing - Geometric Operation - Invalid field to add " 780 std::unique_ptr<te::da::DataSetType> dsTypeSource(
788 if(geoVec.size() > 0)
790 for(std::size_t geoPos = 0; geoPos < geoVec.size(); ++geoPos)
796 switch(geoVec[geoPos])
801 if(pos < outDSet->getNumProperties() && pos > 0)
803 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
818 fields->push_back(f_geom);
825 if(pos < outDSet->getNumProperties() && pos > 0)
827 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
842 fields->push_back(f_geom);
849 if(pos < outDSet->getNumProperties() && pos > 0)
851 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
866 fields->push_back(f_geom);
873 "Vector Processing - Geometric Operation - Invalid field to add " 883 if(geomPropertySource->getSRID() != geomPropertyLayer->getSRID())
896 fields->push_back(f_prop);
902 from->push_back(fromItem);
908 groupBy->push_back(e_groupBy);
912 std::unique_ptr<te::da::DataSet> dsQuery =
m_inDsrc->query(select);
914 if(dsQuery->isEmpty())
919 return outDSet.release();
931 bool geomFlag =
true;
937 for(std::size_t i = 0; i < numProps; ++i)
963 std::unique_ptr<te::gm::Geometry> geom(
966 if(inPropName ==
"convex_hull")
973 else if(inPropName ==
"centroid")
977 else if(inPropName ==
"mbr")
990 switch(geom->getGeomTypeId())
1006 teGeomColl->
add(geom.release());
1012 "Vector Processing - Geometric Operation - Could not " 1013 "insert the geometry in collection.");
1027 "Vector Processing - Geometric Operation - Property type not " 1035 outDataSet->
add(dItem);
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
std::size_t getNumGeometries() const
It returns the number of geometries in this GeometryCollection.
te::da::DataSetType * GetDataSetType(te::vp::GeometricOpObjStrategy, bool MultiGeomColumns, int geomOp=-1)
boost::ptr_vector< GroupByItem > GroupBy
A class that can be used to model a GROUP BY clause.
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value.
A class that can be used in a GROUP BY clause.
An abstract class that models a source of data in a query.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
std::vector< std::string > m_outDsetNameVec
void setDouble(std::size_t i, double value)
It sets the value of the i-th property.
The geographic operation Line.
A class that models the name of a dataset used in a From clause.
The geographic operation Minimum Bounding Rectangle.
A class that models the name of any property of an object.
Base exception class for plugin module.
A class that models the description of a dataset.
void setInt16(std::size_t i, boost::int16_t value)
It sets the value of the i-th property.
#define TE_LOG_INFO(message)
Use this tag in order to log a message to the TerraLib default logger with the INFO level...
Spatial envelope operator.
This is an abstract class that models a query expression.
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
Spatial perimeter operator.
Geometric Operation Vector Processing functions.
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.
TEVPEXPORT void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType, const bool &enableProgress=true)
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
The geographic operation Area.
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long).
int getSRID() const
It returns the spatial reference system identifier associated to this property.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long).
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
std::unique_ptr< te::da::DataSource > m_outDsrc
Aggregate objects by attribute.
void SetOutputDSet(te::da::DataSet *inDataSet, te::mem::DataSet *outDataSet)
The geographic operation Perimeter.
Utility functions for the data access module.
void setGroupBy(GroupBy *g)
It sets the list of expressions used to condense the result set.
The geographic operation Centroid.
te::mem::DataSet * SetAggregByAttribute(te::da::DataSetType *dsType, std::vector< int > tabVec, std::vector< int > geoVec)
A Select models a query to be used when retrieving data from a DataSource.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
Spatial Set SRID operator.
Spatial centroid operator.
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.
te::da::DataSourcePtr m_inDsrc
std::vector< std::string > m_selectedProps
std::vector< te::vp::GeometricOperation > m_operations
void add(Geometry *g)
It adds the geometry into the collection.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
The geographic operation Convex Hull.
std::size_t getPropertyPosition(const std::string &name) const
It returns the property position based on its name.
ST_Union statistical function.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
te::mem::DataSet * SetAllObjects(te::da::DataSetType *dsType, std::vector< int > tabVec, std::vector< int > geoVec)
virtual boost::int64_t getInt64(std::size_t i) const =0
Method for retrieving a 64-bit integer attribute value (8 bytes long).
te::vp::GeometricOpObjStrategy m_objStrategy
void setString(std::size_t i, const std::string &value)
It sets the value of the i-th property.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
void setInt64(std::size_t i, boost::int64_t value)
It sets the value of the i-th property.
It is a collection of other geometric objects.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
All objects individually.
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
te::mem::DataSet * SetAggregObj(te::da::DataSetType *dsType, std::vector< int > tabVec, std::vector< int > geoVec)
std::unique_ptr< te::da::DataSetTypeConverter > m_converter
const std::string & getName() const
It returns the property name.