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"
35 #include "AbstractGraphBuilder.h"
36 
37 // STL Includes
38 #include <map>
39 #include <memory>
40 #include <vector>
41 
42 
43 namespace te
44 {
45  // Forward declarations
46  namespace da
47  {
48  class DataSource;
49  class DataSet;
50  }
51 
52  namespace dt { class Property; }
53 
54  namespace gm { class GeometryProperty; }
55 
56  namespace graph
57  {
58 
59  /*!
60  \class FlowGraphBuilder
61 
62  \brief This class defines the Flow strategy to build a graph.
63 
64  This function needs a vectorial data and table with flow information,
65  this table must have the origin and destination info about each flow.
66 
67  \note For now the the shapefile must have only polygon geometries and the
68  flow table must be a CSV file.
69 
70  \sa AbstractGraphBuilder
71  */
72 
74  {
75  public:
76 
77  /*! \brief Default constructor. */
79 
80  /*! \brief Virtual destructor. */
81  virtual ~FlowGraphBuilder();
82 
83 
84  /** @name Methods
85  * Methods used by this builder
86  */
87  //@{
88 
89 
90  /*!
91  \brief Function used to build the output graph based on input parameters.
92 
93  \param shapeFileName File name wiht vectorial data
94  \param linkColumn Column name from vectorial data used as link column
95  \param srid Vectorial projection id
96  \param csvFileName CSV File name with flow data
97  \param fromIdx Index for column table with origin information.
98  \param toIdx Index for column table with destiny information.
99  \param weightIdx Index for column table with weight information.
100  \param dsInfo Container with data source information
101  \param graphType Attribute used to define the output graph type
102  \param gInfo Container with graph generation parameters
103 
104  \return True if the graph was correctly generated and false in other case.
105 
106  */
107  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,
108  const std::map<std::string, std::string>& dsInfo, const std::string& graphType, const std::map<std::string, std::string>& gInfo);
109 
110  //@}
111 
112  protected:
113 
114  /*!
115  \brief Function used to generated the edge id
116 
117  \return Integer value as ID
118 
119  */
120  int getEdgeId();
121 
122  /*!
123  \brief Function used to get the data source with the vectorial data
124 
125  \return Data source.
126 
127  */
128  std::auto_ptr<te::da::DataSource> getDataSource(const std::string fileName);
129 
130  /*!
131  \brief Function used to get the data set with the vectorial data
132 
133  \return Data set.
134 
135  */
136  std::auto_ptr<te::da::DataSet> getDataSet(te::da::DataSource* ds);
137 
138  /*!
139  \brief Function used to get the data source properties
140 
141  \return A vector with all properties from a data source
142 
143  */
144  boost::ptr_vector<te::dt::Property> getProperties(te::da::DataSource* ds);
145 
146  /*!
147  \brief Function used to create all vertex object based on vectorial data
148 
149  \param shapeFileName File name wiht vectorial data
150  \param linkColumn Column name from vectorial data used as link column
151  \param srid Vectorial projection id
152 
153  \return True if the vertexs was created correctly and false in othe case
154 
155  */
156  bool createVertexObjects(const std::string& shapeFileName, const std::string& linkColumn, const int& srid);
157 
158  /*!
159  \brief Function used to create all edges object based on flow table data
160 
161  \param csvFileName CSV File name with flow data
162  \param fromIdx Index for column table with origin information.
163  \param toIdx Index for column table with destiny information.
164  \param weightIdx Index for column table with weight information.
165 
166  \return True if the edges was created correctly and false in othe case
167 
168  */
169  bool createEdgeObjects(const std::string& csvFileName, const int& fromIdx, const int& toIdx, const int& weightIdx);
170 
171  private:
172 
173  int m_edgeId; //!< Attribute used as a index counter for edge objects
174  };
175  } // end namespace graph
176 } // end namespace te
177 
178 #endif // __TERRALIB_GRAPH_INTERNAL_LDDGRAPHBUILDER_H
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:178
int m_edgeId
Attribute used as a index counter for edge objects.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:118
This abstract class provides the common functions for graph builder classes. Each builder strategy ha...
URI C++ Library.
This class defines the Flow strategy to build a graph.
This abstract class provides the common functions for graph builder classes. Each builder strategy ha...