28 #include "../common/StringUtils.h" 30 #include "../core/translator/Translator.h" 32 #include "../dataaccess/dataset/DataSetTypeConverter.h" 33 #include "../dataaccess/dataset/DataSetTypeCapabilities.h" 34 #include "../dataaccess/datasource/DataSourceCapabilities.h" 35 #include "../dataaccess/datasource/DataSourceInfo.h" 36 #include "../dataaccess/datasource/DataSourceManager.h" 37 #include "../dataaccess/datasource/DataSourceInfoManager.h" 38 #include "../dataaccess/datasource/DataSourceTransactor.h" 39 #include "../dataaccess/utils/Utils.h" 41 #include "../geometry/GeometryProperty.h" 42 #include "../geometry/MultiPoint.h" 43 #include "../geometry/MultiLineString.h" 44 #include "../geometry/MultiPolygon.h" 45 #include "../geometry/Point.h" 55 #include <boost/algorithm/string.hpp> 56 #include <boost/filesystem.hpp> 57 #include <boost/lexical_cast.hpp> 58 #include <boost/uuid/random_generator.hpp> 59 #include <boost/uuid/uuid_io.hpp> 66 std::unique_ptr<te::gm::Geometry> seedGeometry = items[0]->getGeometry(geomIdx);
69 resultGeometry = seedGeometry.release();
73 std::unique_ptr<te::gm::Geometry> teGeom = items[1]->getGeometry(geomIdx);
76 resultGeometry = seedGeometry->
Union(teGeom.release());
78 resultGeometry = seedGeometry.release();
85 while (!seedGeometry->isValid())
87 seedGeometry = items[pos]->getGeometry(geomIdx);
91 for (std::size_t i = pos; i < items.size(); ++i)
93 std::unique_ptr<te::gm::Geometry> currentGeom = items[i]->getGeometry(geomIdx);
95 if(currentGeom->isValid())
96 resultGeometry = seedGeometry->
Union(currentGeom.release());
98 seedGeometry.reset(resultGeometry);
101 resultGeometry = seedGeometry.release();
112 for(std::size_t i = 0; i < geomVec.size(); ++i)
130 return resultGeometry;
137 std::unique_ptr<te::gm::Geometry> seedGeometry = items[0]->getGeometry(geomIdx);
140 resultGeometry = seedGeometry.release();
142 if(items.size() == 2)
144 std::unique_ptr<te::gm::Geometry> teGeom = items[1]->getGeometry(geomIdx);
146 if(teGeom->isValid())
147 resultGeometry = seedGeometry->
Union(teGeom.release());
149 resultGeometry = seedGeometry.release();
155 for(std::size_t i = 1; i < items.size(); ++i)
157 std::unique_ptr<te::gm::Geometry> currentGeom = items[i]->getGeometry(geomIdx);
159 if(currentGeom->isValid())
160 teGeomColl->
add(currentGeom.release());
163 resultGeometry = seedGeometry->
Union(teGeomColl);
166 return resultGeometry;
172 for(std::size_t i = 0; i < geomVec.size(); ++i)
184 std::size_t found = fullName.rfind(
".");
186 if(found >= std::string::npos)
189 return fullName.substr(found + 1);
194 std::vector<std::string> pkPropNames;
197 std::vector<te::dt::Property*> props;
202 for (std::size_t i = 0; i < props.size(); ++i)
207 pkPropNames.push_back(sp->
getName());
211 std::unique_ptr<te::da::DataSet> dataSet;
213 if (!pkPropNames.empty())
227 std::unique_ptr<te::da::DataSourceTransactor> t = source->
getTransactor();
229 std::map<std::string, std::string> options;
235 std::string dsTypeName = outDsType->
getName();
236 std::vector<std::string> dataSetNames = t->getDataSetNames();
239 for (std::size_t i = 0; i < dataSetNames.size(); ++i)
241 std::vector<std::string> tok;
244 std::string temp_dsName;
247 temp_dsName = tok[1];
249 temp_dsName = dataSetNames[i];
251 if (dsTypeName == temp_dsName)
260 t->createDataSet(dsTypeResult, options);
265 t->add(dsTypeName, result, options, 0, enableProgress);
274 catch(std::exception& e)
284 boost::filesystem::path uri(repository);
286 const std::string dsInfo(
"file://" + uri.string());
288 boost::uuids::basic_random_generator<boost::mt19937> gen;
289 boost::uuids::uuid u = gen();
290 std::string id_ds = boost::uuids::to_string(u);
293 dsInfoPtr->setConnInfo(dsInfo);
294 dsInfoPtr->setTitle(uri.stem().string());
295 dsInfoPtr->setAccessDriver(
"OGR");
296 dsInfoPtr->setType(
"OGR");
297 dsInfoPtr->setDescription(uri.string());
298 dsInfoPtr->setId(id_ds);
307 std::vector<te::vp::InputParams> inputParams = mainParams->
getInputParams();
309 for (std::size_t i = 0; i < inputParams.size(); ++i)
311 if (!inputParams[i].m_inputDataSetType)
316 if (!inputParams[i].m_inputDataSet)
321 if (!inputParams[i].m_inputQuery)
341 if (!data->
isNull(geomPos)) {
342 std::unique_ptr<te::gm::Geometry> geom = data->
getGeometry(geomPos);
344 rtree->
insert(*geom->getMBR(), count);
360 geomColl->
add(dynamic_cast<te::gm::Geometry*>(geom.
clone()));
367 geomColl->
add(dynamic_cast<te::gm::Geometry*>(geom.
clone()));
374 geomColl->
add(dynamic_cast<te::gm::Geometry*>(geom.
clone()));
387 std::string result = name;
389 bool hasToResize =
false;
394 std::size_t count = 1;
396 while (std::find(names.begin(), names.end(), result) != names.end())
406 if (result.size() + aux > maxSize)
408 result = result.substr(0, maxSize - aux) +
"_" + boost::lexical_cast<std::string>(count);
412 result = result +
"_" + boost::lexical_cast<std::string>(count);
417 result = result +
"_" + boost::lexical_cast<std::string>(count);
423 if (maxSize > 0 && name.size() > maxSize)
424 result = result.substr(0, maxSize);
484 for(std::size_t i = 0; i < numberOfProperties; ++i)
487 dataSetItem->
setValue(i, value.release());
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
MultiPolygon is a MultiSurface whose elements are Polygons.
TEVPEXPORT std::unique_ptr< te::da::DataSet > PrepareAdd(te::da::DataSet *ds, te::da::DataSetType *dt)
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
virtual std::unique_ptr< DataSourceTransactor > getTransactor()=0
It returns the set of parameters used to set up the access channel to the underlying repository...
An atomic property like an integer or double.
TEVPEXPORT te::da::DataSourcePtr CreateOGRDataSource(std::string repository)
boost::shared_ptr< DataSource > DataSourcePtr
TEVPEXPORT bool IsPointType(const te::gm::GeomType &geomType)
A class that represents an R-tree.
A class that models the description of a dataset.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
TEVPEXPORT te::gm::Geometry * GetGeometryUnion(const std::vector< te::mem::DataSetItem * > &items, size_t geomIdx, te::gm::GeomType outGeoType)
It returns the union of a geometry vector.
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property.
PrimaryKey * getPrimaryKey() const
It returns the primary key associated to the dataset type.
std::vector< te::vp::InputParams > getInputParams()
TEVPEXPORT te::sam::rtree::Index< size_t, 8 > * GetRtree(te::da::DataSet *data)
TEVPEXPORT bool IsPolygonType(const te::gm::GeomType &geomType)
static te::dt::Date ds(2010, 01, 01)
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
#define TE_TR(message)
It marks a string in order to get translated.
virtual Geometry * Union(const Geometry *const rhs) const _NOEXCEPT_OP(false)
It returns a geometric object that represents the point set union with another geometry.
std::size_t getNumProperties() const
It returns the number of properties.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the primary key.
TEDATAACCESSEXPORT std::unique_ptr< te::da::DataSet > HideColumns(te::da::DataSet *ds, te::da::DataSetType *dst, const std::vector< std::string > &columns)
It hide columns of a DataSet using DataSetAdapter.
An converter for DataSetType.
te::gm::GeometryCollection * gc
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
TEVPEXPORT void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType, const bool &enableProgress=true)
void Tokenize(const std::string &str, std::vector< std::string > &tokens, const std::string &delimiters=" ")
It tokenizes a given string with a delimiter of your own choice.
int getSRID() const _NOEXCEPT_OP(true)
It returns the Spatial Reference System ID associated to this geometric object.
virtual const DataSourceCapabilities & getCapabilities() const =0
It returns the known capabilities of the data source.
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.
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
TEVPEXPORT bool IsLineStringType(const te::gm::GeomType &geomType)
TEVPEXPORT void SplitGeometryCollection(te::gm::GeometryCollection *geomIn, te::gm::GeometryCollection *gcOut)
static te::dt::TimeDuration dt(20, 30, 50, 11)
virtual AbstractData * clone() const =0
It returns a clone of this object.
te::da::DataSourcePtr getOutputDataSource()
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.
MultiLineString is a MultiCurve whose elements are LineStrings.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
A dataset is the unit of information manipulated by the data access module of TerraLib.
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
virtual std::unique_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
It describes a primary key (pk) constraint.
void add(Geometry *g)
It adds the geometry into the collection.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
const std::vector< Geometry * > & getGeometries() const
It returns a reference to the internal list of geometries.
void setGeometryN(std::size_t i, Geometry *g)
It sets the n-th geometry in this geometry collection.
TEVPEXPORT te::mem::DataSetItem * GetFilledItemMemory(te::da::DataSet *dataSet)
It returns a memory item with all properties filled with values from the current position dataset...
A class that represents a data source component.
TEVPEXPORT void ValidateAlgorithmParams(AlgorithmParams *mainParams, Strategy st)
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
TEVPEXPORT std::string GetDistinctName(const std::string &name, std::vector< std::string > names, std::size_t maxSize=0)
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
It is a collection of other geometric objects.
bool isAutoNumber() const
It returns true if the attribute is an autonumber, otherwise it returns false.
TEVPEXPORT te::gm::Geometry * SetGeomAsMulti(const te::gm::Geometry &geom)
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
const std::string & getName() const
It returns the property name.
TEVPEXPORT std::string GetSimpleTableName(std::string fullName)