LuciadCPillar 2023.1.04
|
Class to format points as LonLat coordinates. More...
#include <luciad/grids/lonlat/LonLatFormat.h>
Public Member Functions | |
LonLatFormat () | |
Creates a new LonLatFormat from the default format "lat(-DMS), lon(-DMS)". More... | |
LonLatFormat (const std::string &pattern) | |
Creates a new LonLatFormat from the given pattern. More... | |
std::string | format (const Point &lonLatPoint) const |
Format the given Point according to this LonLatFormat. More... | |
std::string | format (Coordinate lonLatCoord) const |
Format the given LonLat Coordinate according to this LonLatFormat. More... | |
std::string | formatLat (double lat) const |
Format the given latitude according to this LonLatFormat. More... | |
std::string | formatLon (double lon) const |
Format the given longitude according to this LonLatFormat. More... | |
std::string | toPattern () const |
Get the pattern string used to create this format. More... | |
Static Public Member Functions | |
static bool | isValidFormatString (const std::string &format) |
Returns if the given string is a valid LonLat format string. More... | |
Class to format points as LonLat coordinates.
The EBNF for the pattern syntax is
pattern = lon, separator, lat | lat, separator, lon lon = "lon(", { "+" | "-" }, { axis | degrees | minutes | seconds }+, ")" lat = "lat(", { "+" | "-" }, { axis | degrees | minutes | seconds }+, ")" axis = "a" degrees = { "d" | "D" }+, { digit }* minutes = { "m" | "M" }+, { digit }* seconds = { "s" | "S" }+, { digit }* digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" separator = { ? any character ? }
where "{ x }" means x is optional, "{ x }*" means x occurs zero or more times, and "{ x }+" means x occurs at least once.
The table below details the meaning of each pattern character.
Symbol | Meaning | Examples |
---|---|---|
d | Integer degrees.* | d: 12, ddd: 012 |
d<n> | Degrees with <n> fractional digits.* | d2: 12.34, ddd2: 012.34 |
D | Integer degrees with degrees symbol.* | D: 12°, DDD: 012° |
D<n> | Degrees with symbol and <n> fractional digits.* | D2: 12.34°, DDD2: 012.34° |
m | Integer minutes.* | m: 3, mm: 03 |
m<n> | Minutes with <n> fractional digits.* | m2: 3.45, mm2: 03.45 |
M | Integer minutes with degrees symbol.* | M: 3', MM: 03' |
M<n> | Minutes with symbol and <n> fractional digits.* | M2: 3.45', MM2: 03.45' |
s | Integer seconds.* | s: 7, ss: 07 |
s<n> | Seconds with <n> fractional digits.* | s2: 7.89, ss2: 07.89 |
S | Integer seconds with degrees symbol.* | S: 7", SS: 07" |
S<n> | Seconds with symbol and <n> fractional digits.* | S2: 7.89", SS2: 07.89" |
+ | Coordinate sign. Results in a + if the coordinate is positive, and a - if it is negative. | +, - |
- | Coordinate sign. Results in a - if the coordinate is negative. | - |
a | Hemisphere indicator | N, S, E, W |
*Repeating this character pads the number with leading zeros.
As an example, the default formatting pattern is "lat(-DMS), lon(-DMS)". This results in a format that generates formatted coordinates like -12°34'56", 123°45'12".
luciad::LonLatFormat::LonLatFormat | ( | ) |
Creates a new LonLatFormat from the default format "lat(-DMS), lon(-DMS)".
|
explicit |
Creates a new LonLatFormat from the given pattern.
pattern | the pattern string. |
luciad::InvalidArgumentException | if pattern is not a valid pattern. |
std::string luciad::LonLatFormat::format | ( | const Point & | lonLatPoint | ) | const |
std::string luciad::LonLatFormat::format | ( | Coordinate | lonLatCoord | ) | const |
Format the given LonLat Coordinate according to this LonLatFormat.
lonLatCoord | the Coordinate. |
std::string luciad::LonLatFormat::formatLat | ( | double | lat | ) | const |
Format the given latitude according to this LonLatFormat.
lat | the latitude. |
std::string luciad::LonLatFormat::formatLon | ( | double | lon | ) | const |
Format the given longitude according to this LonLatFormat.
lon | the longitude. |
|
static |
Returns if the given string is a valid LonLat format string.
format | the format string. |
std::string luciad::LonLatFormat::toPattern | ( | ) | const |
Get the pattern string used to create this format.