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/dataset/ObjectIdSet.h"
39 #include "../dataaccess/query/Avg.h"
40 #include "../dataaccess/query/Count.h"
41 #include "../dataaccess/query/DataSetName.h"
42 #include "../dataaccess/query/Expression.h"
43 #include "../dataaccess/query/Field.h"
44 #include "../dataaccess/query/Fields.h"
45 #include "../dataaccess/query/From.h"
46 #include "../dataaccess/query/FromItem.h"
47 #include "../dataaccess/query/GroupBy.h"
48 #include "../dataaccess/query/GroupByItem.h"
49 #include "../dataaccess/query/Max.h"
50 #include "../dataaccess/query/Min.h"
51 #include "../dataaccess/query/PropertyName.h"
52 #include "../dataaccess/query/Select.h"
53 #include "../dataaccess/query/Sub.h"
54 #include "../dataaccess/query/Sum.h"
55 #include "../dataaccess/query/StdDev.h"
56 #include "../dataaccess/query/ST_Union.h"
57 #include "../dataaccess/query/Variance.h"
58 #include "../dataaccess/query/Where.h"
59 #include "../dataaccess/utils/Utils.h"
61 #include "../geometry/Geometry.h"
62 #include "../geometry/GeometryCollection.h"
63 #include "../geometry/GeometryProperty.h"
64 #include "../geometry/Utils.h"
66 #include "../memory/DataSet.h"
67 #include "../memory/DataSetItem.h"
69 #include "../statistics/core/SummaryFunctions.h"
70 #include "../statistics/core/StringStatisticalSummary.h"
71 #include "../statistics/core/NumericStatisticalSummary.h"
85 #include <boost/lexical_cast.hpp>
86 #include <boost/algorithm/string.hpp>
101 outDSetType->add(pkProperty);
105 outDSetType->setPrimaryKey(pk);
109 for(std::size_t i=0; i<m_groupProps.size(); ++i)
112 fields->push_back(f_aggName);
115 outDSetType->add(propclone);
121 fields->push_back(f_aggCount);
124 outDSetType->add(countProp);
127 std::map<te::dt::Property*, std::vector<te::stat::StatisticalSummary> >::const_iterator itStat = m_statSum.begin();
129 while(itStat != m_statSum.end())
131 std::vector<te::stat::StatisticalSummary>::const_iterator itFunc = itStat->second.begin();
132 while (itFunc != itStat->second.end())
135 int p_type = itStat->first->getType();
194 fields->push_back(sfield);
195 outDSetType->add(newProp);
205 fields->push_back(f_union);
215 outDSetType->add(geometry);
219 from->push_back(fromItem);
229 for(std::size_t i=0; i<m_groupProps.size(); ++i)
232 groupBy->push_back(e_groupBy);
234 select.setGroupBy(groupBy);
236 std::auto_ptr<te::da::DataSet> dsQuery = m_inDsrc->query(select);
239 if (dsQuery->isEmpty())
242 std::auto_ptr<te::mem::DataSet> outDSet(
new te::mem::DataSet(outDSetType.get()));
245 dsQuery->moveBeforeFirst();
246 while (dsQuery->moveNext())
251 for (
size_t i=1; i<outDSetType->size(); ++i)
253 switch (outDSetType->getProperty(i)->getType())
256 if (!dsQuery->isNull(i-1))
257 outDSetItem->
setString(i,dsQuery->getAsString(i-1));
260 if (!dsQuery->isNull(i-1))
261 outDSetItem->
setInt32(i, boost::lexical_cast<int>(dsQuery->getAsString(i-1)));
264 if (!dsQuery->isNull(i-1))
265 outDSetItem->
setInt64(i,dsQuery->getInt64(i-1));
268 if (!dsQuery->isNull(i-1))
269 outDSetItem->
setDouble(i,dsQuery->getDouble(i-1));
272 if (!dsQuery->isNull(i-1))
273 outDSetItem->
setNumeric(i,dsQuery->getNumeric(i-1));
276 if (!dsQuery->isNull(i-1))
278 std::auto_ptr<te::gm::Geometry> agg_geo(dsQuery->getGeometry(i-1));
279 if (agg_geo->getGeomTypeId() != geotype)
286 outDSetItem->
setGeometry(
"geom", agg_geo.release());
293 outDSet->add(outDSetItem);
297 te::vp::Save(m_outDsrc.get(), outDSet.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.
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.
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)
Max statistical function.
const std::string & getName() const
It returns the property name.