AbstractPoint.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/AbstractPoint.h
22 
23  \brief A base abstract class for 0-dimensional geometric objects that represents a single location in coordinate space.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_ABSTRACTPOINT_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_ABSTRACTPOINT_H
28 
29 // TerraLib
30 #include "Geometry.h"
31 
32 namespace te
33 {
34  namespace gm
35  {
36  /*!
37  \class AbstractPoint
38 
39  \brief A base abstract class for 0-dimensional geometric objects that represents a single location in coordinate space.
40 
41  \ingroup geometry
42 
43  \sa Geometry,
44  Point, PointM, PointZ, PointZM, PointKd,
45  Curve, LineString, LinearRing, Line, CircularString, CompoundCurve,
46  Surface, Polygon, Triangle, CurvePolygon, PolyhedralSurface, TIN,
47  GeometryCollection, MultiSurface, MultiCurve,
48  MultiPoint, MultiLineString, MultiPolygon
49  */
51  {
52  public:
53 
55 
56  /*!
57  \brief It initializes the point with the specified spatial reference system id and envelope.
58 
59  \param t The internal point type.
60  \param srid The Spatial Reference System ID associated to the point.
61  \param mbr The minimum bounding rectangle of this point (i.e., its envelope).
62 
63  \note The point will take the ownership of the given mbr.
64  */
65  AbstractPoint(GeomType t, int srid = 0, Envelope* mbr = 0);
66 
67  /*!
68  \brief Copy constructor.
69 
70  \param rhs The other geometry.
71  */
72  AbstractPoint(const AbstractPoint& rhs);
73 
74  /*! \brief Virtual destructor. */
75  virtual ~AbstractPoint() { }
76 
77  /*!
78  \brief Assignment operator.
79 
80  \param rhs The other geometry.
81 
82  \return A reference for this.
83  */
84  virtual AbstractPoint& operator=(const AbstractPoint& rhs);
85 
86  //@}
87 
88  /** @name Point Specific Methods
89  * Specific methods that a point subclass must implement.
90  */
91  //@{
92 
93  /*!
94  \brief It returns the point x-coordinate value.
95 
96  \return The x-coordinate value for this point.
97  */
98  virtual const double& getX() const = 0;
99 
100  /*!
101  \brief It sets the point x-coordinate value.
102 
103  \param x The x-coordinate value for this point.
104  */
105  virtual void setX(const double& x) = 0;
106 
107  /*!
108  \brief It returns the point y-coordinate value.
109 
110  \return The y-coordinate value for this point.
111  */
112  virtual const double& getY() const = 0;
113 
114  /*!
115  \brief It sets the point y-coordinate value.
116 
117  \param y The y-coordinate value for this point.
118  */
119  virtual void setY(const double& y) = 0;
120 
121  /*!
122  \brief It returns the point z-coordinate value, if it has one or TE_DOUBLE_NOT_A_NUMBER otherwise.
123 
124  \return The z-coordinate value for this point.
125  */
126  virtual const double& getZ() const = 0;
127 
128  /*!
129  \brief It sets the point z-coordinate value.
130 
131  \param z The z-coordinate value for this point.
132  */
133  virtual void setZ(const double& z) = 0;
134 
135  /*!
136  \brief It returns the point m-coordinate value, if it has one or TE_DOUBLE_NOT_A_NUMBER otherwise.
137 
138  \return The m-coordinate value for this point.
139  */
140  virtual const double& getM() const = 0;
141 
142  /*!
143  \brief It sets the point m-coordinate value.
144 
145  \param m The m-coordinate value for this point.
146  */
147  virtual void setM(const double& m) = 0;
148 
149  //@}
150 
151  /** @name Re-Implmentation of methods from Geometry class
152  * Re-Implmentation of basic methods from Geometry class.
153  */
154  //@{
155 
156  /*!
157  \brief Points are 0-dimensional objects.
158 
159  \return te::gm::P (0-dimensional)
160  */
161  Dimensionality getDimension() const throw();
162 
163  /*!
164  \brief The name of instantiable subtype is: Point.
165 
166  \return The name of instantiable subtype is: Point.
167  */
168  const std::string& getGeometryType() const throw();
169 
170  /*!
171  \brief It sets the Spatial Reference System ID of the Point.
172 
173  \param srid The Spatial Reference System ID to be associated to the geometric object.
174 
175  \note TerraLib extended method.
176  */
177  void setSRID(int srid) throw();
178 
179  /*!
180  \brief It converts the coordinate values of the point to the new spatial reference system.
181 
182  After calling this method the point will be associated to the new SRID.
183 
184  \param srid The new Spatial Reference System ID used to transform the coordinates of the point.
185 
186  \exception Exception It will throw an exception if it can not do the transformation.
187 
188  \note The point must be associated to a valid SRID before calling this method.
189 
190  \note If the point already has an associated MBR, this method will automatically update it (i. e. automatically recompute it).
191  */
192  void transform(int srid) throw(te::common::Exception);
193 
194  /*!
195  \brief It computes the minimum bounding rectangle for the point.
196 
197  \param cascade For points this flag doesn't have effect.
198 
199  \note You can use this method in order to update the MBR of the point.
200 
201  \note TerraLib extended method.
202  */
203  void computeMBR(bool cascade) const throw();
204 
205  /*!
206  \brief it returns the number of points (vertexes) in the geometry.
207 
208  \return The number of points (vertexes) in the geometry.
209 
210  \note TerraLib extended method.
211  */
212  std::size_t getNPoints() const throw() { return 1; }
213 
214  //@}
215 
216  protected:
217 
218  static const std::string sm_typeName; //!< Geometry type name for AbstractPoint.
219 
220  static const double sm_notNumber; //!< Just a special value to return in the case of an invalid geometry.
221  };
222 
223  } // end namespace gm
224 } // end namespace te
225 
226 #endif // __TERRALIB_GEOMETRY_INTERNAL_ABSTRACTPOINT_H
227 
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
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
Dimensionality
From Wikipedia: "in mathematics, the dimension of an object is an intrinsic property, independent of the space in which the object may happen to be embedded".
Definition: Enums.h:147
URI C++ Library.
#define TE_DEFINE_VISITABLE
Definition: BaseVisitable.h:75
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:73
virtual ~AbstractPoint()
Virtual destructor.
Definition: AbstractPoint.h:75
static const double sm_notNumber
Just a special value to return in the case of an invalid geometry.
static const std::string sm_typeName
Geometry type name for AbstractPoint.
A base abstract class for 0-dimensional geometric objects that represents a single location in coordi...
Definition: AbstractPoint.h:50
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.