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
// 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);

View File

@ -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<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
#[wasm_bindgen]
pub fn from_coordinate(i: &str) -> Result<EncodedAddress, String> {
@ -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,
}