Point.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/Point.h
22 
23  \brief A point with x and y coordinate values.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_POINT_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_POINT_H
28 
29 // TerraLib
30 #include "Geometry.h"
31 
32 namespace te
33 {
34  namespace gm
35  {
36  /*!
37  \class Point
38 
39  \brief A point with x and y coordinate values.
40 
41  \ingroup geometry
42 
43  \sa Geometry,
44  AbstractPoint, 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  */
50  class TEGEOMEXPORT Point: public Geometry
51  {
52  public:
53 
55 
56  /** @name Initializer methods on geometric objects
57  * Methods for initializing a geometric object.
58  */
59  //@{
60 
61  /*!
62  \brief It initializes the Geometry with the specified spatial reference system id and envelope.
63 
64  \param t The internal type of the Geometry.
65  \param srid The Spatial Reference System ID associated to the Geometry.
66  \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope). It may be a NULL value.
67 
68  \note The Geometry will take the ownership of the given mbr.
69  */
70  Point(int srid = 0, GeomType t = te::gm::PointType, Envelope* mbr = 0);
71 
72  /*!
73  \brief It initializes the Geometry with the specified spatial reference system id and envelope.
74 
75  \param t The internal type of the Geometry.
76  \param x The Point x-coordinate value.
77  \param y The Point y-coordinate value.
78  \param srid The Spatial Reference System ID associated to the Geometry.
79  \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope). It may be a NULL value.
80 
81  \note The Geometry will take the ownership of the given mbr.
82  */
83  Point(const double& x, const double& y, int srid = 0, GeomType t = te::gm::PointType, Envelope* mbr = 0);
84 
85  /*!
86  \brief Copy constructor.
87 
88  \param rhs The other geometry.
89  */
90  Point(const Point& rhs);
91 
92  /*!
93  \brief Assignment operator.
94 
95  \param rhs The other geometry.
96 
97  \return A reference for this.
98  */
99  virtual Point& operator=(const Point& rhs);
100 
101  /*! \brief Virtual destructor. */
102  virtual ~Point() { }
103 
104  //@}
105 
106  /** @name Re-Implementation from AbstractData
107  * Methods re-Implementated from AbstractData.
108  */
109  //@{
110 
111  /*!
112  \brief It clones the point.
113 
114  \return A copy of the given point.
115 
116  \note The caller of this method will take the ownership of the returned point.
117 
118  \note The cloned point will not have the
119  MBR computed. This will save time when you
120  are just cloning a geometry and don't intend
121  to waste time computing the bounding box.
122  If you have another suggestion, please, let me know.
123  */
124  virtual te::dt::AbstractData* clone() const;
125 
126  //@}
127 
128  /** @name Point Specific Methods
129  * Specific methods that a point must implement.
130  */
131  //@{
132 
133  /*!
134  \brief It returns the Point x-coordinate value.
135 
136  \return The x-coordinate value for this Point.
137  */
138  const double& getX() const { return m_x; }
139 
140  /*!
141  \brief It sets the Point x-coordinate value.
142 
143  \param x The x-coordinate value for this Point.
144  */
145  void setX(const double& x) { m_x = x; }
146 
147  /*!
148  \brief It returns the Point y-coordinate value.
149 
150  \return The y-coordinate value for this Point.
151  */
152  const double& getY() const { return m_y; }
153 
154  /*!
155  \brief It sets the Point y-coordinate value.
156 
157  \param y The y-coordinate value for this Point.
158  */
159  void setY(const double& y) { m_y = y; }
160 
161  /*!
162  \brief It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
163 
164  \return The z-coordinate value for this Point.
165  */
166  const double& getZ() const { return m_z; }
167 
168  /*!
169  \brief It sets the Point z-coordinate value.
170 
171  \param z The z-coordinate value for this Point.
172  */
173  void setZ(const double& z) { m_z = z; }
174 
175  /*!
176  \brief It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
177 
178  \return The m-coordinate value for this Point.
179  */
180  const double& getM() const { return m_m; }
181 
182  /*!
183  \brief It sets the Point m-coordinate value.
184 
185  \param m The m-coordinate value for this Point.
186  */
187  void setM(const double& m) { m_m = m; };
188 
189  /*!
190  \brief Less then operator.
191 
192  \param rhs The source object to be compared.
193 
194  \return True if the point have the coordinates values is less.
195  */
196  bool operator<(const Point& rhs);
197 
198  //@}
199 
200  /** @name Re-Implmentation of methods from Geometry class
201  * Re-Implmentation of basic methods from Geometry class.
202  */
203  //@{
204 
205  /*!
206  \brief Points are 0-dimensional objects.
207 
208  \return te::gm::P (0-dimensional)
209  */
210  Dimensionality getDimension() const throw();
211 
212  /*!
213  \brief The name of instantiable subtype is: Point.
214 
215  \return The name of instantiable subtype is: Point.
216  */
217  const std::string& getGeometryType() const throw();
218 
219  /*!
220  \brief It sets the Spatial Reference System ID of the Point.
221 
222  \param srid The Spatial Reference System ID to be associated to the geometric object.
223 
224  \note TerraLib extended method.
225  */
226  void setSRID(int srid) throw();
227 
228  /*!
229  \brief It converts the coordinate values of the point to the new spatial reference system.
230 
231  After calling this method the point will be associated to the new SRID.
232 
233  \param srid The new Spatial Reference System ID used to transform the coordinates of the point.
234 
235  \exception Exception It will throw an exception if it can not do the transformation.
236 
237  \note The point must be associated to a valid SRID before calling this method.
238 
239  \note If the point already has an associated MBR, this method will automatically update it (i. e. automatically recompute it).
240  */
241  void transform(int srid) throw(te::common::Exception);
242 
243  /*!
244  \brief It computes the minimum bounding rectangle for the point.
245 
246  \param cascade For points this flag doesn't have effect.
247 
248  \note You can use this method in order to update the MBR of the point.
249 
250  \note TerraLib extended method.
251  */
252  void computeMBR(bool cascade) const throw();
253 
254  /*!
255  \brief it returns the number of points (vertexes) in the geometry.
256 
257  \return The number of points (vertexes) in the geometry.
258 
259  \note TerraLib extended method.
260  */
261  std::size_t getNPoints() const throw() { return 1; }
262 
263  //@}
264 
265  protected:
266 
267  double m_x; //!< The Point x-coordinate value.
268  double m_y; //!< The Point y-coordinate value.
269  double m_z; //!< The Point z-coordinate value.
270  double m_m; //!< The Point m-coordinate value.
271 
272  static const std::string sm_typeName; //!< Geometry type name for Point.
273  static const double sm_notNumber; //!< Just a special value to return in the case of a invalid Geometry.
274  };
275 
276  } // end namespace gm
277 } // end namespace te
278 
279 #endif // __TERRALIB_GEOMETRY_INTERNAL_POINT_H
280 
TEDATAACCESSEXPORT te::da::Expression * operator<(const te::da::Expression &e1, const te::da::Expression &e2)
static const double sm_notNumber
Just a special value to return in the case of a invalid Geometry.
Definition: Point.h:273
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
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:152
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
void setM(const double &m)
It sets the Point m-coordinate value.
Definition: Point.h:187
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.
virtual ~Point()
Virtual destructor.
Definition: Point.h:102
A base class for values that can be retrieved from the data access module.
Definition: AbstractData.h:57
double m_z
The Point z-coordinate value.
Definition: Point.h:269
#define TE_DEFINE_VISITABLE
Definition: BaseVisitable.h:75
const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
Definition: Point.h:166
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Definition: Geometry.h:74
double m_y
The Point y-coordinate value.
Definition: Point.h:268
double m_m
The Point m-coordinate value.
Definition: Point.h:270
void setX(const double &x)
It sets the Point x-coordinate value.
Definition: Point.h:145
const double & getM() const
It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
Definition: Point.h:180
void setY(const double &y)
It sets the Point y-coordinate value.
Definition: Point.h:159
static const std::string sm_typeName
Geometry type name for Point.
Definition: Point.h:272
double m_x
The Point x-coordinate value.
Definition: Point.h:267
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:138
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void setZ(const double &z)
It sets the Point z-coordinate value.
Definition: Point.h:173