28 #include "../common/progress/TaskProgress.h" 29 #include "../core/logger/Logger.h" 30 #include "../core/translator/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> 90 std::unique_ptr<te::da::DataSet> inDs;
96 std::unique_ptr<te::da::DataSetType> outDst =
getOutDst();
100 inDs->moveBeforeFirst();
104 while(inDs->moveNext())
108 if (inDs->isNull(geomPos))
111 std::unique_ptr<te::gm::Geometry> geom = inDs->getGeometry(geomPos);
113 std::vector<te::gm::Geometry*> geoms;
116 if(geoms.size() == 1)
120 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
124 item->
setInt32(0, (int32_t)pkCount);
126 item->
setValue(1, inDs->getValue(i).release());
128 else if(i != geomPos)
129 item->
setValue((i+1), inDs->getValue(i).release());
138 for(std::size_t g = 0; g < geoms.size(); ++g)
142 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
146 item->
setInt32(0, (int32_t)pkCount);
148 item->
setValue(1, inDs->getValue(i).release());
150 else if(i != geomPos)
151 item->
setValue((i+1), inDs->getValue(i).release());
174 std::unique_ptr<te::da::DataSet> inDs;
180 std::unique_ptr<te::da::DataSetType> outDst =
getOutDst(
true);
182 std::unique_ptr<te::mem::DataSet> outDs(
new te::mem::DataSet(outDst.get()));
184 inDs->moveBeforeFirst();
188 while(inDs->moveNext())
192 if (inDs->isNull(geomPos))
195 std::unique_ptr<te::gm::Geometry> geom = inDs->getGeometry(geomPos);
199 std::vector<te::gm::Geometry*> geoms;
200 std::vector<te::gm::Geometry*> multiGeoms;
206 for(std::size_t i = 0; i < geoms.size(); ++i)
213 geoms.push_back(geom.release());
216 if(geoms.size() == 1)
220 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
224 item->
setInt32(0, (int32_t)pkCount);
226 item->
setValue(1, inDs->getValue(i).release());
228 else if(i != geomPos)
229 item->
setValue((i+1), inDs->getValue(i).release());
238 for(std::size_t g = 0; g < multiGeoms.size(); ++g)
242 for(std::size_t i = 0; i < inDs->getNumProperties(); ++i)
246 item->
setInt32(0, (int32_t)pkCount);
248 item->
setValue(1, inDs->getValue(i).release());
250 else if(i != geomPos)
251 item->
setValue((i+1), inDs->getValue(i).release());
272 std::string inDsName,
273 std::unique_ptr<te::da::DataSetType> inDsType,
297 std::vector<te::dt::Property*> pkProps{ newId };
301 outDst->setPrimaryKey(pk);
303 for(std::size_t i = 0; i <
m_inDsType->size(); ++i)
An exception class for the Vector processing module.
MultiPolygon is a MultiSurface whose elements are Polygons.
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
te::gm::Geometry * single2multi(te::gm::Geometry *geom)
void setGeometryType(GeomType t)
It sets the geometry subtype.
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.
virtual const char * what() const
It outputs the exception message.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
std::unique_ptr< te::da::DataSetType > m_inDsType
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property.
TEGEOMEXPORT bool IsMultiType(te::gm::GeomType geomType)
Verifies if the geomType is a collection type.
TEGEOMEXPORT te::gm::GeomType GetSimpleType(te::gm::GeomType geomType)
Get the simple type of GeomType.
#define TE_TR(message)
It marks a string in order to get translated.
virtual Property * clone() const =0
It returns a clone of the object.
TEGEOMEXPORT void Multi2Single(const te::gm::Geometry *g, std::vector< te::gm::Geometry * > &geoms)
It will get a GeometryCollection and distribute in a vector.
It models a property definition.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
TEVPEXPORT void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType, const bool &enableProgress=true)
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
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.
void setInput(te::da::DataSourcePtr inDsrc, std::string inDsName, std::unique_ptr< te::da::DataSetType > inDsType, const te::da::ObjectIdSet *oidSet=0)
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
te::da::DataSourcePtr m_inDsrc
void setProperties(const std::vector< te::dt::Property * > &properties)
It sets the properties that form the primary key.
Utility functions for the data access module.
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.
te::da::DataSourcePtr m_outDsrc
It describes a primary key (pk) constraint.
void add(Geometry *g)
It adds the geometry into the collection.
std::unique_ptr< te::da::DataSetType > getOutDst(bool onlySelected=false)
Configuration flags for the Terrralib Vector Processing module.
bool contains(ObjectId *oid) const
It returns if the object id set contains the given oid.
#define TE_LOG_ERROR(message)
Use this tag in order to log a message to the TerraLib default logger with the ERROR level...
const std::vector< std::string > & getPropertyNames() const
It returns the property names used to generated the oids.
Multipart to Singlepart Vector Processing functions.
TEDATAACCESSEXPORT te::dt::Property * GetFirstSpatialProperty(const DataSetType *dt)
const te::da::ObjectIdSet * m_oidSet