27 #include "../../common/Exception.h"
28 #include "../../common/Translator.h"
29 #include "../../common/STLUtils.h"
30 #include "../../common/progress/TaskProgress.h"
31 #include "../../dataaccess/datasource/DataSource.h"
32 #include "../../dataaccess/utils/Utils.h"
33 #include "../../datatype/SimpleData.h"
34 #include "../../datatype/SimpleProperty.h"
35 #include "../../geometry/Point.h"
36 #include "../../graph/core/Edge.h"
37 #include "../../graph/core/Vertex.h"
48 m_calcDistance(calcDistance)
60 std::auto_ptr<te::da::DataSet> dataSet = m_ds->getDataSet(m_gpm->getDataSetName());
67 createDistanceAttribute(m_gpm);
72 std::map<int, te::gm::Geometry*> geomMap;
74 dataSet->moveBeforeFirst();
76 while(dataSet->moveNext())
78 std::string strId = dataSet->getAsString(m_gpm->getAttributeName());
80 int id = atoi(strId.c_str());
87 geomMap.insert(std::map<int, te::gm::Geometry*>::value_type(
id, g));
97 dataSet->moveBeforeFirst();
99 while(dataSet->moveNext())
101 std::string strIdFrom = dataSet->getAsString(m_gpm->getAttributeName());
103 int vFromId = atoi(strIdFrom.c_str());
105 std::auto_ptr<te::gm::Geometry> g = dataSet->getGeometry(geomPos);
107 std::vector<int> results;
109 rtree.
search(*g->getMBR(), results);
111 for(
size_t t = 0; t < results.size(); ++t)
113 std::map<int, te::gm::Geometry*>::iterator it = geomMap.find(results[t]);
115 if(it != geomMap.end())
117 if(g->touches(it->second) || g->intersects(it->second))
119 int edgeId = getEdgeId();
121 int vToId = results[t];
141 m_gpm->getGraph()->add(e);
void setMessage(const std::string &message)
Set the task message.
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the edge elements.
This class can be used to inform the progress of a task.
std::vector< te::dt::AbstractData * > & getAttributes()
It returns the vector of attributes associated with this element.
#define TE_TR(message)
It marks a string in order to get translated.
virtual void constructStrategy()
Build the edges using specific strategy.
bool isActive() const
Verify if the task is active.
From the point of view of graph theory, vertices are treated as featureless and indivisible objects...
void setTotalSteps(int value)
Set the task total stepes.
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
TEDATAACCESSEXPORT std::size_t GetFirstSpatialPropertyPos(const te::da::DataSet *dataset)
It returns the first dataset spatial property or NULL if none is found.
A point with x and y coordinate values.
An Envelope defines a 2D rectangular region.
This class defines a an adjacency strategy class for a GPM constructor.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
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. ...
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
GPMConstructorStrategyType m_type
Constructor Type.
This class defines a an Abstract class for a GPM constructor.
GPMConstructorAdjacencyStrategy()
Default constructor.
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
virtual ~GPMConstructorAdjacencyStrategy()
Virtual destructor.
A template for atomic data types (integers, floats, strings and others).
void addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element.
void FreeContents(boost::unordered_map< K, V * > &m)
This function can be applied to a map of pointers. It will delete each pointer in the map...
virtual double distance(const Geometry *const rhs) const
It returns the shortest distance between any two points in the two geometry objects.
This class defines the GPM class.