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/DataSetName.h"
40 #include "../dataaccess/query/Expression.h"
41 #include "../dataaccess/query/Field.h"
42 #include "../dataaccess/query/Fields.h"
43 #include "../dataaccess/query/From.h"
44 #include "../dataaccess/query/FromItem.h"
45 #include "../dataaccess/query/PropertyName.h"
46 #include "../dataaccess/query/Select.h"
47 #include "../dataaccess/query/ST_Buffer.h"
48 #include "../dataaccess/query/ST_Difference.h"
49 #include "../dataaccess/query/Where.h"
50 #include "../dataaccess/utils/Utils.h"
52 #include "../geometry/Geometry.h"
53 #include "../geometry/GeometryCollection.h"
54 #include "../geometry/GeometryProperty.h"
55 #include "../geometry/Utils.h"
57 #include "../memory/DataSet.h"
58 #include "../memory/DataSetItem.h"
60 #include "../sam/rtree.h"
74 #include <boost/lexical_cast.hpp>
75 #include <boost/algorithm/string.hpp>
87 if(m_copyInputColumns)
89 std::vector<te::dt::Property*> props = m_inDsetType->getProperties();
90 for(std::size_t i=0; i < props.size(); ++i)
95 fields->push_back(f_props);
107 for(
int i=1; i <= m_levels; ++i)
109 std::stringstream ss;
111 std::string index = ss.str();
138 fields->push_back(f_buffer);
145 fields->push_back(f_buffer);
152 from->push_back(fromItem);
162 std::auto_ptr<te::da::DataSet> dsQuery = m_inDsrc->query(select);
165 std::auto_ptr<te::mem::DataSet> outDSet(
new te::mem::DataSet(outDSType.get()));
169 std::vector<std::vector<te::gm::Geometry*> > vecDissolvedGeom = dissolveQuery(dsQuery.get(), m_levels);
170 prepareDataSet(outDSType.get(), vecDissolvedGeom, outDSet.get(), m_distance);
174 prepareDataSet(outDSType.get(), dsQuery.get(), outDSet.get(), m_distance);
177 te::vp::Save(m_outDsrc.get(), outDSet.get(), outDSType.get());
185 std::map<int, std::vector<te::gm::Geometry*> > mapGeom;
186 std::vector<std::vector<te::gm::Geometry*> > vecGeom;
188 for(
int i = 0; i < levels; ++i)
197 std::vector<te::gm::Geometry*> vec;
203 for(std::size_t t = 0; t < vec.size(); ++t)
207 geom = geom->
Union(vec[t]);
208 rtree.
remove(*(vec[t]->getMBR()), vec[t]);
215 std::vector<te::gm::Geometry*> geomVec;
216 std::auto_ptr<te::gm::Envelope> e = dsQuery->
getExtent(i);
217 rtree.
search(*(e.get()), geomVec);
218 vecGeom.push_back(geomVec);
223 std::size_t vecSize = vecGeom.size();
227 for(std::size_t i = vecSize - 1; i > 0; --i)
229 std::vector<te::gm::Geometry*> currentVec = vecGeom[i];
230 std::size_t c_vecSize = currentVec.size();
232 for(std::size_t j = 0; j < i; ++j)
234 std::vector<te::gm::Geometry*> innerVec = vecGeom[j];
235 std::size_t i_vecSize = innerVec.size();
237 for(std::size_t k = 0; k < c_vecSize; ++k)
239 for(std::size_t l = 0; l < i_vecSize; ++l)
249 delete currentVec[k];
250 currentVec[k] = tGeom;
251 vecGeom[i] = currentVec;
266 const double& distance)
270 int numItems = numProps - firstGeomPos;
278 int numCurrentItem = 0;
280 for(
int i = 0; i < numItems; ++i)
284 for(std::size_t j = 0; j < numProps; ++j)
305 dataSetItem->
setDouble(2, distance*(i+1));
307 std::auto_ptr<te::gm::Geometry> geom = dataSetQuery->
getGeometry(j+numCurrentItem);
315 mPolygon->add(geom.release());
319 outputDataSet->
add(dataSetItem);
327 #ifdef TERRALIB_LOGGER_ENABLED
328 te::common::Logger::logDebug(
"vp",
"Buffer - Type not found.");
329 #endif //TERRALIB_LOGGER_ENABLED
338 std::vector<std::vector<te::gm::Geometry*> > vecDissolvedGeom,
340 const double& distance)
344 for(std::size_t i = 0; i < vecDissolvedGeom.size(); ++i)
346 std::vector<te::gm::Geometry*> vecGeom = vecDissolvedGeom[i];
347 std::size_t sizeVecGeom = vecGeom.size();
349 for(std::size_t j=0; j < sizeVecGeom; ++j)
354 dataSetItem->
setDouble(2, distance*(i+1));
356 std::auto_ptr<te::gm::Geometry> geom(vecGeom[j]);
365 mPolygon->add(geom.release());
369 outputDataSet->
add(dataSetItem);
bool remove(const te::gm::Envelope &mbr, const DATATYPE &data)
It removes an item from the tree.
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.
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...
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long).
void setDouble(std::size_t i, double value)
It sets the value of the i-th property.
A class that models the name of a dataset used in a From clause.
virtual bool intersects(const Geometry *const rhs) const
It returns true if the geometry object spatially intersects rhs geometry.
A class that represents an R-tree.
A class that models the name of any property of an object.
A class that models the description of a dataset.
void prepareDataSet(te::da::DataSetType *dataSetType, te::da::DataSet *dataSetQuery, te::mem::DataSet *outputDataSet, const double &distance)
virtual boost::int64_t getInt64(std::size_t i) const =0
Method for retrieving a 64-bit integer attribute value (8 bytes long).
void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType)
std::vector< std::vector< te::gm::Geometry * > > dissolveQuery(te::da::DataSet *dsQuery, const int &levels)
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value.
This is an abstract class that models a query expression.
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
The buffer is generated only outside of the polygons.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
TEDATAACCESSEXPORT std::size_t GetFirstSpatialPropertyPos(const te::da::DataSet *dataset)
It returns the first dataset spatial property or NULL if none is found.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
Spatial difference operator.
A class that can be used to model a filter expression that can be applied to a query.
virtual bool isValid() const
It tells if the geometry is well formed.
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
A Select models a query to be used when retrieving data from a DataSource.
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
The buffer is generated Inside and outside of the polygons.
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::auto_ptr< te::gm::Envelope > getExtent(std::size_t i)=0
It computes the bounding rectangle for a spatial property of the dataset.
virtual bool moveBeforeFirst()=0
It moves the internal pointer to a position before the first item in the collection.
TEDATAACCESSEXPORT DataSetType * GetDataSetType(const std::string &name, const std::string &datasourceId)
Configuration flags for the Terrralib Vector Processing module.
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
void setString(std::size_t i, const std::string &value)
It sets the value of the i-th property.
virtual Geometry * Union(const Geometry *const rhs) const
It returns a geometric object that represents the point set union with another geometry.
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)
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
const Envelope * getMBR() const
It returns the minimum bounding rectangle for the geometry in an internal representation.
virtual Geometry * difference(const Geometry *const rhs) const
It returns a geometric object that represents the point set difference with another geometry...
The boundaries between buffers will be dissolved.
const std::string & getName() const
It returns the property name.