Convert between degrees to DMS representation. More...
#include <GeographicLib/DMS.hpp>
Public Types | |
enum | flag { NONE = 0, LATITUDE = 1, LONGITUDE = 2, AZIMUTH = 3 } |
enum | component { DEGREE = 0, MINUTE = 1, SECOND = 2 } |
Static Public Member Functions | |
static double | Decode (const std::string &dms, flag &ind) |
static void | DecodeLatLon (const std::string &dmsa, const std::string &dmsb, double &lat, double &lon) |
static std::string | Encode (double degree, component trailing, unsigned prec, flag ind=NONE) |
static std::string | Encode (double degree, unsigned prec, flag ind=NONE) |
Convert between degrees to DMS representation.
Parse a string representing degree, minutes, and seconds and return the angle in degrees and format an angle in degrees as degree, minutes, and seconds.
double GeographicLib::DMS::Decode | ( | const std::string & | dms, |
flag & | ind | ||
) | [static] |
Read a string dms in DMS format and return the resulting angle in degrees. Degrees, minutes, and seconds are indicated by the letters d, ', ", and these components may only be given in this order. Any (but not all) components may be omitted. The last component indicator may be omitted and is assumed to be tbe next smallest unit (thus 33d10 is interpreted as 33d10'). The final component may be a decimal fraction but the non-final components must be integers. The integer parts of the minutes and seconds components must be less than 60. A single leading sign is permitted. A hemisphere designator (N, E, W, S) may be added to tbe beginning or end of the string. The result is mulitplied by the implied signed of the hemisphere designator (negative for S and W). In addition flag is used to indicate whether such a designator was found and whether it implies that the angle is a latitude (N or S) or longitude (E or W).
Definition at line 31 of file DMS.cpp.
Referenced by ReadAzimuth().
void GeographicLib::DMS::DecodeLatLon | ( | const std::string & | dmsa, |
const std::string & | dmsb, | ||
double & | lat, | ||
double & | lon | ||
) | [static] |
Convert two strings dmsa and dmsb to a latitude, lat, and longitude, lon. By default, the lat (resp., lon) is assigned to the results of decoding dmsa (resp., dmsb). However this is overridden if either dmsa or dmsb contain a latitude or longitude hemisphere designator (N, S, E, W).
Definition at line 157 of file DMS.cpp.
Referenced by GeographicLib::GeoCoords::Reset(), and main().
string GeographicLib::DMS::Encode | ( | double | degree, |
component | trailing, | ||
unsigned | prec, | ||
flag | ind = NONE |
||
) | [static] |
Convert degree into a DMS string. trailing indicates the least significant component of the string (and this component is given as a decimal number if necessary). prec indicates the number of digits after the decimal point for the trailing component. flag indicates whether the result should be include a sign (if negative) or a trailing latitude or longitude hemisphere indicator. In the latter two cases, the integer part of the degrees component is given with 2 (latitude) or 3 (longitude) digits (with leading zeros if necessary). The integer parts of the minutes and seconds components are always given with 2 digits.
Definition at line 191 of file DMS.cpp.
Referenced by Encode(), GeographicLib::GeoCoords::DMSRepresentation(), LatLonString(), and AzimuthString().
static std::string GeographicLib::DMS::Encode | ( | double | degree, |
unsigned | prec, | ||
flag | ind = NONE |
||
) | [inline, static] |