All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Utils.h
Go to the documentation of this file.
1 /* Copyright (C) 2009-2013 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 
40 // TerraLib 4.x
41 #include <terralib/kernel/TeAttribute.h>
42 #include <terralib/kernel/TeDatabase.h>
43 
44 namespace te
45 {
46  namespace da { class DataSetType; }
47  namespace dt { class Property; }
48  namespace gm { class Envelope; }
49  namespace rst { class RasterProperty; }
50 }
51 
52 struct TeBox;
53 class TeDatabaseFactoryParams;
54 class TeRasterParams;
55 class TeTable;
56 
57 namespace terralib4
58 {
59  /*!
60  \brief It creates a valid TerraLib 5 property given a valid TerraLib 4.x attribute representation.
61 
62  \param attRep A TerraLib 3 data type.
63 
64  \return The TerraLib 5 equivalent property.
65 
66  \exception Exception It throws an exception if a type cannot be conveted to TerraLib 5 datatype system.
67 
68  \note The returned PropertyType will not have an identification number, it is the caller
69  responsability to set one.
70  */
71  std::auto_ptr<te::dt::Property> Convert2T5(const TeAttributeRep& attRep);
72 
73  te::gm::GeomType Convert2T5GeomType(TeAttrDataType type);
74 
75  /*!
76  \brief It converts a Terralib 4.x data type to Terralib 5 data type.
77 
78  \param type The type to convert.
79 
80  \return A TerraLib 5 data type.
81  */
82  int Convert2T5(TeAttrDataType type);
83 
84  /*!
85  \brief It converts a Terralib 4.x data type to Terralib 5 data type.
86 
87  \param type The type to convert.
88 
89  \return A TerraLib 5 data type.
90  */
91  te::gm::GeomType Convert2T5GeomType(TeGeomRep type);
92 
93  /*!
94  \brief It converts a Terralib 5 data type to Terralib 4.x data type.
95 
96  \param type The type to convert.
97 
98  \return A TerraLib 4.x data type.
99  */
100  TeAttrDataType Convert2T4(int type);
101 
102  TeAttrDataType Convert2T4GeomType(te::gm::GeomType type);
103 
104  int Convert2T5(TeDataType dt);
105 
106  std::auto_ptr<te::gm::Envelope> Convert2T5(TeBox box);
107 
108  std::auto_ptr<te::da::DataSetType> Convert2T5(TeTable table);
109 
110  /*!
111  \brief It converts a data source information to a TerraLib 4.x database params.
112 
113  \param dsInfo The data source information to be converted to a TerraLib 4.x database params.
114 
115  \return A TerraLib 4.x database params.
116  */
117  std::auto_ptr<TeDatabaseFactoryParams> Convert2T4DatabaseParams(const std::map<std::string, std::string>& dsInfo);
118 
119  te::rst::RasterProperty* Convert2T5(TeRasterParams& rparams);
120 
121 } // end namespace terralib4
122 
123 #endif // __TERRALIB_T4_INTERNAL_UTILS_H
124 
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.
Definition: Utils.cpp:52
TeAttrDataType Convert2T4GeomType(te::gm::GeomType type)
Definition: Utils.cpp:325
te::gm::GeomType Convert2T5GeomType(TeAttrDataType type)
Definition: Utils.cpp:193
std::auto_ptr< TeDatabaseFactoryParams > Convert2T4DatabaseParams(const std::map< std::string, std::string > &dsInfo)
It converts a data source information to a TerraLib 4.x database params.
Definition: Utils.cpp:127
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
TeAttrDataType Convert2T4(int type)
It converts a Terralib 5 data type to Terralib 4.x data type.
Definition: Utils.cpp:283
Raster property.