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
GeographicLib::UTMUPS::Flattening
static Math::real Flattening()
Definition: UTMUPS.hpp:414
GeographicLib::GeoCoords::GeoCoords
GeoCoords(real latitude, real longitude, int zone=UTMUPS::STANDARD)
Definition: GeoCoords.hpp:194
s
RealScalar s
Definition: level1_cplx_impl.h:126
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
GeographicLib::GeoCoords::AltScale
Math::real AltScale() const
Definition: GeoCoords.hpp:375
GeographicLib::GeoCoords::Easting
Math::real Easting() const
Definition: GeoCoords.hpp:288
GeographicLib::GeoCoords::Reset
void Reset(real latitude, real longitude, int zone=UTMUPS::STANDARD)
Definition: GeoCoords.hpp:238
GEOGRAPHICLIB_EXPORT
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
GeographicLib::GeoCoords::Northp
bool Northp() const
Definition: GeoCoords.hpp:308
GeographicLib::UTMUPS::MATCH
@ MATCH
Definition: UTMUPS.hpp:122
GeographicLib::GeoCoords::Flattening
Math::real Flattening() const
Definition: GeoCoords.hpp:540
GeographicLib::GeoCoords::_alt_northing
real _alt_northing
Definition: GeoCoords.hpp:55
GeographicLib::GeoCoords::CopyToAlt
void CopyToAlt() const
Definition: GeoCoords.hpp:58
GeographicLib::UTMUPS::MajorRadius
static Math::real MajorRadius()
Definition: UTMUPS.hpp:405
UTMUPS.hpp
Header for GeographicLib::UTMUPS class.
GeographicLib::GeoCoords::AltZone
int AltZone() const
Definition: GeoCoords.hpp:355
GeographicLib::GeoCoords::Convergence
Math::real Convergence() const
Definition: GeoCoords.hpp:298
GeographicLib::GeoCoords::Longitude
Math::real Longitude() const
Definition: GeoCoords.hpp:283
GeographicLib::Math::real
double real
Definition: Math.hpp:129
GeographicLib::GeoCoords
Conversion between geographic coordinates.
Definition: GeoCoords.hpp:49
GeographicLib::Math
Mathematical functions needed by GeographicLib.
Definition: Math.hpp:102
GeographicLib::GeoCoords::Latitude
Math::real Latitude() const
Definition: GeoCoords.hpp:278
GeographicLib::GeoCoords::_northp
bool _northp
Definition: GeoCoords.hpp:53
GeographicLib::GeoCoords::Scale
Math::real Scale() const
Definition: GeoCoords.hpp:303
GeographicLib::UTMUPS::STANDARD
@ STANDARD
Definition: UTMUPS.hpp:138
GeographicLib::GeoCoords::Zone
int Zone() const
Definition: GeoCoords.hpp:318
GeographicLib::UTMUPS::Forward
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
GeographicLib::GeoCoords::real
Math::real real
Definition: GeoCoords.hpp:51
Constants.hpp
Header for GeographicLib::Constants class.
GeographicLib::GeoCoords::GeoCoords
GeoCoords(int zone, bool northp, real easting, real northing)
Definition: GeoCoords.hpp:208
GeographicLib::GeoCoords::GeoCoords
GeoCoords()
Definition: GeoCoords.hpp:77
GeographicLib::GeoCoords::_zone
int _zone
Definition: GeoCoords.hpp:54
GeographicLib::GeoCoords::Reset
void Reset(int zone, bool northp, real easting, real northing)
Definition: GeoCoords.hpp:260
GeographicLib::GeoCoords::SetAltZone
void SetAltZone(int zone=UTMUPS::STANDARD) const
Definition: GeoCoords.hpp:337
GeographicLib::GeoCoords::MajorRadius
Math::real MajorRadius() const
Definition: GeoCoords.hpp:532
GeographicLib::UTMUPS
Convert between geographic coordinates and UTM/UPS.
Definition: UTMUPS.hpp:75
GeographicLib::GeoCoords::Northing
Math::real Northing() const
Definition: GeoCoords.hpp:293
GeographicLib::GeoCoords::GeoCoords
GeoCoords(const std::string &s, bool centerp=true, bool longfirst=false)
Definition: GeoCoords.hpp:179
GeographicLib::UTMUPS::Reverse
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
GeographicLib::GeoCoords::_alt_zone
int _alt_zone
Definition: GeoCoords.hpp:56
GeographicLib::GeoCoords::_northing
real _northing
Definition: GeoCoords.hpp:52
GeographicLib::UTMUPS::StandardZone
static int StandardZone(real lat, real lon, int setzone=STANDARD)
Definition: src/UTMUPS.cpp:43
GeographicLib::GeoCoords::AltEasting
Math::real AltEasting() const
Definition: GeoCoords.hpp:360
GeographicLib::GeoCoords::Hemisphere
char Hemisphere() const
Definition: GeoCoords.hpp:313
INVALID
#define INVALID
Definition: gtsam/3rdparty/Eigen/blas/common.h:45
real
Definition: main.h:100
GeographicLib::GeoCoords::AltNorthing
Math::real AltNorthing() const
Definition: GeoCoords.hpp:365
GeographicLib::GeoCoords::AltConvergence
Math::real AltConvergence() const
Definition: GeoCoords.hpp:370


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:02:21