30 #include "../../common/progress/TaskProgress.h" 31 #include "../../common/StringUtils.h" 32 #include "../../common/STLUtils.h" 33 #include "../../core/translator/Translator.h" 34 #include "../../dataaccess/datasource/DataSource.h" 35 #include "../../dataaccess/datasource/DataSourceFactory.h" 36 #include "../../datatype/AbstractData.h" 37 #include "../../geometry/GeometryProperty.h" 38 #include "../../geometry/MultiPolygon.h" 39 #include "../../geometry/Point.h" 40 #include "../../geometry/Polygon.h" 41 #include "../../sam/rtree.h" 42 #include "../core/AbstractGraphFactory.h" 43 #include "../core/Edge.h" 44 #include "../core/Vertex.h" 45 #include "../core/VertexProperty.h" 46 #include "../graphs/Graph.h" 47 #include "../Config.h" 48 #include "../Exception.h" 60 const std::string& dsInfo,
const std::string& graphType,
const std::map<std::string, std::string>& gInfo)
104 std::string dsName = names[0];
106 std::unique_ptr<te::da::DataSet> dataset = ds->
getDataSet(dsName);
115 std::string dsName = names[0];
125 if(ds.get() ==
nullptr)
131 std::unique_ptr<te::da::DataSet> dataSet =
getDataSet(ds.get());
133 if(dataSet.get() ==
nullptr)
144 m_graph->addVertexProperty(gProp);
147 std::string geomColumn;
154 while(dataSet->moveNext())
156 int id = dataSet->getInt32(linkColumn);
201 if(ds.get() ==
nullptr)
207 std::unique_ptr<te::da::DataSet> dataSet =
getDataSet(ds.get());
209 if(dataSet.get() ==
nullptr)
215 std::string geomColumn;
222 std::map<int, te::gm::Geometry*> geomMap;
224 while(dataSet->moveNext())
226 int id = dataSet->getInt32(linkColumn);
232 geomMap.insert(std::map<int, te::gm::Geometry*>::value_type(
id, g));
235 dataSet->moveBeforeFirst();
240 task.
setMessage(
"RAG Builder - Extracting Edges");
243 while(dataSet->moveNext())
245 int vFromId = dataSet->getInt32(linkColumn);
247 std::unique_ptr<te::gm::Geometry> g = dataSet->getGeometry(geomColumn);
249 std::vector<int> results;
251 rtree.
search(*g->getMBR(), results);
253 for(
size_t t = 0; t < results.size(); ++t)
255 std::map<int, te::gm::Geometry*>::iterator it = geomMap.find(results[t]);
257 if(it != geomMap.end())
259 if(g->touches(it->second))
263 int vToId = results[t];
265 Edge* e =
new Edge(edgeId, vFromId, vToId);
286 if(ds.get() ==
nullptr)
292 boost::ptr_vector<te::dt::Property> properties =
getProperties(ds.get());
294 if(properties.empty())
299 boost::ptr_vector<te::dt::Property>::iterator it = properties.begin();
300 while(it != properties.end())
304 columnName = it->getName();
310 if(columnName.empty())
MultiPolygon is a MultiSurface whose elements are Polygons.
void setAttributeVecSize(int size)
This function is used to set the number of attributes associated with the vertex elements.
static std::unique_ptr< DataSource > make(const std::string &driver, const te::core::URI &connInfo)
void setMessage(const std::string &message)
Set the task message.
void setSRID(int srid)
It sets the spatial reference system identifier associated to this property.
void setGeometryType(GeomType t)
It sets the geometry subtype.
void setSRID(int srid) _NOEXCEPT_OP(true)
It sets the Spatial Reference System ID of the Point.
virtual boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
std::unique_ptr< te::da::DataSet > getDataSet(te::da::DataSource *ds)
Function used to get the data set with the vectorial data.
This class can be used to inform the progress of a task.
static te::dt::Date ds(2010, 01, 01)
bool getGeometryColumn(const std::string &shapeFileName, std::string &columnName)
Function used to get the geometry column name.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
This class defines the RAG strategy to build a graph,.
int m_edgeId
Attribute used as a index counter for edge objects.
int getEdgeId()
Function used to generated the edge id.
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.
std::unique_ptr< te::da::DataSource > getDataSource(const std::string &fileName)
Function used to get the data source with the vectorial data.
void setId(unsigned int id)
It sets the property identifier.
Class used to define the edge struct of a graph. Its compose with a identifier, the vertex origin and...
A point with x and y coordinate values.
const Envelope * getMBR() const _NOEXCEPT_OP(true)
It returns the minimum bounding rectangle for the geometry in an internal representation.
An Envelope defines a 2D rectangular region.
boost::ptr_vector< te::dt::Property > getProperties(te::da::DataSource *ds)
Function used to get the data source properties.
bool createVertexObjects(const std::string &shapeFileName, const std::string &linkColumn, const int &srid)
Function used to create all vertex object based on vectorial data.
void pulse()
Calls setCurrentStep() function using getCurrentStep() + 1.
A base class for values that can be retrieved from the data access module.
virtual std::vector< std::string > getDataSetNames()
It gets the dataset names available in the data source.
int search(const te::gm::Envelope &mbr, std::vector< DATATYPE > &report) const
Range search query.
virtual ~RAGGraphBuilder()
Virtual destructor.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
virtual std::unique_ptr< DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. This method always returns a disconnected dataset...
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
void insert(const te::gm::Envelope &mbr, const DATATYPE &data)
It inserts an item into the tree.
virtual void setSRID(int srid) _NOEXCEPT_OP(true)=0
It sets the Spatial Reference System ID of the geometry and all its parts if it is a GeometryCollecti...
Point * getCentroid() const
It returns the mathematical centroid for this surface as a point.
RAGGraphBuilder()
Default constructor.
void addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element.
boost::shared_ptr< AbstractGraph > m_graph
Graph object.
static AbstractGraph * make()
It creates and returns an empty graph with default graph type.
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...
bool build(const std::string &shapeFileName, const std::string &linkColumn, const int &srid, const std::string &dsInfo, const std::string &graphType, const std::map< std::string, std::string > &gInfo)
Function used to generated a graph using the RAG strategy.
bool createEdgeObjects(const std::string &shapeFileName, const std::string &linkColumn)
Function used to create all edges object based on vectorial data.