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