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>
91 std::auto_ptr<te::da::DataSet> inDs;
93 inDs = m_inDsrc->getDataSet(m_inDsName);
97 std::auto_ptr<te::da::DataSetType> outDst = getOutDst();
101 inDs->moveBeforeFirst();
103 std::size_t pkCount = 0;
105 while(inDs->moveNext())
107 std::auto_ptr<te::gm::Geometry> geom = inDs->getGeometry(geomPos);
109 std::vector<te::gm::Geometry*> geoms;
112 if(geoms.size() == 1)
116 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
122 item->
setValue(1, inDs->getValue(i).release());
124 else if(i != geomPos)
125 item->
setValue((i+1), inDs->getValue(i).release());
134 for(std::size_t g = 0; g < geoms.size(); ++g)
138 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
144 item->
setValue(1, inDs->getValue(i).release());
146 else if(i != geomPos)
147 item->
setValue((i+1), inDs->getValue(i).release());
157 te::vp::Save(m_outDsrc.get(), outDs.get(), outDst.get());
164 std::auto_ptr<te::da::DataSet> inDs;
166 inDs = m_inDsrc->getDataSet(m_inDsName);
170 std::auto_ptr<te::da::DataSetType> outDst = getOutDst(
true);
174 inDs->moveBeforeFirst();
176 std::size_t pkCount = 0;
178 while(inDs->moveNext())
180 std::auto_ptr<te::gm::Geometry> geom = inDs->getGeometry(geomPos);
184 std::vector<te::gm::Geometry*> geoms;
185 std::vector<te::gm::Geometry*> multiGeoms;
187 if(m_oidSet->contains(geomOid))
191 for(std::size_t i = 0; i < geoms.size(); ++i)
193 multiGeoms.push_back(single2multi(geoms[i]));
198 geoms.push_back(geom.release());
201 if(geoms.size() == 1)
205 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
211 item->
setValue(1, inDs->getValue(i).release());
213 else if(i != geomPos)
214 item->
setValue((i+1), inDs->getValue(i).release());
223 for(std::size_t g = 0; g < multiGeoms.size(); ++g)
227 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
233 item->
setValue(1, inDs->getValue(i).release());
235 else if(i != geomPos)
236 item->
setValue((i+1), inDs->getValue(i).release());
246 te::vp::Save(m_outDsrc.get(), outDs.get(), outDst.get());
251 std::string inDsName,
252 std::auto_ptr<te::da::DataSetType> inDsType,
256 m_inDsName = inDsName;
257 m_inDsType = inDsType;
264 m_outDsName = outDsName;
275 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)