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
Matrix3f m
#define GEOGRAPHICLIB_EXPORT
Definition: Constants.hpp:91
return int(ret)+1
static const double lat
Header for GeographicLib::Utility class.
Scalar Scalar * c
Definition: benchVecAdd.cpp:17
static const char *const dmsindicators_
Definition: DMS.hpp:106
static std::string Encode(real angle, unsigned prec, flag ind=NONE, char dmssep=char(0))
Definition: DMS.hpp:329
static const char *const hemispheres_
Definition: DMS.hpp:103
static const char *const signs_
Definition: DMS.hpp:104
Convert between degrees and the DMS representation.
Definition: DMS.hpp:34
Namespace for GeographicLib.
RealScalar s
static std::string str(T x, int p=-1)
Definition: Utility.hpp:276
static const char *const digits_
Definition: DMS.hpp:105
static Math::real Decode(real d, real m=0, real s=0)
Definition: DMS.hpp:223
static void Encode(real ang, real &d, real &m, real &s)
Definition: DMS.hpp:357
Header for GeographicLib::Constants class.
static void Encode(real ang, real &d, real &m)
Definition: DMS.hpp:345
float * p
static void replace(std::string &s, const std::string &pat, char c)
Definition: DMS.hpp:94
Math::real real
Definition: DMS.hpp:92
static const double lon


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:41:59