geoarrow_wasm/array/
coord.rs

1use wasm_bindgen::prelude::*;
2
3#[wasm_bindgen]
4pub struct InterleavedCoordBuffer(pub(crate) geoarrow::array::InterleavedCoordBuffer);
5
6#[wasm_bindgen]
7impl InterleavedCoordBuffer {
8    #[wasm_bindgen(constructor)]
9    pub fn new(coords: Vec<f64>) -> Self {
10        Self(geoarrow::array::InterleavedCoordBuffer::new(coords.into()))
11    }
12}
13
14#[wasm_bindgen]
15pub struct SeparatedCoordBuffer(pub(crate) geoarrow::array::SeparatedCoordBuffer);
16
17#[wasm_bindgen]
18impl SeparatedCoordBuffer {
19    #[wasm_bindgen(constructor)]
20    pub fn new(x: Vec<f64>, y: Vec<f64>) -> Self {
21        Self(geoarrow::array::SeparatedCoordBuffer::new(
22            x.into(),
23            y.into(),
24        ))
25    }
26}
27
28#[wasm_bindgen]
29pub struct CoordBuffer(pub(crate) geoarrow::array::CoordBuffer);
30
31#[wasm_bindgen]
32impl CoordBuffer {
33    #[wasm_bindgen]
34    pub fn from_interleaved_coords(coords: InterleavedCoordBuffer) -> Self {
35        Self(geoarrow::array::CoordBuffer::Interleaved(coords.0))
36    }
37
38    #[wasm_bindgen]
39    pub fn from_separated_coords(coords: SeparatedCoordBuffer) -> Self {
40        Self(geoarrow::array::CoordBuffer::Separated(coords.0))
41    }
42}