Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JUTMPosition.hh
Go to the documentation of this file.
1 #ifndef __JUTM__JUTMPOSITION__
2 #define __JUTM__JUTMPOSITION__
3 
4 #include <istream>
5 #include <ostream>
6 
8 #include "JIO/JSerialisable.hh"
9 
10 
11 /**
12  * \author mdejong
13  */
14 
15 namespace JUTM {}
16 namespace JPP { using namespace JUTM; }
17 
18 namespace JUTM {
19 
22  using JIO::JReader;
23  using JIO::JWriter;
24 
25 
26  /**
27  * Data structure for UTM position.
28  * The z-coordinate corresponds to the depth where <tt>z = 0</tt> is at sea level.
29  */
30  class JUTMPosition {
31  public:
32  /**
33  * Default constructor.
34  */
36  east (0.0),
37  north(0.0),
38  z (0.0)
39  {}
40 
41 
42  /**
43  * Constructor.
44  *
45  * \param pos UTM position
46  */
47  JUTMPosition(const JVector3D& pos) :
48  east (pos.getX()),
49  north(pos.getY()),
50  z (pos.getZ())
51  {}
52 
53 
54  /**
55  * Constructor.
56  *
57  * \param east UTM East
58  * \param north UTM North
59  * \param z UTM Z
60  */
61  JUTMPosition(const double east,
62  const double north,
63  const double z)
64  {
65  this->east = east;
66  this->north = north;
67  this->z = z;
68  }
69 
70 
71  /**
72  * Get position.
73  *
74  * \return position
75  */
77  {
78  return JPosition3D(east, north, z);
79  }
80 
81 
82  /**
83  * Get UTM east.
84  *
85  * \return UTM East
86  */
87  double getUTMEast() const
88  {
89  return this->east;
90  }
91 
92 
93  /**
94  * Get UTM north.
95  *
96  * \return UTM North
97  */
98  double getUTMNorth() const
99  {
100  return this->north;
101  }
102 
103 
104  /**
105  * Get UTM Z.
106  *
107  * \return UTM Z
108  */
109  double getUTMZ() const
110  {
111  return this->z;
112  }
113 
114 
115  /**
116  * Read UTM position from input.
117  *
118  * \param in input stream
119  * \param pos UTM position
120  * \return input stream
121  */
122  friend inline std::istream& operator>>(std::istream& in, JUTMPosition& pos)
123  {
124  return in >> pos.east >> pos.north >> pos.z;
125  }
126 
127 
128  /**
129  * Write UTM position to output.
130  *
131  * \param out output stream
132  * \param pos UTM position
133  * \return output stream
134  */
135  friend inline std::ostream& operator<<(std::ostream& out, const JUTMPosition& pos)
136  {
137  return out << pos.east << ' ' << pos.north << ' ' << pos.z;
138  }
139 
140 
141 
142  /**
143  * Read UTM position from input.
144  *
145  * \param in input stream
146  * \param pos UTM position
147  * \return input stream
148  */
149  friend inline JReader& operator>>(JReader& in, JUTMPosition& pos)
150  {
151  return in >> pos.east >> pos.north >> pos.z;
152  }
153 
154 
155  /**
156  * Write UTM position to output.
157  *
158  * \param out output stream
159  * \param pos UTM position
160  * \return output stream
161  */
162  friend inline JWriter& operator<<(JWriter& out, const JUTMPosition& pos)
163  {
164  return out << pos.east << pos.north << pos.z;
165  }
166 
167 
168  protected:
169  double east;
170  double north;
171  double z;
172  };
173 }
174 
175 #endif
Interface for binary output.
JUTMPosition()
Default constructor.
Definition: JUTMPosition.hh:35
double getUTMEast() const
Get UTM east.
Definition: JUTMPosition.hh:87
friend JWriter & operator<<(JWriter &out, const JUTMPosition &pos)
Write UTM position to output.
friend JReader & operator>>(JReader &in, JUTMPosition &pos)
Read UTM position from input.
Data structure for UTM position.
Definition: JUTMPosition.hh:30
double getUTMZ() const
Get UTM Z.
double getUTMNorth() const
Get UTM north.
Definition: JUTMPosition.hh:98
Data structure for vector in three dimensions.
Definition: JVector3D.hh:32
Interface for binary input.
JUTMPosition(const JVector3D &pos)
Constructor.
Definition: JUTMPosition.hh:47
JPosition3D getPosition() const
Get position.
Definition: JUTMPosition.hh:76
friend std::istream & operator>>(std::istream &in, JUTMPosition &pos)
Read UTM position from input.
Data structure for position in three dimensions.
Definition: JPosition3D.hh:35
friend std::ostream & operator<<(std::ostream &out, const JUTMPosition &pos)
Write UTM position to output.
JUTMPosition(const double east, const double north, const double z)
Constructor.
Definition: JUTMPosition.hh:61