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/DataSetAdapter.h"
34 #include "../dataaccess/dataset/DataSetTypeConverter.h"
36 #include "../datatype/Property.h"
37 #include "../datatype/SimpleProperty.h"
38 #include "../datatype/StringProperty.h"
40 #include "../dataaccess/dataset/ObjectIdSet.h"
41 #include "../dataaccess/query/DataSetName.h"
42 #include "../dataaccess/query/Expression.h"
43 #include "../dataaccess/query/Field.h"
44 #include "../dataaccess/query/Fields.h"
45 #include "../dataaccess/query/From.h"
46 #include "../dataaccess/query/FromItem.h"
47 #include "../dataaccess/query/PropertyName.h"
48 #include "../dataaccess/query/Select.h"
49 #include "../dataaccess/query/ST_Buffer.h"
50 #include "../dataaccess/query/ST_Difference.h"
51 #include "../dataaccess/query/Where.h"
52 #include "../dataaccess/utils/Utils.h"
54 #include "../geometry/Geometry.h"
55 #include "../geometry/GeometryCollection.h"
56 #include "../geometry/GeometryProperty.h"
57 #include "../geometry/Utils.h"
59 #include "../memory/DataSet.h"
60 #include "../memory/DataSetItem.h"
62 #include "../sam/rtree.h"
76 #include <boost/lexical_cast.hpp>
77 #include <boost/algorithm/string.hpp>
89 if(m_copyInputColumns)
91 std::vector<te::dt::Property*> props = m_converter->getResult()->getProperties();
92 for(std::size_t i=0; i < props.size(); ++i)
97 fields->push_back(f_props);
109 for(
int i=1; i <= m_levels; ++i)
111 std::stringstream ss;
113 std::string index = ss.str();
140 fields->push_back(f_buffer);
147 fields->push_back(f_buffer);
154 from->push_back(fromItem);
164 std::auto_ptr<te::da::DataSet> dsQuery = m_inDsrc->query(select);
167 std::auto_ptr<te::mem::DataSet> outDSet(
new te::mem::DataSet(outDSType.get()));
171 std::vector<std::vector<te::gm::Geometry*> > vecDissolvedGeom = dissolveQuery(dsQuery.get(), m_levels);
172 prepareDataSet(outDSType.get(), vecDissolvedGeom, outDSet.get(), m_distance);
176 prepareDataSet(outDSType.get(), dsQuery.get(), outDSet.get(), m_distance);
181 int layerSRID = geomPropertyLayer->
getSRID();
188 te::vp::Save(m_outDsrc.get(), dsAdapter.get(), dsTypeResult);
196 std::map<int, std::vector<te::gm::Geometry*> > mapGeom;
197 std::vector<std::vector<te::gm::Geometry*> > vecGeom;
199 for(
int i = 0; i < levels; ++i)
208 std::vector<te::gm::Geometry*> vec;
214 for(std::size_t t = 0; t < vec.size(); ++t)
218 geom = geom->
Union(vec[t]);
219 rtree.
remove(*(vec[t]->getMBR()), vec[t]);
226 std::vector<te::gm::Geometry*> geomVec;
227 std::auto_ptr<te::gm::Envelope> e = dsQuery->
getExtent(i);
228 rtree.
search(*(e.get()), geomVec);
229 vecGeom.push_back(geomVec);
234 std::size_t vecSize = vecGeom.size();
238 for(std::size_t i = vecSize - 1; i > 0; --i)
240 std::vector<te::gm::Geometry*> currentVec = vecGeom[i];
241 std::size_t c_vecSize = currentVec.size();
243 for(std::size_t j = 0; j < i; ++j)
245 std::vector<te::gm::Geometry*> innerVec = vecGeom[j];
246 std::size_t i_vecSize = innerVec.size();
248 for(std::size_t k = 0; k < c_vecSize; ++k)
250 for(std::size_t l = 0; l < i_vecSize; ++l)
260 delete currentVec[k];
261 currentVec[k] = tGeom;
262 vecGeom[i] = currentVec;
277 const double& distance)
281 int numItems = (int)numProps - (
int)firstGeomPos;
289 int numCurrentItem = 0;
291 for(
int i = 0; i < numItems; ++i)
295 for(std::size_t j = 0; j < numProps; ++j)
316 dataSetItem->
setDouble(2, distance*(i+1));
318 std::auto_ptr<te::gm::Geometry> geom = dataSetQuery->
getGeometry(j+numCurrentItem);
326 mPolygon->add(geom.release());
330 outputDataSet->
add(dataSetItem);
338 #ifdef TERRALIB_LOGGER_ENABLED
339 te::common::Logger::logDebug(
"vp",
"Buffer - Type not found.");
340 #endif //TERRALIB_LOGGER_ENABLED
349 std::vector<std::vector<te::gm::Geometry*> > vecDissolvedGeom,
351 const double& distance)
355 for(std::size_t i = 0; i < vecDissolvedGeom.size(); ++i)
357 std::vector<te::gm::Geometry*> vecGeom = vecDissolvedGeom[i];
358 std::size_t sizeVecGeom = vecGeom.size();
360 for(std::size_t j=0; j < sizeVecGeom; ++j)
365 dataSetItem->
setDouble(2, distance*((
int)i+1));
367 std::auto_ptr<te::gm::Geometry> geom(vecGeom[j]);
376 mPolygon->add(geom.release());
380 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.
TEDATAACCESSEXPORT void AssociateDataSetTypeConverterSRID(DataSetTypeConverter *converter, const int &inputSRID, const int &outputSRID=TE_UNKNOWN_SRS)
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).
DataSetType * getResult() const
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.
An converter for DataSetType.
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.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
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)
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
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.