Cleanup
This commit is contained in:
parent
d8958e0645
commit
0546720e3d
Binary file not shown.
@ -29,9 +29,9 @@ pub const V0_MIN_NUMBER: u32 = 1;
|
|||||||
|
|
||||||
#[derive(Error, Debug, Eq, PartialEq)]
|
#[derive(Error, Debug, Eq, PartialEq)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
#[error("Word does not exist")]
|
#[error("Word does not exist: {0}")]
|
||||||
WordDoesNotExist(String),
|
WordDoesNotExist(String),
|
||||||
#[error("Invalid version")]
|
#[error("Invalid version: {0}")]
|
||||||
InvalidVersion(u8),
|
InvalidVersion(u8),
|
||||||
#[error("Unimplemented version")]
|
#[error("Unimplemented version")]
|
||||||
UnimplementedVersion(Version),
|
UnimplementedVersion(Version),
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#![allow(dead_code)]
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
|
|
||||||
use csv::ReaderBuilder;
|
use csv::ReaderBuilder;
|
||||||
|
@ -7,6 +7,8 @@ import init, { address_from_lat_lon, address_to_lat_lon } from "./pkg/this_algor
|
|||||||
init().then(() => {
|
init().then(() => {
|
||||||
let updateEncode = () => {
|
let updateEncode = () => {
|
||||||
if (!encodeAddressLat.value || !encodeAddressLon.value) {
|
if (!encodeAddressLat.value || !encodeAddressLon.value) {
|
||||||
|
encodeAddressResult.value = "";
|
||||||
|
encodeAddressError.textContent = "";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,6 +19,7 @@ init().then(() => {
|
|||||||
encodeAddressResult.value = address_from_lat_lon(lat, lon);
|
encodeAddressResult.value = address_from_lat_lon(lat, lon);
|
||||||
encodeAddressError.textContent = "";
|
encodeAddressError.textContent = "";
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
|
encodeAddressResult.value = "";
|
||||||
encodeAddressError.textContent = e;
|
encodeAddressError.textContent = e;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
||||||
use this_algorithm::Address;
|
|
||||||
use wasm_bindgen::prelude::*;
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
@ -12,16 +11,16 @@ extern "C" {
|
|||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn address_from_lat_lon(lat: f64, lon: f64) -> Result<String, String> {
|
pub fn address_from_lat_lon(lat: f64, lon: f64) -> Result<String, String> {
|
||||||
Address::from_lat_lon(lat, lon)
|
this_algorithm::Address::from_lat_lon(lat, lon)
|
||||||
.map(|a| a.to_string())
|
.map(|a| a.to_string())
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn address_to_lat_lon(addr_str: &str) -> Result<Vec<f64>, String> {
|
pub fn address_to_lat_lon(addr_str: &str) -> Result<Vec<f64>, String> {
|
||||||
Address::from_str(addr_str)
|
this_algorithm::Address::from_str(addr_str)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map_err(|e| e.to_string())
|
.map_err(|e| e.to_string())
|
||||||
.map(Address::to_lat_lon)
|
.map(this_algorithm::Address::to_lat_lon)
|
||||||
.map(|(lat, lon)| vec![lat, lon])
|
.map(|(lat, lon)| vec![lat, lon])
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user