All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
SpatialWeightsExchanger.h
Go to the documentation of this file.
1 /* Copyright (C) 2001-2009 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 SpatialWeightsExchanger.h
22 
23  \brief This class defines functions used to load and save graphs using GAL and GWT formats,
24  both formats use a ' ' as separator.
25 
26  GAL FORMAT
27 
28  0 NUMBER_OBSERVATIONS DATASET_NAME ATTRIBUTE_ID_NAME (HEADER LINE)
29  OBSERVATION_ID NUMBER_NEIGHBOURS
30  NEIGHBOURS_1 NEIGHBOURS_2 ... NEIGHBOURS_N
31  OBSERVATION_ID NUMBER_NEIGHBOURS
32  NEIGHBOURS_1 NEIGHBOURS_2 ... NEIGHBOURS_N
33  ...
34 
35 
36  GWT FORMAT
37 
38  0 NUMBER_OBSERVATIONS DATASET_NAME ATTRIBUTE_ID_NAME (HEADER LINE)
39  OBSERVATION_ID_FROM OBSERVATION_ID_TO DISTANCE
40  OBSERVATION_ID_FROM OBSERVATION_ID_TO DISTANCE
41  OBSERVATION_ID_FROM OBSERVATION_ID_TO DISTANCE
42  ...
43 */
44 
45 #ifndef __TERRALIB_GRAPH_INTERNAL_SPATIALWEIGHTSEXCHANGER_H
46 #define __TERRALIB_GRAPH_INTERNAL_SPATIALWEIGHTSEXCHANGER_H
47 
48 // Terralib Includes
49 #include "../Config.h"
50 
51 //STL Includes
52 #include <map>
53 #include <string>
54 
55 namespace te
56 {
57  namespace da
58  {
59  class DataSource;
60  }
61 
62  namespace graph
63  {
64  //forward declarations
65  class AbstractGraph;
66 
67  /*!
68  \class SpatialWeightsExchanger
69 
70  \brief This class defines functions used to load and save graphs using GAL and GWT formats,
71  both formats use a ' ' as separator.
72 
73  */
75  {
76  public:
77 
78  /*! \brief Default constructor. */
80 
81  /*! \brief Virtual destructor. */
83 
84  public:
85 
86  /*!
87  \brief Function used to export a graph to Spatial Weights File GAL Format
88 
89  \param g Pointer to a valid graph
90  \param pathFileName Path and file name (with extension) for file creation.
91  \param dataSetName Data Set name that contains the geometry information
92  \param propertyName The attribute name used as vertex id and dataset id column
93 
94  */
95  void exportToGAL(te::graph::AbstractGraph* g, std::string pathFileName, std::string dataSetName = "", std::string propertyName = "");
96 
97  /*!
98  \brief Function used to import a graph from a Spatial Weights File GAL Format
99 
100  \param pathFileName Path and file name (with extension) with Spatial Weights information.
101  \param dsInfo Container with data source information
102  \param graphType Attribute used to define the output graph type
103  \param gInfo Container with graph generation parameters
104  \param ds Pointer to a datasource in case the gal file has the shapefile information.
105 
106  \return A Valid graph pointer if the file was correctly readed and null pointer in other case.
107 
108  */
109  te::graph::AbstractGraph* importFromGAL(std::string pathFileName, std::map<std::string, std::string> dsInfo, std::string graphType,
110  std::map<std::string, std::string> gInfo, te::da::DataSource* ds = 0);
111 
112  /*!
113  \brief Function used to export a graph to Spatial Weights File GWT Format
114 
115  \param g Pointer to a valid graph
116  \param pathFileName Path and file name (with extension) for file creation.
117  \param dataSetName Data Set name that contains the geometry information
118  \param propertyName The attribute name used as vertex id and dataset id column
119 
120  */
121  void exportToGWT(te::graph::AbstractGraph* g, std::string pathFileName, int distAttrIdx, std::string dataSetName = "", std::string propertyName = "");
122 
123  /*!
124  \brief Function used to import a graph from a Spatial Weights File GWT Format
125 
126  \param pathFileName Path and file name (with extension) with Spatial Weights information.
127  \param dsInfo Container with data source information
128  \param graphType Attribute used to define the output graph type
129  \param gInfo Container with graph generation parameters
130  \param ds Pointer to a datasource in case the gwt file has the shapefile information.
131 
132  \return A Valid graph pointer if the file was correctly readed and null pointer in other case.
133 
134  */
135  te::graph::AbstractGraph* importFromGWT(std::string pathFileName, std::map<std::string, std::string> dsInfo, std::string graphType,
136  std::map<std::string, std::string> gInfo, te::da::DataSource* ds = 0);
137 
138  protected:
139 
140  /*!
141  \brief Function used to generated the edge id
142 
143  \return Integer value as ID
144 
145  */
146  int getEdgeId();
147 
148  /*!
149  \brief Function used to associate the geometry coord attribute to vertex objects.
150 
151  \param g Pointer to a valid graph
152  \param ds Pointer to a valid data source
153  \param dataSetName Data Set name that contains the geometry information
154  \param propertyName The attribute name used as vertex id and dataset id column
155 
156  */
157  void associateGeometry(te::graph::AbstractGraph* g, te::da::DataSource* ds, std::string dataSetName, std::string propertyName);
158 
159  private:
160 
161  int m_edgeId; //!< Attribute used as a index counter for edge objects
162  };
163 
164  } // end namespace graph
165 } // end namespace te
166 
167 #endif //__TERRALIB_GRAPH_INTERNAL_SPATIALWEIGHTSEXCHANGER_H
#define TEGRAPHEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:181
This class defines functions used to load and save graphs using GAL and GWT formats, both formats use a ' ' as separator.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:118
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Definition: AbstractGraph.h:55
int m_edgeId
Attribute used as a index counter for edge objects.