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 
33 // STL
34 #include <vector>
35 
36 // Forward declaration
37 namespace geos
38 {
39  namespace geom
40  {
41  class CoordinateSequence;
42  class Envelope;
43  class Geometry;
44  class GeometryCollection;
45  class LinearRing;
46  class LineSegment;
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 Line;
64  class LinearRing;
65  class LineString;
66  class MultiLineString;
67  class MultiPoint;
68  class MultiPolygon;
69  class Point;
70  class Polygon;
71  class Envelope;
72 
73  /*!
74  \class GEOSWriter
75 
76  \brief A class that converts a TerraLib geometry to a GEOS geometry.
77 
78  \sa GEOSReader
79  */
81  {
82  public:
83 
84  /*!
85  \brief It reads a TerraLib geometry and make a GEOS geometry.
86 
87  \param teGeom The TerraLib geometry to be used to create the GEOS geometry.
88 
89  \return A GEOS geometry. The client will take its ownership.
90 
91  \exception It throws an exception if a conversion is not possible.
92  */
93  static geos::geom::Geometry* write(const Geometry* teGeom);
94 
95  /*!
96  \brief It converts the TerraLib point to a GEOS point.
97 
98  \param tePt The TerraLib point to be used to create the GEOS point.
99 
100  \return A GEOS point geometry. The client will take it ownership.
101 
102  \exception It throws an exception if a conversion is not possible.
103  */
104  static geos::geom::Point* write(const Point* tePt);
105 
106  /*!
107  \brief It converts the TerraLib line string to a GEOS line string.
108 
109  \param teLine The TerraLib line string to be used to create the GEOS line string.
110 
111  \return A GEOS line string geometry. The client will take its ownership.
112 
113  \exception It throws an exception if a conversion is not possible.
114  */
115  static geos::geom::LineString* write(const LineString* teLine);
116 
117  /*!
118  \brief It converts the TerraLib linear ring to a GEOS linear ring.
119 
120  \param teRing The TerraLib linear ring to be used to create the GEOS linear ring.
121 
122  \return A GEOS linear ring geometry. The client will take its ownership.
123 
124  \exception It throws an exception if a conversion is not possible.
125  */
126  static geos::geom::LinearRing* write(const LinearRing* teRing);
127 
128  /*!
129  \brief It converts the TerraLib polygon to a GEOS polygon.
130 
131  \param tePoly The TerraLib polygon to be used to create the GEOS polygon.
132 
133  \return A GEOS polygon geometry. The client will take its ownership.
134 
135  \exception It throws an exception if a conversion is not possible.
136  */
137  static geos::geom::Polygon* write(const Polygon* tePoly);
138 
139  /*!
140  \brief It converts the TerraLib multi polygon to a GEOS multi polygon.
141 
142  \param teMPoly The TerraLib multi polygon to be used to create the GEOS multi polygon.
143 
144  \return A GEOS multi polygon geometry. The client will take its ownership.
145 
146  \exception It throws an exception if a conversion is not possible.
147  */
148  static geos::geom::MultiPolygon* write(const MultiPolygon* teMPoly);
149 
150  /*!
151  \brief It converts the TerraLib multi line string to a GEOS multi line string.
152 
153  \param teMLine The TerraLib multi line string to be used to create the GEOS multi line string.
154 
155  \return A GEOS multi line string geometry. The client will take its ownership.
156 
157  \exception It throws an exception if a conversion is not possible.
158  */
159  static geos::geom::MultiLineString* write(const MultiLineString* teMLine);
160 
161  /*!
162  \brief It converts the TerraLib multi point to a GEOS multi point.
163 
164  \param teMPt The TerraLib multi point to be used to create the GEOS multi point.
165 
166  \return A GEOS multi point geometry. The client will take its ownership.
167 
168  \exception It throws an exception if a conversion is not possible.
169  */
170  static geos::geom::MultiPoint* write(const MultiPoint* teMPt);
171 
172  /*!
173  \brief It converts the TerraLib Geometry Envelope to a GEOS Envelope.
174 
175  \param teEnv The TerraLib Envelope to be used to create the GEOS Envelope.
176 
177  \return A GEOS Envelope geometry. The client will take its ownership.
178 
179  \exception It throws an exception if a conversion is not possible.
180  */
181  static geos::geom::Envelope* write(const Envelope* teEnv);
182  static geos::geom::LineSegment* write(const Line* teLine);
183 
184  /*!
185  \brief It converts the TerraLib geometry collection to a GEOS geometry collection.
186 
187  \param teGeomColl The TerraLib geometry collection to be used to create the GEOS geometry collection.
188 
189  \return A GEOS geometry collection. The client will take its ownership.
190 
191  \exception It throws an exception if a conversion is not possible.
192  */
193  static geos::geom::GeometryCollection* write(const GeometryCollection* teGeomColl);
194 
195  protected:
196 
197  /*!
198  \brief It creates a coordinate sequence from the input TerraLib line string (or TerraLib linear ring).
199 
200  \param teLine The TerraLib line string to be used to create the GEOS coordinate sequence.
201 
202  \return A GEOS coordinate sequence. The caller will take its ownership.
203  */
204  static geos::geom::CoordinateSequence* getCoordinateSequence(const LineString* teLine);
205 
206  /*!
207  \brief It creates a vector of GEOS geometry from the input TerraLib geometry collection.
208 
209  \param teGeomColl The TerraLib line string to be used to create the GEOS coordinate sequence.
210 
211  \return A vector of GEOS geometry. The caller will take its ownership.
212  */
213  static std::vector<geos::geom::Geometry*>* getGeometries(const GeometryCollection* teGeomColl);
214  };
215 
216  } // end namespace gm
217 } // end namespace te
218 
219 #endif // __TERRALIB_GEOMETRY_INTERNAL_GEOSWRITER_H
220 
221 
222 
MultiPolygon is a MultiSurface whose elements are Polygons.
Definition: MultiPolygon.h:50
A Line is LineString with 2 points.
Definition: Line.h:50
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
A LinearRing is a LineString that is both closed and simple.
Definition: LinearRing.h:53
MultiPoint is a GeometryCollection whose elements are restricted to points.
Definition: MultiPoint.h:50
LineString is a curve with linear interpolation between points.
Definition: LineString.h:62
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
URI C++ Library.
A class that converts a TerraLib geometry to a GEOS geometry.
Definition: GEOSWriter.h:80
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:75
MultiLineString is a MultiCurve whose elements are LineStrings.
Polygon is a subclass of CurvePolygon whose rings are defined by linear rings.
Definition: Polygon.h:50
Configuration flags for the Vector Geometry Model of TerraLib.
It is a collection of other geometric objects.
A base type for static classes.
Definition: Static.h:43