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/terralib4/Utils.h
22 
23  \brief Utilitary functions for dealing with TerraLib 5 and 4.x conversion.
24 */
25 
26 #ifndef __TERRALIB_T4_INTERNAL_UTILS_H
27 #define __TERRALIB_T4_INTERNAL_UTILS_H
28 
29 // STL
30 #include <map>
31 #include <memory>
32 #include <string>
33 
34 // Terralib 5
35 #include "../common/Enums.h"
36 #include "../datatype/Enums.h"
37 #include "../datatype/Property.h"
38 #include "../geometry/Enums.h"
39 #include "Config.h"
40 
41 // TerraLib 4.x
42 #include <terralib4/kernel/TeAttribute.h>
43 #include <terralib4/kernel/TeDatabase.h>
44 
45 namespace te
46 {
47  namespace da { class DataSetType; }
48  namespace dt { class Property; }
49  namespace gm { class Envelope; }
50  namespace rst { class RasterProperty; }
51 }
52 
53 struct TeBox;
54 class TeDatabaseFactoryParams;
55 class TeRasterParams;
56 class TeTable;
57 
58 namespace terralib4
59 {
60  /*!
61  \brief It creates a valid TerraLib 5 property given a valid TerraLib 4.x attribute representation.
62 
63  \param attRep A TerraLib 3 data type.
64 
65  \return The TerraLib 5 equivalent property.
66 
67  \exception Exception It throws an exception if a type cannot be conveted to TerraLib 5 datatype system.
68 
69  \note The returned PropertyType will not have an identification number, it is the caller
70  responsability to set one.
71  */
72  std::auto_ptr<te::dt::Property> Convert2T5(const TeAttributeRep& attRep);
73 
74  te::gm::GeomType Convert2T5GeomType(TeAttrDataType type);
75 
76  /*!
77  \brief It converts a Terralib 4.x data type to Terralib 5 data type.
78 
79  \param type The type to convert.
80 
81  \return A TerraLib 5 data type.
82  */
83  TETERRALIB4EXPORT int Convert2T5(TeAttrDataType type);
84 
85  /*!
86  \brief It converts a Terralib 4.x data type to Terralib 5 data type.
87 
88  \param type The type to convert.
89 
90  \return A TerraLib 5 data type.
91  */
93 
94  /*!
95  \brief It converts a Terralib 5 data type to Terralib 4.x data type.
96 
97  \param type The type to convert.
98 
99  \return A TerraLib 4.x data type.
100  */
101  TeAttrDataType Convert2T4(int type);
102 
103  TeAttrDataType Convert2T4GeomType(te::gm::GeomType type);
104 
105  int Convert2T5(TeDataType dt);
106 
107  std::auto_ptr<te::gm::Envelope> Convert2T5(TeBox box);
108 
109  std::auto_ptr<te::da::DataSetType> Convert2T5(TeTable table);
110 
111  /*!
112  \brief It converts a data source information to a TerraLib 4.x database params.
113 
114  \param dsInfo The data source information to be converted to a TerraLib 4.x database params.
115 
116  \return A TerraLib 4.x database params.
117  */
118  std::auto_ptr<TeDatabaseFactoryParams> Convert2T4DatabaseParams(const std::string& dsInfo);
119 
120  te::rst::RasterProperty* Convert2T5(TeRasterParams& rparams);
121 
122  void CheckDecimalSeparator(std::string& value);
123 
124  te::gm::GeomType GetMinimalRepresentation(const std::vector<TeGeometry*>& geoms);
125 
126  te::gm::GeomType GetCollection(TeGeomRep rep);
127 
128  TETERRALIB4EXPORT std::string Convert2Utf8(const std::string& str);
129 
130  TETERRALIB4EXPORT std::string Convert2Latin1(const std::string& str);
131 
132 } // end namespace terralib4
133 
134 #endif // __TERRALIB_T4_INTERNAL_UTILS_H
135 
TeAttrDataType Convert2T4GeomType(te::gm::GeomType type)
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
std::auto_ptr< TeDatabaseFactoryParams > Convert2T4DatabaseParams(const std::string &dsInfo)
It converts a data source information to a TerraLib 4.x database params.
te::gm::GeomType GetCollection(TeGeomRep rep)
TETERRALIB4EXPORT std::string Convert2Utf8(const std::string &str)
Configuration flags for the TerraLib 4 driver.
Raster property.
Definition: Band.h:34
te::gm::GeomType Convert2T5GeomType(TeAttrDataType type)
URI C++ Library.
te::gm::GeomType GetMinimalRepresentation(const std::vector< TeGeometry * > &geoms)
std::auto_ptr< te::dt::Property > Convert2T5(const TeAttributeRep &attRep)
It creates a valid TerraLib 5 property given a valid TerraLib 4.x attribute representation.
void CheckDecimalSeparator(std::string &value)
#define TETERRALIB4EXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:123
TETERRALIB4EXPORT std::string Convert2Latin1(const std::string &str)
TeAttrDataType Convert2T4(int type)
It converts a Terralib 5 data type to Terralib 4.x data type.