28 #include "../common/progress/TaskProgress.h"
29 #include "../common/Logger.h"
30 #include "../common/Translator.h"
32 #include "../dataaccess/dataset/DataSet.h"
33 #include "../dataaccess/dataset/DataSetAdapter.h"
35 #include "../datatype/Property.h"
36 #include "../datatype/SimpleProperty.h"
37 #include "../datatype/StringProperty.h"
39 #include "../dataaccess/dataset/ObjectIdSet.h"
40 #include "../dataaccess/query/Avg.h"
41 #include "../dataaccess/query/Count.h"
42 #include "../dataaccess/query/DataSetName.h"
43 #include "../dataaccess/query/Expression.h"
44 #include "../dataaccess/query/Field.h"
45 #include "../dataaccess/query/Fields.h"
46 #include "../dataaccess/query/From.h"
47 #include "../dataaccess/query/FromItem.h"
48 #include "../dataaccess/query/GroupBy.h"
49 #include "../dataaccess/query/GroupByItem.h"
50 #include "../dataaccess/query/Max.h"
51 #include "../dataaccess/query/Min.h"
52 #include "../dataaccess/query/PropertyName.h"
53 #include "../dataaccess/query/Select.h"
54 #include "../dataaccess/query/Sub.h"
55 #include "../dataaccess/query/Sum.h"
56 #include "../dataaccess/query/StdDev.h"
57 #include "../dataaccess/query/ST_Union.h"
58 #include "../dataaccess/query/Variance.h"
59 #include "../dataaccess/query/Where.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>
102 outDSetType->add(pkProperty);
106 outDSetType->setPrimaryKey(pk);
110 for(std::size_t i=0; i<m_groupProps.size(); ++i)
113 fields->push_back(f_aggName);
116 outDSetType->add(propclone);
122 fields->push_back(f_aggCount);
125 outDSetType->add(countProp);
128 std::map<te::dt::Property*, std::vector<te::stat::StatisticalSummary> >::const_iterator itStat = m_statSum.begin();
130 while(itStat != m_statSum.end())
132 std::vector<te::stat::StatisticalSummary>::const_iterator itFunc = itStat->second.begin();
133 while (itFunc != itStat->second.end())
136 int p_type = itStat->first->getType();
195 fields->push_back(sfield);
196 outDSetType->add(newProp);
206 fields->push_back(f_union);
216 outDSetType->add(geometry);
220 from->push_back(fromItem);
230 for(std::size_t i=0; i<m_groupProps.size(); ++i)
233 groupBy->push_back(e_groupBy);
235 select.setGroupBy(groupBy);
237 std::auto_ptr<te::da::DataSet> dsQuery = m_inDsrc->query(select);
240 if (dsQuery->isEmpty())
243 std::auto_ptr<te::mem::DataSet> outDSet(
new te::mem::DataSet(outDSetType.get()));
246 dsQuery->moveBeforeFirst();
248 while (dsQuery->moveNext())
253 for (
size_t i=1; i<outDSetType->size(); ++i)
255 switch (outDSetType->getProperty(i)->getType())
258 if (!dsQuery->isNull(i - 1))
259 outDSetItem->
setString(i, dsQuery->getAsString(i - 1));
262 if (!dsQuery->isNull(i - 1))
263 outDSetItem->
setInt32(i, boost::lexical_cast<int>(dsQuery->getAsString(i - 1)));
266 if (!dsQuery->isNull(i - 1))
267 outDSetItem->
setInt64(i, dsQuery->getInt64(i - 1));
270 if (!dsQuery->isNull(i - 1))
271 outDSetItem->
setDouble(i, dsQuery->getDouble(i - 1));
274 if (!dsQuery->isNull(i - 1))
275 outDSetItem->
setNumeric(i, dsQuery->getNumeric(i - 1));
278 if (!dsQuery->isNull(i - 1))
280 std::auto_ptr<te::gm::Geometry> agg_geo(dsQuery->getGeometry(i - 1));
282 if (agg_geo->getGeomTypeId() != geotype)
289 outDSetItem->
setGeometry(
"geom", agg_geo.release());
296 outDSet->add(outDSetItem);
304 te::vp::Save(m_outDsrc.get(), dsAdapter.get(), outDSetType.get());
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
const std::string & getName() const
It returns the property name.
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 add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
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...
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
void setGeometryType(GeomType t)
It sets the geometry subtype.
void setDouble(std::size_t i, double value)
It sets the value of the i-th property.
An atomic property like an integer or double.
A class that models the name of a dataset used in a From clause.
TEDATAACCESSEXPORT void AssociateDataSetTypeConverterSRID(DataSetTypeConverter *converter, const int &inputSRID, const int &outputSRID=TE_UNKNOWN_SRS)
A class that models the name of any property of an object.
A class that models the description of a dataset.
void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType)
virtual Property * clone() const =0
It returns a clone of the object.
Count statistical function.
It models a property definition.
Avg statistical function.
Min statistical function.
void setNumeric(std::size_t i, const std::string &value)
It sets the value of the i-th property.
This is an abstract class that models a query expression.
StdDev statistical function.
An converter for DataSetType.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
TESAEXPORT double Sum(te::sa::GeneralizedProximityMatrix *gpm, int attrIdx)
Function used to calculate sum of a specific attribute from a gpm.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
A class that can be used to model a filter expression that can be applied to a query.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
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.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
The subtraction operator.
Aggregation Vector Processing functions.
It describes a primary key (pk) constraint.
Variance statistical function.
void setGeometryN(std::size_t i, Geometry *g)
It sets the n-th geometry in this geometry collection.
ST_Union statistical function.
Configuration flags for the Terrralib Vector Processing module.
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)
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
Max statistical function.
const std::string & getName() const
It returns the property name.