Impl From<LatLon> for Coordinate

This commit is contained in:
Austen Adler 2023-04-18 21:14:43 -04:00
parent cd1c1d1d7c
commit c53f00ea4a
2 changed files with 7 additions and 4 deletions

View File

@ -126,6 +126,12 @@ impl Coordinate {
} }
} }
impl From<LatLon> for Coordinate {
fn from(latlon: LatLon) -> Self {
Self::DD(dd::Coordinate::from(latlon))
}
}
impl From<&Coordinate> for LatLon { impl From<&Coordinate> for LatLon {
fn from(value: &Coordinate) -> LatLon { fn from(value: &Coordinate) -> LatLon {
match value { match value {

View File

@ -52,10 +52,7 @@ impl EncodedAddress {
.map_err(|e| e.to_string())? .map_err(|e| e.to_string())?
.as_lat_lon(); .as_lat_lon();
let src_coords = Coordinate::from(LatLon::new(lat, lon).map_err(|e| e.to_string())?);
// TODO: Do not allocate a string here
let src_coords =
Coordinate::from_str(&format!("{}, {}", lat, lon)).map_err(|e| e.to_string())?;
Self::try_from(src_coords) Self::try_from(src_coords)
} }