28 #include "../common/progress/TaskProgress.h" 
   29 #include "../common/Logger.h" 
   30 #include "../common/Translator.h" 
   32 #include "../dataaccess/dataset/DataSet.h" 
   34 #include "../datatype/Property.h" 
   35 #include "../datatype/SimpleProperty.h" 
   36 #include "../datatype/StringProperty.h" 
   38 #include "../dataaccess/query/Avg.h" 
   39 #include "../dataaccess/query/Count.h" 
   40 #include "../dataaccess/query/DataSetName.h" 
   41 #include "../dataaccess/query/Expression.h" 
   42 #include "../dataaccess/query/Field.h" 
   43 #include "../dataaccess/query/Fields.h" 
   44 #include "../dataaccess/query/From.h" 
   45 #include "../dataaccess/query/FromItem.h" 
   46 #include "../dataaccess/query/GroupBy.h" 
   47 #include "../dataaccess/query/GroupByItem.h" 
   48 #include "../dataaccess/query/Literal.h" 
   49 #include "../dataaccess/query/LiteralBool.h" 
   50 #include "../dataaccess/query/PropertyName.h" 
   51 #include "../dataaccess/query/Select.h" 
   52 #include "../dataaccess/query/ST_Area.h" 
   53 #include "../dataaccess/query/ST_Centroid.h" 
   54 #include "../dataaccess/query/ST_ConvexHull.h" 
   55 #include "../dataaccess/query/ST_Envelope.h" 
   56 #include "../dataaccess/query/ST_Length.h" 
   57 #include "../dataaccess/query/ST_Perimeter.h" 
   58 #include "../dataaccess/query/ST_Union.h" 
   59 #include "../dataaccess/query/Variance.h" 
   60 #include "../dataaccess/utils/Utils.h" 
   62 #include "../geometry/Geometry.h" 
   63 #include "../geometry/GeometryCollection.h" 
   64 #include "../geometry/GeometryProperty.h" 
   65 #include "../geometry/Utils.h" 
   67 #include "../memory/DataSet.h" 
   68 #include "../memory/DataSetItem.h" 
   70 #include "../statistics/core/SummaryFunctions.h" 
   71 #include "../statistics/core/StringStatisticalSummary.h" 
   72 #include "../statistics/core/NumericStatisticalSummary.h" 
   86 #include <boost/lexical_cast.hpp> 
   87 #include <boost/algorithm/string.hpp> 
   98   std::vector<int> opGeom;
 
   99   std::vector<int> opTab;
 
  100   std::vector<te::da::DataSetType*> dsTypeVec;
 
  102   for(std::size_t i = 0; i < m_operations.size(); ++i)
 
  104     switch(m_operations[i])
 
  125         te::common::Logger::logDebug(
"vp", 
"Geometric Operation - The operation is not valid.");
 
  131     bool hasMultiGeomColumns = 
false;
 
  134     switch(m_objStrategy)
 
  138           if(hasMultiGeomColumns) 
 
  144             if(opGeom.size() > 0)
 
  146               for(std::size_t i = 0; i < opGeom.size(); ++i)
 
  155           for(std::size_t dsTypePos = 0; dsTypePos < dsTypeVec.size(); ++dsTypePos)
 
  157             m_outDsetNameVec.push_back(dsTypeVec[dsTypePos]->getName());
 
  159             std::auto_ptr<te::da::DataSetType> outDataSetType(dsTypeVec[dsTypePos]);
 
  160             std::auto_ptr<te::mem::DataSet> outDataSet(SetAllObjects(dsTypeVec[dsTypePos], opTab, opGeom));
 
  161             result = save(outDataSet, outDataSetType);
 
  169           if(hasMultiGeomColumns) 
 
  175             if(opGeom.size() > 0)
 
  177               for(std::size_t i = 0; i < opGeom.size(); ++i)
 
  186           for(std::size_t dsTypePos = 0; dsTypePos < dsTypeVec.size(); ++dsTypePos)
 
  188             m_outDsetNameVec.push_back(dsTypeVec[dsTypePos]->getName());
 
  190             std::auto_ptr<te::da::DataSetType> outDataSetType(dsTypeVec[dsTypePos]);
 
  191             std::auto_ptr<te::mem::DataSet> outDataSet(SetAggregObj(dsTypeVec[dsTypePos], opTab, opGeom));
 
  192             result = save(outDataSet, outDataSetType);
 
  200           if(hasMultiGeomColumns) 
 
  206             if(opGeom.size() > 0)
 
  208               for(std::size_t i = 0; i < opGeom.size(); ++i)
 
  217           for(std::size_t dsTypePos = 0; dsTypePos < dsTypeVec.size(); ++dsTypePos)
 
  219             m_outDsetNameVec.push_back(dsTypeVec[dsTypePos]->getName());
 
  221             std::auto_ptr<te::da::DataSetType> outDataSetType(dsTypeVec[dsTypePos]);
 
  222             std::auto_ptr<te::mem::DataSet> outDataSet(SetAggregByAttribute(dsTypeVec[dsTypePos], opTab, opGeom));
 
  223             result = save(outDataSet, outDataSetType);
 
  230         te::common::Logger::logDebug(
"vp", 
"Geometric Operation - Strategy Not found!");
 
  247                                                           std::vector<int> tabVec,
 
  248                                                           std::vector<int> geoVec)
 
  251   std::auto_ptr<te::da::DataSet> inDset = m_inDsrc->getDataSet(m_inDsetName);
 
  256   if(m_selectedProps.size() > 0)
 
  258     for(std::size_t prop_pos = 0; prop_pos < m_selectedProps.size(); ++prop_pos)
 
  261       fields->push_back(f_prop);
 
  265   std::string name = inDset->getPropertyName(geom_pos);
 
  267   if(tabVec.size() > 0)
 
  269     for(std::size_t tabPos = 0; tabPos < tabVec.size(); ++tabPos)
 
  276       switch(tabVec[tabPos])
 
  282             fields->push_back(f);
 
  289             fields->push_back(f);
 
  296             fields->push_back(f);
 
  300           te::common::Logger::logDebug(
"vp", 
"Geometric Operation - Invalid field to add in query.");
 
  305   if(geoVec.size() > 0)
 
  307     for(std::size_t geoPos = 0; geoPos < geoVec.size(); ++geoPos)
 
  312       switch(geoVec[geoPos])
 
  317             if( pos < outDSet->getNumProperties() && pos > 0)
 
  321               fields->push_back(f_geom);
 
  328             if( pos < outDSet->getNumProperties() && pos > 0)
 
  332               fields->push_back(f_geom);
 
  339             if( pos < outDSet->getNumProperties() && pos > 0)
 
  343               fields->push_back(f_geom);
 
  348           te::common::Logger::logDebug(
"vp", 
"Geometric Operation - Invalid field to add in query.");
 
  355     fields->push_back(f_prop);
 
  360   from->push_back(fromItem);
 
  364   std::auto_ptr<te::da::DataSet> dsQuery = m_inDsrc->query(select);
 
  366   if (dsQuery->isEmpty())
 
  369   SetOutputDSet(dsQuery.get(), outDSet.get());
 
  371   return outDSet.release();
 
  375                                                           std::vector<int> tabVec,
 
  376                                                           std::vector<int> geoVec)
 
  380   std::auto_ptr<te::da::DataSet> inDset = m_inDsrc->getDataSet(m_inDsetName);
 
  382   std::string name = inDset->getPropertyName(geom_pos);
 
  386   if(tabVec.size() > 0)
 
  388     for(std::size_t tabPos = 0; tabPos < tabVec.size(); ++tabPos)
 
  395       switch(tabVec[tabPos])
 
  402             fields->push_back(f);
 
  410             fields->push_back(f);
 
  418             fields->push_back(f);
 
  422           te::common::Logger::logDebug(
"vp", 
"Geometric Operation - Invalid field to add in query.");
 
  427   if(geoVec.size() > 0)
 
  429     for(std::size_t geoPos = 0; geoPos < geoVec.size(); ++geoPos)
 
  434       switch(geoVec[geoPos])
 
  439             if( pos < outDSet->getNumProperties() && pos > 0)
 
  444               fields->push_back(f_geom);
 
  451             if( pos < outDSet->getNumProperties() && pos > 0)
 
  456               fields->push_back(f_geom);
 
  463             if( pos < outDSet->getNumProperties() && pos > 0)
 
  468               fields->push_back(f_geom);
 
  473           te::common::Logger::logDebug(
"vp", 
"Geometric Operation - Invalid field to add in query.");
 
  481     fields->push_back(f_prop);
 
  486   from->push_back(fromItem);
 
  490   std::auto_ptr<te::da::DataSet> dsQuery = m_inDsrc->query(select);
 
  492   if (dsQuery->isEmpty())
 
  495   SetOutputDSet(dsQuery.get(), outDSet.get());
 
  497   return outDSet.release();
 
  501                                                                   std::vector<int> tabVec,
 
  502                                                                   std::vector<int> geoVec)
 
  505   std::auto_ptr<te::da::DataSet> inDset = m_inDsrc->getDataSet(m_inDsetName);
 
  507   std::string name = inDset->getPropertyName(geom_pos);
 
  512   fields->push_back(f_aggreg);
 
  514   if(tabVec.size() > 0)
 
  516     for(std::size_t tabPos = 0; tabPos < tabVec.size(); ++tabPos)
 
  523       switch(tabVec[tabPos])
 
  530             fields->push_back(f);
 
  538             fields->push_back(f);
 
  546             fields->push_back(f);
 
  550           te::common::Logger::logDebug(
"vp", 
"Geometric Operation - Invalid field to add in query.");
 
  555   if(geoVec.size() > 0)
 
  557     for(std::size_t geoPos = 0; geoPos < geoVec.size(); ++geoPos)
 
  562       switch(geoVec[geoPos])
 
  567             if( pos < outDSet->getNumProperties() && pos > 0)
 
  572               fields->push_back(f_geom);
 
  579             if( pos < outDSet->getNumProperties() && pos > 0)
 
  584               fields->push_back(f_geom);
 
  591             if( pos < outDSet->getNumProperties() && pos > 0)
 
  596               fields->push_back(f_geom);
 
  601           te::common::Logger::logDebug(
"vp", 
"Geometric Operation - Invalid field to add in query.");
 
  609     fields->push_back(f_prop);
 
  614   from->push_back(fromItem);
 
  620   groupBy->push_back(e_groupBy);
 
  624   std::auto_ptr<te::da::DataSet> dsQuery = m_inDsrc->query(select);
 
  626   if (dsQuery->isEmpty())
 
  629   SetOutputDSet(dsQuery.get(), outDSet.get());
 
  631   return outDSet.release();
 
  640   bool geomFlag = 
true;
 
  652     for(std::size_t i = 0; i < numProps; ++i)
 
  676             if(inPropName == 
"convex_hull")
 
  687             else if(inPropName == 
"centroid")
 
  693             else if(inPropName == 
"mbr")
 
  750           te::common::Logger::logDebug(
"vp", 
"Geometric Operation - Property type not found.");
 
  756       outDataSet->
add(dItem);
 
te::da::DataSetType * GetDataSetType(te::vp::GeometricOpObjStrategy, bool MultiGeomColumns, int geomOp=-1)
int getSRID() const 
It returns the Spatial Reference System ID associated to this geometric object. 
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long). 
boost::ptr_vector< GroupByItem > GroupBy
A class that can be used to model a GROUP BY clause. 
An exception class for the Vector processing module. 
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property. 
Utility functions for the data access module. 
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...
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long). 
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. 
A class that models the description of a dataset. 
virtual boost::int64_t getInt64(std::size_t i) const =0
Method for retrieving a 64-bit integer attribute value (8 bytes long). 
void setInt16(std::size_t i, boost::int16_t value)
It sets the value of the i-th property. 
std::size_t getNumProperties() const 
It returns the number of properties. 
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value. 
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. 
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. 
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
TEDATAACCESSEXPORT std::size_t GetFirstSpatialPropertyPos(const te::da::DataSet *dataset)
It returns the first dataset spatial property or NULL if none is found. 
The geographic operation Area. 
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos. 
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers. 
Aggregate objects by attribute. 
void SetOutputDSet(te::da::DataSet *inDataSet, te::mem::DataSet *outDataSet)
The geographic operation Perimeter. 
virtual bool isValid() const 
It tells if the geometry is well formed. 
GeomType getGeomTypeId() const 
It returns the geometry subclass type identifier. 
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset. 
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)
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards. 
A Select models a query to be used when retrieving data from a DataSource. 
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value. 
boost::ptr_vector< FromItem > From
It models the FROM clause for a query. 
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. 
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection. 
void setGeometryN(std::size_t i, Geometry *g)
It sets the n-th geometry in this geometry 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. 
te::mem::DataSet * SetAllObjects(te::da::DataSetType *dsType, std::vector< int > tabVec, std::vector< int > geoVec)
Configuration flags for the Terrralib Vector Processing module. 
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute. 
void setString(std::size_t i, const std::string &value)
It sets the value of the i-th property. 
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)
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos. 
All objects individually. 
te::mem::DataSet * SetAggregObj(te::da::DataSetType *dsType, std::vector< int > tabVec, std::vector< int > geoVec)