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"
60 std::auto_ptr<te::da::DataSet> dataSet = m_ds->getDataSet(m_gpm->getDataSetName());
65 createDistanceAttribute(m_gpm);
69 std::map<int, te::gm::Geometry*> geomMap;
71 dataSet->moveBeforeFirst();
73 while(dataSet->moveNext())
75 std::string strId = dataSet->getAsString(m_gpm->getAttributeName());
77 int id = atoi(strId.c_str());
84 geomMap.insert(std::map<int, te::gm::Geometry*>::value_type(
id, g));
94 dataSet->moveBeforeFirst();
96 while(dataSet->moveNext())
98 std::string strIdFrom = dataSet->getAsString(m_gpm->getAttributeName());
100 int vFromId = atoi(strIdFrom.c_str());
102 std::auto_ptr<te::gm::Geometry> g = dataSet->getGeometry(geomPos);
104 std::vector<int> results;
108 ext.
m_llx -= m_distance;
109 ext.m_lly -= m_distance;
110 ext.m_urx += m_distance;
111 ext.m_ury += m_distance;
113 rtree.
search(ext, results);
115 for(
size_t t = 0; t < results.size(); ++t)
117 std::map<int, te::gm::Geometry*>::iterator it = geomMap.find(results[t]);
119 if(it != geomMap.end())
121 int vToId = results[t];
131 if(dist <= m_distance)
133 int edgeId = getEdgeId();
142 m_gpm->getGraph()->add(e);
virtual void constructStrategy()
Build the edges using specific strategy.
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.
GPMConstructorDistanceStrategy()
Default constructor.
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.
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...
double m_llx
Lower left corner x-coordinate.
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.
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.
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
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...
This class defines a an distance strategy class for a GPM constructor.
virtual double distance(const Geometry *const rhs) const
It returns the shortest distance between any two points in the two geometry objects.
virtual ~GPMConstructorDistanceStrategy()
Virtual destructor.
This class defines the GPM class.