All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 "AbstractPoint.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  */
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 x The Point x-coordinate value.
65  \param y The Point y-coordinate value.
66  \param srid The Spatial Reference System ID associated to the Geometry.
67  \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope).
68 
69  \note The Geometry will take the ownership of the given mbr.
70  */
71  Point(const double& x, const double& y, int srid = 0, Envelope* mbr = 0);
72 
73  /*!
74  \brief It initializes the Geometry with the specified spatial reference system id and envelope.
75 
76  \param srid The Spatial Reference System ID associated to the Geometry.
77  \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope). It may be a NULL value.
78 
79  \note The Geometry will take the ownership of the given mbr.
80  */
81  Point(int srid = 0, Envelope* mbr = 0);
82 
83  /*!
84  \brief Copy constructor.
85 
86  \param rhs The other geometry.
87  */
88  Point(const Point& rhs);
89 
90  /*!
91  \brief Assignment operator.
92 
93  \param rhs The other geometry.
94 
95  \return A reference for this.
96  */
97  virtual Point& operator=(const Point& rhs);
98 
99  /*! \brief Virtual destructor. */
100  virtual ~Point() { }
101 
102  //@}
103 
104  /** @name Re-Implementation from AbstractData
105  * Methods re-Implementated from AbstractData.
106  */
107  //@{
108 
109  /*!
110  \brief It clones the point.
111 
112  \return A copy of the given point.
113 
114  \note The caller of this method will take the ownership of the returned point.
115 
116  \note The cloned point will not have the
117  MBR computed. This will save time when you
118  are just cloning a geometry and don't intend
119  to waste time computing the bounding box.
120  If you have another suggestion, please, let me know.
121  */
122  virtual te::dt::AbstractData* clone() const;
123 
124  //@}
125 
126  /** @name Re-Implmentation from AbstractPoint
127  * Methods re-implemented from AbstractPoint.
128  */
129  //@{
130 
131  /*!
132  \brief It returns the Point x-coordinate value.
133 
134  \return The x-coordinate value for this Point.
135  */
136  const double& getX() const { return m_x; }
137 
138  /*!
139  \brief It sets the Point x-coordinate value.
140 
141  \param x The x-coordinate value for this Point.
142  */
143  void setX(const double& x) { m_x = x; }
144 
145  /*!
146  \brief It returns the Point y-coordinate value.
147 
148  \return The y-coordinate value for this Point.
149  */
150  const double& getY() const { return m_y; }
151 
152  /*!
153  \brief It sets the Point y-coordinate value.
154 
155  \param y The y-coordinate value for this Point.
156  */
157  void setY(const double& y) { m_y = y; }
158 
159  /*!
160  \brief It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
161 
162  \return The z-coordinate value for this Point.
163  */
164  virtual const double& getZ() const { return sm_notNumber; }
165 
166  /*!
167  \brief It sets the Point z-coordinate value.
168 
169  \param z The z-coordinate value for this Point.
170  */
171  virtual void setZ(const double& z);
172 
173  /*!
174  \brief It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
175 
176  \return The m-coordinate value for this Point.
177  */
178  virtual const double& getM() const { return sm_notNumber; }
179 
180  /*!
181  \brief It sets the Point m-coordinate value.
182 
183  \param m The m-coordinate value for this Point.
184  */
185  virtual void setM(const double& m);
186 
187  //@}
188 
189  protected:
190 
191  /** @name Protected Initializers
192  * Just subclasses can access these constructors.
193  */
194  //@{
195 
196  /*!
197  \brief It initializes the Geometry with the specified spatial reference system id and envelope.
198 
199  \param t The internal type of the Geometry.
200  \param srid The Spatial Reference System ID associated to the Geometry.
201  \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope). It may be a NULL value.
202 
203  \note The Geometry will take the ownership of the given mbr.
204  */
205  Point(GeomType t, int srid = 0, Envelope* mbr = 0);
206 
207  /*!
208  \brief It initializes the Geometry with the specified spatial reference system id and envelope.
209 
210  \param t The internal type of the Geometry.
211  \param srid The Spatial Reference System ID associated to the Geometry.
212  \param mbr The minimum bounding rectangle of this geometry (i.e., its envelope). It may be a NULL value.
213  \param x The Point x-coordinate value.
214  \param y The Point y-coordinate value.
215 
216  \note The Geometry will take the ownership of the given mbr.
217  */
218  Point(GeomType t, int srid, Envelope* mbr, const double& x, const double& y);
219 
220  //@}
221 
222  protected:
223 
224  double m_x; //!< The Point x-coordinate value.
225  double m_y; //!< The Point y-coordinate value.
226 
227  static const std::string sm_typeName; //!< Geometry type name for Point.
228  static const double sm_notNumber; //!< Just a special value to return in the case of a invalid Geometry.
229  };
230 
231  } // end namespace gm
232 } // end namespace te
233 
234 #endif // __TERRALIB_GEOMETRY_INTERNAL_POINT_H
235 
A base abstract class for 0-dimensional geometric objects that represents a single location in coordi...
virtual const double & getM() const
It returns the Point m-coordinate value, if it has one or DoubleNotANumber otherwise.
Definition: Point.h:178
static const double sm_notNumber
Just a special value to return in the case of a invalid Geometry.
Definition: Point.h:228
GeomType
Each enumerated type is compatible with a Well-known Binary (WKB) type code.
Definition: Enums.h:41
virtual const double & getZ() const
It returns the Point z-coordinate value, if it has one or DoubleNotANumber otherwise.
Definition: Point.h:164
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:79
const double & getY() const
It returns the Point y-coordinate value.
Definition: Point.h:150
A point with x and y coordinate values.
Definition: Point.h:50
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
virtual ~Point()
Virtual destructor.
Definition: Point.h:100
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
double m_y
The Point y-coordinate value.
Definition: Point.h:225
void setX(const double &x)
It sets the Point x-coordinate value.
Definition: Point.h:143
void setY(const double &y)
It sets the Point y-coordinate value.
Definition: Point.h:157
static const std::string sm_typeName
Geometry type name for Point.
Definition: Point.h:227
double m_x
The Point x-coordinate value.
Definition: Point.h:224
A base abstract class for 0-dimensional geometric objects that represents a single location in coordi...
Definition: AbstractPoint.h:50
const double & getX() const
It returns the Point x-coordinate value.
Definition: Point.h:136