use std::str::FromStr; use crate::{ dd, dmm, dms, plus, //xpin utm, Coordinate, Error, LatLon, }; pub struct Coordinates { pub latlon: LatLon, pub dd: dd::Coordinate, pub dms: dms::Coordinate, pub dmm: dmm::Coordinate, pub utm: utm::Coordinate, // pub xpin: xpin::Xpin, pub plus: plus::Coordinate, } impl TryFrom for Coordinates { type Error = Error; fn try_from(latlon: LatLon) -> Result { Ok(Self { latlon, dd: dd::Coordinate::try_from(latlon)?, dms: dms::Coordinate::try_from(latlon)?, dmm: dmm::Coordinate::try_from(latlon)?, utm: utm::Coordinate::try_from(latlon)?, plus: plus::Coordinate::try_from(latlon)?, }) } } impl TryFrom<&crate::Coordinate> for Coordinates { type Error = Error; fn try_from(value: &crate::Coordinate) -> Result { Self::try_from(LatLon::from(value)) } } impl TryFrom for Coordinates { type Error = Error; fn try_from(value: crate::Coordinate) -> Result { Self::try_from(&value) } } impl FromStr for Coordinates { type Err = Error; fn from_str(i: &str) -> Result { Self::try_from(LatLon::from(&Coordinate::from_str(i)?)) } }