yjh0502 / rust-s2

S2 geometry library in Rust
Apache License 2.0
74 stars 19 forks source link

Are there an example how to use CellID from wasm? #10

Closed thstart closed 1 year ago

thstart commented 3 years ago

I was able to generate wasm.

Are there an example how to use from Javascript?

yjh0502 commented 3 years ago

@thstart You could use wasm-bindgen, but you should define your own Javascript API interface in that case. CellID is a u64 type so we cannot use Javascript Number type for that. I think following type signature could be used for the job.

#[wasm_bindgen]
pub fn cellid_from_latlng(lat: f32, lng: f32) -> String