added binary to generate landmarks from geojson file

This commit is contained in:
Johannes Erwerle 2022-09-15 16:29:42 +02:00
parent 1067c6a514
commit a2cb9520cc
2 changed files with 109 additions and 0 deletions

View file

@ -51,6 +51,7 @@ impl From<RadianCoordinate> for DegreeCoordinate {
}
}
impl RadianCoordinate {
/// Builds a RadianCoordinate from latitude and longitude given in
/// degrees.
@ -154,6 +155,20 @@ impl DegreeCoordinate {
Ok(DegreeCoordinate{lat, lon})
}
/// tries to parse a DegreeCoordinate from a GeoJSON Position
pub fn from_geojson_position(position: geojson::Position) -> Result<Self, String> {
if position.len() != 2 {
return Err("String has more than 2 values".to_string());
}
let lat = position[1];
let lon = position[0];
Ok(DegreeCoordinate { lat, lon })
}
}
/// normalizes longitude values given in radians to the range (-PI, PI]