GEOSWriter.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/geometry/GEOSWriter.h
22 
23  \brief A class that converts a TerraLib geometry to a GEOS geometry.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_GEOSWRITER_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_GEOSWRITER_H
28 
29 // TerraLib
30 #include "../BuildConfig.h"
31 #include "../common/Static.h"
32 #include "Config.h"
33 
34 #ifdef TERRALIB_GEOS_ENABLED
35 
36 // STL
37 #include <vector>
38 
39 // Forward declaration
40 namespace geos
41 {
42  namespace geom
43  {
44  class CoordinateSequence;
45  class Envelope;
46  class Geometry;
47  class GeometryCollection;
48  class LinearRing;
49  class LineSegment;
50  class LineString;
51  class MultiLineString;
52  class MultiPoint;
53  class MultiPolygon;
54  class Point;
55  class Polygon;
56  } // end namespace geom
57 } // end namespace geos
58 
59 namespace te
60 {
61  namespace gm
62  {
63 // Forward declaration
64  class Geometry;
65  class GeometryCollection;
66  class Line;
67  class LinearRing;
68  class LineString;
69  class MultiLineString;
70  class MultiPoint;
71  class MultiPolygon;
72  class Point;
73  class PointM;
74  class PointZ;
75  class PointZM;
76  class Polygon;
77  class Envelope;
78 
79  /*!
80  \class GEOSWriter
81 
82  \brief A class that converts a TerraLib geometry to a GEOS geometry.
83 
84  \sa GEOSReader
85  */
86  class TEGEOMEXPORT GEOSWriter : public te::common::Static
87  {
88  public:
89 
90  /*!
91  \brief It reads a TerraLib geometry and make a GEOS geometry.
92 
93  \param teGeom The TerraLib geometry to be used to create the GEOS geometry.
94 
95  \return A GEOS geometry. The client will take its ownership.
96 
97  \exception It throws an exception if a conversion is not possible.
98  */
99  static geos::geom::Geometry* write(const Geometry* teGeom);
100 
101  /*!
102  \brief It converts the TerraLib point to a GEOS point.
103 
104  \param tePt The TerraLib point to be used to create the GEOS point.
105 
106  \return A GEOS point geometry. The client will take it ownership.
107 
108  \exception It throws an exception if a conversion is not possible.
109  */
110  static geos::geom::Point* write(const Point* tePt);
111 
112  /*!
113  \brief It converts the TerraLib point to a GEOS point.
114 
115  \param tePt The TerraLib point to be used to create the GEOS point.
116 
117  \return A GEOS point geometry. The client will take it ownership.
118 
119  \exception It throws an exception if a conversion is not possible.
120  */
121  static geos::geom::Point* write(const PointM* tePt);
122 
123  /*!
124  \brief It converts the TerraLib point to a GEOS point.
125 
126  \param tePt The TerraLib point to be used to create the GEOS point.
127 
128  \return A GEOS point geometry. The client will take it ownership.
129 
130  \exception It throws an exception if a conversion is not possible.
131  */
132  static geos::geom::Point* write(const PointZ* tePt);
133 
134  /*!
135  \brief It converts the TerraLib point to a GEOS point.
136 
137  \param tePt The TerraLib point to be used to create the GEOS point.
138 
139  \return A GEOS point geometry. The client will take it ownership.
140 
141  \exception It throws an exception if a conversion is not possible.
142  */
143  static geos::geom::Point* write(const PointZM* tePt);
144 
145  /*!
146  \brief It converts the TerraLib line string to a GEOS line string.
147 
148  \param teLine The TerraLib line string to be used to create the GEOS line string.
149 
150  \return A GEOS line string geometry. The client will take its ownership.
151 
152  \exception It throws an exception if a conversion is not possible.
153  */
154  static geos::geom::LineString* write(const LineString* teLine);
155 
156  /*!
157  \brief It converts the TerraLib linear ring to a GEOS linear ring.
158 
159  \param teRing The TerraLib linear ring to be used to create the GEOS linear ring.
160 
161  \return A GEOS linear ring geometry. The client will take its ownership.
162 
163  \exception It throws an exception if a conversion is not possible.
164  */
165  static geos::geom::LinearRing* write(const LinearRing* teRing);
166 
167  /*!
168  \brief It converts the TerraLib polygon to a GEOS polygon.
169 
170  \param tePoly The TerraLib polygon to be used to create the GEOS polygon.
171 
172  \return A GEOS polygon geometry. The client will take its ownership.
173 
174  \exception It throws an exception if a conversion is not possible.
175  */
176  static geos::geom::Polygon* write(const Polygon* tePoly);
177 
178  /*!
179  \brief It converts the TerraLib multi polygon to a GEOS multi polygon.
180 
181  \param teMPoly The TerraLib multi polygon to be used to create the GEOS multi polygon.
182 
183  \return A GEOS multi polygon geometry. The client will take its ownership.
184 
185  \exception It throws an exception if a conversion is not possible.
186  */
187  static geos::geom::MultiPolygon* write(const MultiPolygon* teMPoly);
188 
189  /*!
190  \brief It converts the TerraLib multi line string to a GEOS multi line string.
191 
192  \param teMLine The TerraLib multi line string to be used to create the GEOS multi line string.
193 
194  \return A GEOS multi line string geometry. The client will take its ownership.
195 
196  \exception It throws an exception if a conversion is not possible.
197  */
198  static geos::geom::MultiLineString* write(const MultiLineString* teMLine);
199 
200  /*!
201  \brief It converts the TerraLib multi point to a GEOS multi point.
202 
203  \param teMPt The TerraLib multi point to be used to create the GEOS multi point.
204 
205  \return A GEOS multi point geometry. The client will take its ownership.
206 
207  \exception It throws an exception if a conversion is not possible.
208  */
209  static geos::geom::MultiPoint* write(const MultiPoint* teMPt);
210 
211  /*!
212  \brief It converts the TerraLib Geometry Envelope to a GEOS Envelope.
213 
214  \param teEnv The TerraLib Envelope to be used to create the GEOS Envelope.
215 
216  \return A GEOS Envelope geometry. The client will take its ownership.
217 
218  \exception It throws an exception if a conversion is not possible.
219  */
220  static geos::geom::Envelope* write(const Envelope* teEnv);
221  static geos::geom::LineSegment* write(const Line* teLine);
222 
223  /*!
224  \brief It converts the TerraLib geometry collection to a GEOS geometry collection.
225 
226  \param teGeomColl The TerraLib geometry collection to be used to create the GEOS geometry collection.
227 
228  \return A GEOS geometry collection. The client will take its ownership.
229 
230  \exception It throws an exception if a conversion is not possible.
231  */
232  static geos::geom::GeometryCollection* write(const GeometryCollection* teGeomColl);
233 
234  protected:
235 
236  /*!
237  \brief It creates a coordinate sequence from the input TerraLib line string (or TerraLib linear ring).
238 
239  \param teLine The TerraLib line string to be used to create the GEOS coordinate sequence.
240 
241  \return A GEOS coordinate sequence. The caller will take its ownership.
242  */
243  static geos::geom::CoordinateSequence* getCoordinateSequence(const LineString* teLine);
244 
245  /*!
246  \brief It creates a vector of GEOS geometry from the input TerraLib geometry collection.
247 
248  \param teGeomColl The TerraLib line string to be used to create the GEOS coordinate sequence.
249 
250  \return A vector of GEOS geometry. The caller will take its ownership.
251  */
252  static std::vector<geos::geom::Geometry*>* getGeometries(const GeometryCollection* teGeomColl);
253  };
254 
255  } // end namespace gm
256 } // end namespace te
257 
258 #endif // TERRALIB_GEOS_ENABLED
259 
260 #endif // __TERRALIB_GEOMETRY_INTERNAL_GEOSWRITER_H
261 
262 
263 
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
URI C++ Library.
Configuration flags for the Vector Geometry Model of TerraLib.
A base type for static classes.
Definition: Static.h:43