SpatialWeightsExchanger.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 SpatialWeightsExchanger.h
22 
23  \brief This class defines functions used to load and save gpm's 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_SA_INTERNAL_SPATIALWEIGHTSEXCHANGER_H
46 #define __TERRALIB_SA_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 sa
63  {
64  // Forward declarations
65  class GeneralizedProximityMatrix;
66 
67  /*!
68  \class SpatialWeightsExchanger
69 
70  \brief This class defines functions used to load and save gpm's 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 gpm to Spatial Weights File GAL Format
88 
89  \param gpm Pointer to a valid graph
90  \param pathFileName Path and file name (with extension) for file creation.
91 
92  */
93  void exportToGAL(te::sa::GeneralizedProximityMatrix* gpm, std::string pathFileName);
94 
95  /*!
96  \brief Function used to import a gpm from a Spatial Weights File GAL Format
97 
98  \param pathFileName Path and file name (with extension) with Spatial Weights information.
99  \param ds Pointer to a datasource in case the gal file has the shapefile information.
100 
101  \return A Valid gpm pointer if the file was correctly readed and null pointer in other case.
102 
103  */
104  te::sa::GeneralizedProximityMatrix* importFromGAL(std::string pathFileName, te::da::DataSource* ds = 0);
105 
106  /*!
107  \brief Function used to export a gpm to Spatial Weights File GWT Format
108 
109  \param gpm Pointer to a valid graph
110  \param pathFileName Path and file name (with extension) for file creation.
111  \param distAttrIdx Edge Atrribute index with distance information
112 
113  */
114  void exportToGWT(te::sa::GeneralizedProximityMatrix* gpm, std::string pathFileName, int distAttrIdx);
115 
116  /*!
117  \brief Function used to import a gpm from a Spatial Weights File GWT Format
118 
119  \param pathFileName Path and file name (with extension) with Spatial Weights information.
120  \param ds Pointer to a datasource in case the gwt file has the shapefile information.
121 
122  \return A Valid gpm pointer if the file was correctly readed and null pointer in other case.
123 
124  */
125  te::sa::GeneralizedProximityMatrix* importFromGWT(std::string pathFileName, te::da::DataSource* ds = 0);
126 
127  /*!
128  \brief Function used to get information of how a Spatial Weights was generated
129 
130  \param pathFileName Path and file name (with extension) with Spatial Weights information.
131  \param dataSetName Information about the dataset used to generate this file.
132  \param attrName Information about the attribute used to generate this file.
133 
134  \return A Valid gpm pointer if the file was correctly readed and null pointer in other case.
135 
136  */
137  static void getSpatialWeightsFileInfo(std::string pathFileName, std::string& dataSetName, std::string& attrName);
138 
139  protected:
140 
141  /*!
142  \brief Function used to generated the edge id
143 
144  \return Integer value as ID
145 
146  */
147  int getEdgeId();
148 
149  /*!
150  \brief Function used to associate the geometry coord attribute to vertex objects.
151 
152  \param g Pointer to a valid graph
153  \param ds Pointer to a valid data source
154 
155  */
156  void associateGeometry(te::sa::GeneralizedProximityMatrix* gpm, te::da::DataSource* ds);
157 
158  private:
159 
160  int m_edgeId; //!< Attribute used as a index counter for edge objects
161  };
162 
163  } // end namespace sa
164 } // end namespace te
165 
166 #endif //__TERRALIB_SA_INTERNAL_SPATIALWEIGHTSEXCHANGER_H
This class defines a Generalized Proximity Matrix.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:119
int m_edgeId
Attribute used as a index counter for edge objects.
URI C++ Library.
#define TESAEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:133
This class defines functions used to load and save gpm's using GAL and GWT formats, both formats use a ' ' as separator.