CompoundCurve.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/CompoundCurve.h
22 
23  \brief CompoundCurve is a curve that may have circular and linear segments.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_COMPOUNDCURVE_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_COMPOUNDCURVE_H
28 
29 // TerraLib
30 #include "Curve.h"
31 
32 // STL
33 #include <vector>
34 
35 namespace te
36 {
37  namespace gm
38  {
39  /*!
40  \class CompoundCurve
41 
42  \brief CompoundCurve is a curve that may have circular and linear segments.
43 
44  \ingroup geometry
45 
46  \sa Geometry,
47  AbstractPoint, Point, PointM, PointZ, PointZM, PointKd,
48  Curve, Line, LineString, LinearRing, CircularString,
49  Surface, Polygon, Triangle, CurvePolygon, PolyhedralSurface, TIN,
50  GeometryCollection, MultiSurface, MultiCurve,
51  MultiPoint, MultiLineString, MultiPolygon
52  */
54  {
55  public:
56 
58 
59  /** @name Initializer methods on geometric objects
60  * Methods for initializing a geometric object.
61  */
62  //@{
63 
64  /*!
65  \brief It initializes the compound curve with the specified spatial reference system id and envelope.
66 
67  \param t The internal type of the compound curve.
68  \param srid The Spatial Reference System ID associated to the compound curve.
69  \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope).
70 
71  \note The compound curve will take the ownership of the given mbr.
72  */
73  CompoundCurve(GeomType t, int srid = 0, Envelope* mbr = 0);
74 
75  /*!
76  \brief It initializes the compound curve with the specified spatial reference system id and envelope.
77 
78  \param size The number of elements in the CompoundCurve. It must be a value greater than 0.
79  \param t The internal type of the compound curve.
80  \param srid The Spatial Reference System ID associated to the compound curve.
81  \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope).
82 
83  \note The compound curve will take the ownership of the given mbr.
84  */
85  CompoundCurve(std::size_t size, GeomType t, int srid = 0, Envelope* mbr = 0);
86 
87  /*!
88  \brief Copy constructor.
89 
90  \param rhs The other geometry.
91  */
92  CompoundCurve(const CompoundCurve& rhs);
93 
94  /*! \brief Virtual destructor. */
95  ~CompoundCurve();
96 
97  /*!
98  \brief Assignment operator.
99 
100  \param rhs The other geometry.
101 
102  \return A reference for this.
103  */
104  CompoundCurve& operator=(const CompoundCurve& rhs);
105 
106  //@}
107 
108  /** @name Re-Implementation from AbstractData
109  * Methods re-Implementated from AbstractData.
110  */
111  //@{
112 
113  /*!
114  \brief It clones the compound curve.
115 
116  \return A copy of the given compound curve.
117 
118  \note The caller of this method will take the ownership of the returned compound curve.
119 
120  \note The cloned compound curve will not have the
121  MBR computed. This will save time when you
122  are just cloning a geometry and don't intend
123  to waste time computing the bounding box.
124  If you have another suggestion, please, let me know.
125  */
126  te::dt::AbstractData* clone() const;
127 
128  //@}
129 
130  /** @name Re-Implmentation of methods from Geometry class
131  * Re-Implmentation of basic methods from Geometry class.
132  */
133  //@{
134 
135  /*!
136  \brief The name of instantiable subtype is: CompoundCurve.
137 
138  \return The name of instantiable subtype is: CompoundCurve.
139  */
140  const std::string& getGeometryType() const throw();
141 
142  /*!
143  \brief It sets the Spatial Reference System ID of the compound curve.
144 
145  \param srid The Spatial Reference System ID to be associated to the compound curve.
146 
147  \note TerraLib extended method.
148  */
149  void setSRID(int srid) throw();
150 
151  /*!
152  \brief It converts the coordinate values of the compound curve to the new spatial reference system.
153 
154  After calling this method the compound curve will be associated to the new SRID.
155 
156  \param srid The new Spatial Reference System ID used to transform the coordinates of the compound curve.
157 
158  \exception Exception It will throw an exception if it can not do the transformation.
159 
160  \note The compound curve must be associated to a valid SRID before calling this method.
161 
162  \note If the compound curve already has an associated MBR, this method will automatically update it (i. e. automatically recompute it).
163  */
164  void transform(int srid) throw(te::common::Exception);
165 
166  /*!
167  \brief It computes the minimum bounding rectangle for the compound curve.
168 
169  \param cascade For compound curve this flag doesn't have effect.
170 
171  \note You can use this method in order to update the MBR of the compound curve.
172 
173  \note TerraLib extended method.
174  */
175  void computeMBR(bool cascade) const throw();
176 
177  /*!
178  \brief It returns the number of points (vertexes) in the compound curve.
179 
180  \return The number of points (vertexes) in the compound curve.
181 
182  \note TerraLib extended method.
183  */
184  std::size_t getNPoints() const throw();
185 
186  /*!
187  \brief It returns a derived geometry collection value according to the range of coordinate values inclusively.
188 
189  \param mStart The initial coordinate value.
190  \param mEnd The final coordinate value.
191 
192  \return A GeometryCollection value.
193 
194  \note The caller of this method will take the ownership of geometry.
195  */
196  Geometry* locateBetween(const double& mStart, const double& mEnd) const throw(Exception);
197 
198  //@}
199 
200  /** @name Re-Implementation from Curve
201  * Methods re-impleented from Curve.
202  */
203  //@{
204 
205  /*!
206  \brief The length of this Curve in its associated spatial reference.
207 
208  \return The length of this Curve in its associated spatial reference.
209  */
210  double getLength() const;
211 
212  /*!
213  \brief It returns the curve start point.
214 
215  \return The curve start point.
216 
217  \note The caller of this method will take the ownership of the point geometry.
218  */
219  Point* getStartPoint() const;
220 
221  /*!
222  \brief It returns the curve end point.
223 
224  \return The curve end point.
225 
226  \note The caller of this method will take the ownership of the point geometry.
227  */
228  Point* getEndPoint() const;
229 
230  /*!
231  \brief It returns true if the curve is closed (startPoint = endPoint).
232 
233  \return True if the curve is closed (startPoint = endPoint).
234 
235  \warning The line must have at least 2 points.
236  */
237  bool isClosed() const;
238 
239  //@}
240 
241  /** @name CompoundCurve Specific Methods
242  * Specific methods for a CompoundCurve.
243  */
244  //@{
245 
246  /*!
247  \brief It returns the number of elements in the compound geometry.
248 
249  \return The number of elements in the compound geometry.
250 
251  \note TerraLib extended method.
252  */
253  std::size_t size() const { return m_curves.size(); }
254 
255  /*!
256  \brief It clears all the segments.
257 
258  \note TerraLib extended method.
259  */
260  void makeEmpty();
261 
262  /*!
263  \brief It returns the i-th curve.
264 
265  \return The i-th curve.
266  */
267  Curve* getCurve(std::size_t i) const;
268 
269  /*!
270  \brief It adds the curve to the compound.
271 
272  \param c The curve to be added to the compound. The compound will take its ownership.
273  */
274  void add(Curve* c);
275 
276  /*!
277  \brief It returns a pointer to the internal array of segments.
278 
279  \return A pointer to the internal array of segments.
280 
281  \warning Don't use this method unless you know exactly what you're doing!
282 
283  \note TerraLib extended method.
284  */
285  const std::vector<Curve*>& getCurves() const
286  {
287  return m_curves;
288  }
289 
290  /*!
291  \brief It returns a pointer to the internal array of segments.
292 
293  \return A pointer to the internal array of segments.
294 
295  \warning Don't use this method unless you know exactly what you're doing!
296 
297  \note TerraLib extended method.
298  */
299  std::vector<Curve*>& getCurves()
300  {
301  return m_curves;
302  }
303 
304  //@}
305 
306  protected:
307 
308  std::vector<Curve*> m_curves; //!< The list of segments of the compund curve.
309 
310  private:
311 
312  static const std::string sm_typeName; //! Geometry type name for CompoundCurve.
313  };
314 
315  } // end namespace gm
316 } // end namespace te
317 
318 #endif // __TERRALIB_GEOMETRY_INTERNAL_COMPOUNDCURVE_H
319 
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
Base exception class for plugin module.
Definition: Exception.h:42
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
Definition: Curve.h:58
std::vector< Curve * > m_curves
The list of segments of the compund curve.
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
std::size_t size() const
It returns the number of elements in the compound geometry.
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.
CompoundCurve is a curve that may have circular and linear segments.
Definition: CompoundCurve.h:53
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
#define TE_DEFINE_VISITABLE
Definition: BaseVisitable.h:75
This class is designed to declare objects to be thrown as exceptions by TerraLib. ...
Definition: Exception.h:58
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
Curve is an abstract class that represents 1-dimensional geometric objects stored as a sequence of co...
const std::vector< Curve * > & getCurves() const
It returns a pointer to the internal array of segments.
static const std::string sm_typeName
std::vector< Curve * > & getCurves()
It returns a pointer to the internal array of segments.