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/DataSetAdapter.h" 34 #include "../dataaccess/utils/Utils.h" 35 #include "../datatype/Property.h" 37 #include "../datatype/SimpleProperty.h" 38 #include "../datatype/StringProperty.h" 40 #include "../geometry/Geometry.h" 41 #include "../geometry/GeometryCollection.h" 42 #include "../geometry/GeometryProperty.h" 43 #include "../geometry/MultiLineString.h" 44 #include "../geometry/MultiPoint.h" 45 #include "../geometry/MultiPolygon.h" 46 #include "../geometry/Utils.h" 48 #include "../memory/DataSet.h" 49 #include "../memory/DataSetItem.h" 65 #include <boost/lexical_cast.hpp> 66 #include <boost/algorithm/string.hpp> 91 firstMember.props = firstProps;
110 std::pair<te::da::DataSetType*, te::da::DataSet*> resultPair;
113 if(resultPair.second->size() < 1)
116 std::unique_ptr<te::da::DataSet> outDataSet(resultPair.second);
117 std::unique_ptr<te::da::DataSetType> outDataSetType(resultPair.first);
134 size_t secondDsCount = 0;
140 if (secondMember.
ds->
isNull(secGeomPropPos))
143 std::unique_ptr<te::gm::Geometry> g = secondMember.
ds->
getGeometry(secGeomPropPos);
146 sridSecond = geomProp->
getSRID();
148 rtree->
insert(*g->getMBR(), secondDsCount);
162 std::pair<te::da::DataSetType*, te::da::DataSet*> resultPair;
172 if (firstMember.
ds->
isNull(fiGeomPropPos))
175 std::unique_ptr<te::gm::Geometry> currGeom = firstMember.
ds->
getGeometry(fiGeomPropPos);
177 if(!currGeom->isValid())
179 std::string processing =
"Vector Processing";
180 std::string operation =
"Intersection";
181 std::string message =
"Invalid geometry in input layer.";
189 if(currGeom->getSRID() != sridSecond)
190 currGeom->transform(sridSecond);
192 std::vector<size_t> report;
193 rtree->
search(*currGeom->getMBR(), report);
196 currGeom->transform(fiGeomProp->
getSRID());
198 for(
size_t i = 0; i < report.size(); ++i)
200 secondMember.
ds->
move(report[i]);
201 std::unique_ptr<te::gm::Geometry> secGeom = secondMember.
ds->
getGeometry(secGeomPropPos);
202 secGeom->setSRID(sridSecond);
204 if(!secGeom->isValid())
206 std::string processing =
"Vector Processing";
207 std::string operation =
"Intersection";
208 std::string message =
"Invalid geometry in overlay layer.";
216 if (secGeom->getSRID() != fiGeomProp->
getSRID())
217 secGeom->transform(fiGeomProp->
getSRID());
219 if(!currGeom->intersects(secGeom.get()))
223 std::unique_ptr<te::gm::Geometry> resultGeom;
225 if (currGeom->isValid() && secGeom->isValid())
226 resultGeom.reset(currGeom->intersection(secGeom.get()));
228 if(resultGeom.get()!=
nullptr && resultGeom->isValid())
247 newGeom->
add(resultGeom.release());
266 newGeom->
add(resultGeom.release());
286 newGeom->
add(resultGeom.release());
293 #ifdef TERRALIB_LOGGER_ENABLED 295 #endif //TERRALIB_LOGGER_ENABLED 299 for(
size_t j = 0; j < firstMember.
props.size(); ++j)
301 std::string name = firstMember.
props[j]->getName();
307 if (outputPropPos >= outputDt->
size())
310 if (!firstMember.
ds->
isNull(inputPropPos))
317 for(
size_t j = 0; j < secondMember.
props.size(); ++j)
319 std::string name = secondMember.
props[j]->getName();
325 if (outputPropPos >= outputDt->
size())
328 if (!secondMember.
ds->
isNull(inputPropPos))
335 item->
setInt32(newName +
"_id", pk);
359 resultPair.first = outputDt;
360 resultPair.second = outputDs;
An exception class for the Vector processing module.
std::unique_ptr< te::da::DataSet > m_firstDs
virtual std::unique_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
std::unique_ptr< te::da::DataSet > m_secondDs
std::vector< te::dt::Property * > getTabularProps(te::da::DataSetType *dsType)
std::string m_inSecondDsetName
MultiPolygon is a MultiSurface whose elements are Polygons.
te::da::DataSetType * getOutputDsType()
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
void setGeometry(std::size_t i, te::gm::Geometry *value)
It sets the value of the i-th property.
A class that represents an R-tree.
const te::da::ObjectIdSet * m_firstOidSet
Base exception class for plugin module.
A class that models the description of a dataset.
bool isNull(std::size_t i) const
void useTimer(bool flag)
Used to define if task use progress timer information.
std::string m_outDsetName
#define TE_CORE_LOG_DEBUG(channel, message)
Use this tag in order to log a message to a specified logger with the DEBUG level.
std::vector< te::dt::Property * > props
This class can be used to inform the progress of a task.
void setValue(std::size_t i, te::dt::AbstractData *value)
It sets the value of the i-th property.
#define TE_TR(message)
It marks a string in order to get translated.
#define TE_LOG_INFO(message)
Use this tag in order to log a message to the TerraLib default logger with the INFO level...
bool isActive() const
Verify if the task is active.
te::da::DataSourcePtr m_inSecondDsrc
void add(DataSetItem *item)
It adds a new item to the dataset and takes its ownership.
virtual bool move(std::size_t i)=0
It moves the dataset internal pointer to a given position.
void setTotalSteps(int value)
Set the task total stepes.
void setInt32(std::size_t i, boost::int32_t value)
It sets the value of the i-th property.
virtual std::size_t size() const =0
It returns the collection size, if it is known.
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)
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
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.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
Intersection Vector Processing functions.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
std::pair< te::da::DataSetType *, te::da::DataSet * > pairwiseIntersection(std::string newName, IntersectionMember firstMember, IntersectionMember secondMember)
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
A base class for values that can be retrieved from the data access module.
std::unique_ptr< te::da::DataSetTypeConverter > m_firstConverter
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
std::size_t size() const
It returns the number of properties of the CompositeProperty.
Utility functions for the data access module.
te::da::DataSourcePtr m_outDsrc
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
std::string m_inFirstDsetName
te::da::DataSourcePtr m_inFirstDsrc
std::unique_ptr< te::da::DataSetTypeConverter > m_secondConverter
bool moveBeforeFirst()
It moves the internal pointer to a position before the first item in the collection.
bool moveNext()
It moves the internal pointer to the next item of the collection.
MultiLineString is a MultiCurve whose elements are LineStrings.
An implementation of the DatasetItem class for the TerraLib In-Memory Data Access driver...
Property * findFirstPropertyOfType(const int t) const
returns the first property of the given data type. Caller doesn't take ownership of the returned poin...
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.
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.
Configuration flags for the Terrralib Vector Processing module.
std::size_t getPropertyPosition(const std::string &name) const
It returns the property position based on its name.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
TEDATAACCESSEXPORT DataSetAdapter * CreateAdapter(DataSet *ds, DataSetTypeConverter *converter, bool isOwner=false)
const te::da::ObjectIdSet * m_secondOidSet