diff --git a/spatial-coordinate-systems/src/lib.rs b/spatial-coordinate-systems/src/lib.rs index 8424321..5ac6280 100644 --- a/spatial-coordinate-systems/src/lib.rs +++ b/spatial-coordinate-systems/src/lib.rs @@ -126,6 +126,12 @@ impl Coordinate { } } +impl From for Coordinate { + fn from(latlon: LatLon) -> Self { + Self::DD(dd::Coordinate::from(latlon)) + } +} + impl From<&Coordinate> for LatLon { fn from(value: &Coordinate) -> LatLon { match value { diff --git a/xpin-wasm/src/lib.rs b/xpin-wasm/src/lib.rs index dc561bc..f4a1297 100644 --- a/xpin-wasm/src/lib.rs +++ b/xpin-wasm/src/lib.rs @@ -52,10 +52,7 @@ impl EncodedAddress { .map_err(|e| e.to_string())? .as_lat_lon(); - - // TODO: Do not allocate a string here - let src_coords = - Coordinate::from_str(&format!("{}, {}", lat, lon)).map_err(|e| e.to_string())?; + let src_coords = Coordinate::from(LatLon::new(lat, lon).map_err(|e| e.to_string())?); Self::try_from(src_coords) }