diff --git a/spatial-coordinate-systems/src/all.rs b/spatial-coordinate-systems/src/all.rs index 6b1be6b..0964231 100644 --- a/spatial-coordinate-systems/src/all.rs +++ b/spatial-coordinate-systems/src/all.rs @@ -7,6 +7,7 @@ use crate::{ dmm, dms, plus, //xpin + skyvector, utm, Coordinate, Error, @@ -23,6 +24,7 @@ pub struct Coordinates { pub utm: utm::Coordinate, // pub xpin: xpin::Xpin, pub plus: plus::Coordinate, + pub skyvector: skyvector::Coordinate, } impl TryFrom for Coordinates { @@ -36,6 +38,7 @@ impl TryFrom for Coordinates { dmm: dmm::Coordinate::from(latlon), utm: utm::Coordinate::try_from(latlon)?, plus: plus::Coordinate::try_from(latlon)?, + skyvector: skyvector::Coordinate::from(latlon), }) } } diff --git a/spatial-coordinate-systems/src/skyvector.rs b/spatial-coordinate-systems/src/skyvector.rs index 580af7e..1c4e63d 100644 --- a/spatial-coordinate-systems/src/skyvector.rs +++ b/spatial-coordinate-systems/src/skyvector.rs @@ -69,14 +69,14 @@ impl Coordinate { let lat = dms.get_lat(); let lon = dms.get_lon(); format!( - "{:02}{:02}{:02}{}{:03}{:02}{:02}{}", + "{:02.0}{:02.0}{:02.0}{}{:03.0}{:02.0}{:02.0}{}", lat.degrees, lat.minutes, - lat.seconds, + lat.seconds.trunc(), lat.direction, lon.degrees, lon.minutes, - lon.seconds, + lon.seconds.trunc(), lon.direction, ) } @@ -171,5 +171,10 @@ mod tests { Coordinate::from_str("900000S1000000E"), Ok(Coordinate::from(LatLon::new(-90.0_f64, 100.0_f64).unwrap())) ); + + assert_eq!( + Coordinate::from_str("697926N1082388W").unwrap().0, + Coordinate::from(LatLon::new(69.79268710495744, -108.23886036872865).unwrap()).0 + ) } } diff --git a/xpin-wasm/src/lib.rs b/xpin-wasm/src/lib.rs index f4a1297..f27db4c 100644 --- a/xpin-wasm/src/lib.rs +++ b/xpin-wasm/src/lib.rs @@ -74,6 +74,8 @@ pub struct Coordinates { // pub xpin: String, #[wasm_bindgen(js_name = "Plus")] pub plus: String, + #[wasm_bindgen(js_name = "Skyvector")] + pub skyvector: String, } impl From<&spatial_coordinate_systems::all::Coordinates> for Coordinates { @@ -84,6 +86,7 @@ impl From<&spatial_coordinate_systems::all::Coordinates> for Coordinates { dmm: value.dmm.to_string(), utm: value.utm.to_string(), plus: value.plus.to_string(), + skyvector: value.skyvector.to_string(), } } }