All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Coord2D.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/Coord2D.h
22 
23  \brief An utility struct for representing 2D coordinates.
24 */
25 
26 #ifndef __TERRALIB_GEOMETRY_INTERNAL_COORD2D_H
27 #define __TERRALIB_GEOMETRY_INTERNAL_COORD2D_H
28 
29 namespace te
30 {
31  namespace gm
32  {
33  /*!
34  \struct Coord2D
35 
36  \brief An utility struct for representing 2D coordinates.
37 
38  \ingroup geometry
39  */
40  struct Coord2D
41  {
42  /*! \brief Constructor. */
43  Coord2D() { }
44 
45  /*!
46  \brief Constructor.
47 
48  \param xx The x-coordinate.
49  \param yy The y-coordinate.
50  */
51  Coord2D(const double& xx, const double& yy)
52  : x(xx),
53  y(yy)
54  {
55  }
56 
57  /*!
58  \brief Copy constructor.
59 
60  \param rhs The right-hand-side instance.
61  */
62  Coord2D(const Coord2D& rhs)
63  : x(rhs.x),
64  y(rhs.y)
65  {
66  }
67 
68  /*!
69  \brief It compares if two coordinates have the same exact values.
70 
71  \param rhs The right-hand-side coordinate.
72 
73  \return True if they have exact the same values.
74  */
75  bool operator==(const Coord2D& rhs) const
76  {
77  if(x != rhs.x)
78  return false;
79 
80  if(y != rhs.y)
81  return false;
82 
83  return true;
84  }
85 
86  /*! \brief Lexicographic compare (x-y). */
87  bool operator<(const Coord2D& rhs) const
88  {
89  if(x < rhs.x)
90  return true;
91 
92  if(x > rhs.x)
93  return false;
94 
95  if(y < rhs.y)
96  return true;
97 
98  return false;
99  }
100 
101  /*! \brief It returns the x-coordinate. */
102  double getX() const
103  {
104  return x;
105  }
106 
107  /*! \brief It returns the y-coordinate. */
108  double getY() const
109  {
110  return y;
111  }
112 
113  double x; //!< x-coordinate.
114  double y; //!< y-coordinate.
115  };
116 
117  } // end namespace gm
118 } // end namespace te
119 
120 #endif // __TERRALIB_GEOMETRY_INTERNAL_COORD2D_H
121 
double y
y-coordinate.
Definition: Coord2D.h:114
double x
x-coordinate.
Definition: Coord2D.h:113
An utility struct for representing 2D coordinates.
Definition: Coord2D.h:40
double getY() const
It returns the y-coordinate.
Definition: Coord2D.h:108
Coord2D(const Coord2D &rhs)
Copy constructor.
Definition: Coord2D.h:62
bool operator<(const Coord2D &rhs) const
Lexicographic compare (x-y).
Definition: Coord2D.h:87
double getX() const
It returns the x-coordinate.
Definition: Coord2D.h:102
Coord2D()
Constructor.
Definition: Coord2D.h:43
bool operator==(const Coord2D &rhs) const
It compares if two coordinates have the same exact values.
Definition: Coord2D.h:75
Coord2D(const double &xx, const double &yy)
Constructor.
Definition: Coord2D.h:51