Utils.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/sa/core/Utils.h
22 
23  \brief Utilitary function for spatial analysis module.
24 */
25 
26 #ifndef __TERRALIB_SA_INTERNAL_UTILS_H
27 #define __TERRALIB_SA_INTERNAL_UTILS_H
28 
29 // TerraLib
30 #include "../../maptools/AbstractLayer.h"
31 #include "../../srs/Config.h"
32 #include "../Config.h"
33 
34 // STL
35 #include <string>
36 
37 namespace te
38 {
39  // Forward declaration
40  namespace da { class DataSource; }
41  namespace dt { class AbstractData; }
42  namespace graph { class AbstractGraph; }
43 
44  namespace sa
45  {
46  // Forward declaration
47  class GeneralizedProximityMatrix;
48 
49  /*!
50  \brief Function used to set a an attribute valeu from a dataset to the vertex objects from a gpm.
51 
52  \param gpm Pointer to gpm that has the graph information.
53  \param ds DataSource pointer that has the dataset information.
54  \param dataSetName Dataset name to get the attribute information.
55  \param attrLink Attribute name used to link the vertex id to dataset.
56  \param attr Attribute name that will be associated to the graph.
57  \param dataType The type of the attribute that will be associated.
58  \param srid If the new attribute was a geometry type
59 
60  \return Return the vertex attribute index.
61  */
62  TESAEXPORT int AssociateGPMVertexAttribute(te::sa::GeneralizedProximityMatrix* gpm, te::da::DataSource* ds, std::string dataSetName, std::string attrLink, std::string attr, int dataType, int srid = TE_UNKNOWN_SRS, int subType = te::gm::UnknownGeometryType);
63 
64  /*!
65  \brief Function used to set a an attribute valeu from a dataset to the vertex objects from a gpm.
66 
67  \param gpm Pointer to gpm that has the graph information.
68  \param ds DataSet pointer
69  \param attrLink Attribute name used to link the vertex id to dataset.
70  \param attr Attribute name that will be associated to the graph.
71  \param dataType The type of the attribute that will be associated.
72  \param srid If the new attribute was a geometry type
73 
74  \return Return the vertex attribute index.
75  */
76  TESAEXPORT int AssociateGPMVertexAttribute(te::sa::GeneralizedProximityMatrix* gpm, te::da::DataSet* ds, std::string attrLink, std::string attr, int dataType, int srid = TE_UNKNOWN_SRS, int subType = te::gm::UnknownGeometryType);
77 
78  /*!
79  \brief Function used to create the vertex attribute metadata in the graph of the gpm.
80 
81  \param graph Pointer to the graph associated to the gpm.
82  \param attrName Attribute name that will be created.
83  \param dataType The data type of the new attribute.
84  \param srid If the new attribute was a geometry type
85 
86  \return Return the vertex attribute index.
87  */
88  TESAEXPORT int AddGraphVertexAttribute(te::graph::AbstractGraph* graph, std::string attrName, int dataType, int srid = TE_UNKNOWN_SRS, int subType = te::gm::UnknownGeometryType);
89 
90  /*!
91  \brief Function used to create the edge attribute metadata in the graph of the gpm.
92 
93  \param graph Pointer to the graph associated to the gpm.
94  \param attrName Attribute name that will be created.
95  \param dataType The data type of the new attribute.
96 
97  \return Return the edge attribute index.
98  */
99  TESAEXPORT int AddGraphEdgeAttribute(te::graph::AbstractGraph* graph, std::string attrName, int dataType);
100 
101  /*!
102  \brief Function used to get the vertex attribute index in the graph of the gpm.
103 
104  \param graph Pointer to the graph associated to the gpm.
105  \param attrName Attribute name to be searched.
106  \param index The index of the attribute searched.
107 
108  \return Return true if the attribute was found and false in other case.
109  */
110  TESAEXPORT bool GetGraphVertexAttrIndex(te::graph::AbstractGraph* graph, std::string attrName, int& index);
111 
112  /*!
113  \brief Function used to get the edge attribute index in the graph of the gpm.
114 
115  \param graph Pointer to the graph associated to the gpm.
116  \param attrName Attribute name to be searched.
117  \param index The index of the attribute searched.
118 
119  \return Return true if the attribute was found and false in other case.
120  */
121  TESAEXPORT bool GetGraphEdgeAttrIndex(te::graph::AbstractGraph* graph, std::string attrName, int& index);
122 
123  /*!
124  \brief Function used to get the numeric value from a gpm property.
125 
126  \param ad Pointer to a abstract data that represents a property value from a gpm.
127 
128  \return Return a double value if its possible.
129  */
131 
132  /*!
133  \brief Function used to calculate the distance from a coord to the center of a geometry
134 
135  \param geom Pointer to a geometry
136  \param coord Reference to a coord
137 
138  \return Return a double value with distance information
139 
140  \note It's only possible if the geom has a centroid.
141  */
143 
144  /*!
145  \brief Function used to get centroid coord of a geometry
146 
147  \param geom Pointer to a geometry
148 
149  \return Return a coord with centroid information
150 
151  \note It's only possible if the geom has a centroid.
152  */
154 
155  /*!
156  \brief Function used to get area of a geometry
157 
158  \param geom Pointer to a geometry
159 
160  \return Return a double value with area information
161 
162  \note It's only possible if the geom has a area
163  */
164  TESAEXPORT double GetArea(te::gm::Geometry* geom);
165 
166  } // end namespace sa
167 } // end namespace te
168 
169 #endif // __TERRALIB_SA_INTERNAL_UTILS_H
170 
TESAEXPORT double GetDataValue(te::dt::AbstractData *ad)
Function used to get the numeric value from a gpm property.
TESAEXPORT bool GetGraphEdgeAttrIndex(te::graph::AbstractGraph *graph, std::string attrName, int &index)
Function used to get the edge attribute index in the graph of the gpm.
This class defines a Generalized Proximity Matrix.
TESAEXPORT double CalculateDistance(te::gm::Geometry *geom, te::gm::Coord2D &coord)
Function used to calculate the distance from a coord to the center of a geometry. ...
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
Definition: DataSource.h:118
TESAEXPORT bool GetGraphVertexAttrIndex(te::graph::AbstractGraph *graph, std::string attrName, int &index)
Function used to get the vertex attribute index in the graph of the gpm.
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
Definition: Config.h:41
TESAEXPORT int AddGraphEdgeAttribute(te::graph::AbstractGraph *graph, std::string attrName, int dataType)
Function used to create the edge attribute metadata in the graph of the gpm.
Abstract class used to define the main functions of graph struct. All graph implementations must used...
Definition: AbstractGraph.h:55
URI C++ Library.
TESAEXPORT te::gm::Coord2D GetCentroidCoord(te::gm::Geometry *geom)
Function used to get centroid coord of a geometry.
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
A dataset is the unit of information manipulated by the data access module of TerraLib.
Definition: DataSet.h:112
#define TESAEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:133
TESAEXPORT int AssociateGPMVertexAttribute(te::sa::GeneralizedProximityMatrix *gpm, te::da::DataSource *ds, std::string dataSetName, std::string attrLink, std::string attr, int dataType, int srid=TE_UNKNOWN_SRS, int subType=te::gm::UnknownGeometryType)
Function used to set a an attribute valeu from a dataset to the vertex objects from a gpm...
TESAEXPORT int AddGraphVertexAttribute(te::graph::AbstractGraph *graph, std::string attrName, int dataType, int srid=TE_UNKNOWN_SRS, int subType=te::gm::UnknownGeometryType)
Function used to create the vertex attribute metadata in the graph of the gpm.
TESAEXPORT double GetArea(te::gm::Geometry *geom)
Function used to get area of a geometry.