fix: update JS/WASM flatgeobuf and geojson bindings for split crate API#2
fix: update JS/WASM flatgeobuf and geojson bindings for split crate API#2brad-richardson wants to merge 1 commit intofix/js-parquet-bindingsfrom
Conversation
Restore flatgeobuf and geojson IO modules that were commented out in geoarrow#1133 when the monolithic geoarrow crate was split. Updates to use the new geoarrow-flatgeobuf and geoarrow-geojson crate APIs. readGeoJSON is dropped — the upstream geoarrow-geojson crate has no reader yet. A GeoJSON decoder is planned via arrow-json's DecoderFactory (geoarrow#1416), pending apache/arrow-rs#9021. See also geoarrow#1303. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Updates the JS/WASM IO bindings to match the new split geoarrow-* crate APIs, replacing the removed monolithic geoarrow::io::* modules and aligning feature flags/dependencies accordingly.
Changes:
- Re-enabled
io::flatgeobufandio::geojsonmodules behindio_flatgeobuf/io_geojsonfeature flags. - Migrated
readFlatGeobuftoflatgeobuf::FgbReader+geoarrow_flatgeobuf::reader::FlatGeobufRecordBatchIterator. - Migrated
writeGeoJSONtogeoarrow_geojson::writer::GeoJsonWriterand removed thereadGeoJSONbinding.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| js/src/io/mod.rs | Enables the flatgeobuf and geojson submodules behind feature gates. |
| js/src/io/flatgeobuf.rs | Reimplements FlatGeobuf reading using the new geoarrow-flatgeobuf reader API. |
| js/src/io/geojson.rs | Switches GeoJSON writing to geoarrow-geojson and removes the reader binding. |
| js/src/error.rs | Expands the internal error enum to cover new error sources (Arrow / FlatGeobuf / IO). |
| js/Cargo.toml | Adds new split-crate dependencies and updates feature definitions. |
| js/Cargo.lock | Locks new transitive dependencies introduced by the split crates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let properties_schema = header | ||
| .properties_schema(true) | ||
| .unwrap_or_else(|| std::sync::Arc::new(arrow_schema::Schema::empty())); | ||
| let geometry_type = header.geoarrow_type(CoordType::Interleaved)?; | ||
| let selection = fgb_reader.select_all_seq()?; | ||
| let options = FlatGeobufReaderOptions::new(properties_schema, geometry_type) | ||
| .with_batch_size(batch_size.unwrap_or(65536)); |
There was a problem hiding this comment.
When the FlatGeobuf header lacks column metadata, header.properties_schema(true) returns None and this code falls back to an empty schema. That will silently drop all properties/attribute columns for heterogeneous FlatGeobuf files (only geometry will be read). Consider inferring the properties schema via geoarrow_flatgeobuf::reader::schema::FlatGeobufSchemaScanner (scan first N features) or returning an explicit error instead of defaulting to Schema::empty().
Summary
readFlatGeobuf: Updated to useFgbReader+FlatGeobufRecordBatchIteratorfrom the newgeoarrow-flatgeobufcrate (replaces the old monolithicgeoarrow::io::flatgeobufAPI removed in Remove geoarrow crate from JS bindings deps geoarrow/geoarrow-rs#1133)writeGeoJSON: Updated to useGeoJsonWriterfrom the newgeoarrow-geojsoncratereadGeoJSON: Removed — the upstreamgeoarrow-geojsoncrate has no reader yet. A decoder usingarrow-json'sDecoderFactoryis planned (#1416), pending apache/arrow-rs#9021. See also #1303.Stacked on
fix/js-parquet-bindings.Test plan
cargo check --features io_flatgeobufpassescargo check --features io_geojsonpassescargo check --features io_flatgeobuf,io_geojson,io_parquetpassescargo clippy --features io_flatgeobuf,io_geojson,io_parquet -- -D warningscleannpm run build(full WASM build) — to verify after merge with parquet PR🤖 Generated with Claude Code