Remove srcCoordsRepr
This commit is contained in:
parent
9e2373919c
commit
bcb605741f
@ -5,7 +5,6 @@ export const emptyxpin = {
|
||||
address: '',
|
||||
latLon: [0.0, 0.0],
|
||||
decimalDegrees: '',
|
||||
srcCoordsRepr: '0.0, 0.0'
|
||||
};
|
||||
|
||||
export const WasmStatus = {
|
||||
|
@ -135,7 +135,7 @@
|
||||
// Update coordinate display
|
||||
if (fromTextInput) {
|
||||
selectedCoordinateType = coordinateTypes[addr.srcCoordsType] || selectedCoordinateType;
|
||||
coordinateInputValue = addr.srcCoordsRepr || coordinateInputValue;
|
||||
coordinateInputValue = addr.getCoordsRepr() || coordinateInputValue;
|
||||
} else {
|
||||
coordinateInputValue = addr.get_coords_repr_as(
|
||||
coordinateTypes.indexOf(selectedCoordinateType)
|
||||
|
@ -47,8 +47,6 @@ pub struct EncodedAddress {
|
||||
pub address: String,
|
||||
/// The coordinates used to encode this address
|
||||
src_coords: Coordinate,
|
||||
#[wasm_bindgen(js_name = srcCoordsRepr)]
|
||||
pub src_coords_repr: String,
|
||||
#[wasm_bindgen(js_name = srcCoordsType)]
|
||||
pub src_coords_type: CoordinateType,
|
||||
#[wasm_bindgen(js_name = latLon)]
|
||||
@ -66,6 +64,13 @@ impl EncodedAddress {
|
||||
/// Get the string representation of the encoded value
|
||||
#[wasm_bindgen]
|
||||
// TODO: Do not return option
|
||||
pub fn get_coords_repr(&self, coordinate_type: CoordinateType) -> String {
|
||||
self.src_coords.to_string()
|
||||
}
|
||||
|
||||
/// Get the string representation of the encoded value as a different type
|
||||
#[wasm_bindgen]
|
||||
// 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
|
||||
@ -94,19 +99,23 @@ impl EncodedAddress {
|
||||
let src_coords = Coordinate::from_str(i)
|
||||
.map_err(|e| format!("Could not parse str {i:?} as a coordinate {e:?}"))?;
|
||||
|
||||
// TODO: Remove the clone here
|
||||
let latlon = LatLon::from(&src_coords);
|
||||
let src_latlon = LatLon::from(&src_coords);
|
||||
|
||||
let mut ret = Self::try_from(
|
||||
xpin::Address::from_lat_lon(latlon.get_lat(), latlon.get_lon())
|
||||
xpin::Address::from_lat_lon(src_latlon.get_lat(), src_latlon.get_lon())
|
||||
.as_ref()
|
||||
.map_err(|e| e.to_string())?,
|
||||
)
|
||||
.map_err(|e| e.to_string())?;
|
||||
|
||||
ret.src_coords_repr = src_coords.to_string();
|
||||
ret.src_coords = ret
|
||||
.src_coords
|
||||
.try_as_type(&src_coords.get_type().into())
|
||||
.map_err(|e| e.to_string())?
|
||||
.into();
|
||||
|
||||
// TODO: Remove this
|
||||
ret.src_coords_type = src_coords.get_type().into();
|
||||
ret.src_coords = src_coords;
|
||||
|
||||
Ok(ret)
|
||||
}
|
||||
@ -163,7 +172,6 @@ impl TryFrom<&'_ Address<'_>> for EncodedAddress {
|
||||
Ok(Self {
|
||||
address: addr.to_string(),
|
||||
lat_lon: Box::new([lat, lon]),
|
||||
src_coords_repr: src_coords.to_string(),
|
||||
src_coords_type: src_coords.get_type().into(),
|
||||
src_coords,
|
||||
decimal_degrees: format!("{}, {}", lat, lon),
|
||||
|
Loading…
Reference in New Issue
Block a user