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