Public Types | Static Public Member Functions
GeographicLib::DMS Class Reference

Convert between degrees to DMS representation. More...

#include <GeographicLib/DMS.hpp>

List of all members.

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)

Detailed Description

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.


Member Enumeration Documentation

Indicator for presence of hemisphere indicator (N/S/E/W) on latitudes and longitudes. AZIMUTH is used in Encode to indicate output in [000, 360) with no letter indicator.

Enumerator:
NONE 
LATITUDE 
LONGITUDE 
AZIMUTH 

Definition at line 47 of file DMS.hpp.

Indicator for trailing units on an angle.

Enumerator:
DEGREE 
MINUTE 
SECOND 

Definition at line 52 of file DMS.hpp.


Member Function Documentation

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]

Convert degree into a DMS string selecting the trailing component based on prec. prec indicates the precision relative to 1 degree, e.g., prec = 3 gives a result accurate to 0.1' and prec = 4 gives a result accurate to 1".

Definition at line 105 of file DMS.hpp.

References Encode(), DEGREE, MINUTE, and SECOND.


The documentation for this class was generated from the following files: