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/utils/Utils.h"
34 #include "../datatype/Property.h"
35 #include "../datatype/SimpleProperty.h"
36 #include "../datatype/StringProperty.h"
38 #include "../geometry/Geometry.h"
39 #include "../geometry/GeometryCollection.h"
40 #include "../geometry/GeometryProperty.h"
41 #include "../geometry/Utils.h"
43 #include "../memory/DataSet.h"
44 #include "../memory/DataSetItem.h"
46 #include "../sam/rtree.h"
59 #include <boost/lexical_cast.hpp>
60 #include <boost/algorithm/string.hpp>
71 std::auto_ptr<te::mem::DataSet> outDSet(
new te::mem::DataSet(outDSType.get()));
76 std::auto_ptr<te::da::DataSet> inDset;
79 inDset = m_inDsrc->getDataSet(m_inDsetName);
81 inDset = m_inDsrc->getDataSet(m_inDsetName, m_oidSet);
83 inDset->moveBeforeFirst();
85 while(inDset->moveNext())
89 for(
int i = 1; i <= m_levels; ++i)
93 for(std::size_t j = 0; j < inDset->getNumProperties(); ++j)
96 if(m_copyInputColumns)
101 if(inDset->getPropertyName(j) !=
"FID")
102 dataSetItem->
setInt32(j+2, inDset->getInt32(j));
105 dataSetItem->
setInt64(j+2, inDset->getInt64(j));
108 dataSetItem->
setDouble(j+2, inDset->getDouble(j));
111 dataSetItem->
setString(j+2, inDset->getString(j));
117 dataSetItem->
setDouble(2, m_distance*(i));
119 std::auto_ptr<te::gm::Geometry> currentGeom = inDset->getGeometry(j);
120 std::auto_ptr<te::gm::Geometry> outGeom;
122 if(currentGeom->isValid())
123 outGeom.reset(setBuffer(currentGeom.get(), m_distance, i, auxGeom));
125 te::common::Logger::logDebug(
"vp",
"Buffer - Invalid geometry found");
127 if(outGeom.get() && outGeom->isValid())
136 mPolygon->add(outGeom.release());
140 outDSet->add(dataSetItem);
146 te::common::Logger::logDebug(
"vp",
"Buffer - Type not found.");
155 dataSetItem->
setDouble(2, m_distance*(i));
157 std::auto_ptr<te::gm::Geometry> currentGeom = inDset->getGeometry(j);
158 std::auto_ptr<te::gm::Geometry> outGeom;
160 if(currentGeom->isValid())
161 outGeom.reset(setBuffer(currentGeom.get(), m_distance, i, auxGeom));
163 te::common::Logger::logDebug(
"vp",
"Buffer - Invalid geometry found");
165 if(outGeom.get() && outGeom->isValid())
174 mPolygon->add(outGeom.release());
178 outDSet->add(dataSetItem);
189 dissolveMemory(outDSet.get(), m_levels);
192 return save(outDSet,outDSType);
197 const double& distance,
203 std::auto_ptr<te::gm::Geometry> outGeom;
204 std::auto_ptr<te::gm::Geometry> inGeom;
205 switch(m_bufferPolygonRule)
210 geomResult = outGeom->
difference(inGeom.get());
213 if(auxGeom && auxGeom->
isValid())
226 if(auxGeom && auxGeom->
isValid())
239 if(auxGeom && auxGeom->
isValid())
248 te::common::Logger::logDebug(
"vp",
"Buffer - Polygon rule not found.");
256 std::vector<std::vector<te::gm::Geometry*> > vecGeom;
265 for(
int i = 1; i <= levels; ++i)
272 level = outDSet->
getInt32(levelPos);
277 std::vector<te::gm::Geometry*> vec;
283 for(std::size_t t = 0; t < vec.size(); ++t)
287 geom = geom->
Union(vec[t]);
288 rtree.
remove(*(vec[t]->getMBR()), vec[t]);
297 std::vector<te::gm::Geometry*> geomVec;
298 std::auto_ptr<te::gm::Envelope> e = outDSet->
getExtent(geomPos);
299 rtree.
search(*(e.get()), geomVec);
301 vecGeom.push_back(geomVec);
311 std::size_t vecSize = vecGeom.size();
317 for(std::size_t i = vecSize - 1; i > 0; --i)
319 std::vector<te::gm::Geometry*> currentVec = vecGeom[i];
320 std::size_t c_vecSize = currentVec.size();
322 for(std::size_t j = 0; j < i; ++j)
324 std::vector<te::gm::Geometry*> innerVec = vecGeom[j];
325 std::size_t i_vecSize = innerVec.size();
327 for(std::size_t k = 0; k < c_vecSize; ++k)
329 for(std::size_t l = 0; l < i_vecSize; ++l)
339 delete currentVec[k];
340 currentVec[k] = tGeom;
341 vecGeom[i] = currentVec;
353 for(std::size_t i = 0; i < vecSize; ++i)
355 std::vector<te::gm::Geometry*> currentVec = vecGeom[i];
356 std::size_t c_vecSize = currentVec.size();
358 for(std::size_t j = 0; j < c_vecSize; ++j)
374 mPolygon->
add(currentVec[j]);
381 outDSet->
add(dataSetItem);
bool remove(const te::gm::Envelope &mbr, const DATATYPE &data)
It removes an item from the tree.
std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const
Method for retrieving a geometric attribute value.
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.
virtual Geometry * buffer(const double &distance) const
This method calculates the buffer of a geometry.
void setDouble(std::size_t i, double value)
It sets the value of the i-th property.
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.
int getPropertyDataType(std::size_t pos) const
It returns the type of the pos-th property.
TEDATAACCESSEXPORT std::size_t GetPropertyPos(const DataSet *dataset, const std::string &name)
te::gm::Geometry * setBuffer(te::gm::Geometry *geom, const double &distance, const int &level, te::gm::Geometry *&auxGeom)
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.
The buffer is generated only outside of the polygons.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
boost::int32_t getInt32(std::size_t i) const
Method for retrieving a 32-bit integer attribute value (4 bytes long).
void SplitGeometryCollection(te::gm::GeometryCollection *geomIn, te::gm::GeometryCollection *gcOut)
The buffer is generated only inside of the polygons.
std::auto_ptr< te::gm::Envelope > getExtent(std::size_t i)
It computes the bounding rectangle for a spatial property of the dataset.
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.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
void dissolveMemory(te::mem::DataSet *outDSet, const int &levels)
bool moveNext()
It moves the internal pointer to the next item of the collection.
The buffer is generated Inside and outside of the polygons.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
void add(Geometry *g)
It adds the geometry into the collection.
TEDATAACCESSEXPORT DataSetType * GetDataSetType(const std::string &name, const std::string &datasourceId)
void clear()
It clears all the dataset items.
Configuration flags for the Terrralib Vector Processing module.
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.
virtual AbstractData * clone() const =0
It returns a clone of this object.
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.