DMS.hpp
Go to the documentation of this file.
1 
10 #if !defined(GEOGRAPHICLIB_DMS_HPP)
11 #define GEOGRAPHICLIB_DMS_HPP 1
12 
15 
16 #if defined(_MSC_VER)
17 // Squelch warnings about dll vs vector and constant conditional expressions
18 # pragma warning (push)
19 # pragma warning (disable: 4251 4127)
20 #endif
21 
22 namespace GeographicLib {
23 
35  public:
36 
41  enum flag {
46  NONE = 0,
51  LATITUDE = 1,
56  LONGITUDE = 2,
62  AZIMUTH = 3,
67  NUMBER = 4,
68  };
69 
73  enum component {
78  DEGREE = 0,
83  MINUTE = 1,
88  SECOND = 2,
89  };
90 
91  private:
92  typedef Math::real real;
93  // Replace all occurrences of pat by c
94  static void replace(std::string& s, const std::string& pat, char c) {
95  std::string::size_type p = 0;
96  while (true) {
97  p = s.find(pat, p);
98  if (p == std::string::npos)
99  break;
100  s.replace(p, pat.length(), 1, c);
101  }
102  }
103  static const char* const hemispheres_;
104  static const char* const signs_;
105  static const char* const digits_;
106  static const char* const dmsindicators_;
107  static const char* const components_[3];
108  static Math::real NumMatch(const std::string& s);
109  static Math::real InternalDecode(const std::string& dmsa, flag& ind);
110  DMS(); // Disable constructor
111 
112  public:
113 
209  static Math::real Decode(const std::string& dms, flag& ind);
210 
223  static Math::real Decode(real d, real m = 0, real s = 0)
224  { return d + (m + s / 60) / 60; }
225 
249  static void DecodeLatLon(const std::string& dmsa, const std::string& dmsb,
250  real& lat, real& lon,
251  bool longfirst = false);
252 
264  static Math::real DecodeAngle(const std::string& angstr);
265 
278  static Math::real DecodeAzimuth(const std::string& azistr);
279 
308  static std::string Encode(real angle, component trailing, unsigned prec,
309  flag ind = NONE, char dmssep = char(0));
310 
329  static std::string Encode(real angle, unsigned prec, flag ind = NONE,
330  char dmssep = char(0)) {
331  return ind == NUMBER ? Utility::str(angle, int(prec)) :
332  Encode(angle,
333  prec < 2 ? DEGREE : (prec < 4 ? MINUTE : SECOND),
334  prec < 2 ? prec : (prec < 4 ? prec - 2 : prec - 4),
335  ind, dmssep);
336  }
337 
345  static void Encode(real ang, real& d, real& m) {
346  d = int(ang); m = 60 * (ang - d);
347  }
348 
357  static void Encode(real ang, real& d, real& m, real& s) {
358  d = int(ang); ang = 60 * (ang - d);
359  m = int(ang); s = 60 * (ang - m);
360  }
361 
362  };
363 
364 } // namespace GeographicLib
365 
366 #if defined(_MSC_VER)
367 # pragma warning (pop)
368 #endif
369 
370 #endif // GEOGRAPHICLIB_DMS_HPP
ind
std::vector< int > ind
Definition: Slicing_stdvector_cxx11.cpp:1
gtsam.examples.DogLegOptimizerExample.int
int
Definition: DogLegOptimizerExample.py:111
GeographicLib::DMS::digits_
static const char *const digits_
Definition: DMS.hpp:105
GeographicLib::DMS::replace
static void replace(std::string &s, const std::string &pat, char c)
Definition: DMS.hpp:94
s
RealScalar s
Definition: level1_cplx_impl.h:126
d
static const double d[K][N]
Definition: igam.h:11
GeographicLib::Utility::str
static std::string str(T x, int p=-1)
Definition: Utility.hpp:276
GeographicLib
Namespace for GeographicLib.
Definition: JacobiConformal.hpp:15
GeographicLib::DMS::Encode
static std::string Encode(real angle, unsigned prec, flag ind=NONE, char dmssep=char(0))
Definition: DMS.hpp:329
c
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
GeographicLib::DMS::signs_
static const char *const signs_
Definition: DMS.hpp:104
GeographicLib::DMS
Convert between degrees and the DMS representation.
Definition: DMS.hpp:34
GEOGRAPHICLIB_EXPORT
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
GeographicLib::DMS::dmsindicators_
static const char *const dmsindicators_
Definition: DMS.hpp:106
GeographicLib::Math::real
double real
Definition: Math.hpp:129
GeographicLib::DMS::hemispheres_
static const char *const hemispheres_
Definition: DMS.hpp:103
Utility.hpp
Header for GeographicLib::Utility class.
GeographicLib::DMS::flag
flag
Definition: DMS.hpp:41
GeographicLib::DMS::Decode
static Math::real Decode(real d, real m=0, real s=0)
Definition: DMS.hpp:223
m
Matrix3f m
Definition: AngleAxis_mimic_euler.cpp:1
GeographicLib::DMS::Encode
static void Encode(real ang, real &d, real &m, real &s)
Definition: DMS.hpp:357
Constants.hpp
Header for GeographicLib::Constants class.
GeographicLib::DMS::real
Math::real real
Definition: DMS.hpp:92
GeographicLib::DMS::component
component
Definition: DMS.hpp:73
GeographicLib::DMS::Encode
static void Encode(real ang, real &d, real &m)
Definition: DMS.hpp:345
p
float * p
Definition: Tutorial_Map_using.cpp:9
lon
static const double lon
Definition: testGeographicLib.cpp:34
real
Definition: main.h:100
lat
static const double lat
Definition: testGeographicLib.cpp:34


gtsam
Author(s):
autogenerated on Sun Dec 22 2024 04:11:29