Remove get_coords_repr_as

This commit is contained in:
Austen Adler 2023-04-18 18:01:07 -04:00
parent d371a0786d
commit ce3a20bace
2 changed files with 7 additions and 16 deletions

View File

@ -101,7 +101,7 @@
// TODO: Does not work well when the address field is invalid // TODO: Does not work well when the address field is invalid
// updateAddr(wasm.call.EncodedAddress.from_coordinate(coordinateInputValue), true); // updateAddr(wasm.call.EncodedAddress.from_coordinate(coordinateInputValue), true);
coordinateInputValue = addr.getCoordsReprAs(coordinateTypes.indexOf(selectedCoordinateType)); coordinateInputValue = addr.allCoordinates[selectedCoordinateType];
}; };
const coordinateInput = () => { const coordinateInput = () => {
@ -133,9 +133,7 @@
selectedCoordinateType = coordinateTypes[addr.getCoordsType()] || selectedCoordinateType; selectedCoordinateType = coordinateTypes[addr.getCoordsType()] || selectedCoordinateType;
coordinateInputValue = addr.getCoordsRepr() || coordinateInputValue; coordinateInputValue = addr.getCoordsRepr() || coordinateInputValue;
} else { } else {
coordinateInputValue = addr.getCoordsReprAs( coordinateInputValue = addr.allCoordinates[selectedCoordinateType];
coordinateTypes.indexOf(selectedCoordinateType)
);
} }
map.panTo(latlng, 20); map.panTo(latlng, 20);

View File

@ -36,18 +36,6 @@ impl EncodedAddress {
self.src_coords.to_string() 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<String> {
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 /// Get an encoded address from a coordinate
#[wasm_bindgen] #[wasm_bindgen]
pub fn from_coordinate(i: &str) -> Result<EncodedAddress, String> { pub fn from_coordinate(i: &str) -> Result<EncodedAddress, String> {
@ -74,11 +62,16 @@ impl EncodedAddress {
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Coordinates { pub struct Coordinates {
// pub latlon: LatLon, // pub latlon: LatLon,
#[wasm_bindgen(js_name = "DD")]
pub dd: String, pub dd: String,
#[wasm_bindgen(js_name = "DMS")]
pub dms: String, pub dms: String,
#[wasm_bindgen(js_name = "DMM")]
pub dmm: String, pub dmm: String,
#[wasm_bindgen(js_name = "UTM")]
pub utm: String, pub utm: String,
// pub xpin: String, // pub xpin: String,
#[wasm_bindgen(js_name = "Plus")]
pub plus: String, pub plus: String,
} }