PointKd.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/PointKd.h
22 
23  \brief A k-dimensional point.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_POINTKD_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_POINTKD_H
28 
29 // TerraLib
30 #include "AbstractPoint.h"
31 
32 // STL
33 #include <vector>
34 
35 namespace te
36 {
37  namespace gm
38  {
39  /*!
40  \class PointKd
41 
42  \brief A k-dimensional point.
43 
44  \ingroup geometry
45 
46  \sa Geometry,
47  AbstractPoint, Point, PointM, PointZ, PointZM,
48  Curve, LineString, LinearRing, Line, CircularString, CompoundCurve,
49  Surface, Polygon, Triangle, CurvePolygon, PolyhedralSurface, TIN,
50  GeometryCollection, MultiSurface, MultiCurve,
51  MultiPoint, MultiLineString, MultiPolygon
52  */
54  {
55  public:
56 
58 
59  /*!
60  \brief it constructs a new point with k-dimension.
61 
62  \param k The number of dimensions.
63  \param srid The Spatial Reference System ID associated to the point.
64  \param mbr The minimum bounding rectangle of this point (i.e., its envelope).
65  */
66  PointKd(unsigned int k, int srid = 0, Envelope* mbr = 0);
67 
68  /*!
69  \brief Copy constructor.
70 
71  \param rhs The other geometry.
72  */
73  PointKd(const PointKd& rhs);
74 
75  /*! \brief Destructor. */
76  ~PointKd() { }
77 
78  /*!
79  \brief Assignment operator.
80 
81  \param rhs The other geometry.
82 
83  \return A reference for this.
84  */
85  PointKd& operator=(const PointKd& rhs);
86 
87  /*!
88  \brief It returns the i-th coordinate value.
89 
90  \param i The index of the desired coordinate value.
91 
92  \return The i-th coordinate value.
93  */
94  const double& getCoord(std::size_t i) const { return m_coords[i]; }
95 
96  /*!
97  \brief It returns the i-th coordinate value.
98 
99  \param i The index of the desired coordinate value.
100 
101  \return The i-th coordinate value.
102  */
103  double& getCoord(std::size_t i) { return m_coords[i]; }
104 
105  /*!
106  \brief It returns the number of coordinates of the point.
107 
108  \return The number of coordinates of the point.
109  */
110  std::size_t size() const { return m_coords.size(); }
111 
112  /** @name Re-Implementation from AbstractData
113  * Methods re-Implementated from AbstractData.
114  */
115  //@{
116 
117  /*!
118  \brief It clones the point.
119 
120  \return A copy of the given point.
121 
122  \note The caller of this method will take the ownership of the returned point.
123 
124  \note The cloned point will not have the
125  MBR computed. This will save time when you
126  are just cloning a geometry and don't intend
127  to waste time computing the bounding box.
128  If you have another suggestion, please, let me know.
129  */
130  te::dt::AbstractData* clone() const;
131 
132  //@}
133 
134  /** @name Re-Implementation from AbstractPoint
135  * Methods re-Implementated from AbstractPoint.
136  */
137  //@{
138 
139  /*!
140  \brief It returns the point x-coordinate value.
141 
142  \return The x-coordinate value for this point.
143  */
144  const double& getX() const;
145 
146  /*!
147  \brief It sets the point x-coordinate value.
148 
149  \param x The x-coordinate value for this point.
150  */
151  void setX(const double& x);
152 
153  /*!
154  \brief It returns the point y-coordinate value.
155 
156  \return The y-coordinate value for this point.
157  */
158  const double& getY() const;
159 
160  /*!
161  \brief It sets the point y-coordinate value.
162 
163  \param y The y-coordinate value for this point.
164  */
165  void setY(const double& y);
166 
167  /*!
168  \brief It returns the point z-coordinate value, if it has one or TE_DOUBLE_NOT_A_NUMBER otherwise.
169 
170  \return The z-coordinate value for this point.
171  */
172  const double& getZ() const;
173 
174  /*!
175  \brief It sets the point z-coordinate value.
176 
177  \param z The z-coordinate value for this point.
178  */
179  void setZ(const double& z);
180 
181  /*!
182  \brief It returns TE_DOUBLE_NOT_A_NUMBER.
183 
184  \return TE_DOUBLE_NOT_A_NUMBER.
185  */
186  const double& getM() const;
187 
188  /*!
189  \brief It doesn't perform any operation in a Kd point.
190 
191  \param m The m-coordinate value for this point.
192  */
193  void setM(const double& m);
194 
195  //@}
196 
197  private:
198 
199  std::vector<double> m_coords; //!< The array of coordinates.
200  };
201 
202  } // end namespace gm
203 } // end namespace te
204 
205 #endif // __TERRALIB_GEOMETRY_INTERNAL_POINTKD_H
206 
A base abstract class for 0-dimensional geometric objects that represents a single location in coordi...
std::vector< double > m_coords
The array of coordinates.
Definition: PointKd.h:199
~PointKd()
Destructor.
Definition: PointKd.h:76
const double & getCoord(std::size_t i) const
It returns the i-th coordinate value.
Definition: PointKd.h:94
double & getCoord(std::size_t i)
It returns the i-th coordinate value.
Definition: PointKd.h:103
#define TEGEOMEXPORT
You can use this macro in order to export/import classes and functions from this module.
Definition: Config.h:76
A k-dimensional point.
Definition: PointKd.h:53
An Envelope defines a 2D rectangular region.
Definition: Envelope.h:51
URI C++ Library.
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
A base abstract class for 0-dimensional geometric objects that represents a single location in coordi...
Definition: AbstractPoint.h:50
std::size_t size() const
It returns the number of coordinates of the point.
Definition: PointKd.h:110