Skip to content

Commit dd88c85

Browse files
authored
Remove geoarrow crate from JS bindings deps (#1133)
For #1102 and #1126
1 parent 5e6b08f commit dd88c85

22 files changed

+156
-923
lines changed

js/Cargo.lock

Lines changed: 16 additions & 492 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ data = []
2626

2727
geodesy = ["dep:geodesy"]
2828
debug = ["console_error_panic_hook"]
29-
io_flatgeobuf = ["geoarrow/flatgeobuf", "table"]
29+
# io_flatgeobuf = ["geoarrow/flatgeobuf", "table"]
3030
io_geojson = ["table"]
3131
io_http = []
3232
io_object_store = [
@@ -96,7 +96,6 @@ console_error_panic_hook = { version = "0.1.6", optional = true }
9696
futures = { version = "0.3.30", optional = true }
9797
geo = "0.30"
9898
geo-traits = "0.2"
99-
geoarrow = { path = "../rust/geoarrow" }
10099
geoarrow-schema = { path = "../rust/geoarrow-schema" }
101100
geoarrow-array = { path = "../rust/geoarrow-array" }
102101
geoarrow-geoparquet = { path = "../rust/geoarrow-geoparquet", optional = true }

js/src/broadcasting/affine.rs

Lines changed: 0 additions & 41 deletions
This file was deleted.

js/src/broadcasting/linestring.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

js/src/broadcasting/mod.rs

Lines changed: 0 additions & 17 deletions
This file was deleted.

js/src/broadcasting/multilinestring.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

js/src/broadcasting/multipoint.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

js/src/broadcasting/multipolygon.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

js/src/broadcasting/point.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

js/src/broadcasting/polygon.rs

Lines changed: 0 additions & 24 deletions
This file was deleted.

js/src/broadcasting/primitive.rs

Lines changed: 0 additions & 36 deletions
This file was deleted.

js/src/data/coord.rs

Lines changed: 8 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,27 @@
1-
use arrow_buffer::ScalarBuffer;
1+
use geoarrow_array::array::{CoordBuffer, InterleavedCoordBuffer, SeparatedCoordBuffer};
22
use geoarrow_schema::Dimension;
33
use wasm_bindgen::prelude::*;
44

5-
// TODO: remove InterleavedCoordBuffer and SeparatedCoordBuffer structs?
6-
7-
/// An immutable buffer of interleaved coordinates in WebAssembly memory.
8-
#[wasm_bindgen]
9-
pub struct InterleavedCoordBuffer(pub(crate) geoarrow::array::InterleavedCoordBuffer);
10-
11-
#[wasm_bindgen]
12-
impl InterleavedCoordBuffer {
13-
#[wasm_bindgen(constructor)]
14-
pub fn new(coords: Vec<f64>) -> Self {
15-
Self(geoarrow::array::InterleavedCoordBuffer::new(
16-
coords.into(),
17-
Dimension::XY,
18-
))
19-
}
20-
}
21-
22-
/// An immutable buffer of separated coordinates in WebAssembly memory.
23-
#[wasm_bindgen]
24-
pub struct SeparatedCoordBuffer(pub(crate) geoarrow::array::SeparatedCoordBuffer);
25-
26-
#[wasm_bindgen]
27-
impl SeparatedCoordBuffer {
28-
#[wasm_bindgen(constructor)]
29-
pub fn new(x: Vec<f64>, y: Vec<f64>) -> Self {
30-
Self(geoarrow::array::SeparatedCoordBuffer::new(
31-
[
32-
x.into(),
33-
y.into(),
34-
ScalarBuffer::from(vec![]),
35-
ScalarBuffer::from(vec![]),
36-
],
37-
Dimension::XY,
38-
))
39-
}
40-
}
5+
use crate::dimension::JsDimension;
416

427
/// An immutable buffer of coordinates in WebAssembly memory, that can be either interleaved or
438
/// separated.
449
#[wasm_bindgen]
4510
#[allow(dead_code)]
46-
pub struct CoordBuffer(pub(crate) geoarrow::array::CoordBuffer);
11+
pub struct JsCoordBuffer(CoordBuffer);
4712

4813
#[wasm_bindgen]
49-
impl CoordBuffer {
14+
impl JsCoordBuffer {
5015
/// Create a new CoordBuffer from a `Float64Array` of interleaved XY coordinates
5116
#[wasm_bindgen(js_name = fromInterleaved)]
52-
pub fn from_interleaved(coords: Vec<f64>) -> Self {
53-
let buffer = geoarrow::array::InterleavedCoordBuffer::new(coords.into(), Dimension::XY);
54-
Self(geoarrow::array::CoordBuffer::Interleaved(buffer))
17+
pub fn from_interleaved(coords: Vec<f64>, dim: JsDimension) -> Self {
18+
Self(InterleavedCoordBuffer::new(coords.into(), dim.into()).into())
5519
}
5620

5721
/// Create a new CoordBuffer from two `Float64Array`s of X and Y
5822
#[wasm_bindgen(js_name = fromSeparated)]
5923
pub fn from_separated(x: Vec<f64>, y: Vec<f64>) -> Self {
60-
let buffer = geoarrow::array::SeparatedCoordBuffer::new(
61-
[
62-
x.into(),
63-
y.into(),
64-
ScalarBuffer::from(vec![]),
65-
ScalarBuffer::from(vec![]),
66-
],
67-
Dimension::XY,
68-
);
69-
Self(geoarrow::array::CoordBuffer::Separated(buffer))
70-
}
71-
72-
/// Create a new CoordBuffer from an `InterleavedCoordBuffer` object
73-
#[wasm_bindgen(js_name = fromInterleavedCoords)]
74-
pub fn from_interleaved_coords(coords: InterleavedCoordBuffer) -> Self {
75-
Self(geoarrow::array::CoordBuffer::Interleaved(coords.0))
76-
}
77-
78-
/// Create a new CoordBuffer from a `SeparatedCoordBuffer` object
79-
#[wasm_bindgen(js_name = fromSeparatedCoords)]
80-
pub fn from_separated_coords(coords: SeparatedCoordBuffer) -> Self {
81-
Self(geoarrow::array::CoordBuffer::Separated(coords.0))
24+
let cb = SeparatedCoordBuffer::from_vec(vec![x.into(), y.into()], Dimension::XY).unwrap();
25+
Self(cb.into())
8226
}
8327
}

js/src/data/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
pub mod coord;
1+
mod coord;
22

3-
pub use coord::{CoordBuffer, InterleavedCoordBuffer, SeparatedCoordBuffer};
3+
pub use coord::JsCoordBuffer;

js/src/data_type.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use geoarrow_array::GeoArrowType;
2+
use wasm_bindgen::prelude::*;
3+
4+
#[wasm_bindgen(js_name = GeoArrowType)]
5+
pub struct JsGeoArrowType(GeoArrowType);
6+
7+
impl JsGeoArrowType {
8+
pub fn new(geoarrow_type: GeoArrowType) -> Self {
9+
Self(geoarrow_type)
10+
}
11+
}
12+
13+
impl From<JsGeoArrowType> for GeoArrowType {
14+
fn from(value: JsGeoArrowType) -> Self {
15+
value.0
16+
}
17+
}
18+
19+
impl From<GeoArrowType> for JsGeoArrowType {
20+
fn from(value: GeoArrowType) -> Self {
21+
Self(value)
22+
}
23+
}

0 commit comments

Comments
 (0)