From a193108ebf8fc078566aacad1069a323cf7cf5fe Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Sun, 7 Jan 2024 13:08:07 -0500 Subject: [PATCH] Remove Arrow mod, point to geoarrow crate --- Cargo.toml | 1 - README.md | 9 +++- geozero/Cargo.toml | 2 - geozero/src/arrow/geoarrow_reader.rs | 63 ---------------------------- geozero/src/arrow/mod.rs | 5 --- geozero/src/lib.rs | 5 +-- 6 files changed, 8 insertions(+), 77 deletions(-) delete mode 100644 geozero/src/arrow/geoarrow_reader.rs delete mode 100644 geozero/src/arrow/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 7df545fd..42fe3ec8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -20,7 +20,6 @@ license = "MIT OR Apache-2.0" # which in turn relies on geozero itself. geozero = { version = "0.11.0", default-features = false } -arrow2 = { version = "0.17", features = ["io_ipc"] } async-trait = "0.1" byteorder = { version = "1.4.3", default-features = false } bytes = "1.4" diff --git a/README.md b/README.md index 9b3f7cb7..dfff9f19 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,6 @@ Supported dimensions: X, Y, Z, M, T - GeoPackage geometries for [SQLx](https://github.com/launchbadge/sqlx) * [WKT](https://github.com/georust/wkt) Reader + Writer * CSV Reader + Writer -* GeoArrow WKB reader * SVG Writer * [geo-types](https://github.com/georust/geo) Reader + Writer * MVT (Mapbox Vector Tiles) Reader + Writer @@ -45,6 +44,12 @@ Supported dimensions: X, Y, Z, M, T * FlatGeobuf Reader +[geoarrow](https://github.com/geoarrow/geoarrow-rs) [![crates.io version](https://img.shields.io/crates/v/geoarrow.svg)](https://crates.io/crates/geoarrow) +[![docs.rs docs](https://docs.rs/geoarrow/badge.svg)](https://docs.rs/geoarrow) + +* GeoArrow Reader and Writer +* GeoParquet Reader and Writer + ## Applications * [flatgeobuf-gpu](https://github.com/pka/flatgeobuf-gpu): Demo rendering FlatGeobuf to GPU @@ -157,7 +162,7 @@ let _ = sqlx::query( .await?; ``` -Using compile-time verification requires [type overrides](https://docs.rs/sqlx/latest/sqlx/macro.query.html#force-a-differentcustom-type): +Using compile-time verification requires [type overrides](https://docs.rs/sqlx/latest/sqlx/macro.query.html#force-a-differentcustom-type): ```rust,ignore let _ = sqlx::query!( "INSERT INTO point2d (datetimefield, geom) VALUES(now(), $1::geometry)", diff --git a/geozero/Cargo.toml b/geozero/Cargo.toml index c83a8bc2..692d7f3b 100644 --- a/geozero/Cargo.toml +++ b/geozero/Cargo.toml @@ -13,7 +13,6 @@ license.workspace = true [features] default = ["with-svg", "with-wkt", "with-geo", "with-geojson"] -with-arrow = ["dep:arrow2"] with-csv = ["dep:csv", "with-wkt"] with-gdal = ["dep:gdal", "dep:gdal-sys"] with-geo = ["dep:geo-types"] @@ -36,7 +35,6 @@ serde_json.workspace = true thiserror.workspace = true # Optional dependencies -arrow2 = { workspace = true, optional = true } byteorder = { workspace = true, optional = true } bytes = { workspace = true, optional = true } csv = { workspace = true, optional = true } diff --git a/geozero/src/arrow/geoarrow_reader.rs b/geozero/src/arrow/geoarrow_reader.rs deleted file mode 100644 index 24d61a79..00000000 --- a/geozero/src/arrow/geoarrow_reader.rs +++ /dev/null @@ -1,63 +0,0 @@ -use crate::error::Result; -use crate::wkb::wkb_reader::{process_wkb_geom_n, read_wkb_header, read_wkb_nested_header}; -use crate::{GeomProcessor, GeozeroGeometry}; -use arrow2::array::BinaryArray; -use arrow2::types::Offset; - -impl GeozeroGeometry for BinaryArray { - fn process_geom(&self, processor: &mut P) -> Result<()> { - process_geoarrow_wkb_geom(self, processor) - } -} - -impl GeozeroGeometry for BinaryArray { - fn process_geom(&self, processor: &mut P) -> Result<()> { - process_geoarrow_wkb_geom(self, processor) - } -} - -pub fn process_geoarrow_wkb_geom( - array: &BinaryArray, - processor: &mut impl GeomProcessor, -) -> Result<()> { - let array_len = array.len(); - processor.geometrycollection_begin(array_len, 0)?; - - for i in 0..array_len { - let raw = &mut array.value(i); - let info = read_wkb_header(raw)?; - process_wkb_geom_n(raw, &info, read_wkb_nested_header, i, processor)?; - } - - processor.geometrycollection_end(array_len - 1) -} - -#[cfg(test)] -mod test { - use super::*; - use crate::wkt::conversion::ToWkt; - use arrow2::io::ipc::read; - use std::fs::File; - - #[test] - fn multipoly_file() -> arrow2::error::Result<()> { - let mut file = File::open("tests/data/countries.arrow")?; - let metadata = read::read_file_metadata(&mut file)?; - let mut reader = read::FileReader::new(file, metadata, None, None); - - let columns = reader.next().unwrap()?; - - let array = &columns.arrays()[2]; - let wkbarr = array.as_any().downcast_ref::>().unwrap(); - let wkt = wkbarr.to_wkt().unwrap(); - assert_eq!( - &wkt[0..100], - "GEOMETRYCOLLECTION(MULTIPOLYGON(((-59.572095 -80.040179,-59.865849 -80.549657,-60.159656 -81.000327," - ); - assert_eq!( - &wkt[wkt.len()-100..], - "-51.5,-58.55 -51.1,-57.75 -51.55,-58.05 -51.9,-59.4 -52.2,-59.85 -51.85,-60.7 -52.3,-61.2 -51.85))))" - ); - Ok(()) - } -} diff --git a/geozero/src/arrow/mod.rs b/geozero/src/arrow/mod.rs deleted file mode 100644 index 85254263..00000000 --- a/geozero/src/arrow/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -//! GeoArrow conversions. -//! -pub(crate) mod geoarrow_reader; - -pub use geoarrow_reader::*; diff --git a/geozero/src/lib.rs b/geozero/src/lib.rs index ba1a0402..81f1d15a 100644 --- a/geozero/src/lib.rs +++ b/geozero/src/lib.rs @@ -14,6 +14,7 @@ //! Available implementations: //! * [geozero-shp](https://docs.rs/geozero-shp) //! * [flatgeobuf](https://docs.rs/flatgeobuf) +//! * [geoarrow](https://docs.rs/geoarrow) //! //! ## Format conversion overview //! @@ -22,7 +23,6 @@ //! | CSV | [csv::Csv], [csv::CsvString] | XY | - | [ProcessToCsv] | [CsvWriter](csv::CsvWriter) | //! | GDAL | `gdal::vector::Geometry` | XYZ | - | [ToGdal] | [GdalWriter](gdal::GdalWriter) | //! | geo-types | `geo_types::Geometry` | XY | - | [ToGeo] | [GeoWriter](geo_types::GeoWriter) | -//! | GeoArrow | `arrow2::array::BinaryArray` | XY | - | - | - | //! | GeoJSON | [GeoJson](geojson::GeoJson), [GeoJsonString](geojson::GeoJsonString) | XYZ | [GeoJsonReader](geojson::GeoJsonReader), [GeoJson](geojson::GeoJson) | [ToJson] | [GeoJsonWriter](geojson::GeoJsonWriter) | //! | GEOS | `geos::Geometry` | XYZ | - | [ToGeos] | [GeosWriter](geos::GeosWriter) | //! | GPX | | XY | [GpxReader](gpx::GpxReader) | | | @@ -60,9 +60,6 @@ pub use geometry_processor::*; pub use multiplex::*; pub use property_processor::*; -#[cfg(feature = "with-arrow")] -pub mod arrow; - #[cfg(feature = "with-csv")] pub mod csv; #[cfg(feature = "with-csv")]