Loading...
Searching...
No Matches
FlowGraphBuilder.h
Go to the documentation of this file.
1/* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2
3 This file is part of the TerraLib - a Framework for building GIS enabled applications.
4
5 TerraLib is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License,
8 or (at your option) any later version.
9
10 TerraLib is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License
16 along with TerraLib. See COPYING. If not, write to
17 TerraLib Team at <terralib-team@terralib.org>.
18 */
19
20/*!
21 \file terralib/graph/FlowGraphBuilder.h
22
23 \brief This class defines the Flow strategy to build a graph.
24
25 This function needs a vectorial data and table with flow information,
26 this table must have the origin and destination info about each flow.
27
28*/
29
30#ifndef __TERRALIB_GRAPH_INTERNAL_FLOWGRAPHBUILDER_H
31#define __TERRALIB_GRAPH_INTERNAL_FLOWGRAPHBUILDER_H
32
33// Terralib Includes
34#include "../Config.h"
36
37// STL Includes
38#include <map>
39#include <memory>
40#include <vector>
41
42// Boost
43#include <boost/ptr_container/ptr_vector.hpp>
44
45
46namespace te
47{
48 // Forward declarations
49 namespace da
50 {
51 class DataSource;
52 class DataSet;
53 }
54
55 namespace dt { class Property; }
56
57 namespace gm { class GeometryProperty; }
58
59 namespace graph
60 {
61
62 /*!
63 \class FlowGraphBuilder
64
65 \brief This class defines the Flow strategy to build a graph.
66
67 This function needs a vectorial data and table with flow information,
68 this table must have the origin and destination info about each flow.
69
70 \note For now the the shapefile must have only polygon geometries and the
71 flow table must be a CSV file.
72
73 \sa AbstractGraphBuilder
74 */
75
77 {
78 public:
79
80 /*! \brief Default constructor. */
82
83 /*! \brief Virtual destructor. */
85
86
87 /** @name Methods
88 * Methods used by this builder
89 */
90 //@{
91
92
93 /*!
94 \brief Function used to build the output graph based on input parameters.
95
96 \param shapeFileName File name wiht vectorial data
97 \param linkColumn Column name from vectorial data used as link column
98 \param srid Vectorial projection id
99 \param csvFileName CSV File name with flow data
100 \param fromIdx Index for column table with origin information.
101 \param toIdx Index for column table with destiny information.
102 \param weightIdx Index for column table with weight information.
103 \param dsInfo The necessary information to access the data source.
104 \param graphType Attribute used to define the output graph type
105 \param gInfo Container with graph generation parameters
106
107 \return True if the graph was correctly generated and false in other case.
108
109 */
110 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,
111 const std::string& dsInfo, const std::string& graphType, const std::map<std::string, std::string>& gInfo);
112
113 //@}
114
115 protected:
116
117 /*!
118 \brief Function used to generated the edge id
119
120 \return Integer value as ID
121
122 */
124
125 /*!
126 \brief Function used to get the data source with the vectorial data
127
128 \return Data source.
129
130 */
131 std::unique_ptr<te::da::DataSource> getDataSource(const std::string fileName);
132
133 /*!
134 \brief Function used to get the data set with the vectorial data
135
136 \return Data set.
137
138 */
139 std::unique_ptr<te::da::DataSet> getDataSet(te::da::DataSource* ds);
140
141 /*!
142 \brief Function used to get the data source properties
143
144 \return A vector with all properties from a data source
145
146 */
147 boost::ptr_vector<te::dt::Property> getProperties(te::da::DataSource* ds);
148
149 /*!
150 \brief Function used to create all vertex object based on vectorial data
151
152 \param shapeFileName File name wiht vectorial data
153 \param linkColumn Column name from vectorial data used as link column
154 \param srid Vectorial projection id
155
156 \return True if the vertexs was created correctly and false in othe case
157
158 */
159 bool createVertexObjects(const std::string& shapeFileName, const std::string& linkColumn, const int& srid);
160
161 /*!
162 \brief Function used to create all edges object based on flow table data
163
164 \param csvFileName CSV File name with flow data
165 \param fromIdx Index for column table with origin information.
166 \param toIdx Index for column table with destiny information.
167 \param weightIdx Index for column table with weight information.
168
169 \return True if the edges was created correctly and false in othe case
170
171 */
172 bool createEdgeObjects(const std::string& csvFileName, const int& fromIdx, const int& toIdx, const int& weightIdx);
173
174 private:
175
176 int m_edgeId; //!< Attribute used as a index counter for edge objects
177 };
178 } // end namespace graph
179} // end namespace te
180
181#endif // __TERRALIB_GRAPH_INTERNAL_LDDGRAPHBUILDER_H
This abstract class provides the common functions for graph builder classes. Each builder strategy ha...
An abstract class for data providers like a DBMS, Web Services or a regular file.
Definition: DataSource.h:120
This abstract class provides the common functions for graph builder classes. Each builder strategy ha...
This class defines the Flow strategy to build a graph.
int m_edgeId
Attribute used as a index counter for edge objects.
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 ~FlowGraphBuilder()
Virtual destructor.
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.
boost::ptr_vector< te::dt::Property > getProperties(te::da::DataSource *ds)
Function used to get the data source properties.
std::unique_ptr< te::da::DataSource > getDataSource(const std::string fileName)
Function used to get the data source with the vectorial data.
int getEdgeId()
Function used to generated the edge id.
std::unique_ptr< te::da::DataSet > getDataSet(te::da::DataSource *ds)
Function used to get the data set with the vectorial data.
FlowGraphBuilder()
Default constructor.
bool createVertexObjects(const std::string &shapeFileName, const std::string &linkColumn, const int &srid)
Function used to create all vertex object based on vectorial data.
TerraLib.
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:178