UTMPoint.h
Go to the documentation of this file.
1 #ifndef _utl_UTMPoint_h_
2 #define _utl_UTMPoint_h_
3 
4 #include <utl/CoordinateSystem.h>
5 #include <utl/ReferenceEllipsoid.h>
6 
7 #include <boost/tuple/tuple.hpp>
8 #include <string>
9 
10 
11 namespace utl {
12 
13  class Point;
14 
15 
40  class UTMPoint {
41  public:
43  enum ZoneRange {
44  eZoneMin = 1,
45  eZoneMax = 60
46  };
47 
49 
62  UTMPoint(const double theNorthing, const double theEasting,
63  const double theHeight,
64  const int theZone, const char theBand,
65  const ReferenceEllipsoid& theEllipsoid) :
66  fNorthing(theNorthing),
67  fEasting(theEasting),
68  fHeight(theHeight),
69  fZone(theZone),
70  fBand(theBand),
71  fEllipsoid(&theEllipsoid)
72  {
73  VerifyZone();
74  }
75 
77 
90  UTMPoint(const double theNorthing, const double theEasting,
91  const double theHeight,
92  const int theZone, const char theBand,
93  const ReferenceEllipsoid::EllipsoidID theEllipsoidID) :
94  fNorthing(theNorthing),
95  fEasting(theEasting),
96  fHeight(theHeight),
97  fZone(theZone),
98  fBand(theBand),
99  fEllipsoid(&ReferenceEllipsoid::Get(theEllipsoidID))
100  {
101  VerifyZone();
102  }
103 
105 
110  UTMPoint(const UTMPoint& theUTMPoint,
111  const ReferenceEllipsoid& theEllipsoid)
112  : fEllipsoid(&theEllipsoid) { SetFromOtherDatum(theUTMPoint); }
113 
115 
120  UTMPoint(const UTMPoint& theUTMPoint,
121  const ReferenceEllipsoid::EllipsoidID theEllipsoidID) :
122  fEllipsoid(&ReferenceEllipsoid::Get(theEllipsoidID))
123  {
124  SetFromOtherDatum(theUTMPoint);
125  }
126 
128 
133  UTMPoint(const Point& thePoint, const ReferenceEllipsoid& theEllipsoid)
134  : fEllipsoid(&theEllipsoid) { SetFromCartesian(thePoint); }
135 
137 
142  UTMPoint(const Point& thePoint,
143  const ReferenceEllipsoid::EllipsoidID theEllipsoidID) :
144  fEllipsoid(&ReferenceEllipsoid::Get(theEllipsoidID))
145  {
146  SetFromCartesian(thePoint);
147  }
148 
150 
157  UTMPoint(const double theLatitude,
158  const double theLongitude,
159  const double theHeight,
160  const ReferenceEllipsoid& theEllipsoid) :
161  fHeight(theHeight),
162  fEllipsoid(&theEllipsoid)
163  {
164  SetFromLatitudeLongitude(theLatitude, theLongitude);
165  }
166 
168 
175  UTMPoint(const double theLatitude,
176  const double theLongitude,
177  const double theHeight,
178  const ReferenceEllipsoid::EllipsoidID theEllipsoidID) :
179  fHeight(theHeight),
180  fEllipsoid(&ReferenceEllipsoid::Get(theEllipsoidID))
181  {
182  SetFromLatitudeLongitude(theLatitude, theLongitude);
183  }
184 
186  ~UTMPoint() { }
187 
189  bool
190  operator==(const UTMPoint& rhs)
191  const
192  {
193  return fNorthing == rhs.fNorthing &&
194  fEasting == rhs.fEasting &&
195  fHeight == rhs.fHeight &&
196  fZone == rhs.fZone &&
197  fBand == rhs.fBand &&
198  *fEllipsoid == *rhs.fEllipsoid;
199  }
200 
202  bool operator!=(const UTMPoint& rhs) const
203  { return !operator==(rhs); }
204 
206  double GetNorthing() const { return fNorthing; }
207 
209  double GetEasting() const { return fEasting; }
210 
212  double GetHeight() const { return fHeight; }
213 
215  int GetZone() const { return fZone; }
216 
218  char GetBand() const { return fBand; }
219 
221  const ReferenceEllipsoid& GetEllipsoid() const { return *fEllipsoid; }
222 
224  boost::tuple<double, double, double> GetCoordinates3() const
225  { return boost::make_tuple(fNorthing, fEasting, fHeight); }
226 
228  boost::tuple<double, double, double, int> GetCoordinates4() const
229  { return boost::make_tuple(fNorthing, fEasting, fHeight, fZone); }
230 
232  boost::tuple<double, double, double, int, char> GetCoordinates() const
233  { return boost::make_tuple(fNorthing, fEasting, fHeight, fZone, fBand); }
234 
236  boost::tuple<double, double, double> GetGeodeticCoordinates() const;
237 
239 
245  Point GetPoint(const CoordinateSystemPtr& theCS = CoordinateSystemPtr()) const;
246 
251  class UTMException;
252 
257  class UTMZoneException;
258 
259  private:
261  void VerifyZone();
262 
264  void SetFromOtherDatum(const UTMPoint& theUTMPoint);
266  void SetFromCartesian(const Point& thePoint);
268  void SetFromLatitudeLongitude(const double theLatitude,
269  const double theLongitude);
270 
272  static char BandFromLatitude(const double theLatitude);
274  static int ZoneFromLatitudeLongitude(const double theLatitude,
275  const double theLongitude);
276 
277  double fNorthing;
278  double fEasting;
279  double fHeight;
281  int fZone;
283  char fBand;
284  const ReferenceEllipsoid* fEllipsoid; // pretend-reference
285  };
286 
287 
289  public:
291  UTMException(std::string message = std::string())
292  : AugerException(message) { }
293 
295  virtual std::string GetExceptionName() const
296  { return "Invalid UTM operation exception"; }
297  };
298 
299 
301  public:
303  UTMZoneException(std::string message = std::string())
304  : UTMException(message) { }
305 
307  virtual std::string GetExceptionName() const
308  { return "Invalid UTM zone exception"; }
309  };
310 
311 
313  std::ostream& operator<<(std::ostream& s, const UTMPoint& p);
314 
315 }
316 
317 
318 #endif
bool operator==(const UTMPoint &rhs) const
equality operator
Definition: UTMPoint.h:190
Point object.
Definition: Point.h:32
UTMPoint(const UTMPoint &theUTMPoint, const ReferenceEllipsoid::EllipsoidID theEllipsoidID)
Construct UTMPoint with an alternative reference ellipsoid.
Definition: UTMPoint.h:120
Base class for all exceptions used in the auger offline code.
double fHeight
Definition: UTMPoint.h:279
UTMPoint(const Point &thePoint, const ReferenceEllipsoid &theEllipsoid)
Construct UTMPoint from cartesian point with given reference ellipsoid.
Definition: UTMPoint.h:133
boost::tuple< double, double, double, int, char > GetCoordinates() const
Get norting, easting, height, zone, and band.
Definition: UTMPoint.h:232
Class to hold and convert a point in geodetic coordinates.
Definition: UTMPoint.h:40
static int ZoneFromLatitudeLongitude(const double theLatitude, const double theLongitude)
Calculate zone number from latitude and longitude.
Definition: UTMPoint.cc:274
UTMPoint(const Point &thePoint, const ReferenceEllipsoid::EllipsoidID theEllipsoidID)
Construct UTMPoint from cartesian point with named reference ellipsoid.
Definition: UTMPoint.h:142
void SetFromOtherDatum(const UTMPoint &theUTMPoint)
Datum transformation.
Definition: UTMPoint.cc:142
int GetZone() const
Get the zone.
Definition: UTMPoint.h:215
char GetBand() const
Get the band.
Definition: UTMPoint.h:218
double GetNorthing() const
Get the northing.
Definition: UTMPoint.h:206
Report attempts to use invalid UTM zone.
Definition: UTMPoint.h:300
Stream & operator<<(Stream &s, MessageLoggerConfig &mlc)
Applies the configuration to the given stream.
void VerifyZone()
verify zone and throw exception if out of bounds
Definition: UTMPoint.cc:257
UTMPoint(const UTMPoint &theUTMPoint, const ReferenceEllipsoid &theEllipsoid)
Construct UTMPoint with an alternative reference ellipsoid.
Definition: UTMPoint.h:110
boost::shared_ptr< const CoordinateTransformer > CoordinateSystemPtr
Shared pointer for coordinate systems.
constexpr double s
Definition: AugerUnits.h:163
Reference ellipsoids for UTM transformations.
UTMPoint(const double theNorthing, const double theEasting, const double theHeight, const int theZone, const char theBand, const ReferenceEllipsoid::EllipsoidID theEllipsoidID)
Construct UTMPoint from the UTM information, ellipsoid by name.
Definition: UTMPoint.h:90
double GetHeight() const
Get the height.
Definition: UTMPoint.h:212
ZoneRange
range of zone numbers
Definition: UTMPoint.h:43
double GetEasting() const
Get the easting.
Definition: UTMPoint.h:209
Maximum UTM zone number.
Definition: UTMPoint.h:45
UTMPoint(const double theLatitude, const double theLongitude, const double theHeight, const ReferenceEllipsoid::EllipsoidID theEllipsoidID)
Construct UTMPoint from geodetic Coordinates with named ellipsoid.
Definition: UTMPoint.h:175
Report attempts to use invalid UTM zone.
int fZone
zone runs from 1 to 60
Definition: UTMPoint.h:281
bool operator!=(const UTMPoint &rhs) const
inequality operator
Definition: UTMPoint.h:202
double fNorthing
Definition: UTMPoint.h:277
boost::tuple< double, double, double, int > GetCoordinates4() const
Get norting, easting, height, and zone.
Definition: UTMPoint.h:228
boost::tuple< double, double, double > GetCoordinates3() const
Get norting, easting, and height.
Definition: UTMPoint.h:224
Report problems in UTM handling.
Definition: UTMPoint.h:288
double fEasting
Definition: UTMPoint.h:278
~UTMPoint()
Destructor - should be virtual for base classes.
Definition: UTMPoint.h:186
const ReferenceEllipsoid & GetEllipsoid() const
Get the reference ellipsoid.
Definition: UTMPoint.h:221
const ReferenceEllipsoid * fEllipsoid
Definition: UTMPoint.h:284
UTMPoint(const double theLatitude, const double theLongitude, const double theHeight, const ReferenceEllipsoid &theEllipsoid)
Construct UTMPoint from geodetic Coordinates with given ellipsoid.
Definition: UTMPoint.h:157
UTMPoint(const double theNorthing, const double theEasting, const double theHeight, const int theZone, const char theBand, const ReferenceEllipsoid &theEllipsoid)
Construct UTMPoint from the UTM information.
Definition: UTMPoint.h:62
char fBand
Letter indicating band, C-X, w/o O, I.
Definition: UTMPoint.h:283
void SetFromLatitudeLongitude(const double theLatitude, const double theLongitude)
Construction from geodetic Latitude and Longitude (height identical)
Definition: UTMPoint.cc:179
utl::CoordinateSystemPtr Get(const std::string &id)
Get a well-known Coordinate System.
static char BandFromLatitude(const double theLatitude)
Calculate band letter from latitude and longitude.
Definition: UTMPoint.cc:302
EllipsoidID
ID&#39;s of known reference ellipsoid&#39;s.
void SetFromCartesian(const Point &thePoint)
Construction from Cartesian coordinates.
Definition: UTMPoint.cc:160
Point GetPoint(const CoordinateSystemPtr &theCS=CoordinateSystemPtr()) const
Get a cartesian point from an UTMPoint.
Definition: UTMPoint.cc:45
boost::tuple< double, double, double > GetGeodeticCoordinates() const
Get geodetic latitude, longitude, height.
Definition: UTMPoint.cc:67
Minimum UTM zone number.
Definition: UTMPoint.h:44

, generated on Tue Sep 26 2023.