diff --git a/spatial-coordinate-systems/src/error.rs b/spatial-coordinate-systems/src/error.rs index eabc323..1810f54 100644 --- a/spatial-coordinate-systems/src/error.rs +++ b/spatial-coordinate-systems/src/error.rs @@ -2,7 +2,7 @@ use thiserror::Error; use crate::Direction; -#[derive(Error, Debug)] +#[derive(Error, Debug, PartialEq)] pub enum Error { #[error("Invalid latitude: {0}")] InvalidLatitude(f64), @@ -20,7 +20,7 @@ pub enum Error { #[error("Error parsing: {0}")] NomErr(String), #[error("No UTM zone letter")] - NoUtmZoneLetter + NoUtmZoneLetter, } impl From for Error { diff --git a/spatial-coordinate-systems/src/lib.rs b/spatial-coordinate-systems/src/lib.rs index 08765c9..a6341e1 100644 --- a/spatial-coordinate-systems/src/lib.rs +++ b/spatial-coordinate-systems/src/lib.rs @@ -230,22 +230,13 @@ mod tests { assert!(cvt.is_ok()); }}; } - // assert_eq!( - // Coordinate::from_str("0.000000 100.500278"), - // Ok(Coordinate::DD(dd::Coordinate::new(LatLon::from( - // 0.0, 100.500278 - // )))) - // ); - // assert_eq!( - // Coordinate::from_str("47N 666962.588 0.000"), - // Ok(Coordinate::UTM(utm::Coordinate { - // zone_num: 47, - // zone_letter: 'N', - // easting: 666962.588, - // northing: 0.0 - // })) - // ); + assert_eq!( + Coordinate::from_str("0.000000 100.500278").unwrap(), + Coordinate::DD( + dd::Coordinate::try_from(LatLon::new(0.0, 100.500278).unwrap()).unwrap() + ) + ); p!("1 2"); p!(r#"0° 0' 0" N 100° 30' 1" W"#); diff --git a/spatial-coordinate-systems/src/utm.rs b/spatial-coordinate-systems/src/utm.rs index ca86e48..157cb59 100644 --- a/spatial-coordinate-systems/src/utm.rs +++ b/spatial-coordinate-systems/src/utm.rs @@ -145,5 +145,17 @@ mod tests { .unwrap() .to_string()); p!("34H 261877.8163738246 6243185.589276327"); + + assert_eq!( + Coordinate::from_str("47N 666962.588 0.000"), + Ok(Coordinate { + zone_num: 47, + zone_letter: 'N', + easting: 666962.588, + northing: 0.0, + + latlon: LatLon::new(1.534972646100779e-9, 100.50027886695585).unwrap() + }) + ); } }