10 #if !defined(GEOGRAPHICLIB_DMS_HPP)
11 #define GEOGRAPHICLIB_DMS_HPP 1
18 # pragma warning (push)
19 # pragma warning (disable: 4251 4127)
38 static void replace(std::string& s,
const std::string& pat,
char c) {
39 std::string::size_type p = 0;
42 if (p == std::string::npos)
44 s.replace(p, pat.length(), 1, c);
47 static const std::string hemispheres_;
48 static const std::string signs_;
49 static const std::string digits_;
50 static const std::string dmsindicators_;
51 static const std::string components_[3];
52 static Math::real NumMatch(
const std::string& s);
179 static Math::real Decode(
const std::string& dms, flag& ind);
194 {
return d + (m + s / 60) / 60; }
205 static Math::real Decode(
const std::string& str)
206 {
return Utility::num<real>(str); }
217 static Math::real DecodeFraction(
const std::string& str)
218 {
return Utility::fract<real>(str); }
247 static void DecodeLatLon(
const std::string& dmsa,
const std::string& dmsb,
248 real& lat, real& lon,
bool swaplatlong =
false);
261 static Math::real DecodeAngle(
const std::string& angstr);
277 static Math::real DecodeAzimuth(
const std::string& azistr);
306 static std::string Encode(real angle, component trailing,
unsigned prec,
307 flag ind = NONE,
char dmssep =
char(0));
327 static std::string
Encode(real angle,
unsigned prec,
flag ind = NONE,
328 char dmssep =
char(0)) {
331 prec < 2 ? DEGREE : (prec < 4 ? MINUTE : SECOND),
332 prec < 2 ? prec : (prec < 4 ? prec - 2 : prec - 4),
343 static void Encode(real ang, real& d, real& m) {
344 d = int(ang); m = 60 * (ang - d);
355 static void Encode(real ang, real& d, real& m, real& s) {
356 d = int(ang); ang = 60 * (ang - d);
357 m = int(ang); s = 60 * (ang - m);
364 #if defined(_MSC_VER)
365 # pragma warning (pop)
368 #endif // GEOGRAPHICLIB_DMS_HPP
#define GEOGRAPHICLIB_EXPORT
GeographicLib::Math::real real
Header for GeographicLib::Utility class.
static std::string Encode(real angle, unsigned prec, flag ind=NONE, char dmssep=char(0))
Convert between degrees and the DMS representation.
Namespace for GeographicLib.
static std::string str(T x, int p=-1)
static Math::real Decode(real d, real m=0, real s=0)
static void Encode(real ang, real &d, real &m, real &s)
Header for GeographicLib::Constants class.
static void Encode(real ang, real &d, real &m)