28 #include "terralib_config.h"
29 #include "../common/progress/TaskProgress.h"
30 #include "../common/Logger.h"
31 #include "../common/Translator.h"
33 #include "../dataaccess/dataset/DataSet.h"
34 #include "../dataaccess/dataset/DataSetType.h"
35 #include "../dataaccess/utils/Utils.h"
36 #include "../datatype/Property.h"
38 #include "../datatype/SimpleProperty.h"
39 #include "../datatype/StringProperty.h"
41 #include "../geometry/Geometry.h"
42 #include "../geometry/GeometryCollection.h"
43 #include "../geometry/GeometryProperty.h"
44 #include "../geometry/MultiLineString.h"
45 #include "../geometry/MultiPoint.h"
46 #include "../geometry/MultiPolygon.h"
47 #include "../geometry/Utils.h"
49 #include "../memory/DataSet.h"
50 #include "../memory/DataSetItem.h"
66 #include <boost/lexical_cast.hpp>
67 #include <boost/algorithm/string.hpp>
85 std::vector<te::dt::Property*> firstProps = getTabularProps(m_inFirstDsetType.get());
88 firstMember.
dt = m_inFirstDsetType.release();
89 if(m_firstOidSet == 0)
90 firstMember.ds = m_inFirstDsrc->getDataSet(m_inFirstDsetName).release();
92 firstMember.ds = m_inFirstDsrc->getDataSet(m_inFirstDsetName, m_firstOidSet).release();
93 firstMember.props = firstProps;
96 secondMember.
dt = m_inSecondDsetType.release();
97 if(m_secondOidSet == 0)
98 secondMember.
ds = m_inSecondDsrc->getDataSet(m_inSecondDsetName).release();
100 secondMember.
ds = m_inSecondDsrc->getDataSet(m_inSecondDsetName, m_secondOidSet).release();
101 if(m_copyInputColumns)
102 secondMember.
props = getTabularProps(secondMember.
dt);
104 std::pair<te::da::DataSetType*, te::da::DataSet*> resultPair;
105 resultPair = this->pairwiseIntersection(m_outDsetName, firstMember, secondMember, m_SRID);
107 if(resultPair.second->size() < 1)
110 std::auto_ptr<te::da::DataSet> outDataSet(resultPair.second);
111 std::auto_ptr<te::da::DataSetType> outDataSetType(resultPair.first);
113 te::vp::Save(m_outDsrc.get(), outDataSet.get(), outDataSetType.get());
121 std::size_t outputSRID)
128 size_t secondDsCount = 0;
133 std::auto_ptr<te::gm::Geometry> g = secondMember.
ds->
getGeometry(secGeomPropPos);
136 sridSecond = g->getSRID();
138 rtree->
insert(*g->getMBR(), secondDsCount);
152 std::pair<te::da::DataSetType*, te::da::DataSet*> resultPair;
162 std::auto_ptr<te::gm::Geometry> currGeom = firstMember.
ds->
getGeometry(fiGeomPropPos);
164 if(currGeom->getSRID() != sridSecond)
165 currGeom->transform(sridSecond);
167 std::vector<size_t> report;
168 rtree->
search(*currGeom->getMBR(), report);
171 currGeom->transform(outputSRID);
173 for(
size_t i = 0; i < report.size(); ++i)
175 secondMember.
ds->
move(report[i]);
176 std::auto_ptr<te::gm::Geometry> secGeom = secondMember.
ds->
getGeometry(secGeomPropPos);
178 if(secGeom->getSRID() != outputSRID)
179 secGeom->transform(outputSRID);
181 if(!currGeom->intersects(secGeom.get()))
185 std::auto_ptr<te::gm::Geometry> resultGeom;
187 if(currGeom->isValid() && secGeom->isValid())
188 resultGeom.reset(currGeom->intersection(secGeom.get()));
190 if(resultGeom.get()!=0 && resultGeom->isValid())
203 newGeom->
add(resultGeom.release());
216 newGeom->
add(resultGeom.release());
229 newGeom->
add(resultGeom.release());
236 #ifdef TERRALIB_LOGGER_ENABLED
237 te::common::Logger::logDebug(
"vp",
"Intersection - Invalid geometry found");
238 #endif //TERRALIB_LOGGER_ENABLED
242 for(
size_t j = 0; j < firstMember.
props.size(); ++j)
244 std::string name = firstMember.
props[j]->getName();
254 for(
size_t j = 0; j < secondMember.
props.size(); ++j)
256 std::string name = secondMember.
props[j]->getName();
266 item->
setInt32(newName +
"_id", pk);
290 resultPair.first = outputDt;
291 resultPair.second = outputDs;
297 std::vector<te::dt::Property*> firstProps,
299 std::vector<te::dt::Property*> secondProps)
307 outputDt->
add(pkProperty);
313 for(
size_t i = 0; i < firstProps.size(); ++i)
321 for(
size_t i = 0; i < secondProps.size(); ++i)
334 outputDt->
add(newGeomProp);
void setAutoNumber(bool a)
It tells if the property is an autonumber or not.
MultiPolygon is a MultiSurface whose elements are Polygons.
An exception class for the Vector processing module.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
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.
Utility functions for the data access module.
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
void setGeometryType(GeomType t)
It sets the geometry subtype.
An atomic property like an integer or double.
A class that represents an R-tree.
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::vector< te::dt::Property * > props
void Save(te::da::DataSource *source, te::da::DataSet *result, te::da::DataSetType *outDsType)
virtual Property * clone() const =0
It returns a clone of the object.
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.
It models a property definition.
bool isActive() const
Verify if the task is active.
te::da::DataSetType * createDataSetType(std::string newName, te::da::DataSetType *firstDt, std::vector< te::dt::Property * > firstProps, te::da::DataSetType *secondDt, std::vector< te::dt::Property * > secondProps)
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 bool moveNext()=0
It moves the internal pointer to the next item of the collection.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
void setName(const std::string &name)
It sets the property name.
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.
std::pair< te::da::DataSetType *, te::da::DataSet * > pairwiseIntersection(std::string newName, IntersectionMember firstMember, IntersectionMember secondMember, std::size_t outputSRID)
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
virtual std::size_t size() const =0
It returns the collection size, if it is known.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
A base class for values that can be retrieved from the data access module.
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
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.
void add(Constraint *c)
It adds a new constraint.
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.
te::gm::GeomType GeomOpResultType(te::gm::GeomType firstGeom, te::gm::GeomType secondGeom)
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.
std::size_t getPropertyPosition(const std::string &name) const
It returns the property position based on its name.
Configuration flags for the Terrralib Vector Processing module.
TEDATAACCESSEXPORT te::gm::GeometryProperty * GetFirstGeomProperty(const DataSetType *dt)
void setPrimaryKey(PrimaryKey *pk)
It sets the primary key constraint.
virtual std::auto_ptr< te::dt::AbstractData > getValue(std::size_t i) const
Method for retrieving any other type of data value stored in the data source.
const std::string & getTitle() const
A human descriptive title for the DataSetType.
const std::string & getName() const
It returns the property name.
std::string GetSimpleTableName(std::string fullName)