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