Rust crate for geo coord parsing
https://crates.io/crates/latlon
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ondřej Hruška
e19d548ede
|
5 years ago | |
---|---|---|
src | 5 years ago | |
.gitignore | 5 years ago | |
Cargo.toml | 5 years ago | |
README.md | 5 years ago |
README.md
latlon
Parse geographic coordinates from string.
A wide range of commonly used formats is supported. See the unit tests for a complete reference.
If a format you need is missing, please submit a merge request (including unit tests).
Usage
// parse a coord
let coord : geo::Point = latlon::parse("N 50°5.30385', E 14°26.94732'").unwrap();
// individual lat/lng parsing
let lat : f64 = latlon::parse_lat("N 50°5.30385'").unwrap();
let lng : f64 = latlon::parse_lng("E 14°26.94732'").unwrap();
Supported formats
Example of supported formats:
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). Positive latitude is North, positive longitude is East.
- Whitespace is optional and ignored, except for formats that would become unparsable.
- Degree, minute and second symbols can be omitted.
- Comma (
,
) may be used as an alternate decimal separator. - 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 (