GeoCoords.hpp
Go to the documentation of this file.
1 
10 #if !defined(GEOGRAPHICLIB_GEOCOORDS_HPP)
11 #define GEOGRAPHICLIB_GEOCOORDS_HPP 1
12 
13 #include <GeographicLib/UTMUPS.hpp>
15 
16 namespace GeographicLib {
17 
50  private:
51  typedef Math::real real;
52  real _lat, _long, _easting, _northing, _gamma, _k;
53  bool _northp;
54  int _zone; // See UTMUPS::zonespec
55  mutable real _alt_easting, _alt_northing, _alt_gamma, _alt_k;
56  mutable int _alt_zone;
57 
58  void CopyToAlt() const {
59  _alt_easting = _easting;
60  _alt_northing = _northing;
61  _alt_gamma = _gamma;
62  _alt_k = _k;
63  _alt_zone = _zone;
64  }
65  static void UTMUPSString(int zone, bool northp,
66  real easting, real northing,
67  int prec, bool abbrev, std::string& utm);
68  void FixHemisphere();
69  public:
70 
73 
78  : _lat(Math::NaN())
79  , _long(Math::NaN())
80  , _easting(Math::NaN())
81  , _northing(Math::NaN())
82  , _gamma(Math::NaN())
83  , _k(Math::NaN())
84  , _northp(false)
85  , _zone(UTMUPS::INVALID)
86  { CopyToAlt(); }
87 
179  explicit GeoCoords(const std::string& s,
180  bool centerp = true, bool longfirst = false)
181  { Reset(s, centerp, longfirst); }
182 
194  GeoCoords(real latitude, real longitude, int zone = UTMUPS::STANDARD) {
195  Reset(latitude, longitude, zone);
196  }
197 
208  GeoCoords(int zone, bool northp, real easting, real northing) {
209  Reset(zone, northp, easting, northing);
210  }
211 
223  void Reset(const std::string& s,
224  bool centerp = true, bool longfirst = false);
225 
238  void Reset(real latitude, real longitude, int zone = UTMUPS::STANDARD) {
239  UTMUPS::Forward(latitude, longitude,
240  _zone, _northp, _easting, _northing, _gamma, _k,
241  zone);
242  _lat = latitude;
243  _long = longitude;
244  if (_long >= 180) _long -= 360;
245  else if (_long < -180) _long += 360;
246  CopyToAlt();
247  }
248 
260  void Reset(int zone, bool northp, real easting, real northing) {
261  UTMUPS::Reverse(zone, northp, easting, northing,
262  _lat, _long, _gamma, _k);
263  _zone = zone;
264  _northp = northp;
265  _easting = easting;
266  _northing = northing;
267  FixHemisphere();
268  CopyToAlt();
269  }
271 
274 
278  Math::real Latitude() const { return _lat; }
279 
283  Math::real Longitude() const { return _long; }
284 
288  Math::real Easting() const { return _easting; }
289 
293  Math::real Northing() const { return _northing; }
294 
298  Math::real Convergence() const { return _gamma; }
299 
303  Math::real Scale() const { return _k; }
304 
308  bool Northp() const { return _northp; }
309 
313  char Hemisphere() const { return _northp ? 'n' : 's'; }
314 
318  int Zone() const { return _zone; }
319 
321 
324 
337  void SetAltZone(int zone = UTMUPS::STANDARD) const {
338  if (zone == UTMUPS::MATCH)
339  return;
340  zone = UTMUPS::StandardZone(_lat, _long, zone);
341  if (zone == _zone)
342  CopyToAlt();
343  else {
344  bool northp;
345  UTMUPS::Forward(_lat, _long,
346  _alt_zone, northp,
347  _alt_easting, _alt_northing, _alt_gamma, _alt_k,
348  zone);
349  }
350  }
351 
355  int AltZone() const { return _alt_zone; }
356 
360  Math::real AltEasting() const { return _alt_easting; }
361 
365  Math::real AltNorthing() const { return _alt_northing; }
366 
370  Math::real AltConvergence() const { return _alt_gamma; }
371 
375  Math::real AltScale() const { return _alt_k; }
377 
380 
396  std::string GeoRepresentation(int prec = 0, bool longfirst = false) const;
397 
419  std::string DMSRepresentation(int prec = 0, bool longfirst = false,
420  char dmssep = char(0))
421  const;
422 
445  std::string MGRSRepresentation(int prec = 0) const;
446 
465  std::string UTMUPSRepresentation(int prec = 0, bool abbrev = true) const;
466 
480  std::string UTMUPSRepresentation(bool northp, int prec = 0,
481  bool abbrev = true) const;
482 
490  std::string AltMGRSRepresentation(int prec = 0) const;
491 
503  std::string AltUTMUPSRepresentation(int prec = 0, bool abbrev = true)
504  const;
505 
519  std::string AltUTMUPSRepresentation(bool northp, int prec = 0,
520  bool abbrev = true) const;
522 
525 
533 
542 
543  };
544 
545 } // namespace GeographicLib
546 
547 #endif // GEOGRAPHICLIB_GEOCOORDS_HPP
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
GeoCoords(int zone, bool northp, real easting, real northing)
Definition: GeoCoords.hpp:208
Math::real Northing() const
Definition: GeoCoords.hpp:293
static Math::real Flattening()
Definition: UTMUPS.hpp:414
Header for GeographicLib::UTMUPS class.
Math::real AltScale() const
Definition: GeoCoords.hpp:375
GeoCoords(real latitude, real longitude, int zone=UTMUPS::STANDARD)
Definition: GeoCoords.hpp:194
Mathematical functions needed by GeographicLib.
Definition: Math.hpp:102
Conversion between geographic coordinates.
Definition: GeoCoords.hpp:49
static Math::real MajorRadius()
Definition: UTMUPS.hpp:405
Math::real Scale() const
Definition: GeoCoords.hpp:303
Math::real AltEasting() const
Definition: GeoCoords.hpp:360
void Reset(real latitude, real longitude, int zone=UTMUPS::STANDARD)
Definition: GeoCoords.hpp:238
static void Forward(real lat, real lon, int &zone, bool &northp, real &x, real &y, real &gamma, real &k, int setzone=STANDARD, bool mgrslimits=false)
Definition: src/UTMUPS.cpp:67
Math::real Easting() const
Definition: GeoCoords.hpp:288
Convert between geographic coordinates and UTM/UPS.
Definition: UTMUPS.hpp:75
Math::real MajorRadius() const
Definition: GeoCoords.hpp:532
Namespace for GeographicLib.
void CopyToAlt() const
Definition: GeoCoords.hpp:58
RealScalar s
Math::real AltNorthing() const
Definition: GeoCoords.hpp:365
Math::real Longitude() const
Definition: GeoCoords.hpp:283
static void Reverse(int zone, bool northp, real x, real y, real &lat, real &lon, real &gamma, real &k, bool mgrslimits=false)
Definition: src/UTMUPS.cpp:121
Header for GeographicLib::Constants class.
Math::real Convergence() const
Definition: GeoCoords.hpp:298
void Reset(int zone, bool northp, real easting, real northing)
Definition: GeoCoords.hpp:260
Math::real Latitude() const
Definition: GeoCoords.hpp:278
void SetAltZone(int zone=UTMUPS::STANDARD) const
Definition: GeoCoords.hpp:337
Math::real AltConvergence() const
Definition: GeoCoords.hpp:370
GeoCoords(const std::string &s, bool centerp=true, bool longfirst=false)
Definition: GeoCoords.hpp:179
Math::real Flattening() const
Definition: GeoCoords.hpp:540
static int StandardZone(real lat, real lon, int setzone=STANDARD)
Definition: src/UTMUPS.cpp:43


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:34:17