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 Polygon;
74  class Envelope;
75 
76  /*!
77  \class GEOSWriter
78 
79  \brief A class that converts a TerraLib geometry to a GEOS geometry.
80 
81  \sa GEOSReader
82  */
83  class TEGEOMEXPORT GEOSWriter : public te::common::Static
84  {
85  public:
86 
87  /*!
88  \brief It reads a TerraLib geometry and make a GEOS geometry.
89 
90  \param teGeom The TerraLib geometry to be used to create the GEOS geometry.
91 
92  \return A GEOS geometry. The client will take its ownership.
93 
94  \exception It throws an exception if a conversion is not possible.
95  */
96  static geos::geom::Geometry* write(const Geometry* teGeom);
97 
98  /*!
99  \brief It converts the TerraLib point to a GEOS point.
100 
101  \param tePt The TerraLib point to be used to create the GEOS point.
102 
103  \return A GEOS point geometry. The client will take it ownership.
104 
105  \exception It throws an exception if a conversion is not possible.
106  */
107  static geos::geom::Point* write(const Point* tePt);
108 
109  /*!
110  \brief It converts the TerraLib line string to a GEOS line string.
111 
112  \param teLine The TerraLib line string to be used to create the GEOS line string.
113 
114  \return A GEOS line string geometry. The client will take its ownership.
115 
116  \exception It throws an exception if a conversion is not possible.
117  */
118  static geos::geom::LineString* write(const LineString* teLine);
119 
120  /*!
121  \brief It converts the TerraLib linear ring to a GEOS linear ring.
122 
123  \param teRing The TerraLib linear ring to be used to create the GEOS linear ring.
124 
125  \return A GEOS linear ring geometry. The client will take its ownership.
126 
127  \exception It throws an exception if a conversion is not possible.
128  */
129  static geos::geom::LinearRing* write(const LinearRing* teRing);
130 
131  /*!
132  \brief It converts the TerraLib polygon to a GEOS polygon.
133 
134  \param tePoly The TerraLib polygon to be used to create the GEOS polygon.
135 
136  \return A GEOS polygon geometry. The client will take its ownership.
137 
138  \exception It throws an exception if a conversion is not possible.
139  */
140  static geos::geom::Polygon* write(const Polygon* tePoly);
141 
142  /*!
143  \brief It converts the TerraLib multi polygon to a GEOS multi polygon.
144 
145  \param teMPoly The TerraLib multi polygon to be used to create the GEOS multi polygon.
146 
147  \return A GEOS multi polygon geometry. The client will take its ownership.
148 
149  \exception It throws an exception if a conversion is not possible.
150  */
151  static geos::geom::MultiPolygon* write(const MultiPolygon* teMPoly);
152 
153  /*!
154  \brief It converts the TerraLib multi line string to a GEOS multi line string.
155 
156  \param teMLine The TerraLib multi line string to be used to create the GEOS multi line string.
157 
158  \return A GEOS multi line string geometry. The client will take its ownership.
159 
160  \exception It throws an exception if a conversion is not possible.
161  */
162  static geos::geom::MultiLineString* write(const MultiLineString* teMLine);
163 
164  /*!
165  \brief It converts the TerraLib multi point to a GEOS multi point.
166 
167  \param teMPt The TerraLib multi point to be used to create the GEOS multi point.
168 
169  \return A GEOS multi point geometry. The client will take its ownership.
170 
171  \exception It throws an exception if a conversion is not possible.
172  */
173  static geos::geom::MultiPoint* write(const MultiPoint* teMPt);
174 
175  /*!
176  \brief It converts the TerraLib Geometry Envelope to a GEOS Envelope.
177 
178  \param teEnv The TerraLib Envelope to be used to create the GEOS Envelope.
179 
180  \return A GEOS Envelope geometry. The client will take its ownership.
181 
182  \exception It throws an exception if a conversion is not possible.
183  */
184  static geos::geom::Envelope* write(const Envelope* teEnv);
185  static geos::geom::LineSegment* write(const Line* teLine);
186 
187  /*!
188  \brief It converts the TerraLib geometry collection to a GEOS geometry collection.
189 
190  \param teGeomColl The TerraLib geometry collection to be used to create the GEOS geometry collection.
191 
192  \return A GEOS geometry collection. The client will take its ownership.
193 
194  \exception It throws an exception if a conversion is not possible.
195  */
196  static geos::geom::GeometryCollection* write(const GeometryCollection* teGeomColl);
197 
198  protected:
199 
200  /*!
201  \brief It creates a coordinate sequence from the input TerraLib line string (or TerraLib linear ring).
202 
203  \param teLine The TerraLib line string to be used to create the GEOS coordinate sequence.
204 
205  \return A GEOS coordinate sequence. The caller will take its ownership.
206  */
207  static geos::geom::CoordinateSequence* getCoordinateSequence(const LineString* teLine);
208 
209  /*!
210  \brief It creates a vector of GEOS geometry from the input TerraLib geometry collection.
211 
212  \param teGeomColl The TerraLib line string to be used to create the GEOS coordinate sequence.
213 
214  \return A vector of GEOS geometry. The caller will take its ownership.
215  */
216  static std::vector<geos::geom::Geometry*>* getGeometries(const GeometryCollection* teGeomColl);
217  };
218 
219  } // end namespace gm
220 } // end namespace te
221 
222 #endif // TERRALIB_GEOS_ENABLED
223 
224 #endif // __TERRALIB_GEOMETRY_INTERNAL_GEOSWRITER_H
225 
226 
227 
#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