GEOSReader.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/GEOSReader.h
22 
23  \brief A class that converts a GEOS geometry to a TerraLib geometry.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_GEOSREADER_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_GEOSREADER_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 // Forward declaration
37 namespace geos
38 {
39  namespace geom
40  {
41  //class CoordinateSequence;
42  class Geometry;
43  class GeometryCollection;
44  class LinearRing;
45  class LineString;
46  class MultiLineString;
47  class MultiPoint;
48  class MultiPolygon;
49  class Point;
50  class Polygon;
51  } // end namespace geom
52 } // end namespace geos
53 
54 namespace te
55 {
56  namespace gm
57  {
58 // Forward declaration
59  class Geometry;
60  class GeometryCollection;
61  class LinearRing;
62  class LineString;
63  class MultiLineString;
64  class MultiPoint;
65  class MultiPolygon;
66  class Point;
67  class Polygon;
68 
69  /*!
70  \class GEOSReader
71 
72  \brief A class that converts a GEOS geometry to a TerraLib geometry.
73 
74  \sa GEOSWriter
75  */
76  class TEGEOMEXPORT GEOSReader : public te::common::Static
77  {
78  public:
79 
80  /*!
81  \brief It reads a GEOS geometry and make a TerraLib geometry.
82 
83  \param geosGeom The GEOS geometry to be used to create the TerraLib geometry.
84 
85  \return A TerraLib geometry. The client will take its ownership.
86 
87  \exception It throws an exception if a conversion is not possible.
88  */
89  static Geometry* read(const geos::geom::Geometry* geosGeom);
90 
91  /*!
92  \brief It converts the GEOS point to a TerraLib point.
93 
94  \param geosPt The GEOS point to be used to create the TerraLib point.
95 
96  \return A TerraLib point geometry. The client will take its ownership.
97 
98  \exception It throws an exception if a conversion is not possible.
99  */
100  static Point* read(const geos::geom::Point* geosPt);
101 
102  /*!
103  \brief It converts the GEOS line string to a TerraLib line string.
104 
105  \param geosLine The GEOS line string to be used to create the TerraLib line string.
106 
107  \return A TerraLib line string geometry. The client will take its ownership.
108 
109  \exception It throws an exception if a conversion is not possible.
110  */
111  static LineString* read(const geos::geom::LineString* geosLine);
112 
113  /*!
114  \brief It converts the GEOS linear ring to a TerraLib linear ring.
115 
116  \param geosRing The GEOS linear ring to be used to create the TerraLib linear ring.
117 
118  \return A TerraLib linear ring geometry. The client will take its ownership.
119 
120  \exception It throws an exception if a conversion is not possible.
121  */
122  static LinearRing* read(const geos::geom::LinearRing* geosRing);
123 
124  /*!
125  \brief It converts the GEOS polygon to a TerraLib polygon.
126 
127  \param geosPoly The GEOS polygon to be used to create the TerraLib polygon.
128 
129  \return A TerraLib polygon geometry. The client will take its ownership.
130 
131  \exception It throws an exception if a conversion is not possible.
132  */
133  static Polygon* read(const geos::geom::Polygon* geosPoly);
134 
135  /*!
136  \brief It converts the GEOS multi polygon to a TerraLib multi polygon.
137 
138  \param geosMPoly The GEOS multi polygon to be used to create the TerraLib multi polygon.
139 
140  \return A TerraLib multi polygon geometry. The client will take its ownership.
141 
142  \exception It throws an exception if a conversion is not possible.
143  */
144  static MultiPolygon* read(const geos::geom::MultiPolygon* geosMPoly);
145 
146  /*!
147  \brief It converts the GEOS multi line string to a TerraLib multi line string.
148 
149  \param geosMLine The GEOS multi line string to be used to create the TerraLib multi line string.
150 
151  \return A TerraLib multi line string geometry. The client will take its ownership.
152 
153  \exception It throws an exception if a conversion is not possible.
154  */
155  static MultiLineString* read(const geos::geom::MultiLineString* geosMLine);
156 
157  /*!
158  \brief It converts the GEOS multi point to a TerraLib multi point.
159 
160  \param geosMPt The GEOS multi point to be used to create the TerraLib multi point.
161 
162  \return A TerraLib multi point geometry. The client will take its ownership.
163 
164  \exception It throws an exception if a conversion is not possible.
165  */
166  static MultiPoint* read(const geos::geom::MultiPoint* geosMPt);
167 
168  /*!
169  \brief It converts the GEOS geometry collection to a TerraLib geometry collection.
170 
171  \param geosGeomColl The GEOS geometry collection to be used to create the TerraLib geometry collection.
172 
173  \return A TerraLib geometry collection. The client will take its ownership.
174 
175  \exception It throws an exception if a conversion is not possible.
176  */
177  static GeometryCollection* read(const geos::geom::GeometryCollection* geosGeomColl);
178 
179  //protected:
180 
181  /*!
182  \brief It sets the TerraLib line string coordinates using a GEOS coordinate sequence.
183 
184  \param teLine The TerraLib line string to be used to create the GEOS coordinate sequence.
185  \param cs A GEOS coordinate sequence to be used to extract the TerraLib line string coordinates.
186  \param nPts The number of coordinates to be extracted from the coordinate sequence.
187 
188  \note The TerraLib line string must have the same capacity (number of vertex) as the input GEOS coordinate sequence.
189  */
190  //static void setCoords(const LineString* teLine, geos::geom::CoordinateSequence* cs, std::size_t nPts) const;
191  };
192 
193  } // end namespace gm
194 } // end namespace te
195 
196 #endif // TERRALIB_GEOS_ENABLED
197 
198 #endif // __TERRALIB_GEOMETRY_INTERNAL_GEOSREADER_H
199 
200 
201 
#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