[−][src]Function latlon::parse
pub fn parse<T: AsRef<str> + Display>(
text: T
) -> Result<Point<f64>, GeoParseError<T>>
Parse a string containing a pair of coordinates (latitude, longitude).
Positive latitude is North, positive longitude is East.
Supported formats (examples)
40° 26′ 46″ N 79° 58′ 56″ W
N 40° 26′ 46″ W 79° 58′ 56″
40° 26.767' N 79° 58.933' W
40° 26′ 46″ 79° 58′ 56″
,40° 26′ 46″, 79° 58′ 56″
, ...N 40° 26.767' W 79° 58.933'
40° 26.767' 79° 58.933'
,40° 26.767', 79° 58.933'
, ...N 40.446° W 79.982°
40.446° N 79.982° W
40.446° 79.982°
,40.446,79.982
, etc.
Parser rules
- All formats support negative degrees (preceded by a minus sign).
- Whitespace is optional and ignored, except for formats that would become unparsable.
- Degree, minute and second symbols can be omitted.
- Unicode quotes (
’
,”
) may be used in place of apostrophe and double quote ('
,"
) for minutes and seconds. - The two coordinates can be separated by comma (
,
), semicolon (;
), whitespace (
Returns
Returns a Point
with longitude as X and latitude as Y (natural map orientation), or
a parse error wrapping the source string (for zero-copy patterns)