From ce3a20bace135499d26d0493e7c92343b654c281 Mon Sep 17 00:00:00 2001 From: Austen Adler Date: Tue, 18 Apr 2023 18:01:07 -0400 Subject: [PATCH] Remove get_coords_repr_as --- web-frontend/src/routes/app/+page.svelte | 6 ++---- xpin-wasm/src/lib.rs | 17 +++++------------ 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/web-frontend/src/routes/app/+page.svelte b/web-frontend/src/routes/app/+page.svelte index c5d06c1..3580946 100644 --- a/web-frontend/src/routes/app/+page.svelte +++ b/web-frontend/src/routes/app/+page.svelte @@ -101,7 +101,7 @@ // TODO: Does not work well when the address field is invalid // updateAddr(wasm.call.EncodedAddress.from_coordinate(coordinateInputValue), true); - coordinateInputValue = addr.getCoordsReprAs(coordinateTypes.indexOf(selectedCoordinateType)); + coordinateInputValue = addr.allCoordinates[selectedCoordinateType]; }; const coordinateInput = () => { @@ -133,9 +133,7 @@ selectedCoordinateType = coordinateTypes[addr.getCoordsType()] || selectedCoordinateType; coordinateInputValue = addr.getCoordsRepr() || coordinateInputValue; } else { - coordinateInputValue = addr.getCoordsReprAs( - coordinateTypes.indexOf(selectedCoordinateType) - ); + coordinateInputValue = addr.allCoordinates[selectedCoordinateType]; } map.panTo(latlng, 20); diff --git a/xpin-wasm/src/lib.rs b/xpin-wasm/src/lib.rs index d98f600..7e4186e 100644 --- a/xpin-wasm/src/lib.rs +++ b/xpin-wasm/src/lib.rs @@ -36,18 +36,6 @@ impl EncodedAddress { self.src_coords.to_string() } - /// Get the string representation of the encoded value as a different type - #[wasm_bindgen(js_name = getCoordsReprAs)] - // TODO: Do not return option - pub fn get_coords_repr_as(&self, coordinate_type: CoordinateType) -> Option { - self.src_coords - // TODO: Remove the clone here - .clone() - .try_as_type(&coordinate_type) - .ok() - .map(|s| s.to_string()) - } - /// Get an encoded address from a coordinate #[wasm_bindgen] pub fn from_coordinate(i: &str) -> Result { @@ -74,11 +62,16 @@ impl EncodedAddress { #[derive(Debug, Clone)] pub struct Coordinates { // pub latlon: LatLon, + #[wasm_bindgen(js_name = "DD")] pub dd: String, + #[wasm_bindgen(js_name = "DMS")] pub dms: String, + #[wasm_bindgen(js_name = "DMM")] pub dmm: String, + #[wasm_bindgen(js_name = "UTM")] pub utm: String, // pub xpin: String, + #[wasm_bindgen(js_name = "Plus")] pub plus: String, }