Loading...
Searching...
No Matches
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/ogr/Utils.h
22
23 \brief Utility functions for OGR support.
24*/
25
26#ifndef __TERRALIB_GPKG_INTERNAL_UTILS_H
27#define __TERRALIB_GPKG_INTERNAL_UTILS_H
28
29// TerraLib
30#include "../Config.h"
31#include "../../../../srs/Config.h"
32
33// OGR
34#include <ogr_core.h>
35
36// Forward declarations
37class OGRGeometry;
38class OGREnvelope;
39class OGRSpatialReference;
40class OGRFeatureDefn;
41class OGRFieldDefn;
42
43namespace te
44{
45 namespace da
46 {
47 class DataSetType;
48 }
49
50 namespace gm
51 {
52 class Envelope;
53 class Geometry;
54 }
55}
56
57namespace te
58{
59 namespace gpkg
60 {
61 /*!
62 \brief It converts the OGR Geometry to TerraLib Geometry.
63
64 \param ogrGeom A valid OGR Geometry.
65
66 \return A valid TerraLib Geometry.
67
68 \exception Exception It throws an exception if the OGR geometry can not be converted.
69
70 \note It uses the WKB to create the TerraLib Geometry
71 \note The caller of this function will take the ownership of the returned TerraLib Geometry.
72 */
74
75 /*!
76 \brief It converts the TerraLib Geometry to OGR Geometry.
77
78 \param teGeom A valid TerraLib Geometry.
79
80 \return A valid TerraLib geometry.
81
82 \exception Exception It throws an exception if the TerraLib geometry can not be converted.
83
84 \note It uses the WKB to create the TerraLib Geometry
85 \note The caller of this function will take the ownership of the returned OGR Geometry.
86 */
88
89 /*!
90 \brief It converts the OGR Envelope to TerraLib Envelope.
91
92 \param env A valid OGR Envelope.
93
94 \return A valid TerraLib Envelope.
95
96 \note The caller of this function will take the ownership of the returned TerraLib Envelope.
97 */
99
100 /*!
101 \brief It converts the TerraLib Envelope to OGR Envelope.
102
103 \param env A valid TerraLib Envelope.
104
105 \return A valid OGR Envelope.
106
107 \note The caller of this function will take the ownership of the returned OGR Envelope.
108 */
110
111 /*!
112 \brief It converts the OGR Projection to TerraLib Projection.
113
114 \param osrs A valid OGR Projection.
115
116 \return An SRS id recognized by TerraLib or an indication of unknown SRS (TE_UNKNOWN_SRS)
117 */
119
120 /*!
121 \brief It converts the TerraLib Projection to OGR Projection.
122
123 \param srid A valid TerraLib Projection id.
124
125 \return A valid OGR Spatial Reference System.
126
127 \exception Exception It throws an exception if the SRS can not be imported using OGR.
128
129 \note The caller of this function will take the ownership of the returned OGR Spatial Reference System.
130 */
132
133 /*!
134 \brief It inserts a OGR Feature Definition to TerraLib DataSet Type
135
136 \param featDef A valid OGR Feature Definition.
137 \param dt Pointer to a TerraLib dataset type previously created. Do not pass NULL.
138 \param srs Optional parameter to set the SRS of geometry fields.
139
140 \exception Exception It throws an exception if the feature definition can not be converted.
141
142 \note It uses the method that converts a OGR Field Definition to TerraLib Property Type.
143 \note It uses the method that converts a OGR Geometry Type to TerraLib Geometry Type.
144 */
146
147 /*!
148 \brief It converts the OGR Feature Definition to TerraLib DataSet Type
149
150 \param featDef A valid OGR Feature Definition.
151 \param srs Optional parameter to set the SRS of geometry fields.
152
153 \return A valid TerraLib DataSet Type.
154
155 \exception Exception It throws an exception if the feature definition can not be converted.
156
157 \note It uses the method that converts a OGR Field Definition to TerraLib Property Type.
158 \note It uses the method that converts a OGR Geometry Type to TerraLib Geometry Type.
159 \note The caller of this function will take the ownership of the returned TerraLib DataSet Type.
160 */
162
163 /*!
164 \brief It converts the TerraLib DataSet Type to OGR Feature Definition
165
166 \param dt A valid TerraLib DataSet Type.
167
168 \return A valid OGR Feature Definition.
169
170 \exception Exception It throws an exception if the data set type can not be converted.
171
172 \note It uses the method that converts a TerraLib Property Type to OGR Field Definition.
173 \note The caller of this function will take the ownership of the returned OGR Feature Definition.
174 */
176
177 /*!
178 \brief It converts the OGR Field Definition to TerraLib Property Type
179
180 \param fieldDef A valid OGR Field Definition.
181
182 \return A valid TerraLib Property Type.
183
184 \exception Exception It throws an exception if the data type is not supported by TerraLib.
185
186 \note The caller of this function will take the ownership of the returned TerraLib Property Type.
187 */
189
190 /*!
191 \brief It converts the TerraLib Property Type to OGR Field Definition
192
193 \param pt A valid TerraLib Property Type.
194
195 \return A valid OGR Field Definition.
196
197 \exception Exception It throws an exception if the data type is not supported by OGR.
198 */
200
201 /*!
202 \brief It converts the OGR Geometry Type element to TerraLib Geometry Type
203
204 \param ogrGeomType A valid OGR Geometry Type element.
205
206 \return A valid TerraLib Geometry Type
207 */
209
210 /*!
211 \brief It converts the TerraLib Geometry Type element to OGR Geometry Type
212
213 \param geomType A valid TerraLib Geometry Type.
214
215 \return A valid OGR Geometry Type element
216
217 \exception Exception It throws an exception if the geometry type is not supported by OGR.
218 */
220
221 /*!
222 \brief It tries extract the driver name used by OGR Library based on the given path.
223
224 \param path The path that will be consulted.
225
226 \return The driver name used by OGR Library or an empty string if not possible extract the driver name.
227 */
228 std::string GetDriverName(const std::string& path);
229
230 /*!
231 \brief It returns the list of OGR Drivers available.
232
233 \param filterCreate Set TRUE to indicate to retrieve only the drivers with the capacity to create datasources.
234
235 \return A list of OGR Drivers.
236 */
237 TERRAMOBILEPLUGINSDLLEXPORT std::vector<std::string> GetOGRDrivers(bool filterCreate = false);
238
239 TERRAMOBILEPLUGINSDLLEXPORT std::string GetOGRConnectionInfo(const std::map<std::string, std::string>& connInfo);
240
241 TERRAMOBILEPLUGINSDLLEXPORT std::string RemoveSpatialSql(const std::string& sql);
242
243 TERRAMOBILEPLUGINSDLLEXPORT void createGeopackage(std::string outFileName);
244
245 TERRAMOBILEPLUGINSDLLEXPORT void copyToGeopackage(te::rst::Raster* raster, std::string outFileName);
246
247 } // end namespace ogr
248} // end namespace te
249
250#endif // __TERRALIB_GPKG_INTERNAL_UTILS_H
A class that models the description of a dataset.
Definition: DataSetType.h:73
It models a property definition.
Definition: Property.h:60
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:52
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:78
An abstract class for raster data strucutures.
Definition: Raster.h:72
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:42
std::string GetDriverName(const std::string &path)
It tries extract the driver name used by OGR Library based on the given path.
TERRAMOBILEPLUGINSDLLEXPORT OGRSpatialReference * Convert2OGRProjection(int srid)
It converts the TerraLib Projection to OGR Projection.
TERRAMOBILEPLUGINSDLLEXPORT void createGeopackage(std::string outFileName)
TERRAMOBILEPLUGINSDLLEXPORT int Convert2TerraLibProjection(OGRSpatialReference *osrs)
It converts the OGR Projection to TerraLib Projection.
TERRAMOBILEPLUGINSDLLEXPORT std::string GetOGRConnectionInfo(const std::map< std::string, std::string > &connInfo)
TERRAMOBILEPLUGINSDLLEXPORT void copyToGeopackage(te::rst::Raster *raster, std::string outFileName)
TERRAMOBILEPLUGINSDLLEXPORT std::vector< std::string > GetOGRDrivers(bool filterCreate=false)
It returns the list of OGR Drivers available.
TERRAMOBILEPLUGINSDLLEXPORT std::string RemoveSpatialSql(const std::string &sql)
TERRAMOBILEPLUGINSDLLEXPORT te::gm::Geometry * Convert2TerraLib(OGRGeometry *ogrGeom)
It converts the OGR Geometry to TerraLib Geometry.
TERRAMOBILEPLUGINSDLLEXPORT OGRGeometry * Convert2OGR(const te::gm::Geometry *teGeom)
It converts the TerraLib Geometry to OGR Geometry.
TerraLib.
#define TERRAMOBILEPLUGINSDLLEXPORT
Definition: Config.h:89
#define TE_UNKNOWN_SRS
A numeric value to represent a unknown SRS identification in TerraLib.
Definition: Config.h:43