31 #include "../../common/StringUtils.h" 32 #include "../../core/translator/Translator.h" 33 #include "../../dataaccess/datasource/DataSource.h" 34 #include "../../dataaccess/datasource/DataSourceFactory.h" 35 #include "../../dataaccess/dataset/DataSet.h" 36 #include "../../datatype/AbstractData.h" 37 #include "../../datatype/SimpleData.h" 38 #include "../../datatype/SimpleProperty.h" 39 #include "../../geometry/GeometryProperty.h" 40 #include "../../geometry/MultiPolygon.h" 41 #include "../../geometry/Point.h" 42 #include "../../geometry/Polygon.h" 43 #include "../core/AbstractGraphFactory.h" 44 #include "../core/Edge.h" 45 #include "../core/Vertex.h" 46 #include "../core/VertexProperty.h" 47 #include "../graphs/Graph.h" 48 #include "../Config.h" 49 #include "../Exception.h" 57 #include<boost/tokenizer.hpp> 67 bool te::graph::FlowGraphBuilder::build(
const std::string& shapeFileName,
const std::string& linkColumn,
const int& srid,
const std::string& csvFileName,
const int& fromIdx,
const int& toIdx,
const int& weightIdx,
68 const std::string& dsInfo,
const std::string& graphType,
const std::map<std::string, std::string>& gInfo)
110 std::string dsName = names[0];
112 std::unique_ptr<te::da::DataSet> dataset = ds->
getDataSet(dsName);
121 std::string dsName = names[0];
131 if(ds.get() ==
nullptr)
137 std::unique_ptr<te::da::DataSet> dataSet =
getDataSet(ds.get());
139 if(dataSet.get() ==
nullptr)
145 boost::ptr_vector<te::dt::Property> properties =
getProperties(ds.get());
147 if(properties.empty())
153 boost::ptr_vector<te::dt::Property>::iterator it = properties.begin();
157 while(it != properties.end())
192 while(dataSet->moveNext())
194 int id = dataSet->getInt32(linkColumn);
202 it = properties.begin();
206 while(it != properties.end())
245 ad = dataSet->getValue(it->getName()).release();
264 std::ifstream in(csvFileName.c_str());
266 if(in.is_open() ==
false)
278 typedef boost::tokenizer< boost::escaped_list_separator<char> > Tokenizer;
279 boost::escaped_list_separator<char> sep(
'\\',
';',
'\"');
281 std::vector<std::string>
line;
285 while(std::getline(in, buffer))
289 Tokenizer tok(buffer, sep);
291 line.assign(tok.begin(), tok.end());
293 std::string fromStr, toStr, weightStr;
296 fromStr = line[fromIdx];
298 weightStr = line[weightIdx];
307 int from = atoi(fromStr.c_str());
308 int to = atoi(toStr.c_str());
309 int weight = atoi(weightStr.c_str());
313 e->setAttributeVecSize(1);
FlowGraphBuilder()
Default constructor.
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 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.
An atomic property like an integer or double.
virtual boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
virtual ~FlowGraphBuilder()
Virtual destructor.
GeomType getGeomTypeId() const _NOEXCEPT_OP(true)
It returns the geometry subclass type identifier.
int m_edgeId
Attribute used as a index counter for edge objects.
std::string Convert2UCase(const std::string &value)
It converts a string to upper case.
static te::dt::Date ds(2010, 01, 01)
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
virtual Property * clone() const =0
It returns a clone of the object.
It models a property definition.
From the point of view of graph theory, vertices are treated as featureless and indivisible objects...
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...
std::unique_ptr< te::da::DataSet > getDataSet(te::da::DataSource *ds)
Function used to get the data set with the vectorial data.
A point with x and y coordinate values.
bool build(const std::string &shapeFileName, const std::string &linkColumn, const int &srid, const std::string &csvFileName, const int &fromIdx, const int &toIdx, const int &weightIdx, const std::string &dsInfo, const std::string &graphType, const std::map< std::string, std::string > &gInfo)
Function used to build the output graph based on input parameters.
std::unique_ptr< te::da::DataSource > getDataSource(const std::string fileName)
Function used to get the data source with the vectorial data.
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.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
boost::ptr_vector< te::dt::Property > getProperties(te::da::DataSource *ds)
Function used to get the data source properties.
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.
bool createEdgeObjects(const std::string &csvFileName, const int &fromIdx, const int &toIdx, const int &weightIdx)
Function used to create all edges object based on flow table data.
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.
int getEdgeId()
Function used to generated the edge id.
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 addAttribute(int idx, te::dt::AbstractData *ad)
Add a new attribute to this element.
boost::shared_ptr< AbstractGraph > m_graph
Graph object.
A template for atomic data types (integers, floats, strings and others).
static AbstractGraph * make()
It creates and returns an empty graph with default graph type.
void setParent(Property *p)
It associate this property to the informed parent.