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/ObjectId.h"
34 #include "../dataaccess/dataset/ObjectIdSet.h"
35 #include "../dataaccess/utils/Utils.h"
36 #include "../datatype/Property.h"
37 #include "../datatype/SimpleProperty.h"
38 #include "../datatype/StringProperty.h"
40 #include "../geometry/Geometry.h"
41 #include "../geometry/GeometryProperty.h"
42 #include "../geometry/MultiLineString.h"
43 #include "../geometry/MultiPoint.h"
44 #include "../geometry/MultiPolygon.h"
45 #include "../geometry/Utils.h"
47 #include "../memory/DataSet.h"
48 #include "../memory/DataSetItem.h"
62 #include <boost/lexical_cast.hpp>
63 #include <boost/algorithm/string.hpp>
92 std::auto_ptr<te::da::DataSet> inDs;
94 inDs = m_inDsrc->getDataSet(m_inDsName);
98 std::auto_ptr<te::da::DataSetType> outDst = getOutDst();
102 inDs->moveBeforeFirst();
104 std::size_t pkCount = 0;
106 while(inDs->moveNext())
108 std::auto_ptr<te::gm::Geometry> geom = inDs->getGeometry(geomPos);
110 std::vector<te::gm::Geometry*> geoms;
113 if(geoms.size() == 1)
117 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
121 item->
setInt32(0, (int32_t)pkCount);
123 item->
setValue(1, inDs->getValue(i).release());
125 else if(i != geomPos)
126 item->
setValue((i+1), inDs->getValue(i).release());
135 for(std::size_t g = 0; g < geoms.size(); ++g)
139 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
143 item->
setInt32(0, (int32_t)pkCount);
145 item->
setValue(1, inDs->getValue(i).release());
147 else if(i != geomPos)
148 item->
setValue((i+1), inDs->getValue(i).release());
158 te::vp::Save(m_outDsrc.get(), outDs.get(), outDst.get());
165 std::auto_ptr<te::da::DataSet> inDs;
167 inDs = m_inDsrc->getDataSet(m_inDsName);
171 std::auto_ptr<te::da::DataSetType> outDst = getOutDst(
true);
175 inDs->moveBeforeFirst();
177 std::size_t pkCount = 0;
179 while(inDs->moveNext())
181 std::auto_ptr<te::gm::Geometry> geom = inDs->getGeometry(geomPos);
185 std::vector<te::gm::Geometry*> geoms;
186 std::vector<te::gm::Geometry*> multiGeoms;
188 if(m_oidSet->contains(geomOid))
192 for(std::size_t i = 0; i < geoms.size(); ++i)
194 multiGeoms.push_back(single2multi(geoms[i]));
199 geoms.push_back(geom.release());
202 if(geoms.size() == 1)
206 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
210 item->
setInt32(0, (int32_t)pkCount);
212 item->
setValue(1, inDs->getValue(i).release());
214 else if(i != geomPos)
215 item->
setValue((i+1), inDs->getValue(i).release());
224 for(std::size_t g = 0; g < multiGeoms.size(); ++g)
228 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
232 item->
setInt32(0, (int32_t)pkCount);
234 item->
setValue(1, inDs->getValue(i).release());
236 else if(i != geomPos)
237 item->
setValue((i+1), inDs->getValue(i).release());
247 te::vp::Save(m_outDsrc.get(), outDs.get(), outDst.get());
252 std::string inDsName,
253 std::auto_ptr<te::da::DataSetType> inDsType,
257 m_inDsName = inDsName;
258 m_inDsType = inDsType;
265 m_outDsName = outDsName;
276 for(std::size_t i = 0; i < m_inDsType->size(); ++i)
int getSRID() const
It returns the Spatial Reference System ID associated to this geometric object.
MultiPolygon is a MultiSurface whose elements are Polygons.
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.
te::gm::Geometry * single2multi(te::gm::Geometry *geom)
void setGeometryType(GeomType t)
It sets the geometry subtype.
void Multi2Single(te::gm::Geometry *g, std::vector< te::gm::Geometry * > &geoms)
An atomic property like an integer or double.
TEDATAACCESSEXPORT ObjectId * GenerateOID(DataSet *dataset, const std::vector< std::string > &names)
boost::shared_ptr< DataSource > DataSourcePtr
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.
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property.
std::auto_ptr< te::da::DataSetType > getOutDst(bool onlySelected=false)
#define TE_TR(message)
It marks a string in order to get translated.
It models a property definition.
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...
MultiPoint is a GeometryCollection whose elements are restricted to points.
TEDATAACCESSEXPORT std::size_t GetFirstSpatialPropertyPos(const te::da::DataSet *dataset)
It returns the first dataset spatial property or NULL if none is found.
void setOutput(te::da::DataSourcePtr outDsrc, std::string outDsName)
This class represents a set of unique ids created in the same context. i.e. from the same data set...
This class represents an unique id for a data set element.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
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.
int getType() const
It returns the property data type.
MultiLineString is a MultiCurve whose elements are LineStrings.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
void setSRID(int srid)
It sets the Spatial Reference System ID of the geometry collection and all its parts.
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsName, std::auto_ptr< te::da::DataSetType > inDsType, const te::da::ObjectIdSet *oidSet=0)
void add(Geometry *g)
It adds the geometry into the collection.
te::gm::GeomType GetSimpleType(te::gm::GeomType geomType)
Configuration flags for the Terrralib Vector Processing module.
Aggregation Vector Processing functions.
TEDATAACCESSEXPORT te::dt::Property * GetFirstSpatialProperty(const DataSetType *dt)
bool IsMultiType(te::gm::GeomType geomType)