From e525deb1c1e3434b18a9d87d5fae2630336b490c Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Thu, 14 Nov 2024 19:25:08 -0500 Subject: [PATCH 01/14] Remove const generic from arrays --- .../src/interop/shapely/to_shapely.rs | 12 +- rust/geoarrow/src/algorithm/geo/affine_ops.rs | 80 ++-- rust/geoarrow/src/algorithm/geo/area.rs | 94 ++--- .../src/algorithm/geo/bounding_rect.rs | 58 +-- rust/geoarrow/src/algorithm/geo/center.rs | 58 +-- rust/geoarrow/src/algorithm/geo/centroid.rs | 62 +-- .../src/algorithm/geo/chaikin_smoothing.rs | 32 +- .../geo/chamberlain_duquette_area.rs | 84 ++-- rust/geoarrow/src/algorithm/geo/contains.rs | 328 ++++++++-------- .../geoarrow/src/algorithm/geo/convex_hull.rs | 70 ++-- rust/geoarrow/src/algorithm/geo/densify.rs | 32 +- rust/geoarrow/src/algorithm/geo/dimensions.rs | 52 ++- .../src/algorithm/geo/euclidean_distance.rs | 146 +++---- .../src/algorithm/geo/euclidean_length.rs | 68 ++-- .../src/algorithm/geo/frechet_distance.rs | 24 +- .../src/algorithm/geo/geodesic_area.rs | 180 ++++----- .../src/algorithm/geo/geodesic_length.rs | 52 +-- .../src/algorithm/geo/haversine_length.rs | 52 +-- rust/geoarrow/src/algorithm/geo/intersects.rs | 363 +++++++++--------- .../algorithm/geo/line_interpolate_point.rs | 32 +- .../src/algorithm/geo/line_locate_point.rs | 22 +- .../src/algorithm/geo/minimum_rotated_rect.rs | 56 +-- .../algorithm/geo/remove_repeated_points.rs | 64 +-- rust/geoarrow/src/algorithm/geo/rotate.rs | 24 +- rust/geoarrow/src/algorithm/geo/scale.rs | 16 +- rust/geoarrow/src/algorithm/geo/simplify.rs | 66 ++-- .../geoarrow/src/algorithm/geo/simplify_vw.rs | 62 +-- .../src/algorithm/geo/simplify_vw_preserve.rs | 60 +-- rust/geoarrow/src/algorithm/geo/skew.rs | 16 +- rust/geoarrow/src/algorithm/geo/translate.rs | 16 +- .../src/algorithm/geo/vincenty_length.rs | 52 +-- rust/geoarrow/src/algorithm/geo/within.rs | 216 +++++------ .../geoarrow/src/algorithm/geo_index/rtree.rs | 91 ++--- rust/geoarrow/src/algorithm/geos/area.rs | 52 +-- rust/geoarrow/src/algorithm/geos/buffer.rs | 6 +- rust/geoarrow/src/algorithm/geos/is_empty.rs | 50 +-- rust/geoarrow/src/algorithm/geos/is_ring.rs | 50 +-- rust/geoarrow/src/algorithm/geos/is_simple.rs | 50 +-- rust/geoarrow/src/algorithm/geos/is_valid.rs | 50 +-- rust/geoarrow/src/algorithm/geos/length.rs | 50 +-- rust/geoarrow/src/algorithm/geos/util.rs | 4 +- rust/geoarrow/src/algorithm/native/binary.rs | 146 +++---- rust/geoarrow/src/algorithm/native/cast.rs | 144 +++---- .../src/algorithm/native/map_coords.rs | 130 +++---- rust/geoarrow/src/algorithm/native/rechunk.rs | 20 +- rust/geoarrow/src/algorithm/native/take.rs | 84 ++-- .../src/algorithm/native/total_bounds.rs | 20 +- rust/geoarrow/src/algorithm/native/unary.rs | 40 +- rust/geoarrow/src/algorithm/polylabel.rs | 16 +- rust/geoarrow/src/algorithm/proj.rs | 20 +- rust/geoarrow/src/algorithm/rstar.rs | 27 +- rust/geoarrow/src/array/cast.rs | 185 +++++---- rust/geoarrow/src/array/dynamic.rs | 18 +- rust/geoarrow/src/array/geometry/array.rs | 4 +- .../src/array/geometrycollection/array.rs | 99 +++-- .../src/array/geometrycollection/builder.rs | 38 +- rust/geoarrow/src/array/linestring/array.rs | 83 ++-- rust/geoarrow/src/array/linestring/builder.rs | 32 +- rust/geoarrow/src/array/mixed/array.rs | 128 +++--- rust/geoarrow/src/array/mixed/builder.rs | 36 +- .../src/array/multilinestring/array.rs | 83 ++-- .../src/array/multilinestring/builder.rs | 68 ++-- rust/geoarrow/src/array/multipoint/array.rs | 83 ++-- rust/geoarrow/src/array/multipoint/builder.rs | 32 +- rust/geoarrow/src/array/multipolygon/array.rs | 79 ++-- .../src/array/multipolygon/builder.rs | 30 +- rust/geoarrow/src/array/point/array.rs | 76 ++-- rust/geoarrow/src/array/point/builder.rs | 28 +- rust/geoarrow/src/array/polygon/array.rs | 87 ++--- rust/geoarrow/src/array/polygon/builder.rs | 32 +- rust/geoarrow/src/array/rect/array.rs | 30 +- rust/geoarrow/src/array/rect/builder.rs | 22 +- rust/geoarrow/src/chunked_array/mod.rs | 30 +- rust/geoarrow/src/indexed/array.rs | 18 +- rust/geoarrow/src/indexed/chunked.rs | 18 +- rust/geoarrow/src/io/display/scalar.rs | 18 +- .../src/io/geos/array/geometrycollection.rs | 4 +- rust/geoarrow/src/io/geos/array/linestring.rs | 4 +- rust/geoarrow/src/io/geos/array/mixed.rs | 4 +- .../src/io/geos/array/multilinestring.rs | 4 +- rust/geoarrow/src/io/geos/array/multipoint.rs | 4 +- .../src/io/geos/array/multipolygon.rs | 4 +- rust/geoarrow/src/io/geos/array/point.rs | 4 +- rust/geoarrow/src/io/geos/array/polygon.rs | 4 +- rust/geoarrow/src/io/geos/scalar/geometry.rs | 4 +- .../src/io/geos/scalar/geometrycollection.rs | 4 +- .../geoarrow/src/io/geos/scalar/linestring.rs | 6 +- .../src/io/geos/scalar/multilinestring.rs | 4 +- .../geoarrow/src/io/geos/scalar/multipoint.rs | 4 +- .../src/io/geos/scalar/multipolygon.rs | 4 +- rust/geoarrow/src/io/geos/scalar/point.rs | 4 +- rust/geoarrow/src/io/geos/scalar/polygon.rs | 4 +- .../io/geozero/array/geometrycollection.rs | 2 +- .../src/io/geozero/array/linestring.rs | 6 +- rust/geoarrow/src/io/geozero/array/mixed.rs | 14 +- .../src/io/geozero/array/multilinestring.rs | 6 +- .../src/io/geozero/array/multipoint.rs | 6 +- .../src/io/geozero/array/multipolygon.rs | 6 +- rust/geoarrow/src/io/geozero/array/point.rs | 6 +- rust/geoarrow/src/io/geozero/array/polygon.rs | 6 +- .../src/io/geozero/scalar/geometry.rs | 2 +- .../io/geozero/scalar/geometry_collection.rs | 2 +- .../src/io/geozero/scalar/linestring.rs | 2 +- .../src/io/geozero/scalar/multilinestring.rs | 2 +- .../src/io/geozero/scalar/multipoint.rs | 2 +- .../src/io/geozero/scalar/multipolygon.rs | 2 +- rust/geoarrow/src/io/geozero/scalar/point.rs | 2 +- .../geoarrow/src/io/geozero/scalar/polygon.rs | 2 +- rust/geoarrow/src/io/parquet/reader/parse.rs | 4 +- rust/geoarrow/src/scalar/geometry/owned.rs | 62 +-- rust/geoarrow/src/scalar/geometry/scalar.rs | 100 ++--- .../src/scalar/geometrycollection/owned.rs | 25 +- .../src/scalar/geometrycollection/scalar.rs | 49 +-- rust/geoarrow/src/scalar/linestring/owned.rs | 24 +- rust/geoarrow/src/scalar/linestring/scalar.rs | 28 +- .../src/scalar/multilinestring/owned.rs | 29 +- .../src/scalar/multilinestring/scalar.rs | 28 +- rust/geoarrow/src/scalar/multipoint/owned.rs | 35 +- rust/geoarrow/src/scalar/multipoint/scalar.rs | 47 ++- .../geoarrow/src/scalar/multipolygon/owned.rs | 35 +- .../src/scalar/multipolygon/scalar.rs | 49 ++- rust/geoarrow/src/scalar/point/owned.rs | 28 +- rust/geoarrow/src/scalar/point/scalar.rs | 26 +- rust/geoarrow/src/scalar/polygon/owned.rs | 23 +- rust/geoarrow/src/scalar/polygon/scalar.rs | 47 ++- rust/geoarrow/src/scalar/rect/owned.rs | 22 +- rust/geoarrow/src/scalar/rect/scalar.rs | 24 +- rust/geoarrow/src/scalar/scalar.rs | 2 +- rust/geoarrow/src/trait_.rs | 12 +- 129 files changed, 2808 insertions(+), 2981 deletions(-) diff --git a/python/geoarrow-core/src/interop/shapely/to_shapely.rs b/python/geoarrow-core/src/interop/shapely/to_shapely.rs index 0516dd8d..640bc59c 100644 --- a/python/geoarrow-core/src/interop/shapely/to_shapely.rs +++ b/python/geoarrow-core/src/interop/shapely/to_shapely.rs @@ -135,7 +135,7 @@ fn pyarray_to_shapely(py: Python, input: PyArray) -> PyGeoArrowResult( +fn point_arr( py: Python, arr: geoarrow::array::PointArray, ) -> PyGeoArrowResult> { @@ -150,7 +150,7 @@ fn point_arr( Ok(shapely_mod.call_method1(intern!(py, "from_ragged_array"), args)?) } -fn linestring_arr( +fn linestring_arr( py: Python, arr: geoarrow::array::LineStringArray, ) -> PyGeoArrowResult> { @@ -168,7 +168,7 @@ fn linestring_arr( Ok(shapely_mod.call_method1(intern!(py, "from_ragged_array"), args)?) } -fn polygon_arr( +fn polygon_arr( py: Python, arr: geoarrow::array::PolygonArray, ) -> PyGeoArrowResult> { @@ -189,7 +189,7 @@ fn polygon_arr( Ok(shapely_mod.call_method1(intern!(py, "from_ragged_array"), args)?) } -fn multipoint_arr( +fn multipoint_arr( py: Python, arr: geoarrow::array::MultiPointArray, ) -> PyGeoArrowResult> { @@ -207,7 +207,7 @@ fn multipoint_arr( Ok(shapely_mod.call_method1(intern!(py, "from_ragged_array"), args)?) } -fn multilinestring_arr( +fn multilinestring_arr( py: Python, arr: geoarrow::array::MultiLineStringArray, ) -> PyGeoArrowResult> { @@ -228,7 +228,7 @@ fn multilinestring_arr( Ok(shapely_mod.call_method1(intern!(py, "from_ragged_array"), args)?) } -fn multipolygon_arr( +fn multipolygon_arr( py: Python, arr: geoarrow::array::MultiPolygonArray, ) -> PyGeoArrowResult> { diff --git a/rust/geoarrow/src/algorithm/geo/affine_ops.rs b/rust/geoarrow/src/algorithm/geo/affine_ops.rs index e3863d8a..12808eed 100644 --- a/rust/geoarrow/src/algorithm/geo/affine_ops.rs +++ b/rust/geoarrow/src/algorithm/geo/affine_ops.rs @@ -54,7 +54,7 @@ pub trait AffineOps { // └─────────────────────────────────┘ // Note: this can't (easily) be parameterized in the macro because PointArray is not generic over O -impl AffineOps<&AffineTransform> for PointArray<2> { +impl AffineOps<&AffineTransform> for PointArray { type Output = Self; fn affine_transform(&self, transform: &AffineTransform) -> Self::Output { @@ -97,27 +97,27 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, LineStringBuilder<2>, push_line_string); -iter_geo_impl!(PolygonArray<2>, PolygonBuilder<2>, push_polygon); -iter_geo_impl!(MultiPointArray<2>, MultiPointBuilder<2>, push_multi_point); +iter_geo_impl!(LineStringArray, LineStringBuilder, push_line_string); +iter_geo_impl!(PolygonArray, PolygonBuilder, push_polygon); +iter_geo_impl!(MultiPointArray, MultiPointBuilder, push_multi_point); iter_geo_impl!( - MultiLineStringArray<2>, - MultiLineStringBuilder<2>, + MultiLineStringArray, + MultiLineStringBuilder, push_multi_line_string ); iter_geo_impl!( - MultiPolygonArray<2>, - MultiPolygonBuilder<2>, + MultiPolygonArray, + MultiPolygonBuilder, push_multi_polygon ); iter_geo_impl!( - MixedGeometryArray<2>, - MixedGeometryBuilder<2>, + MixedGeometryArray, + MixedGeometryBuilder, push_geometry ); iter_geo_impl!( - GeometryCollectionArray<2>, - GeometryCollectionBuilder<2>, + GeometryCollectionArray, + GeometryCollectionBuilder, push_geometry_collection ); @@ -149,7 +149,7 @@ impl AffineOps<&AffineTransform> for &dyn NativeArray { } } -impl AffineOps<&AffineTransform> for ChunkedPointArray<2> { +impl AffineOps<&AffineTransform> for ChunkedPointArray { type Output = Self; fn affine_transform(&self, transform: &AffineTransform) -> Self::Output { @@ -173,13 +173,13 @@ macro_rules! impl_chunked { }; } -impl_chunked!(ChunkedLineStringArray<2>); -impl_chunked!(ChunkedPolygonArray<2>); -impl_chunked!(ChunkedMultiPointArray<2>); -impl_chunked!(ChunkedMultiLineStringArray<2>); -impl_chunked!(ChunkedMultiPolygonArray<2>); -impl_chunked!(ChunkedMixedGeometryArray<2>); -impl_chunked!(ChunkedGeometryCollectionArray<2>); +impl_chunked!(ChunkedLineStringArray); +impl_chunked!(ChunkedPolygonArray); +impl_chunked!(ChunkedMultiPointArray); +impl_chunked!(ChunkedMultiLineStringArray); +impl_chunked!(ChunkedMultiPolygonArray); +impl_chunked!(ChunkedMixedGeometryArray); +impl_chunked!(ChunkedGeometryCollectionArray); impl AffineOps<&AffineTransform> for &dyn ChunkedNativeArray { type Output = Result>; @@ -214,7 +214,7 @@ impl AffineOps<&AffineTransform> for &dyn ChunkedNativeArray { // └────────────────────────────────┘ // Note: this can't (easily) be parameterized in the macro because PointArray is not generic over O -impl AffineOps<&[AffineTransform]> for PointArray<2> { +impl AffineOps<&[AffineTransform]> for PointArray { type Output = Self; fn affine_transform(&self, transform: &[AffineTransform]) -> Self::Output { @@ -261,27 +261,27 @@ macro_rules! iter_geo_impl2 { }; } -iter_geo_impl2!(LineStringArray<2>, LineStringBuilder<2>, push_line_string); -iter_geo_impl2!(PolygonArray<2>, PolygonBuilder<2>, push_polygon); -iter_geo_impl2!(MultiPointArray<2>, MultiPointBuilder<2>, push_multi_point); +iter_geo_impl2!(LineStringArray, LineStringBuilder, push_line_string); +iter_geo_impl2!(PolygonArray, PolygonBuilder, push_polygon); +iter_geo_impl2!(MultiPointArray, MultiPointBuilder, push_multi_point); iter_geo_impl2!( - MultiLineStringArray<2>, - MultiLineStringBuilder<2>, + MultiLineStringArray, + MultiLineStringBuilder, push_multi_line_string ); iter_geo_impl2!( - MultiPolygonArray<2>, - MultiPolygonBuilder<2>, + MultiPolygonArray, + MultiPolygonBuilder, push_multi_polygon ); iter_geo_impl2!( - MixedGeometryArray<2>, - MixedGeometryBuilder<2>, + MixedGeometryArray, + MixedGeometryBuilder, push_geometry ); iter_geo_impl2!( - GeometryCollectionArray<2>, - GeometryCollectionBuilder<2>, + GeometryCollectionArray, + GeometryCollectionBuilder, push_geometry_collection ); @@ -293,19 +293,19 @@ impl AffineOps<&[AffineTransform]> for &dyn NativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().affine_transform(transform)), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().affine_transform(transform)), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().affine_transform(transform)), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().affine_transform(transform)), + Point(_, XY) => Arc::new(self.as_point().affine_transform(transform)), + LineString(_, XY) => Arc::new(self.as_line_string().affine_transform(transform)), + Polygon(_, XY) => Arc::new(self.as_polygon().affine_transform(transform)), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().affine_transform(transform)), MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string::<2>().affine_transform(transform)) + Arc::new(self.as_multi_line_string().affine_transform(transform)) } MultiPolygon(_, XY) => { - Arc::new(self.as_multi_polygon::<2>().affine_transform(transform)) + Arc::new(self.as_multi_polygon().affine_transform(transform)) } - Mixed(_, XY) => Arc::new(self.as_mixed::<2>().affine_transform(transform)), + Mixed(_, XY) => Arc::new(self.as_mixed().affine_transform(transform)), GeometryCollection(_, XY) => Arc::new( - self.as_geometry_collection::<2>() + self.as_geometry_collection() .affine_transform(transform), ), _ => return Err(GeoArrowError::IncorrectType("".into())), diff --git a/rust/geoarrow/src/algorithm/geo/area.rs b/rust/geoarrow/src/algorithm/geo/area.rs index 639d2b47..33065117 100644 --- a/rust/geoarrow/src/algorithm/geo/area.rs +++ b/rust/geoarrow/src/algorithm/geo/area.rs @@ -32,8 +32,8 @@ use geo::prelude::Area as GeoArea; /// line_string.0.reverse(); /// }); /// -/// let polygon_array: PolygonArray<2> = vec![polygon].as_slice().into(); -/// let reversed_polygon_array: PolygonArray<2> = vec![reversed_polygon].as_slice().into(); +/// let polygon_array: PolygonArray = vec![polygon].as_slice().into(); +/// let reversed_polygon_array: PolygonArray = vec![reversed_polygon].as_slice().into(); /// /// assert_eq!(polygon_array.signed_area().value(0), 30.); /// assert_eq!(polygon_array.unsigned_area().value(0), 30.); @@ -66,10 +66,10 @@ macro_rules! zero_impl { }; } -zero_impl!(PointArray<2>); -zero_impl!(LineStringArray<2>); -zero_impl!(MultiPointArray<2>); -zero_impl!(MultiLineStringArray<2>); +zero_impl!(PointArray); +zero_impl!(LineStringArray); +zero_impl!(MultiPointArray); +zero_impl!(MultiLineStringArray); macro_rules! iter_geo_impl { ($type:ty) => { @@ -87,11 +87,11 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(PolygonArray<2>); -iter_geo_impl!(MultiPolygonArray<2>); -iter_geo_impl!(MixedGeometryArray<2>); -iter_geo_impl!(GeometryCollectionArray<2>); -iter_geo_impl!(RectArray<2>); +iter_geo_impl!(PolygonArray); +iter_geo_impl!(MultiPolygonArray); +iter_geo_impl!(MixedGeometryArray); +iter_geo_impl!(GeometryCollectionArray); +iter_geo_impl!(RectArray); impl Area for &dyn NativeArray { type Output = Result; @@ -101,15 +101,15 @@ impl Area for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().signed_area(), - LineString(_, XY) => self.as_line_string::<2>().signed_area(), - Polygon(_, XY) => self.as_polygon::<2>().signed_area(), - MultiPoint(_, XY) => self.as_multi_point::<2>().signed_area(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().signed_area(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().signed_area(), - Mixed(_, XY) => self.as_mixed::<2>().signed_area(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().signed_area(), - Rect(XY) => self.as_rect::<2>().signed_area(), + Point(_, XY) => self.as_point().signed_area(), + LineString(_, XY) => self.as_line_string().signed_area(), + Polygon(_, XY) => self.as_polygon().signed_area(), + MultiPoint(_, XY) => self.as_multi_point().signed_area(), + MultiLineString(_, XY) => self.as_multi_line_string().signed_area(), + MultiPolygon(_, XY) => self.as_multi_polygon().signed_area(), + Mixed(_, XY) => self.as_mixed().signed_area(), + GeometryCollection(_, XY) => self.as_geometry_collection().signed_area(), + Rect(XY) => self.as_rect().signed_area(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -120,15 +120,15 @@ impl Area for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().unsigned_area(), - LineString(_, XY) => self.as_line_string::<2>().unsigned_area(), - Polygon(_, XY) => self.as_polygon::<2>().unsigned_area(), - MultiPoint(_, XY) => self.as_multi_point::<2>().unsigned_area(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().unsigned_area(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().unsigned_area(), - Mixed(_, XY) => self.as_mixed::<2>().unsigned_area(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().unsigned_area(), - Rect(XY) => self.as_rect::<2>().unsigned_area(), + Point(_, XY) => self.as_point().unsigned_area(), + LineString(_, XY) => self.as_line_string().unsigned_area(), + Polygon(_, XY) => self.as_polygon().unsigned_area(), + MultiPoint(_, XY) => self.as_multi_point().unsigned_area(), + MultiLineString(_, XY) => self.as_multi_line_string().unsigned_area(), + MultiPolygon(_, XY) => self.as_multi_polygon().unsigned_area(), + Mixed(_, XY) => self.as_mixed().unsigned_area(), + GeometryCollection(_, XY) => self.as_geometry_collection().unsigned_area(), + Rect(XY) => self.as_rect().unsigned_area(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -157,15 +157,15 @@ impl Area for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().signed_area(), - LineString(_, XY) => self.as_line_string::<2>().signed_area(), - Polygon(_, XY) => self.as_polygon::<2>().signed_area(), - MultiPoint(_, XY) => self.as_multi_point::<2>().signed_area(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().signed_area(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().signed_area(), - Mixed(_, XY) => self.as_mixed::<2>().signed_area(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().signed_area(), - Rect(XY) => self.as_rect::<2>().signed_area(), + Point(_, XY) => self.as_point().signed_area(), + LineString(_, XY) => self.as_line_string().signed_area(), + Polygon(_, XY) => self.as_polygon().signed_area(), + MultiPoint(_, XY) => self.as_multi_point().signed_area(), + MultiLineString(_, XY) => self.as_multi_line_string().signed_area(), + MultiPolygon(_, XY) => self.as_multi_polygon().signed_area(), + Mixed(_, XY) => self.as_mixed().signed_area(), + GeometryCollection(_, XY) => self.as_geometry_collection().signed_area(), + Rect(XY) => self.as_rect().signed_area(), _ => Err(GeoArrowError::IncorrectType("".into())), } } @@ -175,15 +175,15 @@ impl Area for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().unsigned_area(), - LineString(_, XY) => self.as_line_string::<2>().unsigned_area(), - Polygon(_, XY) => self.as_polygon::<2>().unsigned_area(), - MultiPoint(_, XY) => self.as_multi_point::<2>().unsigned_area(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().unsigned_area(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().unsigned_area(), - Mixed(_, XY) => self.as_mixed::<2>().unsigned_area(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().unsigned_area(), - Rect(XY) => self.as_rect::<2>().unsigned_area(), + Point(_, XY) => self.as_point().unsigned_area(), + LineString(_, XY) => self.as_line_string().unsigned_area(), + Polygon(_, XY) => self.as_polygon().unsigned_area(), + MultiPoint(_, XY) => self.as_multi_point().unsigned_area(), + MultiLineString(_, XY) => self.as_multi_line_string().unsigned_area(), + MultiPolygon(_, XY) => self.as_multi_polygon().unsigned_area(), + Mixed(_, XY) => self.as_mixed().unsigned_area(), + GeometryCollection(_, XY) => self.as_geometry_collection().unsigned_area(), + Rect(XY) => self.as_rect().unsigned_area(), _ => Err(GeoArrowError::IncorrectType("".into())), } } diff --git a/rust/geoarrow/src/algorithm/geo/bounding_rect.rs b/rust/geoarrow/src/algorithm/geo/bounding_rect.rs index ad5fa29b..c5c09787 100644 --- a/rust/geoarrow/src/algorithm/geo/bounding_rect.rs +++ b/rust/geoarrow/src/algorithm/geo/bounding_rect.rs @@ -35,8 +35,8 @@ pub trait BoundingRect { fn bounding_rect(&self) -> Self::Output; } -impl BoundingRect for PointArray<2> { - type Output = RectArray<2>; +impl BoundingRect for PointArray { + type Output = RectArray; fn bounding_rect(&self) -> Self::Output { let output_geoms: Vec> = self @@ -52,7 +52,7 @@ impl BoundingRect for PointArray<2> { macro_rules! iter_geo_impl { ($type:ty) => { impl BoundingRect for $type { - type Output = RectArray<2>; + type Output = RectArray; fn bounding_rect(&self) -> Self::Output { let output_geoms: Vec> = self @@ -66,30 +66,30 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(PolygonArray<2>); -iter_geo_impl!(MultiPointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>); -iter_geo_impl!(MixedGeometryArray<2>); -iter_geo_impl!(GeometryCollectionArray<2>); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(PolygonArray); +iter_geo_impl!(MultiPointArray); +iter_geo_impl!(MultiLineStringArray); +iter_geo_impl!(MultiPolygonArray); +iter_geo_impl!(MixedGeometryArray); +iter_geo_impl!(GeometryCollectionArray); impl BoundingRect for &dyn NativeArray { - type Output = Result>; + type Output = Result; fn bounding_rect(&self) -> Self::Output { use Dimension::*; use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().bounding_rect(), - LineString(_, XY) => self.as_line_string::<2>().bounding_rect(), - Polygon(_, XY) => self.as_polygon::<2>().bounding_rect(), - MultiPoint(_, XY) => self.as_multi_point::<2>().bounding_rect(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().bounding_rect(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().bounding_rect(), - Mixed(_, XY) => self.as_mixed::<2>().bounding_rect(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().bounding_rect(), + Point(_, XY) => self.as_point().bounding_rect(), + LineString(_, XY) => self.as_line_string().bounding_rect(), + Polygon(_, XY) => self.as_polygon().bounding_rect(), + MultiPoint(_, XY) => self.as_multi_point().bounding_rect(), + MultiLineString(_, XY) => self.as_multi_line_string().bounding_rect(), + MultiPolygon(_, XY) => self.as_multi_polygon().bounding_rect(), + Mixed(_, XY) => self.as_mixed().bounding_rect(), + GeometryCollection(_, XY) => self.as_geometry_collection().bounding_rect(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -97,7 +97,7 @@ impl BoundingRect for &dyn NativeArray { } impl BoundingRect for ChunkedGeometryArray { - type Output = Result>>; + type Output = Result>; fn bounding_rect(&self) -> Self::Output { self.try_map(|chunk| chunk.as_ref().bounding_rect())? @@ -106,21 +106,21 @@ impl BoundingRect for ChunkedGeometryArray { } impl BoundingRect for &dyn ChunkedNativeArray { - type Output = Result>>; + type Output = Result>; fn bounding_rect(&self) -> Self::Output { use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().bounding_rect(), - LineString(_, XY) => self.as_line_string::<2>().bounding_rect(), - Polygon(_, XY) => self.as_polygon::<2>().bounding_rect(), - MultiPoint(_, XY) => self.as_multi_point::<2>().bounding_rect(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().bounding_rect(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().bounding_rect(), - Mixed(_, XY) => self.as_mixed::<2>().bounding_rect(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().bounding_rect(), + Point(_, XY) => self.as_point().bounding_rect(), + LineString(_, XY) => self.as_line_string().bounding_rect(), + Polygon(_, XY) => self.as_polygon().bounding_rect(), + MultiPoint(_, XY) => self.as_multi_point().bounding_rect(), + MultiLineString(_, XY) => self.as_multi_line_string().bounding_rect(), + MultiPolygon(_, XY) => self.as_multi_polygon().bounding_rect(), + Mixed(_, XY) => self.as_mixed().bounding_rect(), + GeometryCollection(_, XY) => self.as_geometry_collection().bounding_rect(), _ => Err(GeoArrowError::IncorrectType("".into())), } } diff --git a/rust/geoarrow/src/algorithm/geo/center.rs b/rust/geoarrow/src/algorithm/geo/center.rs index 798afcb9..5aa7f10e 100644 --- a/rust/geoarrow/src/algorithm/geo/center.rs +++ b/rust/geoarrow/src/algorithm/geo/center.rs @@ -15,8 +15,8 @@ pub trait Center { fn center(&self) -> Self::Output; } -impl Center for PointArray<2> { - type Output = PointArray<2>; +impl Center for PointArray { + type Output = PointArray; fn center(&self) -> Self::Output { self.clone() @@ -27,7 +27,7 @@ impl Center for PointArray<2> { macro_rules! iter_geo_impl { ($type:ty) => { impl Center for $type { - type Output = PointArray<2>; + type Output = PointArray; fn center(&self) -> Self::Output { let mut output_array = PointBuilder::with_capacity(self.len()); @@ -44,30 +44,30 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(PolygonArray<2>); -iter_geo_impl!(MultiPointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>); -iter_geo_impl!(MixedGeometryArray<2>); -iter_geo_impl!(GeometryCollectionArray<2>); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(PolygonArray); +iter_geo_impl!(MultiPointArray); +iter_geo_impl!(MultiLineStringArray); +iter_geo_impl!(MultiPolygonArray); +iter_geo_impl!(MixedGeometryArray); +iter_geo_impl!(GeometryCollectionArray); impl Center for &dyn NativeArray { - type Output = Result>; + type Output = Result; fn center(&self) -> Self::Output { use Dimension::*; use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().center(), - LineString(_, XY) => self.as_line_string::<2>().center(), - Polygon(_, XY) => self.as_polygon::<2>().center(), - MultiPoint(_, XY) => self.as_multi_point::<2>().center(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().center(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().center(), - Mixed(_, XY) => self.as_mixed::<2>().center(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().center(), + Point(_, XY) => self.as_point().center(), + LineString(_, XY) => self.as_line_string().center(), + Polygon(_, XY) => self.as_polygon().center(), + MultiPoint(_, XY) => self.as_multi_point().center(), + MultiLineString(_, XY) => self.as_multi_line_string().center(), + MultiPolygon(_, XY) => self.as_multi_polygon().center(), + Mixed(_, XY) => self.as_mixed().center(), + GeometryCollection(_, XY) => self.as_geometry_collection().center(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -75,7 +75,7 @@ impl Center for &dyn NativeArray { } impl Center for ChunkedGeometryArray { - type Output = Result>; + type Output = Result; fn center(&self) -> Self::Output { self.try_map(|chunk| chunk.as_ref().center())?.try_into() @@ -83,21 +83,21 @@ impl Center for ChunkedGeometryArray { } impl Center for &dyn ChunkedNativeArray { - type Output = Result>; + type Output = Result; fn center(&self) -> Self::Output { use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().center(), - LineString(_, XY) => self.as_line_string::<2>().center(), - Polygon(_, XY) => self.as_polygon::<2>().center(), - MultiPoint(_, XY) => self.as_multi_point::<2>().center(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().center(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().center(), - Mixed(_, XY) => self.as_mixed::<2>().center(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().center(), + Point(_, XY) => self.as_point().center(), + LineString(_, XY) => self.as_line_string().center(), + Polygon(_, XY) => self.as_polygon().center(), + MultiPoint(_, XY) => self.as_multi_point().center(), + MultiLineString(_, XY) => self.as_multi_line_string().center(), + MultiPolygon(_, XY) => self.as_multi_polygon().center(), + Mixed(_, XY) => self.as_mixed().center(), + GeometryCollection(_, XY) => self.as_geometry_collection().center(), _ => Err(GeoArrowError::IncorrectType("".into())), } } diff --git a/rust/geoarrow/src/algorithm/geo/centroid.rs b/rust/geoarrow/src/algorithm/geo/centroid.rs index f33bd1a2..52d0dcc5 100644 --- a/rust/geoarrow/src/algorithm/geo/centroid.rs +++ b/rust/geoarrow/src/algorithm/geo/centroid.rs @@ -30,7 +30,7 @@ use geo::algorithm::centroid::Centroid as GeoCentroid; /// (x: 1., y: -1.), /// (x: -2., y: 1.), /// ]; -/// let polygon_array: PolygonArray<2> = vec![polygon].as_slice().into(); +/// let polygon_array: PolygonArray = vec![polygon].as_slice().into(); /// /// assert_eq!( /// Some(point!(x: 1., y: 1.)), @@ -54,7 +54,7 @@ pub trait Centroid { /// (x: 40.02f64, y: 116.34), /// (x: 40.02f64, y: 118.23), /// ]; - /// let line_string_array: LineStringArray<2> = vec![line_string].as_slice().into(); + /// let line_string_array: LineStringArray = vec![line_string].as_slice().into(); /// /// assert_eq!( /// Some(point!(x: 40.02, y: 117.285)), @@ -64,8 +64,8 @@ pub trait Centroid { fn centroid(&self) -> Self::Output; } -impl Centroid for PointArray<2> { - type Output = PointArray<2>; +impl Centroid for PointArray { + type Output = PointArray; fn centroid(&self) -> Self::Output { self.clone() @@ -76,7 +76,7 @@ impl Centroid for PointArray<2> { macro_rules! iter_geo_impl { ($type:ty) => { impl Centroid for $type { - type Output = PointArray<2>; + type Output = PointArray; fn centroid(&self) -> Self::Output { let mut output_array = PointBuilder::with_capacity(self.len()); @@ -89,30 +89,30 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(PolygonArray<2>); -iter_geo_impl!(MultiPointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>); -iter_geo_impl!(MixedGeometryArray<2>); -iter_geo_impl!(GeometryCollectionArray<2>); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(PolygonArray); +iter_geo_impl!(MultiPointArray); +iter_geo_impl!(MultiLineStringArray); +iter_geo_impl!(MultiPolygonArray); +iter_geo_impl!(MixedGeometryArray); +iter_geo_impl!(GeometryCollectionArray); impl Centroid for &dyn NativeArray { - type Output = Result>; + type Output = Result; fn centroid(&self) -> Self::Output { use Dimension::*; use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().centroid(), - LineString(_, XY) => self.as_line_string::<2>().centroid(), - Polygon(_, XY) => self.as_polygon::<2>().centroid(), - MultiPoint(_, XY) => self.as_multi_point::<2>().centroid(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().centroid(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().centroid(), - Mixed(_, XY) => self.as_mixed::<2>().centroid(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().centroid(), + Point(_, XY) => self.as_point().centroid(), + LineString(_, XY) => self.as_line_string().centroid(), + Polygon(_, XY) => self.as_polygon().centroid(), + MultiPoint(_, XY) => self.as_multi_point().centroid(), + MultiLineString(_, XY) => self.as_multi_line_string().centroid(), + MultiPolygon(_, XY) => self.as_multi_polygon().centroid(), + Mixed(_, XY) => self.as_mixed().centroid(), + GeometryCollection(_, XY) => self.as_geometry_collection().centroid(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -120,7 +120,7 @@ impl Centroid for &dyn NativeArray { } impl Centroid for ChunkedGeometryArray { - type Output = Result>; + type Output = Result; fn centroid(&self) -> Self::Output { self.try_map(|chunk| chunk.as_ref().centroid())?.try_into() @@ -128,21 +128,21 @@ impl Centroid for ChunkedGeometryArray { } impl Centroid for &dyn ChunkedNativeArray { - type Output = Result>; + type Output = Result; fn centroid(&self) -> Self::Output { use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().centroid(), - LineString(_, XY) => self.as_line_string::<2>().centroid(), - Polygon(_, XY) => self.as_polygon::<2>().centroid(), - MultiPoint(_, XY) => self.as_multi_point::<2>().centroid(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().centroid(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().centroid(), - Mixed(_, XY) => self.as_mixed::<2>().centroid(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().centroid(), + Point(_, XY) => self.as_point().centroid(), + LineString(_, XY) => self.as_line_string().centroid(), + Polygon(_, XY) => self.as_polygon().centroid(), + MultiPoint(_, XY) => self.as_multi_point().centroid(), + MultiLineString(_, XY) => self.as_multi_line_string().centroid(), + MultiPolygon(_, XY) => self.as_multi_polygon().centroid(), + Mixed(_, XY) => self.as_mixed().centroid(), + GeometryCollection(_, XY) => self.as_geometry_collection().centroid(), _ => Err(GeoArrowError::IncorrectType("".into())), } } diff --git a/rust/geoarrow/src/algorithm/geo/chaikin_smoothing.rs b/rust/geoarrow/src/algorithm/geo/chaikin_smoothing.rs index 04a00ac3..0fc85e48 100644 --- a/rust/geoarrow/src/algorithm/geo/chaikin_smoothing.rs +++ b/rust/geoarrow/src/algorithm/geo/chaikin_smoothing.rs @@ -46,10 +46,10 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, geo::LineString); -iter_geo_impl!(PolygonArray<2>, geo::Polygon); -iter_geo_impl!(MultiLineStringArray<2>, geo::MultiLineString); -iter_geo_impl!(MultiPolygonArray<2>, geo::MultiPolygon); +iter_geo_impl!(LineStringArray, geo::LineString); +iter_geo_impl!(PolygonArray, geo::Polygon); +iter_geo_impl!(MultiLineStringArray, geo::MultiLineString); +iter_geo_impl!(MultiPolygonArray, geo::MultiPolygon); impl ChaikinSmoothing for &dyn NativeArray { type Output = Result>; @@ -60,15 +60,15 @@ impl ChaikinSmoothing for &dyn NativeArray { let result: Arc = match self.data_type() { LineString(_, XY) => { - Arc::new(self.as_line_string::<2>().chaikin_smoothing(n_iterations)) + Arc::new(self.as_line_string().chaikin_smoothing(n_iterations)) } - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().chaikin_smoothing(n_iterations)), + Polygon(_, XY) => Arc::new(self.as_polygon().chaikin_smoothing(n_iterations)), MultiLineString(_, XY) => Arc::new( - self.as_multi_line_string::<2>() + self.as_multi_line_string() .chaikin_smoothing(n_iterations), ), MultiPolygon(_, XY) => { - Arc::new(self.as_multi_polygon::<2>().chaikin_smoothing(n_iterations)) + Arc::new(self.as_multi_polygon().chaikin_smoothing(n_iterations)) } _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -90,10 +90,10 @@ macro_rules! impl_chunked { }; } -impl_chunked!(ChunkedLineStringArray<2>); -impl_chunked!(ChunkedPolygonArray<2>); -impl_chunked!(ChunkedMultiLineStringArray<2>); -impl_chunked!(ChunkedMultiPolygonArray<2>); +impl_chunked!(ChunkedLineStringArray); +impl_chunked!(ChunkedPolygonArray); +impl_chunked!(ChunkedMultiLineStringArray); +impl_chunked!(ChunkedMultiPolygonArray); impl ChaikinSmoothing for &dyn ChunkedNativeArray { type Output = Result>; @@ -104,15 +104,15 @@ impl ChaikinSmoothing for &dyn ChunkedNativeArray { let result: Arc = match self.data_type() { LineString(_, XY) => { - Arc::new(self.as_line_string::<2>().chaikin_smoothing(n_iterations)) + Arc::new(self.as_line_string().chaikin_smoothing(n_iterations)) } - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().chaikin_smoothing(n_iterations)), + Polygon(_, XY) => Arc::new(self.as_polygon().chaikin_smoothing(n_iterations)), MultiLineString(_, XY) => Arc::new( - self.as_multi_line_string::<2>() + self.as_multi_line_string() .chaikin_smoothing(n_iterations), ), MultiPolygon(_, XY) => { - Arc::new(self.as_multi_polygon::<2>().chaikin_smoothing(n_iterations)) + Arc::new(self.as_multi_polygon().chaikin_smoothing(n_iterations)) } _ => return Err(GeoArrowError::IncorrectType("".into())), }; diff --git a/rust/geoarrow/src/algorithm/geo/chamberlain_duquette_area.rs b/rust/geoarrow/src/algorithm/geo/chamberlain_duquette_area.rs index 07dc9646..6f1f18ba 100644 --- a/rust/geoarrow/src/algorithm/geo/chamberlain_duquette_area.rs +++ b/rust/geoarrow/src/algorithm/geo/chamberlain_duquette_area.rs @@ -47,8 +47,8 @@ use geo::prelude::ChamberlainDuquetteArea as GeoChamberlainDuquetteArea; /// line_string.0.reverse(); /// }); /// -/// let polygon_array: PolygonArray<2> = vec![polygon].as_slice().into(); -/// let reversed_polygon_array: PolygonArray<2> = vec![reversed_polygon].as_slice().into(); +/// let polygon_array: PolygonArray = vec![polygon].as_slice().into(); +/// let reversed_polygon_array: PolygonArray = vec![reversed_polygon].as_slice().into(); /// /// // 78,478 meters² /// assert_eq!(78_478., polygon_array.chamberlain_duquette_unsigned_area().value(0).round()); @@ -82,10 +82,10 @@ macro_rules! zero_impl { }; } -zero_impl!(PointArray<2>); -zero_impl!(LineStringArray<2>); -zero_impl!(MultiPointArray<2>); -zero_impl!(MultiLineStringArray<2>); +zero_impl!(PointArray); +zero_impl!(LineStringArray); +zero_impl!(MultiPointArray); +zero_impl!(MultiLineStringArray); /// Implementation that iterates over geo objects macro_rules! iter_geo_impl { @@ -114,10 +114,10 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(PolygonArray<2>); -iter_geo_impl!(MultiPolygonArray<2>); -iter_geo_impl!(MixedGeometryArray<2>); -iter_geo_impl!(GeometryCollectionArray<2>); +iter_geo_impl!(PolygonArray); +iter_geo_impl!(MultiPolygonArray); +iter_geo_impl!(MixedGeometryArray); +iter_geo_impl!(GeometryCollectionArray); impl ChamberlainDuquetteArea for &dyn NativeArray { type Output = Result; @@ -127,23 +127,23 @@ impl ChamberlainDuquetteArea for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().chamberlain_duquette_signed_area(), + Point(_, XY) => self.as_point().chamberlain_duquette_signed_area(), LineString(_, XY) => self - .as_line_string::<2>() + .as_line_string() .chamberlain_duquette_signed_area(), - Polygon(_, XY) => self.as_polygon::<2>().chamberlain_duquette_signed_area(), + Polygon(_, XY) => self.as_polygon().chamberlain_duquette_signed_area(), MultiPoint(_, XY) => self - .as_multi_point::<2>() + .as_multi_point() .chamberlain_duquette_signed_area(), MultiLineString(_, XY) => self - .as_multi_line_string::<2>() + .as_multi_line_string() .chamberlain_duquette_signed_area(), MultiPolygon(_, XY) => self - .as_multi_polygon::<2>() + .as_multi_polygon() .chamberlain_duquette_signed_area(), - Mixed(_, XY) => self.as_mixed::<2>().chamberlain_duquette_signed_area(), + Mixed(_, XY) => self.as_mixed().chamberlain_duquette_signed_area(), GeometryCollection(_, XY) => self - .as_geometry_collection::<2>() + .as_geometry_collection() .chamberlain_duquette_signed_area(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -155,23 +155,23 @@ impl ChamberlainDuquetteArea for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().chamberlain_duquette_unsigned_area(), + Point(_, XY) => self.as_point().chamberlain_duquette_unsigned_area(), LineString(_, XY) => self - .as_line_string::<2>() + .as_line_string() .chamberlain_duquette_unsigned_area(), - Polygon(_, XY) => self.as_polygon::<2>().chamberlain_duquette_unsigned_area(), + Polygon(_, XY) => self.as_polygon().chamberlain_duquette_unsigned_area(), MultiPoint(_, XY) => self - .as_multi_point::<2>() + .as_multi_point() .chamberlain_duquette_unsigned_area(), MultiLineString(_, XY) => self - .as_multi_line_string::<2>() + .as_multi_line_string() .chamberlain_duquette_unsigned_area(), MultiPolygon(_, XY) => self - .as_multi_polygon::<2>() + .as_multi_polygon() .chamberlain_duquette_unsigned_area(), - Mixed(_, XY) => self.as_mixed::<2>().chamberlain_duquette_unsigned_area(), + Mixed(_, XY) => self.as_mixed().chamberlain_duquette_unsigned_area(), GeometryCollection(_, XY) => self - .as_geometry_collection::<2>() + .as_geometry_collection() .chamberlain_duquette_unsigned_area(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -209,23 +209,23 @@ impl ChamberlainDuquetteArea for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().chamberlain_duquette_signed_area(), + Point(_, XY) => self.as_point().chamberlain_duquette_signed_area(), LineString(_, XY) => self - .as_line_string::<2>() + .as_line_string() .chamberlain_duquette_signed_area(), - Polygon(_, XY) => self.as_polygon::<2>().chamberlain_duquette_signed_area(), + Polygon(_, XY) => self.as_polygon().chamberlain_duquette_signed_area(), MultiPoint(_, XY) => self - .as_multi_point::<2>() + .as_multi_point() .chamberlain_duquette_signed_area(), MultiLineString(_, XY) => self - .as_multi_line_string::<2>() + .as_multi_line_string() .chamberlain_duquette_signed_area(), MultiPolygon(_, XY) => self - .as_multi_polygon::<2>() + .as_multi_polygon() .chamberlain_duquette_signed_area(), - Mixed(_, XY) => self.as_mixed::<2>().chamberlain_duquette_signed_area(), + Mixed(_, XY) => self.as_mixed().chamberlain_duquette_signed_area(), GeometryCollection(_, XY) => self - .as_geometry_collection::<2>() + .as_geometry_collection() .chamberlain_duquette_signed_area(), _ => Err(GeoArrowError::IncorrectType("".into())), } @@ -236,23 +236,23 @@ impl ChamberlainDuquetteArea for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().chamberlain_duquette_unsigned_area(), + Point(_, XY) => self.as_point().chamberlain_duquette_unsigned_area(), LineString(_, XY) => self - .as_line_string::<2>() + .as_line_string() .chamberlain_duquette_unsigned_area(), - Polygon(_, XY) => self.as_polygon::<2>().chamberlain_duquette_unsigned_area(), + Polygon(_, XY) => self.as_polygon().chamberlain_duquette_unsigned_area(), MultiPoint(_, XY) => self - .as_multi_point::<2>() + .as_multi_point() .chamberlain_duquette_unsigned_area(), MultiLineString(_, XY) => self - .as_multi_line_string::<2>() + .as_multi_line_string() .chamberlain_duquette_unsigned_area(), MultiPolygon(_, XY) => self - .as_multi_polygon::<2>() + .as_multi_polygon() .chamberlain_duquette_unsigned_area(), - Mixed(_, XY) => self.as_mixed::<2>().chamberlain_duquette_unsigned_area(), + Mixed(_, XY) => self.as_mixed().chamberlain_duquette_unsigned_area(), GeometryCollection(_, XY) => self - .as_geometry_collection::<2>() + .as_geometry_collection() .chamberlain_duquette_unsigned_area(), _ => Err(GeoArrowError::IncorrectType("".into())), } diff --git a/rust/geoarrow/src/algorithm/geo/contains.rs b/rust/geoarrow/src/algorithm/geo/contains.rs index a6795de0..d50fa89e 100644 --- a/rust/geoarrow/src/algorithm/geo/contains.rs +++ b/rust/geoarrow/src/algorithm/geo/contains.rs @@ -59,7 +59,7 @@ pub trait Contains { // └────────────────────────────────┘ // Note: this implementation is outside the macro because it is not generic over O -impl Contains for PointArray<2> { +impl Contains for PointArray { fn contains(&self, rhs: &Self) -> BooleanArray { self.try_binary_boolean(rhs, |left, right| { Ok(left.to_geo().contains(&right.to_geo())) @@ -83,51 +83,51 @@ macro_rules! iter_geo_impl { } // Implementations on PointArray -iter_geo_impl!(PointArray<2>, LineStringArray<2>); -iter_geo_impl!(PointArray<2>, PolygonArray<2>); -iter_geo_impl!(PointArray<2>, MultiPointArray<2>); -iter_geo_impl!(PointArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(PointArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(PointArray, LineStringArray); +iter_geo_impl!(PointArray, PolygonArray); +iter_geo_impl!(PointArray, MultiPointArray); +iter_geo_impl!(PointArray, MultiLineStringArray); +iter_geo_impl!(PointArray, MultiPolygonArray); // Implementations on LineStringArray -iter_geo_impl!(LineStringArray<2>, PointArray<2>); -iter_geo_impl!(LineStringArray<2>, LineStringArray<2>); -iter_geo_impl!(LineStringArray<2>, PolygonArray<2>); -iter_geo_impl!(LineStringArray<2>, MultiPointArray<2>); -iter_geo_impl!(LineStringArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(LineStringArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(LineStringArray, PointArray); +iter_geo_impl!(LineStringArray, LineStringArray); +iter_geo_impl!(LineStringArray, PolygonArray); +iter_geo_impl!(LineStringArray, MultiPointArray); +iter_geo_impl!(LineStringArray, MultiLineStringArray); +iter_geo_impl!(LineStringArray, MultiPolygonArray); // Implementations on PolygonArray -iter_geo_impl!(PolygonArray<2>, PointArray<2>); -iter_geo_impl!(PolygonArray<2>, LineStringArray<2>); -iter_geo_impl!(PolygonArray<2>, PolygonArray<2>); -iter_geo_impl!(PolygonArray<2>, MultiPointArray<2>); -iter_geo_impl!(PolygonArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(PolygonArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(PolygonArray, PointArray); +iter_geo_impl!(PolygonArray, LineStringArray); +iter_geo_impl!(PolygonArray, PolygonArray); +iter_geo_impl!(PolygonArray, MultiPointArray); +iter_geo_impl!(PolygonArray, MultiLineStringArray); +iter_geo_impl!(PolygonArray, MultiPolygonArray); // Implementations on MultiPointArray -iter_geo_impl!(MultiPointArray<2>, PointArray<2>); -iter_geo_impl!(MultiPointArray<2>, LineStringArray<2>); -iter_geo_impl!(MultiPointArray<2>, PolygonArray<2>); -iter_geo_impl!(MultiPointArray<2>, MultiPointArray<2>); -iter_geo_impl!(MultiPointArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(MultiPointArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(MultiPointArray, PointArray); +iter_geo_impl!(MultiPointArray, LineStringArray); +iter_geo_impl!(MultiPointArray, PolygonArray); +iter_geo_impl!(MultiPointArray, MultiPointArray); +iter_geo_impl!(MultiPointArray, MultiLineStringArray); +iter_geo_impl!(MultiPointArray, MultiPolygonArray); // Implementations on MultiLineStringArray -iter_geo_impl!(MultiLineStringArray<2>, PointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>, LineStringArray<2>); -iter_geo_impl!(MultiLineStringArray<2>, PolygonArray<2>); -iter_geo_impl!(MultiLineStringArray<2>, MultiPointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(MultiLineStringArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(MultiLineStringArray, PointArray); +iter_geo_impl!(MultiLineStringArray, LineStringArray); +iter_geo_impl!(MultiLineStringArray, PolygonArray); +iter_geo_impl!(MultiLineStringArray, MultiPointArray); +iter_geo_impl!(MultiLineStringArray, MultiLineStringArray); +iter_geo_impl!(MultiLineStringArray, MultiPolygonArray); // Implementations on MultiPolygonArray -iter_geo_impl!(MultiPolygonArray<2>, PointArray<2>); -iter_geo_impl!(MultiPolygonArray<2>, LineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>, PolygonArray<2>); -iter_geo_impl!(MultiPolygonArray<2>, MultiPointArray<2>); -iter_geo_impl!(MultiPolygonArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(MultiPolygonArray, PointArray); +iter_geo_impl!(MultiPolygonArray, LineStringArray); +iter_geo_impl!(MultiPolygonArray, PolygonArray); +iter_geo_impl!(MultiPolygonArray, MultiPointArray); +iter_geo_impl!(MultiPolygonArray, MultiLineStringArray); +iter_geo_impl!(MultiPolygonArray, MultiPolygonArray); // ┌─────────────────────────────────┐ // │ Implementations for RHS scalars │ @@ -137,7 +137,7 @@ pub trait ContainsPoint { fn contains(&self, rhs: &Rhs) -> BooleanArray; } -impl> ContainsPoint for PointArray<2> { +impl> ContainsPoint for PointArray { fn contains(&self, rhs: &G) -> BooleanArray { let rhs = point_to_geo(rhs); self.try_unary_boolean::<_, GeoArrowError>(|geom| Ok(geom.to_geo().contains(&rhs))) @@ -157,13 +157,13 @@ macro_rules! impl_contains_point { }; } -impl_contains_point!(LineStringArray<2>); -impl_contains_point!(PolygonArray<2>); -impl_contains_point!(MultiPointArray<2>); -impl_contains_point!(MultiLineStringArray<2>); -impl_contains_point!(MultiPolygonArray<2>); -impl_contains_point!(MixedGeometryArray<2>); -impl_contains_point!(GeometryCollectionArray<2>); +impl_contains_point!(LineStringArray); +impl_contains_point!(PolygonArray); +impl_contains_point!(MultiPointArray); +impl_contains_point!(MultiLineStringArray); +impl_contains_point!(MultiPolygonArray); +impl_contains_point!(MixedGeometryArray); +impl_contains_point!(GeometryCollectionArray); impl> ContainsPoint for &dyn NativeArray { fn contains(&self, rhs: &G) -> BooleanArray { @@ -171,17 +171,17 @@ impl> ContainsPoint for &dyn NativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => ContainsPoint::contains(self.as_point::<2>(), rhs), - LineString(_, XY) => ContainsPoint::contains(self.as_line_string::<2>(), rhs), - Polygon(_, XY) => ContainsPoint::contains(self.as_polygon::<2>(), rhs), - MultiPoint(_, XY) => ContainsPoint::contains(self.as_multi_point::<2>(), rhs), + Point(_, XY) => ContainsPoint::contains(self.as_point(), rhs), + LineString(_, XY) => ContainsPoint::contains(self.as_line_string(), rhs), + Polygon(_, XY) => ContainsPoint::contains(self.as_polygon(), rhs), + MultiPoint(_, XY) => ContainsPoint::contains(self.as_multi_point(), rhs), MultiLineString(_, XY) => { - ContainsPoint::contains(self.as_multi_line_string::<2>(), rhs) + ContainsPoint::contains(self.as_multi_line_string(), rhs) } - MultiPolygon(_, XY) => ContainsPoint::contains(self.as_multi_polygon::<2>(), rhs), - Mixed(_, XY) => ContainsPoint::contains(self.as_mixed::<2>(), rhs), + MultiPolygon(_, XY) => ContainsPoint::contains(self.as_multi_polygon(), rhs), + Mixed(_, XY) => ContainsPoint::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { - ContainsPoint::contains(self.as_geometry_collection::<2>(), rhs) + ContainsPoint::contains(self.as_geometry_collection(), rhs) } _ => panic!("incorrect type"), // _ => return Err(GeoArrowError::IncorrectType("".into())), } @@ -192,7 +192,7 @@ pub trait ContainsLineString { fn contains(&self, rhs: &Rhs) -> BooleanArray; } -impl> ContainsLineString for PointArray<2> { +impl> ContainsLineString for PointArray { fn contains(&self, rhs: &G) -> BooleanArray { let rhs = line_string_to_geo(rhs); self.try_unary_boolean::<_, GeoArrowError>(|geom| Ok(geom.to_geo().contains(&rhs))) @@ -218,13 +218,13 @@ macro_rules! impl_contains_line_string { }; } -impl_contains_line_string!(LineStringArray<2>); -impl_contains_line_string!(PolygonArray<2>); -impl_contains_line_string!(MultiPointArray<2>); -impl_contains_line_string!(MultiLineStringArray<2>); -impl_contains_line_string!(MultiPolygonArray<2>); -impl_contains_line_string!(MixedGeometryArray<2>); -impl_contains_line_string!(GeometryCollectionArray<2>); +impl_contains_line_string!(LineStringArray); +impl_contains_line_string!(PolygonArray); +impl_contains_line_string!(MultiPointArray); +impl_contains_line_string!(MultiLineStringArray); +impl_contains_line_string!(MultiPolygonArray); +impl_contains_line_string!(MixedGeometryArray); +impl_contains_line_string!(GeometryCollectionArray); impl> ContainsLineString for &dyn NativeArray { fn contains(&self, rhs: &G) -> BooleanArray { @@ -232,17 +232,17 @@ impl> ContainsLineString for &dyn NativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => ContainsLineString::contains(self.as_point::<2>(), rhs), - LineString(_, XY) => ContainsLineString::contains(self.as_line_string::<2>(), rhs), - Polygon(_, XY) => ContainsLineString::contains(self.as_polygon::<2>(), rhs), - MultiPoint(_, XY) => ContainsLineString::contains(self.as_multi_point::<2>(), rhs), + Point(_, XY) => ContainsLineString::contains(self.as_point(), rhs), + LineString(_, XY) => ContainsLineString::contains(self.as_line_string(), rhs), + Polygon(_, XY) => ContainsLineString::contains(self.as_polygon(), rhs), + MultiPoint(_, XY) => ContainsLineString::contains(self.as_multi_point(), rhs), MultiLineString(_, XY) => { - ContainsLineString::contains(self.as_multi_line_string::<2>(), rhs) + ContainsLineString::contains(self.as_multi_line_string(), rhs) } - MultiPolygon(_, XY) => ContainsLineString::contains(self.as_multi_polygon::<2>(), rhs), - Mixed(_, XY) => ContainsLineString::contains(self.as_mixed::<2>(), rhs), + MultiPolygon(_, XY) => ContainsLineString::contains(self.as_multi_polygon(), rhs), + Mixed(_, XY) => ContainsLineString::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { - ContainsLineString::contains(self.as_geometry_collection::<2>(), rhs) + ContainsLineString::contains(self.as_geometry_collection(), rhs) } _ => panic!("incorrect type"), // _ => return Err(GeoArrowError::IncorrectType("".into())), } @@ -253,7 +253,7 @@ pub trait ContainsPolygon { fn contains(&self, rhs: &Rhs) -> BooleanArray; } -impl> ContainsPolygon for PointArray<2> { +impl> ContainsPolygon for PointArray { fn contains(&self, rhs: &G) -> BooleanArray { let rhs = polygon_to_geo(rhs); self.try_unary_boolean::<_, GeoArrowError>(|geom| Ok(geom.to_geo().contains(&rhs))) @@ -273,13 +273,13 @@ macro_rules! impl_contains_polygon { }; } -impl_contains_polygon!(LineStringArray<2>); -impl_contains_polygon!(PolygonArray<2>); -impl_contains_polygon!(MultiPointArray<2>); -impl_contains_polygon!(MultiLineStringArray<2>); -impl_contains_polygon!(MultiPolygonArray<2>); -impl_contains_polygon!(MixedGeometryArray<2>); -impl_contains_polygon!(GeometryCollectionArray<2>); +impl_contains_polygon!(LineStringArray); +impl_contains_polygon!(PolygonArray); +impl_contains_polygon!(MultiPointArray); +impl_contains_polygon!(MultiLineStringArray); +impl_contains_polygon!(MultiPolygonArray); +impl_contains_polygon!(MixedGeometryArray); +impl_contains_polygon!(GeometryCollectionArray); impl> ContainsPolygon for &dyn NativeArray { fn contains(&self, rhs: &G) -> BooleanArray { @@ -287,17 +287,17 @@ impl> ContainsPolygon for &dyn NativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => ContainsPolygon::contains(self.as_point::<2>(), rhs), - LineString(_, XY) => ContainsPolygon::contains(self.as_line_string::<2>(), rhs), - Polygon(_, XY) => ContainsPolygon::contains(self.as_polygon::<2>(), rhs), - MultiPoint(_, XY) => ContainsPolygon::contains(self.as_multi_point::<2>(), rhs), + Point(_, XY) => ContainsPolygon::contains(self.as_point(), rhs), + LineString(_, XY) => ContainsPolygon::contains(self.as_line_string(), rhs), + Polygon(_, XY) => ContainsPolygon::contains(self.as_polygon(), rhs), + MultiPoint(_, XY) => ContainsPolygon::contains(self.as_multi_point(), rhs), MultiLineString(_, XY) => { - ContainsPolygon::contains(self.as_multi_line_string::<2>(), rhs) + ContainsPolygon::contains(self.as_multi_line_string(), rhs) } - MultiPolygon(_, XY) => ContainsPolygon::contains(self.as_multi_polygon::<2>(), rhs), - Mixed(_, XY) => ContainsPolygon::contains(self.as_mixed::<2>(), rhs), + MultiPolygon(_, XY) => ContainsPolygon::contains(self.as_multi_polygon(), rhs), + Mixed(_, XY) => ContainsPolygon::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { - ContainsPolygon::contains(self.as_geometry_collection::<2>(), rhs) + ContainsPolygon::contains(self.as_geometry_collection(), rhs) } _ => panic!("incorrect type"), // _ => return Err(GeoArrowError::IncorrectType("".into())), } @@ -308,7 +308,7 @@ pub trait ContainsMultiPoint { fn contains(&self, rhs: &Rhs) -> BooleanArray; } -impl> ContainsMultiPoint for PointArray<2> { +impl> ContainsMultiPoint for PointArray { fn contains(&self, rhs: &G) -> BooleanArray { let rhs = multi_point_to_geo(rhs); self.try_unary_boolean::<_, GeoArrowError>(|geom| Ok(geom.to_geo().contains(&rhs))) @@ -328,13 +328,13 @@ macro_rules! impl_contains_multi_point { }; } -impl_contains_multi_point!(LineStringArray<2>); -impl_contains_multi_point!(PolygonArray<2>); -impl_contains_multi_point!(MultiPointArray<2>); -impl_contains_multi_point!(MultiLineStringArray<2>); -impl_contains_multi_point!(MultiPolygonArray<2>); -impl_contains_multi_point!(MixedGeometryArray<2>); -impl_contains_multi_point!(GeometryCollectionArray<2>); +impl_contains_multi_point!(LineStringArray); +impl_contains_multi_point!(PolygonArray); +impl_contains_multi_point!(MultiPointArray); +impl_contains_multi_point!(MultiLineStringArray); +impl_contains_multi_point!(MultiPolygonArray); +impl_contains_multi_point!(MixedGeometryArray); +impl_contains_multi_point!(GeometryCollectionArray); impl> ContainsMultiPoint for &dyn NativeArray { fn contains(&self, rhs: &G) -> BooleanArray { @@ -342,17 +342,17 @@ impl> ContainsMultiPoint for &dyn NativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => ContainsMultiPoint::contains(self.as_point::<2>(), rhs), - LineString(_, XY) => ContainsMultiPoint::contains(self.as_line_string::<2>(), rhs), - Polygon(_, XY) => ContainsMultiPoint::contains(self.as_polygon::<2>(), rhs), - MultiPoint(_, XY) => ContainsMultiPoint::contains(self.as_multi_point::<2>(), rhs), + Point(_, XY) => ContainsMultiPoint::contains(self.as_point(), rhs), + LineString(_, XY) => ContainsMultiPoint::contains(self.as_line_string(), rhs), + Polygon(_, XY) => ContainsMultiPoint::contains(self.as_polygon(), rhs), + MultiPoint(_, XY) => ContainsMultiPoint::contains(self.as_multi_point(), rhs), MultiLineString(_, XY) => { - ContainsMultiPoint::contains(self.as_multi_line_string::<2>(), rhs) + ContainsMultiPoint::contains(self.as_multi_line_string(), rhs) } - MultiPolygon(_, XY) => ContainsMultiPoint::contains(self.as_multi_polygon::<2>(), rhs), - Mixed(_, XY) => ContainsMultiPoint::contains(self.as_mixed::<2>(), rhs), + MultiPolygon(_, XY) => ContainsMultiPoint::contains(self.as_multi_polygon(), rhs), + Mixed(_, XY) => ContainsMultiPoint::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { - ContainsMultiPoint::contains(self.as_geometry_collection::<2>(), rhs) + ContainsMultiPoint::contains(self.as_geometry_collection(), rhs) } _ => panic!("incorrect type"), // _ => return Err(GeoArrowError::IncorrectType("".into())), } @@ -363,7 +363,7 @@ pub trait ContainsMultiLineString { fn contains(&self, rhs: &Rhs) -> BooleanArray; } -impl> ContainsMultiLineString for PointArray<2> { +impl> ContainsMultiLineString for PointArray { fn contains(&self, rhs: &G) -> BooleanArray { let rhs = multi_line_string_to_geo(rhs); self.try_unary_boolean::<_, GeoArrowError>(|geom| Ok(geom.to_geo().contains(&rhs))) @@ -383,13 +383,13 @@ macro_rules! impl_contains_multi_line_string { }; } -impl_contains_multi_line_string!(LineStringArray<2>); -impl_contains_multi_line_string!(PolygonArray<2>); -impl_contains_multi_line_string!(MultiPointArray<2>); -impl_contains_multi_line_string!(MultiLineStringArray<2>); -impl_contains_multi_line_string!(MultiPolygonArray<2>); -impl_contains_multi_line_string!(MixedGeometryArray<2>); -impl_contains_multi_line_string!(GeometryCollectionArray<2>); +impl_contains_multi_line_string!(LineStringArray); +impl_contains_multi_line_string!(PolygonArray); +impl_contains_multi_line_string!(MultiPointArray); +impl_contains_multi_line_string!(MultiLineStringArray); +impl_contains_multi_line_string!(MultiPolygonArray); +impl_contains_multi_line_string!(MixedGeometryArray); +impl_contains_multi_line_string!(GeometryCollectionArray); impl> ContainsMultiLineString for &dyn NativeArray { fn contains(&self, rhs: &G) -> BooleanArray { @@ -397,19 +397,19 @@ impl> ContainsMultiLineString for &dyn Nativ use NativeType::*; match self.data_type() { - Point(_, XY) => ContainsMultiLineString::contains(self.as_point::<2>(), rhs), - LineString(_, XY) => ContainsMultiLineString::contains(self.as_line_string::<2>(), rhs), - Polygon(_, XY) => ContainsMultiLineString::contains(self.as_polygon::<2>(), rhs), - MultiPoint(_, XY) => ContainsMultiLineString::contains(self.as_multi_point::<2>(), rhs), + Point(_, XY) => ContainsMultiLineString::contains(self.as_point(), rhs), + LineString(_, XY) => ContainsMultiLineString::contains(self.as_line_string(), rhs), + Polygon(_, XY) => ContainsMultiLineString::contains(self.as_polygon(), rhs), + MultiPoint(_, XY) => ContainsMultiLineString::contains(self.as_multi_point(), rhs), MultiLineString(_, XY) => { - ContainsMultiLineString::contains(self.as_multi_line_string::<2>(), rhs) + ContainsMultiLineString::contains(self.as_multi_line_string(), rhs) } MultiPolygon(_, XY) => { - ContainsMultiLineString::contains(self.as_multi_polygon::<2>(), rhs) + ContainsMultiLineString::contains(self.as_multi_polygon(), rhs) } - Mixed(_, XY) => ContainsMultiLineString::contains(self.as_mixed::<2>(), rhs), + Mixed(_, XY) => ContainsMultiLineString::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { - ContainsMultiLineString::contains(self.as_geometry_collection::<2>(), rhs) + ContainsMultiLineString::contains(self.as_geometry_collection(), rhs) } _ => panic!("incorrect type"), // _ => return Err(GeoArrowError::IncorrectType("".into())), } @@ -420,7 +420,7 @@ pub trait ContainsMultiPolygon { fn contains(&self, rhs: &Rhs) -> BooleanArray; } -impl> ContainsMultiPolygon for PointArray<2> { +impl> ContainsMultiPolygon for PointArray { fn contains(&self, rhs: &G) -> BooleanArray { let rhs = multi_polygon_to_geo(rhs); self.try_unary_boolean::<_, GeoArrowError>(|geom| Ok(geom.to_geo().contains(&rhs))) @@ -440,13 +440,13 @@ macro_rules! impl_contains_multi_polygon { }; } -impl_contains_multi_polygon!(LineStringArray<2>); -impl_contains_multi_polygon!(PolygonArray<2>); -impl_contains_multi_polygon!(MultiPointArray<2>); -impl_contains_multi_polygon!(MultiLineStringArray<2>); -impl_contains_multi_polygon!(MultiPolygonArray<2>); -impl_contains_multi_polygon!(MixedGeometryArray<2>); -impl_contains_multi_polygon!(GeometryCollectionArray<2>); +impl_contains_multi_polygon!(LineStringArray); +impl_contains_multi_polygon!(PolygonArray); +impl_contains_multi_polygon!(MultiPointArray); +impl_contains_multi_polygon!(MultiLineStringArray); +impl_contains_multi_polygon!(MultiPolygonArray); +impl_contains_multi_polygon!(MixedGeometryArray); +impl_contains_multi_polygon!(GeometryCollectionArray); impl> ContainsMultiPolygon for &dyn NativeArray { fn contains(&self, rhs: &G) -> BooleanArray { @@ -454,19 +454,19 @@ impl> ContainsMultiPolygon for &dyn NativeArray use NativeType::*; match self.data_type() { - Point(_, XY) => ContainsMultiPolygon::contains(self.as_point::<2>(), rhs), - LineString(_, XY) => ContainsMultiPolygon::contains(self.as_line_string::<2>(), rhs), - Polygon(_, XY) => ContainsMultiPolygon::contains(self.as_polygon::<2>(), rhs), - MultiPoint(_, XY) => ContainsMultiPolygon::contains(self.as_multi_point::<2>(), rhs), + Point(_, XY) => ContainsMultiPolygon::contains(self.as_point(), rhs), + LineString(_, XY) => ContainsMultiPolygon::contains(self.as_line_string(), rhs), + Polygon(_, XY) => ContainsMultiPolygon::contains(self.as_polygon(), rhs), + MultiPoint(_, XY) => ContainsMultiPolygon::contains(self.as_multi_point(), rhs), MultiLineString(_, XY) => { - ContainsMultiPolygon::contains(self.as_multi_line_string::<2>(), rhs) + ContainsMultiPolygon::contains(self.as_multi_line_string(), rhs) } MultiPolygon(_, XY) => { - ContainsMultiPolygon::contains(self.as_multi_polygon::<2>(), rhs) + ContainsMultiPolygon::contains(self.as_multi_polygon(), rhs) } - Mixed(_, XY) => ContainsMultiPolygon::contains(self.as_mixed::<2>(), rhs), + Mixed(_, XY) => ContainsMultiPolygon::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { - ContainsMultiPolygon::contains(self.as_geometry_collection::<2>(), rhs) + ContainsMultiPolygon::contains(self.as_geometry_collection(), rhs) } _ => panic!("incorrect type"), // _ => return Err(GeoArrowError::IncorrectType("".into())), } @@ -477,7 +477,7 @@ pub trait ContainsGeometry { fn contains(&self, rhs: &Rhs) -> BooleanArray; } -impl> ContainsGeometry for PointArray<2> { +impl> ContainsGeometry for PointArray { fn contains(&self, rhs: &G) -> BooleanArray { let rhs = geometry_to_geo(rhs); self.try_unary_boolean::<_, GeoArrowError>(|geom| Ok(geom.to_geo().contains(&rhs))) @@ -497,13 +497,13 @@ macro_rules! impl_contains_geometry { }; } -impl_contains_geometry!(LineStringArray<2>); -impl_contains_geometry!(PolygonArray<2>); -// impl_contains_geometry!(MultiPointArray<2>); // Not implemented in geo -impl_contains_geometry!(MultiLineStringArray<2>); -// impl_contains_geometry!(MultiPolygonArray<2>); // Not implemented in geo -impl_contains_geometry!(MixedGeometryArray<2>); -impl_contains_geometry!(GeometryCollectionArray<2>); +impl_contains_geometry!(LineStringArray); +impl_contains_geometry!(PolygonArray); +// impl_contains_geometry!(MultiPointArray); // Not implemented in geo +impl_contains_geometry!(MultiLineStringArray); +// impl_contains_geometry!(MultiPolygonArray); // Not implemented in geo +impl_contains_geometry!(MixedGeometryArray); +impl_contains_geometry!(GeometryCollectionArray); impl> ContainsGeometry for &dyn NativeArray { fn contains(&self, rhs: &G) -> BooleanArray { @@ -511,17 +511,17 @@ impl> ContainsGeometry for &dyn NativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => ContainsGeometry::contains(self.as_point::<2>(), rhs), - LineString(_, XY) => ContainsGeometry::contains(self.as_line_string::<2>(), rhs), - Polygon(_, XY) => ContainsGeometry::contains(self.as_polygon::<2>(), rhs), - MultiPoint(_, XY) => todo!(), // ContainsGeometry::contains(self.as_multi_point::<2>(), rhs), + Point(_, XY) => ContainsGeometry::contains(self.as_point(), rhs), + LineString(_, XY) => ContainsGeometry::contains(self.as_line_string(), rhs), + Polygon(_, XY) => ContainsGeometry::contains(self.as_polygon(), rhs), + MultiPoint(_, XY) => todo!(), // ContainsGeometry::contains(self.as_multi_point(), rhs), MultiLineString(_, XY) => { - ContainsGeometry::contains(self.as_multi_line_string::<2>(), rhs) + ContainsGeometry::contains(self.as_multi_line_string(), rhs) } - MultiPolygon(_, XY) => todo!(), // ContainsGeometry::contains(self.as_multi_polygon::<2>(), rhs), - Mixed(_, XY) => ContainsGeometry::contains(self.as_mixed::<2>(), rhs), + MultiPolygon(_, XY) => todo!(), // ContainsGeometry::contains(self.as_multi_polygon(), rhs), + Mixed(_, XY) => ContainsGeometry::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { - ContainsGeometry::contains(self.as_geometry_collection::<2>(), rhs) + ContainsGeometry::contains(self.as_geometry_collection(), rhs) } _ => panic!("incorrect type"), // _ => return Err(GeoArrowError::IncorrectType("".into())), } @@ -532,7 +532,7 @@ pub trait ContainsGeometryCollection { fn contains(&self, rhs: &Rhs) -> BooleanArray; } -impl> ContainsGeometryCollection for PointArray<2> { +impl> ContainsGeometryCollection for PointArray { fn contains(&self, rhs: &G) -> BooleanArray { let rhs = geometry_collection_to_geo(rhs); self.try_unary_boolean::<_, GeoArrowError>(|geom| Ok(geom.to_geo().contains(&rhs))) @@ -552,13 +552,13 @@ macro_rules! impl_contains_geometry_collection { }; } -impl_contains_geometry_collection!(LineStringArray<2>); -impl_contains_geometry_collection!(PolygonArray<2>); -impl_contains_geometry_collection!(MultiPointArray<2>); -impl_contains_geometry_collection!(MultiLineStringArray<2>); -impl_contains_geometry_collection!(MultiPolygonArray<2>); -impl_contains_geometry_collection!(MixedGeometryArray<2>); -impl_contains_geometry_collection!(GeometryCollectionArray<2>); +impl_contains_geometry_collection!(LineStringArray); +impl_contains_geometry_collection!(PolygonArray); +impl_contains_geometry_collection!(MultiPointArray); +impl_contains_geometry_collection!(MultiLineStringArray); +impl_contains_geometry_collection!(MultiPolygonArray); +impl_contains_geometry_collection!(MixedGeometryArray); +impl_contains_geometry_collection!(GeometryCollectionArray); impl> ContainsGeometryCollection for &dyn NativeArray { fn contains(&self, rhs: &G) -> BooleanArray { @@ -566,23 +566,23 @@ impl> ContainsGeometryCollection for &dyn use NativeType::*; match self.data_type() { - Point(_, XY) => ContainsGeometryCollection::contains(self.as_point::<2>(), rhs), + Point(_, XY) => ContainsGeometryCollection::contains(self.as_point(), rhs), LineString(_, XY) => { - ContainsGeometryCollection::contains(self.as_line_string::<2>(), rhs) + ContainsGeometryCollection::contains(self.as_line_string(), rhs) } - Polygon(_, XY) => ContainsGeometryCollection::contains(self.as_polygon::<2>(), rhs), + Polygon(_, XY) => ContainsGeometryCollection::contains(self.as_polygon(), rhs), MultiPoint(_, XY) => { - ContainsGeometryCollection::contains(self.as_multi_point::<2>(), rhs) + ContainsGeometryCollection::contains(self.as_multi_point(), rhs) } MultiLineString(_, XY) => { - ContainsGeometryCollection::contains(self.as_multi_line_string::<2>(), rhs) + ContainsGeometryCollection::contains(self.as_multi_line_string(), rhs) } MultiPolygon(_, XY) => { - ContainsGeometryCollection::contains(self.as_multi_polygon::<2>(), rhs) + ContainsGeometryCollection::contains(self.as_multi_polygon(), rhs) } - Mixed(_, XY) => ContainsGeometryCollection::contains(self.as_mixed::<2>(), rhs), + Mixed(_, XY) => ContainsGeometryCollection::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { - ContainsGeometryCollection::contains(self.as_geometry_collection::<2>(), rhs) + ContainsGeometryCollection::contains(self.as_geometry_collection(), rhs) } _ => panic!("incorrect type"), // _ => return Err(GeoArrowError::IncorrectType("".into())), } diff --git a/rust/geoarrow/src/algorithm/geo/convex_hull.rs b/rust/geoarrow/src/algorithm/geo/convex_hull.rs index 82c8e90e..9def42e0 100644 --- a/rust/geoarrow/src/algorithm/geo/convex_hull.rs +++ b/rust/geoarrow/src/algorithm/geo/convex_hull.rs @@ -53,7 +53,7 @@ pub trait ConvexHull { macro_rules! iter_geo_impl { ($type:ty) => { impl ConvexHull for $type { - type Output = PolygonArray<2>; + type Output = PolygonArray; fn convex_hull(&self) -> Self::Output { let output_geoms: Vec> = self @@ -67,33 +67,33 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(PointArray<2>); -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(PolygonArray<2>); -iter_geo_impl!(MultiPointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>); -iter_geo_impl!(MixedGeometryArray<2>); -iter_geo_impl!(GeometryCollectionArray<2>); -iter_geo_impl!(RectArray<2>); +iter_geo_impl!(PointArray); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(PolygonArray); +iter_geo_impl!(MultiPointArray); +iter_geo_impl!(MultiLineStringArray); +iter_geo_impl!(MultiPolygonArray); +iter_geo_impl!(MixedGeometryArray); +iter_geo_impl!(GeometryCollectionArray); +iter_geo_impl!(RectArray); impl ConvexHull for &dyn NativeArray { - type Output = Result>; + type Output = Result; fn convex_hull(&self) -> Self::Output { use Dimension::*; use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().convex_hull(), - LineString(_, XY) => self.as_line_string::<2>().convex_hull(), - Polygon(_, XY) => self.as_polygon::<2>().convex_hull(), - MultiPoint(_, XY) => self.as_multi_point::<2>().convex_hull(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().convex_hull(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().convex_hull(), - Mixed(_, XY) => self.as_mixed::<2>().convex_hull(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().convex_hull(), - Rect(XY) => self.as_rect::<2>().convex_hull(), + Point(_, XY) => self.as_point().convex_hull(), + LineString(_, XY) => self.as_line_string().convex_hull(), + Polygon(_, XY) => self.as_polygon().convex_hull(), + MultiPoint(_, XY) => self.as_multi_point().convex_hull(), + MultiLineString(_, XY) => self.as_multi_line_string().convex_hull(), + MultiPolygon(_, XY) => self.as_multi_polygon().convex_hull(), + Mixed(_, XY) => self.as_mixed().convex_hull(), + GeometryCollection(_, XY) => self.as_geometry_collection().convex_hull(), + Rect(XY) => self.as_rect().convex_hull(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -101,7 +101,7 @@ impl ConvexHull for &dyn NativeArray { } impl ConvexHull for ChunkedGeometryArray { - type Output = Result>>; + type Output = Result>; fn convex_hull(&self) -> Self::Output { self.try_map(|chunk| chunk.as_ref().convex_hull())? @@ -110,22 +110,22 @@ impl ConvexHull for ChunkedGeometryArray { } impl ConvexHull for &dyn ChunkedNativeArray { - type Output = Result>; + type Output = Result; fn convex_hull(&self) -> Self::Output { use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().convex_hull(), - LineString(_, XY) => self.as_line_string::<2>().convex_hull(), - Polygon(_, XY) => self.as_polygon::<2>().convex_hull(), - MultiPoint(_, XY) => self.as_multi_point::<2>().convex_hull(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().convex_hull(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().convex_hull(), - Mixed(_, XY) => self.as_mixed::<2>().convex_hull(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().convex_hull(), - Rect(XY) => self.as_rect::<2>().convex_hull(), + Point(_, XY) => self.as_point().convex_hull(), + LineString(_, XY) => self.as_line_string().convex_hull(), + Polygon(_, XY) => self.as_polygon().convex_hull(), + MultiPoint(_, XY) => self.as_multi_point().convex_hull(), + MultiLineString(_, XY) => self.as_multi_line_string().convex_hull(), + MultiPolygon(_, XY) => self.as_multi_polygon().convex_hull(), + Mixed(_, XY) => self.as_mixed().convex_hull(), + GeometryCollection(_, XY) => self.as_geometry_collection().convex_hull(), + Rect(XY) => self.as_rect().convex_hull(), _ => Err(GeoArrowError::IncorrectType("".into())), } } @@ -154,8 +154,8 @@ mod tests { Point::new(0.0, 10.0), ] .into(); - let input_array: MultiPointArray<2> = vec![input_geom].as_slice().into(); - let result_array: PolygonArray<2> = input_array.convex_hull(); + let input_array: MultiPointArray = vec![input_geom].as_slice().into(); + let result_array: PolygonArray = input_array.convex_hull(); let expected = polygon![ (x:0.0, y: -10.0), @@ -182,8 +182,8 @@ mod tests { (x: 0.0, y: 10.0), ]; - let input_array: LineStringArray<2> = vec![input_geom].as_slice().into(); - let result_array: PolygonArray<2> = input_array.convex_hull(); + let input_array: LineStringArray = vec![input_geom].as_slice().into(); + let result_array: PolygonArray = input_array.convex_hull(); let expected = polygon![ (x: 0.0, y: -10.0), diff --git a/rust/geoarrow/src/algorithm/geo/densify.rs b/rust/geoarrow/src/algorithm/geo/densify.rs index ef862257..91d7eade 100644 --- a/rust/geoarrow/src/algorithm/geo/densify.rs +++ b/rust/geoarrow/src/algorithm/geo/densify.rs @@ -48,10 +48,10 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, geo::LineString); -iter_geo_impl!(PolygonArray<2>, geo::Polygon); -iter_geo_impl!(MultiLineStringArray<2>, geo::MultiLineString); -iter_geo_impl!(MultiPolygonArray<2>, geo::MultiPolygon); +iter_geo_impl!(LineStringArray, geo::LineString); +iter_geo_impl!(PolygonArray, geo::Polygon); +iter_geo_impl!(MultiLineStringArray, geo::MultiLineString); +iter_geo_impl!(MultiPolygonArray, geo::MultiPolygon); impl Densify for &dyn NativeArray { type Output = Result>; @@ -61,12 +61,12 @@ impl Densify for &dyn NativeArray { use NativeType::*; let result: Arc = match self.data_type() { - LineString(_, XY) => Arc::new(self.as_line_string::<2>().densify(max_distance)), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().densify(max_distance)), + LineString(_, XY) => Arc::new(self.as_line_string().densify(max_distance)), + Polygon(_, XY) => Arc::new(self.as_polygon().densify(max_distance)), MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string::<2>().densify(max_distance)) + Arc::new(self.as_multi_line_string().densify(max_distance)) } - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().densify(max_distance)), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().densify(max_distance)), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -87,10 +87,10 @@ macro_rules! impl_chunked { }; } -impl_chunked!(ChunkedLineStringArray<2>); -impl_chunked!(ChunkedPolygonArray<2>); -impl_chunked!(ChunkedMultiLineStringArray<2>); -impl_chunked!(ChunkedMultiPolygonArray<2>); +impl_chunked!(ChunkedLineStringArray); +impl_chunked!(ChunkedPolygonArray); +impl_chunked!(ChunkedMultiLineStringArray); +impl_chunked!(ChunkedMultiPolygonArray); impl Densify for &dyn ChunkedNativeArray { type Output = Result>; @@ -100,12 +100,12 @@ impl Densify for &dyn ChunkedNativeArray { use NativeType::*; let result: Arc = match self.data_type() { - LineString(_, XY) => Arc::new(self.as_line_string::<2>().densify(max_distance)), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().densify(max_distance)), + LineString(_, XY) => Arc::new(self.as_line_string().densify(max_distance)), + Polygon(_, XY) => Arc::new(self.as_polygon().densify(max_distance)), MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string::<2>().densify(max_distance)) + Arc::new(self.as_multi_line_string().densify(max_distance)) } - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().densify(max_distance)), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().densify(max_distance)), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) diff --git a/rust/geoarrow/src/algorithm/geo/dimensions.rs b/rust/geoarrow/src/algorithm/geo/dimensions.rs index 8f0d1e0e..0332f3d8 100644 --- a/rust/geoarrow/src/algorithm/geo/dimensions.rs +++ b/rust/geoarrow/src/algorithm/geo/dimensions.rs @@ -51,14 +51,14 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(PointArray<2>); -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(PolygonArray<2>); -iter_geo_impl!(MultiPointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>); -iter_geo_impl!(MixedGeometryArray<2>); -iter_geo_impl!(GeometryCollectionArray<2>); +iter_geo_impl!(PointArray); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(PolygonArray); +iter_geo_impl!(MultiPointArray); +iter_geo_impl!(MultiLineStringArray); +iter_geo_impl!(MultiPolygonArray); +iter_geo_impl!(MixedGeometryArray); +iter_geo_impl!(GeometryCollectionArray); impl HasDimensions for &dyn NativeArray { type Output = Result; @@ -68,16 +68,14 @@ impl HasDimensions for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => HasDimensions::is_empty(self.as_point::<2>()), - LineString(_, XY) => HasDimensions::is_empty(self.as_line_string::<2>()), - Polygon(_, XY) => HasDimensions::is_empty(self.as_polygon::<2>()), - MultiPoint(_, XY) => HasDimensions::is_empty(self.as_multi_point::<2>()), - MultiLineString(_, XY) => HasDimensions::is_empty(self.as_multi_line_string::<2>()), - MultiPolygon(_, XY) => HasDimensions::is_empty(self.as_multi_polygon::<2>()), - Mixed(_, XY) => HasDimensions::is_empty(self.as_mixed::<2>()), - GeometryCollection(_, XY) => { - HasDimensions::is_empty(self.as_geometry_collection::<2>()) - } + Point(_, XY) => HasDimensions::is_empty(self.as_point()), + LineString(_, XY) => HasDimensions::is_empty(self.as_line_string()), + Polygon(_, XY) => HasDimensions::is_empty(self.as_polygon()), + MultiPoint(_, XY) => HasDimensions::is_empty(self.as_multi_point()), + MultiLineString(_, XY) => HasDimensions::is_empty(self.as_multi_line_string()), + MultiPolygon(_, XY) => HasDimensions::is_empty(self.as_multi_polygon()), + Mixed(_, XY) => HasDimensions::is_empty(self.as_mixed()), + GeometryCollection(_, XY) => HasDimensions::is_empty(self.as_geometry_collection()), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -101,16 +99,14 @@ impl HasDimensions for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => HasDimensions::is_empty(self.as_point::<2>()), - LineString(_, XY) => HasDimensions::is_empty(self.as_line_string::<2>()), - Polygon(_, XY) => HasDimensions::is_empty(self.as_polygon::<2>()), - MultiPoint(_, XY) => HasDimensions::is_empty(self.as_multi_point::<2>()), - MultiLineString(_, XY) => HasDimensions::is_empty(self.as_multi_line_string::<2>()), - MultiPolygon(_, XY) => HasDimensions::is_empty(self.as_multi_polygon::<2>()), - Mixed(_, XY) => HasDimensions::is_empty(self.as_mixed::<2>()), - GeometryCollection(_, XY) => { - HasDimensions::is_empty(self.as_geometry_collection::<2>()) - } + Point(_, XY) => HasDimensions::is_empty(self.as_point()), + LineString(_, XY) => HasDimensions::is_empty(self.as_line_string()), + Polygon(_, XY) => HasDimensions::is_empty(self.as_polygon()), + MultiPoint(_, XY) => HasDimensions::is_empty(self.as_multi_point()), + MultiLineString(_, XY) => HasDimensions::is_empty(self.as_multi_line_string()), + MultiPolygon(_, XY) => HasDimensions::is_empty(self.as_multi_polygon()), + Mixed(_, XY) => HasDimensions::is_empty(self.as_mixed()), + GeometryCollection(_, XY) => HasDimensions::is_empty(self.as_geometry_collection()), _ => Err(GeoArrowError::IncorrectType("".into())), } } diff --git a/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs b/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs index 32f8c1ca..81910129 100644 --- a/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs +++ b/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs @@ -92,9 +92,9 @@ pub trait EuclideanDistance { // └────────────────────────────────┘ // Note: this implementation is outside the macro because it is not generic over O -impl EuclideanDistance> for PointArray<2> { +impl EuclideanDistance for PointArray { /// Minimum distance between two Points - fn euclidean_distance(&self, other: &PointArray<2>) -> Float64Array { + fn euclidean_distance(&self, other: &PointArray) -> Float64Array { assert_eq!(self.len(), other.len()); let mut output_array = Float64Builder::with_capacity(self.len()); @@ -135,58 +135,58 @@ macro_rules! iter_geo_impl { } // Implementations on PointArray -iter_geo_impl!(PointArray<2>, LineStringArray<2>); -iter_geo_impl!(PointArray<2>, PolygonArray<2>); -iter_geo_impl!(PointArray<2>, MultiPointArray<2>); -iter_geo_impl!(PointArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(PointArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(PointArray, LineStringArray); +iter_geo_impl!(PointArray, PolygonArray); +iter_geo_impl!(PointArray, MultiPointArray); +iter_geo_impl!(PointArray, MultiLineStringArray); +iter_geo_impl!(PointArray, MultiPolygonArray); // Implementations on LineStringArray -iter_geo_impl!(LineStringArray<2>, PointArray<2>); -iter_geo_impl!(LineStringArray<2>, LineStringArray<2>); -iter_geo_impl!(LineStringArray<2>, PolygonArray<2>); -// iter_geo_impl!(LineStringArray<2>, MultiPointArray<2>); -// iter_geo_impl!(LineStringArray<2>, MultiLineStringArray<2>); -// iter_geo_impl!(LineStringArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(LineStringArray, PointArray); +iter_geo_impl!(LineStringArray, LineStringArray); +iter_geo_impl!(LineStringArray, PolygonArray); +// iter_geo_impl!(LineStringArray, MultiPointArray); +// iter_geo_impl!(LineStringArray, MultiLineStringArray); +// iter_geo_impl!(LineStringArray, MultiPolygonArray); // Implementations on PolygonArray -iter_geo_impl!(PolygonArray<2>, PointArray<2>); -iter_geo_impl!(PolygonArray<2>, LineStringArray<2>); -iter_geo_impl!(PolygonArray<2>, PolygonArray<2>); -// iter_geo_impl!(PolygonArray<2>, MultiPointArray<2>); -// iter_geo_impl!(PolygonArray<2>, MultiLineStringArray<2>); -// iter_geo_impl!(PolygonArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(PolygonArray, PointArray); +iter_geo_impl!(PolygonArray, LineStringArray); +iter_geo_impl!(PolygonArray, PolygonArray); +// iter_geo_impl!(PolygonArray, MultiPointArray); +// iter_geo_impl!(PolygonArray, MultiLineStringArray); +// iter_geo_impl!(PolygonArray, MultiPolygonArray); // Implementations on MultiPointArray -iter_geo_impl!(MultiPointArray<2>, PointArray<2>); -// iter_geo_impl!(MultiPointArray<2>, LineStringArray<2>); -// iter_geo_impl!(MultiPointArray<2>, PolygonArray<2>); -// iter_geo_impl!(MultiPointArray<2>, MultiPointArray<2>); -// iter_geo_impl!(MultiPointArray<2>, MultiLineStringArray<2>); -// iter_geo_impl!(MultiPointArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(MultiPointArray, PointArray); +// iter_geo_impl!(MultiPointArray, LineStringArray); +// iter_geo_impl!(MultiPointArray, PolygonArray); +// iter_geo_impl!(MultiPointArray, MultiPointArray); +// iter_geo_impl!(MultiPointArray, MultiLineStringArray); +// iter_geo_impl!(MultiPointArray, MultiPolygonArray); // Implementations on MultiLineStringArray -iter_geo_impl!(MultiLineStringArray<2>, PointArray<2>); -// iter_geo_impl!(MultiLineStringArray<2>, LineStringArray<2>); -// iter_geo_impl!(MultiLineStringArray<2>, PolygonArray<2>); -// iter_geo_impl!(MultiLineStringArray<2>, MultiPointArray<2>); -// iter_geo_impl!(MultiLineStringArray<2>, MultiLineStringArray<2>); -// iter_geo_impl!(MultiLineStringArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(MultiLineStringArray, PointArray); +// iter_geo_impl!(MultiLineStringArray, LineStringArray); +// iter_geo_impl!(MultiLineStringArray, PolygonArray); +// iter_geo_impl!(MultiLineStringArray, MultiPointArray); +// iter_geo_impl!(MultiLineStringArray, MultiLineStringArray); +// iter_geo_impl!(MultiLineStringArray, MultiPolygonArray); // Implementations on MultiPolygonArray -iter_geo_impl!(MultiPolygonArray<2>, PointArray<2>); -// iter_geo_impl!(MultiPolygonArray<2>, LineStringArray<2>); -// iter_geo_impl!(MultiPolygonArray<2>, PolygonArray<2>); -// iter_geo_impl!(MultiPolygonArray<2>, MultiPointArray<2>); -// iter_geo_impl!(MultiPolygonArray<2>, MultiLineStringArray<2>); -// iter_geo_impl!(MultiPolygonArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(MultiPolygonArray, PointArray); +// iter_geo_impl!(MultiPolygonArray, LineStringArray); +// iter_geo_impl!(MultiPolygonArray, PolygonArray); +// iter_geo_impl!(MultiPolygonArray, MultiPointArray); +// iter_geo_impl!(MultiPolygonArray, MultiLineStringArray); +// iter_geo_impl!(MultiPolygonArray, MultiPolygonArray); // ┌─────────────────────────────────┐ // │ Implementations for RHS scalars │ // └─────────────────────────────────┘ // Note: this implementation is outside the macro because it is not generic over O -impl<'a> EuclideanDistance> for PointArray<2> { +impl<'a> EuclideanDistance> for PointArray { /// Minimum distance between two Points fn euclidean_distance(&self, other: &Point<'a, 2>) -> Float64Array { let mut output_array = Float64Builder::with_capacity(self.len()); @@ -220,48 +220,48 @@ macro_rules! iter_geo_impl_scalar { } // Implementations on PointArray -iter_geo_impl_scalar!(PointArray<2>, LineString<'a, 2>); -iter_geo_impl_scalar!(PointArray<2>, Polygon<'a, 2>); -iter_geo_impl_scalar!(PointArray<2>, MultiPoint<'a, 2>); -iter_geo_impl_scalar!(PointArray<2>, MultiLineString<'a, 2>); -iter_geo_impl_scalar!(PointArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(PointArray, LineString<'a, 2>); +iter_geo_impl_scalar!(PointArray, Polygon<'a, 2>); +iter_geo_impl_scalar!(PointArray, MultiPoint<'a, 2>); +iter_geo_impl_scalar!(PointArray, MultiLineString<'a, 2>); +iter_geo_impl_scalar!(PointArray, MultiPolygon<'a, 2>); // Implementations on LineStringArray -iter_geo_impl_scalar!(LineStringArray<2>, Point<'a, 2>); -iter_geo_impl_scalar!(LineStringArray<2>, LineString<'a, 2>); -iter_geo_impl_scalar!(LineStringArray<2>, Polygon<'a, 2>); -// iter_geo_impl_scalar!(LineStringArray<2>, MultiPoint<'a, 2>); -// iter_geo_impl_scalar!(LineStringArray<2>, MultiLineString<'a, 2>); -// iter_geo_impl_scalar!(LineStringArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(LineStringArray, Point<'a, 2>); +iter_geo_impl_scalar!(LineStringArray, LineString<'a, 2>); +iter_geo_impl_scalar!(LineStringArray, Polygon<'a, 2>); +// iter_geo_impl_scalar!(LineStringArray, MultiPoint<'a, 2>); +// iter_geo_impl_scalar!(LineStringArray, MultiLineString<'a, 2>); +// iter_geo_impl_scalar!(LineStringArray, MultiPolygon<'a, 2>); // Implementations on PolygonArray -iter_geo_impl_scalar!(PolygonArray<2>, Point<'a, 2>); -iter_geo_impl_scalar!(PolygonArray<2>, LineString<'a, 2>); -iter_geo_impl_scalar!(PolygonArray<2>, Polygon<'a, 2>); -// iter_geo_impl_scalar!(PolygonArray<2>, MultiPoint<'a, 2>); -// iter_geo_impl_scalar!(PolygonArray<2>, MultiLineString<'a, 2>); -// iter_geo_impl_scalar!(PolygonArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(PolygonArray, Point<'a, 2>); +iter_geo_impl_scalar!(PolygonArray, LineString<'a, 2>); +iter_geo_impl_scalar!(PolygonArray, Polygon<'a, 2>); +// iter_geo_impl_scalar!(PolygonArray, MultiPoint<'a, 2>); +// iter_geo_impl_scalar!(PolygonArray, MultiLineString<'a, 2>); +// iter_geo_impl_scalar!(PolygonArray, MultiPolygon<'a, 2>); // Implementations on MultiPointArray -iter_geo_impl_scalar!(MultiPointArray<2>, Point<'a, 2>); -// iter_geo_impl_scalar!(MultiPointArray<2>, LineString<'a, 2>); -// iter_geo_impl_scalar!(MultiPointArray<2>, Polygon<'a, 2>); -// iter_geo_impl_scalar!(MultiPointArray<2>, MultiPoint<'a, 2>); -// iter_geo_impl_scalar!(MultiPointArray<2>, MultiLineString<'a, 2>); -// iter_geo_impl_scalar!(MultiPointArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(MultiPointArray, Point<'a, 2>); +// iter_geo_impl_scalar!(MultiPointArray, LineString<'a, 2>); +// iter_geo_impl_scalar!(MultiPointArray, Polygon<'a, 2>); +// iter_geo_impl_scalar!(MultiPointArray, MultiPoint<'a, 2>); +// iter_geo_impl_scalar!(MultiPointArray, MultiLineString<'a, 2>); +// iter_geo_impl_scalar!(MultiPointArray, MultiPolygon<'a, 2>); // Implementations on MultiLineStringArray -iter_geo_impl_scalar!(MultiLineStringArray<2>, Point<'a, 2>); -// iter_geo_impl_scalar!(MultiLineStringArray<2>, LineString<'a, 2>); -// iter_geo_impl_scalar!(MultiLineStringArray<2>, Polygon<'a, 2>); -// iter_geo_impl_scalar!(MultiLineStringArray<2>, MultiPoint<'a, 2>); -// iter_geo_impl_scalar!(MultiLineStringArray<2>, MultiLineString<'a, 2>); -// iter_geo_impl_scalar!(MultiLineStringArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(MultiLineStringArray, Point<'a, 2>); +// iter_geo_impl_scalar!(MultiLineStringArray, LineString<'a, 2>); +// iter_geo_impl_scalar!(MultiLineStringArray, Polygon<'a, 2>); +// iter_geo_impl_scalar!(MultiLineStringArray, MultiPoint<'a, 2>); +// iter_geo_impl_scalar!(MultiLineStringArray, MultiLineString<'a, 2>); +// iter_geo_impl_scalar!(MultiLineStringArray, MultiPolygon<'a, 2>); // Implementations on MultiPolygonArray -iter_geo_impl_scalar!(MultiPolygonArray<2>, Point<'a, 2>); -// iter_geo_impl_scalar!(MultiPolygonArray<2>, LineString<'a, 2>); -// iter_geo_impl_scalar!(MultiPolygonArray<2>, Polygon<'a, 2>); -// iter_geo_impl_scalar!(MultiPolygonArray<2>, MultiPoint<'a, 2>); -// iter_geo_impl_scalar!(MultiPolygonArray<2>, MultiLineString<'a, 2>); -// iter_geo_impl_scalar!(MultiPolygonArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(MultiPolygonArray, Point<'a, 2>); +// iter_geo_impl_scalar!(MultiPolygonArray, LineString<'a, 2>); +// iter_geo_impl_scalar!(MultiPolygonArray, Polygon<'a, 2>); +// iter_geo_impl_scalar!(MultiPolygonArray, MultiPoint<'a, 2>); +// iter_geo_impl_scalar!(MultiPolygonArray, MultiLineString<'a, 2>); +// iter_geo_impl_scalar!(MultiPolygonArray, MultiPolygon<'a, 2>); diff --git a/rust/geoarrow/src/algorithm/geo/euclidean_length.rs b/rust/geoarrow/src/algorithm/geo/euclidean_length.rs index ac736a60..2c3c13eb 100644 --- a/rust/geoarrow/src/algorithm/geo/euclidean_length.rs +++ b/rust/geoarrow/src/algorithm/geo/euclidean_length.rs @@ -25,7 +25,7 @@ pub trait EuclideanLength { /// (x: 40.02f64, y: 116.34), /// (x: 42.02f64, y: 116.34), /// ]; - /// let linestring_array: LineStringArray<2> = vec![line_string].as_slice().into(); + /// let linestring_array: LineStringArray = vec![line_string].as_slice().into(); /// /// let length_array = linestring_array.euclidean_length(); /// @@ -50,8 +50,8 @@ macro_rules! zero_impl { }; } -zero_impl!(PointArray<2>); -zero_impl!(MultiPointArray<2>); +zero_impl!(PointArray); +zero_impl!(MultiPointArray); /// Implementation that iterates over geo objects macro_rules! iter_geo_impl { @@ -66,8 +66,8 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(MultiLineStringArray); impl EuclideanLength for &dyn NativeArray { type Output = Result; @@ -77,19 +77,19 @@ impl EuclideanLength for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().euclidean_length(), - LineString(_, XY) => self.as_line_string::<2>().euclidean_length(), - // Polygon(_, XY) => self.as_polygon::<2>().euclidean_length(), - // LargePolygon(_, XY) => self.as_large_polygon::<2>().euclidean_length(), - MultiPoint(_, XY) => self.as_multi_point::<2>().euclidean_length(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().euclidean_length(), - // MultiPolygon(_, XY) => self.as_multi_polygon::<2>().euclidean_length(), - // LargeMultiPolygon(_, XY) => self.as_large_multi_polygon::<2>().euclidean_length(), - // Mixed(_, XY) => self.as_mixed::<2>().euclidean_length(), - // LargeMixed(_, XY) => self.as_large_mixed::<2>().euclidean_length(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().euclidean_length(), + Point(_, XY) => self.as_point().euclidean_length(), + LineString(_, XY) => self.as_line_string().euclidean_length(), + // Polygon(_, XY) => self.as_polygon().euclidean_length(), + // LargePolygon(_, XY) => self.as_large_polygon().euclidean_length(), + MultiPoint(_, XY) => self.as_multi_point().euclidean_length(), + MultiLineString(_, XY) => self.as_multi_line_string().euclidean_length(), + // MultiPolygon(_, XY) => self.as_multi_polygon().euclidean_length(), + // LargeMultiPolygon(_, XY) => self.as_large_multi_polygon().euclidean_length(), + // Mixed(_, XY) => self.as_mixed().euclidean_length(), + // LargeMixed(_, XY) => self.as_large_mixed().euclidean_length(), + // GeometryCollection(_, XY) => self.as_geometry_collection().euclidean_length(), // LargeGeometryCollection(_, XY) => { - // self.as_large_geometry_collection::<2>().euclidean_length() + // self.as_large_geometry_collection().euclidean_length() // } _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -97,7 +97,7 @@ impl EuclideanLength for &dyn NativeArray { } } -impl EuclideanLength for ChunkedGeometryArray> { +impl EuclideanLength for ChunkedGeometryArray { type Output = Result>; fn euclidean_length(&self) -> Self::Output { @@ -118,9 +118,9 @@ macro_rules! chunked_impl { }; } -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); impl EuclideanLength for &dyn ChunkedNativeArray { type Output = Result>; @@ -130,19 +130,19 @@ impl EuclideanLength for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().euclidean_length(), - LineString(_, XY) => self.as_line_string::<2>().euclidean_length(), - // Polygon(_, XY) => self.as_polygon::<2>().euclidean_length(), - // LargePolygon(_, XY) => self.as_large_polygon::<2>().euclidean_length(), - MultiPoint(_, XY) => self.as_multi_point::<2>().euclidean_length(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().euclidean_length(), - // MultiPolygon(_, XY) => self.as_multi_polygon::<2>().euclidean_length(), - // LargeMultiPolygon(_, XY) => self.as_large_multi_polygon::<2>().euclidean_length(), - // Mixed(_, XY) => self.as_mixed::<2>().euclidean_length(), - // LargeMixed(_, XY) => self.as_large_mixed::<2>().euclidean_length(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().euclidean_length(), + Point(_, XY) => self.as_point().euclidean_length(), + LineString(_, XY) => self.as_line_string().euclidean_length(), + // Polygon(_, XY) => self.as_polygon().euclidean_length(), + // LargePolygon(_, XY) => self.as_large_polygon().euclidean_length(), + MultiPoint(_, XY) => self.as_multi_point().euclidean_length(), + MultiLineString(_, XY) => self.as_multi_line_string().euclidean_length(), + // MultiPolygon(_, XY) => self.as_multi_polygon().euclidean_length(), + // LargeMultiPolygon(_, XY) => self.as_large_multi_polygon().euclidean_length(), + // Mixed(_, XY) => self.as_mixed().euclidean_length(), + // LargeMixed(_, XY) => self.as_large_mixed().euclidean_length(), + // GeometryCollection(_, XY) => self.as_geometry_collection().euclidean_length(), // LargeGeometryCollection(_, XY) => { - // self.as_large_geometry_collection::<2>().euclidean_length() + // self.as_large_geometry_collection().euclidean_length() // } _ => Err(GeoArrowError::IncorrectType("".into())), } @@ -166,7 +166,7 @@ mod tests { (x: 10., y: 1.), (x: 11., y: 1.) ]; - let input_array: LineStringArray<2> = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = vec![input_geom].as_slice().into(); let result_array = input_array.euclidean_length(); let expected = 10.0_f64; diff --git a/rust/geoarrow/src/algorithm/geo/frechet_distance.rs b/rust/geoarrow/src/algorithm/geo/frechet_distance.rs index 2c8d93e0..7b792124 100644 --- a/rust/geoarrow/src/algorithm/geo/frechet_distance.rs +++ b/rust/geoarrow/src/algorithm/geo/frechet_distance.rs @@ -26,10 +26,10 @@ pub trait FrechetDistance { fn frechet_distance(&self, rhs: &Rhs) -> Self::Output; } -impl FrechetDistance> for LineStringArray<2> { +impl FrechetDistance for LineStringArray { type Output = Float64Array; - fn frechet_distance(&self, rhs: &LineStringArray<2>) -> Self::Output { + fn frechet_distance(&self, rhs: &LineStringArray) -> Self::Output { self.try_binary_primitive(rhs, |left, right| { Ok(left.to_geo().frechet_distance(&right.to_geo())) }) @@ -37,10 +37,10 @@ impl FrechetDistance> for LineStringArray<2> { } } -impl FrechetDistance> for ChunkedLineStringArray<2> { +impl FrechetDistance for ChunkedLineStringArray { type Output = ChunkedArray; - fn frechet_distance(&self, rhs: &ChunkedLineStringArray<2>) -> Self::Output { + fn frechet_distance(&self, rhs: &ChunkedLineStringArray) -> Self::Output { ChunkedArray::new(self.binary_map(rhs.chunks(), |(left, right)| { FrechetDistance::frechet_distance(left, right) })) @@ -56,8 +56,8 @@ impl FrechetDistance for &dyn NativeArray { let result = match (self.data_type(), rhs.data_type()) { (LineString(_, XY), LineString(_, XY)) => FrechetDistance::frechet_distance( - self.as_line_string::<2>(), - rhs.as_line_string::<2>(), + self.as_line_string(), + rhs.as_line_string(), ), _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -74,8 +74,8 @@ impl FrechetDistance for &dyn ChunkedNativeArray { let result = match (self.data_type(), rhs.data_type()) { (LineString(_, XY), LineString(_, XY)) => FrechetDistance::frechet_distance( - self.as_line_string::<2>(), - rhs.as_line_string::<2>(), + self.as_line_string(), + rhs.as_line_string(), ), _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -93,7 +93,7 @@ pub trait FrechetDistanceLineString { fn frechet_distance(&self, rhs: &Rhs) -> Self::Output; } -impl> FrechetDistanceLineString for LineStringArray<2> { +impl> FrechetDistanceLineString for LineStringArray { type Output = Float64Array; fn frechet_distance(&self, rhs: &G) -> Self::Output { @@ -106,7 +106,7 @@ impl> FrechetDistanceLineString for LineStringArr } impl + Sync> FrechetDistanceLineString - for ChunkedLineStringArray<2> + for ChunkedLineStringArray { type Output = ChunkedArray; @@ -124,7 +124,7 @@ impl> FrechetDistanceLineString for &dyn NativeAr let result = match self.data_type() { LineString(_, XY) => { - FrechetDistanceLineString::frechet_distance(self.as_line_string::<2>(), rhs) + FrechetDistanceLineString::frechet_distance(self.as_line_string(), rhs) } _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -142,7 +142,7 @@ impl> FrechetDistanceLineString for &dyn ChunkedN let rhs = line_string_to_geo(rhs); let result = match self.data_type() { LineString(_, XY) => { - FrechetDistanceLineString::frechet_distance(self.as_line_string::<2>(), &rhs) + FrechetDistanceLineString::frechet_distance(self.as_line_string(), &rhs) } _ => return Err(GeoArrowError::IncorrectType("".into())), }; diff --git a/rust/geoarrow/src/algorithm/geo/geodesic_area.rs b/rust/geoarrow/src/algorithm/geo/geodesic_area.rs index abb24c1d..01c0dec3 100644 --- a/rust/geoarrow/src/algorithm/geo/geodesic_area.rs +++ b/rust/geoarrow/src/algorithm/geo/geodesic_area.rs @@ -60,7 +60,7 @@ pub trait GeodesicArea { /// (x: 0.00185608, y: 51.501770), /// (x: 0.00388383, y: 51.501574), /// ]; - /// let polygon_array: PolygonArray<2> = vec![polygon].as_slice().into(); + /// let polygon_array: PolygonArray = vec![polygon].as_slice().into(); /// /// let area_array = polygon_array.geodesic_area_signed(); /// @@ -100,7 +100,7 @@ pub trait GeodesicArea { /// (x: 1.0, y: 1.0), /// (x: 1.0, y: 0.0), /// ]; - /// let polygon_array: PolygonArray<2> = vec![polygon].as_slice().into(); + /// let polygon_array: PolygonArray = vec![polygon].as_slice().into(); /// /// let area_array = polygon_array.geodesic_area_unsigned(); /// @@ -211,10 +211,10 @@ macro_rules! zero_impl { }; } -zero_impl!(PointArray<2>); -zero_impl!(LineStringArray<2>); -zero_impl!(MultiPointArray<2>); -zero_impl!(MultiLineStringArray<2>); +zero_impl!(PointArray); +zero_impl!(LineStringArray); +zero_impl!(MultiPointArray); +zero_impl!(MultiLineStringArray); /// Implementation that iterates over geo objects macro_rules! iter_geo_impl { @@ -292,10 +292,10 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(PolygonArray<2>); -iter_geo_impl!(MultiPolygonArray<2>); -iter_geo_impl!(MixedGeometryArray<2>); -iter_geo_impl!(GeometryCollectionArray<2>); +iter_geo_impl!(PolygonArray); +iter_geo_impl!(MultiPolygonArray); +iter_geo_impl!(MixedGeometryArray); +iter_geo_impl!(GeometryCollectionArray); impl GeodesicArea for &dyn NativeArray { type OutputSingle = Result; @@ -306,14 +306,14 @@ impl GeodesicArea for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_area_signed(), - LineString(_, XY) => self.as_line_string::<2>().geodesic_area_signed(), - Polygon(_, XY) => self.as_polygon::<2>().geodesic_area_signed(), - MultiPoint(_, XY) => self.as_multi_point::<2>().geodesic_area_signed(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().geodesic_area_signed(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().geodesic_area_signed(), - Mixed(_, XY) => self.as_mixed::<2>().geodesic_area_signed(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().geodesic_area_signed(), + Point(_, XY) => self.as_point().geodesic_area_signed(), + LineString(_, XY) => self.as_line_string().geodesic_area_signed(), + Polygon(_, XY) => self.as_polygon().geodesic_area_signed(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_area_signed(), + MultiLineString(_, XY) => self.as_multi_line_string().geodesic_area_signed(), + MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_area_signed(), + Mixed(_, XY) => self.as_mixed().geodesic_area_signed(), + GeometryCollection(_, XY) => self.as_geometry_collection().geodesic_area_signed(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -324,15 +324,15 @@ impl GeodesicArea for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_area_unsigned(), - LineString(_, XY) => self.as_line_string::<2>().geodesic_area_unsigned(), - Polygon(_, XY) => self.as_polygon::<2>().geodesic_area_unsigned(), - MultiPoint(_, XY) => self.as_multi_point::<2>().geodesic_area_unsigned(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().geodesic_area_unsigned(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().geodesic_area_unsigned(), - Mixed(_, XY) => self.as_mixed::<2>().geodesic_area_unsigned(), + Point(_, XY) => self.as_point().geodesic_area_unsigned(), + LineString(_, XY) => self.as_line_string().geodesic_area_unsigned(), + Polygon(_, XY) => self.as_polygon().geodesic_area_unsigned(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_area_unsigned(), + MultiLineString(_, XY) => self.as_multi_line_string().geodesic_area_unsigned(), + MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_area_unsigned(), + Mixed(_, XY) => self.as_mixed().geodesic_area_unsigned(), GeometryCollection(_, XY) => { - self.as_geometry_collection::<2>().geodesic_area_unsigned() + self.as_geometry_collection().geodesic_area_unsigned() } _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -344,14 +344,14 @@ impl GeodesicArea for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_perimeter(), - LineString(_, XY) => self.as_line_string::<2>().geodesic_perimeter(), - Polygon(_, XY) => self.as_polygon::<2>().geodesic_perimeter(), - MultiPoint(_, XY) => self.as_multi_point::<2>().geodesic_perimeter(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().geodesic_perimeter(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().geodesic_perimeter(), - Mixed(_, XY) => self.as_mixed::<2>().geodesic_perimeter(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().geodesic_perimeter(), + Point(_, XY) => self.as_point().geodesic_perimeter(), + LineString(_, XY) => self.as_line_string().geodesic_perimeter(), + Polygon(_, XY) => self.as_polygon().geodesic_perimeter(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_perimeter(), + MultiLineString(_, XY) => self.as_multi_line_string().geodesic_perimeter(), + MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_perimeter(), + Mixed(_, XY) => self.as_mixed().geodesic_perimeter(), + GeometryCollection(_, XY) => self.as_geometry_collection().geodesic_perimeter(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -362,19 +362,19 @@ impl GeodesicArea for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_perimeter_area_signed(), - LineString(_, XY) => self.as_line_string::<2>().geodesic_perimeter_area_signed(), - Polygon(_, XY) => self.as_polygon::<2>().geodesic_perimeter_area_signed(), - MultiPoint(_, XY) => self.as_multi_point::<2>().geodesic_perimeter_area_signed(), + Point(_, XY) => self.as_point().geodesic_perimeter_area_signed(), + LineString(_, XY) => self.as_line_string().geodesic_perimeter_area_signed(), + Polygon(_, XY) => self.as_polygon().geodesic_perimeter_area_signed(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_perimeter_area_signed(), MultiLineString(_, XY) => self - .as_multi_line_string::<2>() + .as_multi_line_string() .geodesic_perimeter_area_signed(), MultiPolygon(_, XY) => self - .as_multi_polygon::<2>() + .as_multi_polygon() .geodesic_perimeter_area_signed(), - Mixed(_, XY) => self.as_mixed::<2>().geodesic_perimeter_area_signed(), + Mixed(_, XY) => self.as_mixed().geodesic_perimeter_area_signed(), GeometryCollection(_, XY) => self - .as_geometry_collection::<2>() + .as_geometry_collection() .geodesic_perimeter_area_signed(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -386,23 +386,23 @@ impl GeodesicArea for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_perimeter_area_unsigned(), + Point(_, XY) => self.as_point().geodesic_perimeter_area_unsigned(), LineString(_, XY) => self - .as_line_string::<2>() + .as_line_string() .geodesic_perimeter_area_unsigned(), - Polygon(_, XY) => self.as_polygon::<2>().geodesic_perimeter_area_unsigned(), + Polygon(_, XY) => self.as_polygon().geodesic_perimeter_area_unsigned(), MultiPoint(_, XY) => self - .as_multi_point::<2>() + .as_multi_point() .geodesic_perimeter_area_unsigned(), MultiLineString(_, XY) => self - .as_multi_line_string::<2>() + .as_multi_line_string() .geodesic_perimeter_area_unsigned(), MultiPolygon(_, XY) => self - .as_multi_polygon::<2>() + .as_multi_polygon() .geodesic_perimeter_area_unsigned(), - Mixed(_, XY) => self.as_mixed::<2>().geodesic_perimeter_area_unsigned(), + Mixed(_, XY) => self.as_mixed().geodesic_perimeter_area_unsigned(), GeometryCollection(_, XY) => self - .as_geometry_collection::<2>() + .as_geometry_collection() .geodesic_perimeter_area_unsigned(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -455,14 +455,14 @@ impl GeodesicArea for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_area_signed(), - LineString(_, XY) => self.as_line_string::<2>().geodesic_area_signed(), - Polygon(_, XY) => self.as_polygon::<2>().geodesic_area_signed(), - MultiPoint(_, XY) => self.as_multi_point::<2>().geodesic_area_signed(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().geodesic_area_signed(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().geodesic_area_signed(), - Mixed(_, XY) => self.as_mixed::<2>().geodesic_area_signed(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().geodesic_area_signed(), + Point(_, XY) => self.as_point().geodesic_area_signed(), + LineString(_, XY) => self.as_line_string().geodesic_area_signed(), + Polygon(_, XY) => self.as_polygon().geodesic_area_signed(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_area_signed(), + MultiLineString(_, XY) => self.as_multi_line_string().geodesic_area_signed(), + MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_area_signed(), + Mixed(_, XY) => self.as_mixed().geodesic_area_signed(), + GeometryCollection(_, XY) => self.as_geometry_collection().geodesic_area_signed(), _ => Err(GeoArrowError::IncorrectType("".into())), } } @@ -472,15 +472,15 @@ impl GeodesicArea for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_area_unsigned(), - LineString(_, XY) => self.as_line_string::<2>().geodesic_area_unsigned(), - Polygon(_, XY) => self.as_polygon::<2>().geodesic_area_unsigned(), - MultiPoint(_, XY) => self.as_multi_point::<2>().geodesic_area_unsigned(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().geodesic_area_unsigned(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().geodesic_area_unsigned(), - Mixed(_, XY) => self.as_mixed::<2>().geodesic_area_unsigned(), + Point(_, XY) => self.as_point().geodesic_area_unsigned(), + LineString(_, XY) => self.as_line_string().geodesic_area_unsigned(), + Polygon(_, XY) => self.as_polygon().geodesic_area_unsigned(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_area_unsigned(), + MultiLineString(_, XY) => self.as_multi_line_string().geodesic_area_unsigned(), + MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_area_unsigned(), + Mixed(_, XY) => self.as_mixed().geodesic_area_unsigned(), GeometryCollection(_, XY) => { - self.as_geometry_collection::<2>().geodesic_area_unsigned() + self.as_geometry_collection().geodesic_area_unsigned() } _ => Err(GeoArrowError::IncorrectType("".into())), } @@ -491,14 +491,14 @@ impl GeodesicArea for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_perimeter(), - LineString(_, XY) => self.as_line_string::<2>().geodesic_perimeter(), - Polygon(_, XY) => self.as_polygon::<2>().geodesic_perimeter(), - MultiPoint(_, XY) => self.as_multi_point::<2>().geodesic_perimeter(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().geodesic_perimeter(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().geodesic_perimeter(), - Mixed(_, XY) => self.as_mixed::<2>().geodesic_perimeter(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().geodesic_perimeter(), + Point(_, XY) => self.as_point().geodesic_perimeter(), + LineString(_, XY) => self.as_line_string().geodesic_perimeter(), + Polygon(_, XY) => self.as_polygon().geodesic_perimeter(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_perimeter(), + MultiLineString(_, XY) => self.as_multi_line_string().geodesic_perimeter(), + MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_perimeter(), + Mixed(_, XY) => self.as_mixed().geodesic_perimeter(), + GeometryCollection(_, XY) => self.as_geometry_collection().geodesic_perimeter(), _ => Err(GeoArrowError::IncorrectType("".into())), } } @@ -508,19 +508,19 @@ impl GeodesicArea for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_perimeter_area_signed(), - LineString(_, XY) => self.as_line_string::<2>().geodesic_perimeter_area_signed(), - Polygon(_, XY) => self.as_polygon::<2>().geodesic_perimeter_area_signed(), - MultiPoint(_, XY) => self.as_multi_point::<2>().geodesic_perimeter_area_signed(), + Point(_, XY) => self.as_point().geodesic_perimeter_area_signed(), + LineString(_, XY) => self.as_line_string().geodesic_perimeter_area_signed(), + Polygon(_, XY) => self.as_polygon().geodesic_perimeter_area_signed(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_perimeter_area_signed(), MultiLineString(_, XY) => self - .as_multi_line_string::<2>() + .as_multi_line_string() .geodesic_perimeter_area_signed(), MultiPolygon(_, XY) => self - .as_multi_polygon::<2>() + .as_multi_polygon() .geodesic_perimeter_area_signed(), - Mixed(_, XY) => self.as_mixed::<2>().geodesic_perimeter_area_signed(), + Mixed(_, XY) => self.as_mixed().geodesic_perimeter_area_signed(), GeometryCollection(_, XY) => self - .as_geometry_collection::<2>() + .as_geometry_collection() .geodesic_perimeter_area_signed(), _ => Err(GeoArrowError::IncorrectType("".into())), } @@ -531,23 +531,23 @@ impl GeodesicArea for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_perimeter_area_unsigned(), + Point(_, XY) => self.as_point().geodesic_perimeter_area_unsigned(), LineString(_, XY) => self - .as_line_string::<2>() + .as_line_string() .geodesic_perimeter_area_unsigned(), - Polygon(_, XY) => self.as_polygon::<2>().geodesic_perimeter_area_unsigned(), + Polygon(_, XY) => self.as_polygon().geodesic_perimeter_area_unsigned(), MultiPoint(_, XY) => self - .as_multi_point::<2>() + .as_multi_point() .geodesic_perimeter_area_unsigned(), MultiLineString(_, XY) => self - .as_multi_line_string::<2>() + .as_multi_line_string() .geodesic_perimeter_area_unsigned(), MultiPolygon(_, XY) => self - .as_multi_polygon::<2>() + .as_multi_polygon() .geodesic_perimeter_area_unsigned(), - Mixed(_, XY) => self.as_mixed::<2>().geodesic_perimeter_area_unsigned(), + Mixed(_, XY) => self.as_mixed().geodesic_perimeter_area_unsigned(), GeometryCollection(_, XY) => self - .as_geometry_collection::<2>() + .as_geometry_collection() .geodesic_perimeter_area_unsigned(), _ => Err(GeoArrowError::IncorrectType("".into())), } diff --git a/rust/geoarrow/src/algorithm/geo/geodesic_length.rs b/rust/geoarrow/src/algorithm/geo/geodesic_length.rs index 42ecf21d..50811f8f 100644 --- a/rust/geoarrow/src/algorithm/geo/geodesic_length.rs +++ b/rust/geoarrow/src/algorithm/geo/geodesic_length.rs @@ -43,7 +43,7 @@ pub trait GeodesicLength { /// // Osaka /// (135.5244559, 34.687455) /// ]); - /// let linestring_array: LineStringArray<2> = vec![linestring].as_slice().into(); + /// let linestring_array: LineStringArray = vec![linestring].as_slice().into(); /// /// let length_array = linestring_array.geodesic_length(); /// @@ -70,8 +70,8 @@ macro_rules! zero_impl { }; } -zero_impl!(PointArray<2>); -zero_impl!(MultiPointArray<2>); +zero_impl!(PointArray); +zero_impl!(MultiPointArray); /// Implementation that iterates over geo objects macro_rules! iter_geo_impl { @@ -86,8 +86,8 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(MultiLineStringArray); impl GeodesicLength for &dyn NativeArray { type Output = Result; @@ -97,21 +97,21 @@ impl GeodesicLength for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_length(), - LineString(_, XY) => self.as_line_string::<2>().geodesic_length(), - // Polygon(_, XY) => self.as_polygon::<2>().geodesic_length(), - MultiPoint(_, XY) => self.as_multi_point::<2>().geodesic_length(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().geodesic_length(), - // MultiPolygon(_, XY) => self.as_multi_polygon::<2>().geodesic_length(), - // Mixed(_, XY) => self.as_mixed::<2>().geodesic_length(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().geodesic_length(), + Point(_, XY) => self.as_point().geodesic_length(), + LineString(_, XY) => self.as_line_string().geodesic_length(), + // Polygon(_, XY) => self.as_polygon().geodesic_length(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_length(), + MultiLineString(_, XY) => self.as_multi_line_string().geodesic_length(), + // MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_length(), + // Mixed(_, XY) => self.as_mixed().geodesic_length(), + // GeometryCollection(_, XY) => self.as_geometry_collection().geodesic_length(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) } } -impl GeodesicLength for ChunkedGeometryArray> { +impl GeodesicLength for ChunkedGeometryArray { type Output = Result>; fn geodesic_length(&self) -> Self::Output { @@ -132,9 +132,9 @@ macro_rules! chunked_impl { }; } -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); impl GeodesicLength for &dyn ChunkedNativeArray { type Output = Result>; @@ -144,14 +144,14 @@ impl GeodesicLength for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().geodesic_length(), - LineString(_, XY) => self.as_line_string::<2>().geodesic_length(), - // Polygon(_, XY) => self.as_polygon::<2>().geodesic_length(), - MultiPoint(_, XY) => self.as_multi_point::<2>().geodesic_length(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().geodesic_length(), - // MultiPolygon(_, XY) => self.as_multi_polygon::<2>().geodesic_length(), - // Mixed(_, XY) => self.as_mixed::<2>().geodesic_length(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().geodesic_length(), + Point(_, XY) => self.as_point().geodesic_length(), + LineString(_, XY) => self.as_line_string().geodesic_length(), + // Polygon(_, XY) => self.as_polygon().geodesic_length(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_length(), + MultiLineString(_, XY) => self.as_multi_line_string().geodesic_length(), + // MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_length(), + // Mixed(_, XY) => self.as_mixed().geodesic_length(), + // GeometryCollection(_, XY) => self.as_geometry_collection().geodesic_length(), _ => Err(GeoArrowError::IncorrectType("".into())), } } @@ -174,7 +174,7 @@ mod tests { // Osaka (x: 135.5244559, y: 34.687455), ]; - let input_array: LineStringArray<2> = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = vec![input_geom].as_slice().into(); let result_array = input_array.geodesic_length(); // Meters diff --git a/rust/geoarrow/src/algorithm/geo/haversine_length.rs b/rust/geoarrow/src/algorithm/geo/haversine_length.rs index 5f17a6a4..4db3232b 100644 --- a/rust/geoarrow/src/algorithm/geo/haversine_length.rs +++ b/rust/geoarrow/src/algorithm/geo/haversine_length.rs @@ -37,7 +37,7 @@ pub trait HaversineLength { /// // London /// (-0.1278, 51.5074), /// ]); - /// let linestring_array: LineStringArray<2> = vec![linestring].as_slice().into(); + /// let linestring_array: LineStringArray = vec![linestring].as_slice().into(); /// /// let length_array = linestring_array.haversine_length(); /// @@ -64,8 +64,8 @@ macro_rules! zero_impl { }; } -zero_impl!(PointArray<2>); -zero_impl!(MultiPointArray<2>); +zero_impl!(PointArray); +zero_impl!(MultiPointArray); /// Implementation that iterates over geo objects macro_rules! iter_geo_impl { @@ -80,8 +80,8 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(MultiLineStringArray); impl HaversineLength for &dyn NativeArray { type Output = Result; @@ -91,21 +91,21 @@ impl HaversineLength for &dyn NativeArray { use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().haversine_length(), - LineString(_, XY) => self.as_line_string::<2>().haversine_length(), - // Polygon(_, XY) => self.as_polygon::<2>().haversine_length(), - MultiPoint(_, XY) => self.as_multi_point::<2>().haversine_length(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().haversine_length(), - // MultiPolygon(_, XY) => self.as_multi_polygon::<2>().haversine_length(), - // Mixed(_, XY) => self.as_mixed::<2>().haversine_length(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().haversine_length(), + Point(_, XY) => self.as_point().haversine_length(), + LineString(_, XY) => self.as_line_string().haversine_length(), + // Polygon(_, XY) => self.as_polygon().haversine_length(), + MultiPoint(_, XY) => self.as_multi_point().haversine_length(), + MultiLineString(_, XY) => self.as_multi_line_string().haversine_length(), + // MultiPolygon(_, XY) => self.as_multi_polygon().haversine_length(), + // Mixed(_, XY) => self.as_mixed().haversine_length(), + // GeometryCollection(_, XY) => self.as_geometry_collection().haversine_length(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) } } -impl HaversineLength for ChunkedGeometryArray> { +impl HaversineLength for ChunkedGeometryArray { type Output = Result>; fn haversine_length(&self) -> Self::Output { @@ -126,9 +126,9 @@ macro_rules! chunked_impl { }; } -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); impl HaversineLength for &dyn ChunkedNativeArray { type Output = Result>; @@ -138,14 +138,14 @@ impl HaversineLength for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().haversine_length(), - LineString(_, XY) => self.as_line_string::<2>().haversine_length(), - // Polygon(_, XY) => self.as_polygon::<2>().haversine_length(), - MultiPoint(_, XY) => self.as_multi_point::<2>().haversine_length(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().haversine_length(), - // MultiPolygon(_, XY) => self.as_multi_polygon::<2>().haversine_length(), - // Mixed(_, XY) => self.as_mixed::<2>().haversine_length(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().haversine_length(), + Point(_, XY) => self.as_point().haversine_length(), + LineString(_, XY) => self.as_line_string().haversine_length(), + // Polygon(_, XY) => self.as_polygon().haversine_length(), + MultiPoint(_, XY) => self.as_multi_point().haversine_length(), + MultiLineString(_, XY) => self.as_multi_line_string().haversine_length(), + // MultiPolygon(_, XY) => self.as_multi_polygon().haversine_length(), + // Mixed(_, XY) => self.as_mixed().haversine_length(), + // GeometryCollection(_, XY) => self.as_geometry_collection().haversine_length(), _ => Err(GeoArrowError::IncorrectType("".into())), } } @@ -166,7 +166,7 @@ mod tests { // London (x: -0.1278, y: 51.5074), ]; - let input_array: LineStringArray<2> = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = vec![input_geom].as_slice().into(); let result_array = input_array.haversine_length(); // Meters diff --git a/rust/geoarrow/src/algorithm/geo/intersects.rs b/rust/geoarrow/src/algorithm/geo/intersects.rs index 47f0f60c..531e38cf 100644 --- a/rust/geoarrow/src/algorithm/geo/intersects.rs +++ b/rust/geoarrow/src/algorithm/geo/intersects.rs @@ -55,7 +55,7 @@ pub trait Intersects { } // Note: this implementation is outside the macro because it is not generic over O -impl Intersects for IndexedPointArray<2> { +impl Intersects for IndexedPointArray { type Output = BooleanArray; fn intersects(&self, rhs: &Self) -> Self::Output { @@ -83,72 +83,63 @@ macro_rules! iter_geo_impl { } // Implementations on PointArray -iter_geo_impl!(IndexedPointArray<2>, IndexedLineStringArray<2>); -iter_geo_impl!(IndexedPointArray<2>, IndexedPolygonArray<2>); -iter_geo_impl!(IndexedPointArray<2>, IndexedMultiPointArray<2>); -iter_geo_impl!(IndexedPointArray<2>, IndexedMultiLineStringArray<2>); -iter_geo_impl!(IndexedPointArray<2>, IndexedMultiPolygonArray<2>); -iter_geo_impl!(IndexedPointArray<2>, IndexedMixedGeometryArray<2>); -iter_geo_impl!(IndexedPointArray<2>, IndexedGeometryCollectionArray<2>); +iter_geo_impl!(IndexedPointArray, IndexedLineStringArray); +iter_geo_impl!(IndexedPointArray, IndexedPolygonArray); +iter_geo_impl!(IndexedPointArray, IndexedMultiPointArray); +iter_geo_impl!(IndexedPointArray, IndexedMultiLineStringArray); +iter_geo_impl!(IndexedPointArray, IndexedMultiPolygonArray); +iter_geo_impl!(IndexedPointArray, IndexedMixedGeometryArray); +iter_geo_impl!(IndexedPointArray, IndexedGeometryCollectionArray); // Implementations on LineStringArray -iter_geo_impl!(IndexedLineStringArray<2>, IndexedPointArray<2>); -iter_geo_impl!(IndexedLineStringArray<2>, IndexedLineStringArray<2>); -iter_geo_impl!(IndexedLineStringArray<2>, IndexedPolygonArray<2>); -iter_geo_impl!(IndexedLineStringArray<2>, IndexedMultiPointArray<2>); -iter_geo_impl!(IndexedLineStringArray<2>, IndexedMultiLineStringArray<2>); -iter_geo_impl!(IndexedLineStringArray<2>, IndexedMultiPolygonArray<2>); -iter_geo_impl!(IndexedLineStringArray<2>, IndexedMixedGeometryArray<2>); -iter_geo_impl!(IndexedLineStringArray<2>, IndexedGeometryCollectionArray<2>); +iter_geo_impl!(IndexedLineStringArray, IndexedPointArray); +iter_geo_impl!(IndexedLineStringArray, IndexedLineStringArray); +iter_geo_impl!(IndexedLineStringArray, IndexedPolygonArray); +iter_geo_impl!(IndexedLineStringArray, IndexedMultiPointArray); +iter_geo_impl!(IndexedLineStringArray, IndexedMultiLineStringArray); +iter_geo_impl!(IndexedLineStringArray, IndexedMultiPolygonArray); +iter_geo_impl!(IndexedLineStringArray, IndexedMixedGeometryArray); +iter_geo_impl!(IndexedLineStringArray, IndexedGeometryCollectionArray); // Implementations on PolygonArray -iter_geo_impl!(IndexedPolygonArray<2>, IndexedPointArray<2>); -iter_geo_impl!(IndexedPolygonArray<2>, IndexedLineStringArray<2>); -iter_geo_impl!(IndexedPolygonArray<2>, IndexedPolygonArray<2>); -iter_geo_impl!(IndexedPolygonArray<2>, IndexedMultiPointArray<2>); -iter_geo_impl!(IndexedPolygonArray<2>, IndexedMultiLineStringArray<2>); -iter_geo_impl!(IndexedPolygonArray<2>, IndexedMultiPolygonArray<2>); -iter_geo_impl!(IndexedPolygonArray<2>, IndexedMixedGeometryArray<2>); -iter_geo_impl!(IndexedPolygonArray<2>, IndexedGeometryCollectionArray<2>); +iter_geo_impl!(IndexedPolygonArray, IndexedPointArray); +iter_geo_impl!(IndexedPolygonArray, IndexedLineStringArray); +iter_geo_impl!(IndexedPolygonArray, IndexedPolygonArray); +iter_geo_impl!(IndexedPolygonArray, IndexedMultiPointArray); +iter_geo_impl!(IndexedPolygonArray, IndexedMultiLineStringArray); +iter_geo_impl!(IndexedPolygonArray, IndexedMultiPolygonArray); +iter_geo_impl!(IndexedPolygonArray, IndexedMixedGeometryArray); +iter_geo_impl!(IndexedPolygonArray, IndexedGeometryCollectionArray); // Implementations on MultiPointArray -iter_geo_impl!(IndexedMultiPointArray<2>, IndexedPointArray<2>); -iter_geo_impl!(IndexedMultiPointArray<2>, IndexedLineStringArray<2>); -iter_geo_impl!(IndexedMultiPointArray<2>, IndexedPolygonArray<2>); -iter_geo_impl!(IndexedMultiPointArray<2>, IndexedMultiPointArray<2>); -iter_geo_impl!(IndexedMultiPointArray<2>, IndexedMultiLineStringArray<2>); -iter_geo_impl!(IndexedMultiPointArray<2>, IndexedMultiPolygonArray<2>); -iter_geo_impl!(IndexedMultiPointArray<2>, IndexedMixedGeometryArray<2>); -iter_geo_impl!(IndexedMultiPointArray<2>, IndexedGeometryCollectionArray<2>); +iter_geo_impl!(IndexedMultiPointArray, IndexedPointArray); +iter_geo_impl!(IndexedMultiPointArray, IndexedLineStringArray); +iter_geo_impl!(IndexedMultiPointArray, IndexedPolygonArray); +iter_geo_impl!(IndexedMultiPointArray, IndexedMultiPointArray); +iter_geo_impl!(IndexedMultiPointArray, IndexedMultiLineStringArray); +iter_geo_impl!(IndexedMultiPointArray, IndexedMultiPolygonArray); +iter_geo_impl!(IndexedMultiPointArray, IndexedMixedGeometryArray); +iter_geo_impl!(IndexedMultiPointArray, IndexedGeometryCollectionArray); // Implementations on MultiLineStringArray -iter_geo_impl!(IndexedMultiLineStringArray<2>, IndexedPointArray<2>); -iter_geo_impl!(IndexedMultiLineStringArray<2>, IndexedLineStringArray<2>); -iter_geo_impl!(IndexedMultiLineStringArray<2>, IndexedPolygonArray<2>); -iter_geo_impl!(IndexedMultiLineStringArray<2>, IndexedMultiPointArray<2>); -iter_geo_impl!( - IndexedMultiLineStringArray<2>, - IndexedMultiLineStringArray<2> -); -iter_geo_impl!(IndexedMultiLineStringArray<2>, IndexedMultiPolygonArray<2>); -iter_geo_impl!(IndexedMultiLineStringArray<2>, IndexedMixedGeometryArray<2>); -iter_geo_impl!( - IndexedMultiLineStringArray<2>, - IndexedGeometryCollectionArray<2> -); +iter_geo_impl!(IndexedMultiLineStringArray, IndexedPointArray); +iter_geo_impl!(IndexedMultiLineStringArray, IndexedLineStringArray); +iter_geo_impl!(IndexedMultiLineStringArray, IndexedPolygonArray); +iter_geo_impl!(IndexedMultiLineStringArray, IndexedMultiPointArray); +iter_geo_impl!(IndexedMultiLineStringArray, IndexedMultiLineStringArray); +iter_geo_impl!(IndexedMultiLineStringArray, IndexedMultiPolygonArray); +iter_geo_impl!(IndexedMultiLineStringArray, IndexedMixedGeometryArray); +iter_geo_impl!(IndexedMultiLineStringArray, IndexedGeometryCollectionArray); // Implementations on MultiPolygonArray -iter_geo_impl!(IndexedMultiPolygonArray<2>, IndexedPointArray<2>); -iter_geo_impl!(IndexedMultiPolygonArray<2>, IndexedLineStringArray<2>); -iter_geo_impl!(IndexedMultiPolygonArray<2>, IndexedPolygonArray<2>); -iter_geo_impl!(IndexedMultiPolygonArray<2>, IndexedMultiPointArray<2>); -iter_geo_impl!(IndexedMultiPolygonArray<2>, IndexedMultiLineStringArray<2>); -iter_geo_impl!(IndexedMultiPolygonArray<2>, IndexedMultiPolygonArray<2>); -iter_geo_impl!(IndexedMultiPolygonArray<2>, IndexedMixedGeometryArray<2>); -iter_geo_impl!( - IndexedMultiPolygonArray<2>, - IndexedGeometryCollectionArray<2> -); +iter_geo_impl!(IndexedMultiPolygonArray, IndexedPointArray); +iter_geo_impl!(IndexedMultiPolygonArray, IndexedLineStringArray); +iter_geo_impl!(IndexedMultiPolygonArray, IndexedPolygonArray); +iter_geo_impl!(IndexedMultiPolygonArray, IndexedMultiPointArray); +iter_geo_impl!(IndexedMultiPolygonArray, IndexedMultiLineStringArray); +iter_geo_impl!(IndexedMultiPolygonArray, IndexedMultiPolygonArray); +iter_geo_impl!(IndexedMultiPolygonArray, IndexedMixedGeometryArray); +iter_geo_impl!(IndexedMultiPolygonArray, IndexedGeometryCollectionArray); // ┌─────────────────────────────────┐ // │ Implementations for RHS scalars │ @@ -160,7 +151,7 @@ pub trait IntersectsPoint { fn intersects(&self, rhs: &Rhs) -> Self::Output; } -impl> IntersectsPoint for IndexedPointArray<2> { +impl> IntersectsPoint for IndexedPointArray { type Output = BooleanArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -182,15 +173,15 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedLineStringArray<2>); -impl_intersects!(IndexedPolygonArray<2>); -impl_intersects!(IndexedMultiPointArray<2>); -impl_intersects!(IndexedMultiLineStringArray<2>); -impl_intersects!(IndexedMultiPolygonArray<2>); -impl_intersects!(IndexedMixedGeometryArray<2>); -impl_intersects!(IndexedGeometryCollectionArray<2>); +impl_intersects!(IndexedLineStringArray); +impl_intersects!(IndexedPolygonArray); +impl_intersects!(IndexedMultiPointArray); +impl_intersects!(IndexedMultiLineStringArray); +impl_intersects!(IndexedMultiPolygonArray); +impl_intersects!(IndexedMixedGeometryArray); +impl_intersects!(IndexedGeometryCollectionArray); -impl> IntersectsPoint for IndexedChunkedPointArray<2> { +impl> IntersectsPoint for IndexedChunkedPointArray { type Output = ChunkedArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -216,13 +207,13 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedChunkedLineStringArray<2>); -impl_intersects!(IndexedChunkedPolygonArray<2>); -impl_intersects!(IndexedChunkedMultiPointArray<2>); -impl_intersects!(IndexedChunkedMultiLineStringArray<2>); -impl_intersects!(IndexedChunkedMultiPolygonArray<2>); -impl_intersects!(IndexedChunkedMixedGeometryArray<2>); -impl_intersects!(IndexedChunkedGeometryCollectionArray<2>); +impl_intersects!(IndexedChunkedLineStringArray); +impl_intersects!(IndexedChunkedPolygonArray); +impl_intersects!(IndexedChunkedMultiPointArray); +impl_intersects!(IndexedChunkedMultiLineStringArray); +impl_intersects!(IndexedChunkedMultiPolygonArray); +impl_intersects!(IndexedChunkedMixedGeometryArray); +impl_intersects!(IndexedChunkedGeometryCollectionArray); pub trait IntersectsLineString { type Output; @@ -230,7 +221,7 @@ pub trait IntersectsLineString { fn intersects(&self, rhs: &Rhs) -> Self::Output; } -impl> IntersectsLineString for IndexedPointArray<2> { +impl> IntersectsLineString for IndexedPointArray { type Output = BooleanArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -256,15 +247,15 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedLineStringArray<2>); -impl_intersects!(IndexedPolygonArray<2>); -impl_intersects!(IndexedMultiPointArray<2>); -impl_intersects!(IndexedMultiLineStringArray<2>); -impl_intersects!(IndexedMultiPolygonArray<2>); -impl_intersects!(IndexedMixedGeometryArray<2>); -impl_intersects!(IndexedGeometryCollectionArray<2>); +impl_intersects!(IndexedLineStringArray); +impl_intersects!(IndexedPolygonArray); +impl_intersects!(IndexedMultiPointArray); +impl_intersects!(IndexedMultiLineStringArray); +impl_intersects!(IndexedMultiPolygonArray); +impl_intersects!(IndexedMixedGeometryArray); +impl_intersects!(IndexedGeometryCollectionArray); -impl> IntersectsLineString for IndexedChunkedPointArray<2> { +impl> IntersectsLineString for IndexedChunkedPointArray { type Output = ChunkedArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -290,13 +281,13 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedChunkedLineStringArray<2>); -impl_intersects!(IndexedChunkedPolygonArray<2>); -impl_intersects!(IndexedChunkedMultiPointArray<2>); -impl_intersects!(IndexedChunkedMultiLineStringArray<2>); -impl_intersects!(IndexedChunkedMultiPolygonArray<2>); -impl_intersects!(IndexedChunkedMixedGeometryArray<2>); -impl_intersects!(IndexedChunkedGeometryCollectionArray<2>); +impl_intersects!(IndexedChunkedLineStringArray); +impl_intersects!(IndexedChunkedPolygonArray); +impl_intersects!(IndexedChunkedMultiPointArray); +impl_intersects!(IndexedChunkedMultiLineStringArray); +impl_intersects!(IndexedChunkedMultiPolygonArray); +impl_intersects!(IndexedChunkedMixedGeometryArray); +impl_intersects!(IndexedChunkedGeometryCollectionArray); pub trait IntersectsPolygon { type Output; @@ -304,7 +295,7 @@ pub trait IntersectsPolygon { fn intersects(&self, rhs: &Rhs) -> Self::Output; } -impl> IntersectsPolygon for IndexedPointArray<2> { +impl> IntersectsPolygon for IndexedPointArray { type Output = BooleanArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -330,15 +321,15 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedLineStringArray<2>); -impl_intersects!(IndexedPolygonArray<2>); -impl_intersects!(IndexedMultiPointArray<2>); -impl_intersects!(IndexedMultiLineStringArray<2>); -impl_intersects!(IndexedMultiPolygonArray<2>); -impl_intersects!(IndexedMixedGeometryArray<2>); -impl_intersects!(IndexedGeometryCollectionArray<2>); +impl_intersects!(IndexedLineStringArray); +impl_intersects!(IndexedPolygonArray); +impl_intersects!(IndexedMultiPointArray); +impl_intersects!(IndexedMultiLineStringArray); +impl_intersects!(IndexedMultiPolygonArray); +impl_intersects!(IndexedMixedGeometryArray); +impl_intersects!(IndexedGeometryCollectionArray); -impl> IntersectsPolygon for IndexedChunkedPointArray<2> { +impl> IntersectsPolygon for IndexedChunkedPointArray { type Output = ChunkedArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -364,13 +355,13 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedChunkedLineStringArray<2>); -impl_intersects!(IndexedChunkedPolygonArray<2>); -impl_intersects!(IndexedChunkedMultiPointArray<2>); -impl_intersects!(IndexedChunkedMultiLineStringArray<2>); -impl_intersects!(IndexedChunkedMultiPolygonArray<2>); -impl_intersects!(IndexedChunkedMixedGeometryArray<2>); -impl_intersects!(IndexedChunkedGeometryCollectionArray<2>); +impl_intersects!(IndexedChunkedLineStringArray); +impl_intersects!(IndexedChunkedPolygonArray); +impl_intersects!(IndexedChunkedMultiPointArray); +impl_intersects!(IndexedChunkedMultiLineStringArray); +impl_intersects!(IndexedChunkedMultiPolygonArray); +impl_intersects!(IndexedChunkedMixedGeometryArray); +impl_intersects!(IndexedChunkedGeometryCollectionArray); pub trait IntersectsMultiPoint { type Output; @@ -378,7 +369,7 @@ pub trait IntersectsMultiPoint { fn intersects(&self, rhs: &Rhs) -> Self::Output; } -impl> IntersectsMultiPoint for IndexedPointArray<2> { +impl> IntersectsMultiPoint for IndexedPointArray { type Output = BooleanArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -404,15 +395,15 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedLineStringArray<2>); -impl_intersects!(IndexedPolygonArray<2>); -impl_intersects!(IndexedMultiPointArray<2>); -impl_intersects!(IndexedMultiLineStringArray<2>); -impl_intersects!(IndexedMultiPolygonArray<2>); -impl_intersects!(IndexedMixedGeometryArray<2>); -impl_intersects!(IndexedGeometryCollectionArray<2>); +impl_intersects!(IndexedLineStringArray); +impl_intersects!(IndexedPolygonArray); +impl_intersects!(IndexedMultiPointArray); +impl_intersects!(IndexedMultiLineStringArray); +impl_intersects!(IndexedMultiPolygonArray); +impl_intersects!(IndexedMixedGeometryArray); +impl_intersects!(IndexedGeometryCollectionArray); -impl> IntersectsMultiPoint for IndexedChunkedPointArray<2> { +impl> IntersectsMultiPoint for IndexedChunkedPointArray { type Output = ChunkedArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -438,13 +429,13 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedChunkedLineStringArray<2>); -impl_intersects!(IndexedChunkedPolygonArray<2>); -impl_intersects!(IndexedChunkedMultiPointArray<2>); -impl_intersects!(IndexedChunkedMultiLineStringArray<2>); -impl_intersects!(IndexedChunkedMultiPolygonArray<2>); -impl_intersects!(IndexedChunkedMixedGeometryArray<2>); -impl_intersects!(IndexedChunkedGeometryCollectionArray<2>); +impl_intersects!(IndexedChunkedLineStringArray); +impl_intersects!(IndexedChunkedPolygonArray); +impl_intersects!(IndexedChunkedMultiPointArray); +impl_intersects!(IndexedChunkedMultiLineStringArray); +impl_intersects!(IndexedChunkedMultiPolygonArray); +impl_intersects!(IndexedChunkedMixedGeometryArray); +impl_intersects!(IndexedChunkedGeometryCollectionArray); pub trait IntersectsMultiLineString { type Output; @@ -452,7 +443,7 @@ pub trait IntersectsMultiLineString { fn intersects(&self, rhs: &Rhs) -> Self::Output; } -impl> IntersectsMultiLineString for IndexedPointArray<2> { +impl> IntersectsMultiLineString for IndexedPointArray { type Output = BooleanArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -478,17 +469,15 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedLineStringArray<2>); -impl_intersects!(IndexedPolygonArray<2>); -impl_intersects!(IndexedMultiPointArray<2>); -impl_intersects!(IndexedMultiLineStringArray<2>); -impl_intersects!(IndexedMultiPolygonArray<2>); -impl_intersects!(IndexedMixedGeometryArray<2>); -impl_intersects!(IndexedGeometryCollectionArray<2>); +impl_intersects!(IndexedLineStringArray); +impl_intersects!(IndexedPolygonArray); +impl_intersects!(IndexedMultiPointArray); +impl_intersects!(IndexedMultiLineStringArray); +impl_intersects!(IndexedMultiPolygonArray); +impl_intersects!(IndexedMixedGeometryArray); +impl_intersects!(IndexedGeometryCollectionArray); -impl> IntersectsMultiLineString - for IndexedChunkedPointArray<2> -{ +impl> IntersectsMultiLineString for IndexedChunkedPointArray { type Output = ChunkedArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -514,13 +503,13 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedChunkedLineStringArray<2>); -impl_intersects!(IndexedChunkedPolygonArray<2>); -impl_intersects!(IndexedChunkedMultiPointArray<2>); -impl_intersects!(IndexedChunkedMultiLineStringArray<2>); -impl_intersects!(IndexedChunkedMultiPolygonArray<2>); -impl_intersects!(IndexedChunkedMixedGeometryArray<2>); -impl_intersects!(IndexedChunkedGeometryCollectionArray<2>); +impl_intersects!(IndexedChunkedLineStringArray); +impl_intersects!(IndexedChunkedPolygonArray); +impl_intersects!(IndexedChunkedMultiPointArray); +impl_intersects!(IndexedChunkedMultiLineStringArray); +impl_intersects!(IndexedChunkedMultiPolygonArray); +impl_intersects!(IndexedChunkedMixedGeometryArray); +impl_intersects!(IndexedChunkedGeometryCollectionArray); pub trait IntersectsMultiPolygon { type Output; @@ -528,7 +517,7 @@ pub trait IntersectsMultiPolygon { fn intersects(&self, rhs: &Rhs) -> Self::Output; } -impl> IntersectsMultiPolygon for IndexedPointArray<2> { +impl> IntersectsMultiPolygon for IndexedPointArray { type Output = BooleanArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -554,15 +543,15 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedLineStringArray<2>); -impl_intersects!(IndexedPolygonArray<2>); -impl_intersects!(IndexedMultiPointArray<2>); -impl_intersects!(IndexedMultiLineStringArray<2>); -impl_intersects!(IndexedMultiPolygonArray<2>); -impl_intersects!(IndexedMixedGeometryArray<2>); -impl_intersects!(IndexedGeometryCollectionArray<2>); +impl_intersects!(IndexedLineStringArray); +impl_intersects!(IndexedPolygonArray); +impl_intersects!(IndexedMultiPointArray); +impl_intersects!(IndexedMultiLineStringArray); +impl_intersects!(IndexedMultiPolygonArray); +impl_intersects!(IndexedMixedGeometryArray); +impl_intersects!(IndexedGeometryCollectionArray); -impl> IntersectsMultiPolygon for IndexedChunkedPointArray<2> { +impl> IntersectsMultiPolygon for IndexedChunkedPointArray { type Output = ChunkedArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -588,13 +577,13 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedChunkedLineStringArray<2>); -impl_intersects!(IndexedChunkedPolygonArray<2>); -impl_intersects!(IndexedChunkedMultiPointArray<2>); -impl_intersects!(IndexedChunkedMultiLineStringArray<2>); -impl_intersects!(IndexedChunkedMultiPolygonArray<2>); -impl_intersects!(IndexedChunkedMixedGeometryArray<2>); -impl_intersects!(IndexedChunkedGeometryCollectionArray<2>); +impl_intersects!(IndexedChunkedLineStringArray); +impl_intersects!(IndexedChunkedPolygonArray); +impl_intersects!(IndexedChunkedMultiPointArray); +impl_intersects!(IndexedChunkedMultiLineStringArray); +impl_intersects!(IndexedChunkedMultiPolygonArray); +impl_intersects!(IndexedChunkedMixedGeometryArray); +impl_intersects!(IndexedChunkedGeometryCollectionArray); pub trait IntersectsGeometry { type Output; @@ -602,7 +591,7 @@ pub trait IntersectsGeometry { fn intersects(&self, rhs: &Rhs) -> Self::Output; } -impl> IntersectsGeometry for IndexedPointArray<2> { +impl> IntersectsGeometry for IndexedPointArray { type Output = BooleanArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -628,15 +617,15 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedLineStringArray<2>); -impl_intersects!(IndexedPolygonArray<2>); -impl_intersects!(IndexedMultiPointArray<2>); -impl_intersects!(IndexedMultiLineStringArray<2>); -impl_intersects!(IndexedMultiPolygonArray<2>); -impl_intersects!(IndexedMixedGeometryArray<2>); -impl_intersects!(IndexedGeometryCollectionArray<2>); +impl_intersects!(IndexedLineStringArray); +impl_intersects!(IndexedPolygonArray); +impl_intersects!(IndexedMultiPointArray); +impl_intersects!(IndexedMultiLineStringArray); +impl_intersects!(IndexedMultiPolygonArray); +impl_intersects!(IndexedMixedGeometryArray); +impl_intersects!(IndexedGeometryCollectionArray); -impl> IntersectsGeometry for IndexedChunkedPointArray<2> { +impl> IntersectsGeometry for IndexedChunkedPointArray { type Output = ChunkedArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -662,13 +651,13 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedChunkedLineStringArray<2>); -impl_intersects!(IndexedChunkedPolygonArray<2>); -impl_intersects!(IndexedChunkedMultiPointArray<2>); -impl_intersects!(IndexedChunkedMultiLineStringArray<2>); -impl_intersects!(IndexedChunkedMultiPolygonArray<2>); -impl_intersects!(IndexedChunkedMixedGeometryArray<2>); -impl_intersects!(IndexedChunkedGeometryCollectionArray<2>); +impl_intersects!(IndexedChunkedLineStringArray); +impl_intersects!(IndexedChunkedPolygonArray); +impl_intersects!(IndexedChunkedMultiPointArray); +impl_intersects!(IndexedChunkedMultiLineStringArray); +impl_intersects!(IndexedChunkedMultiPolygonArray); +impl_intersects!(IndexedChunkedMixedGeometryArray); +impl_intersects!(IndexedChunkedGeometryCollectionArray); pub trait IntersectsGeometryCollection { type Output; @@ -676,7 +665,7 @@ pub trait IntersectsGeometryCollection { fn intersects(&self, rhs: &Rhs) -> Self::Output; } -impl> IntersectsGeometryCollection for IndexedPointArray<2> { +impl> IntersectsGeometryCollection for IndexedPointArray { type Output = BooleanArray; fn intersects(&self, rhs: &G) -> Self::Output { @@ -702,16 +691,16 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedLineStringArray<2>); -impl_intersects!(IndexedPolygonArray<2>); -impl_intersects!(IndexedMultiPointArray<2>); -impl_intersects!(IndexedMultiLineStringArray<2>); -impl_intersects!(IndexedMultiPolygonArray<2>); -impl_intersects!(IndexedMixedGeometryArray<2>); -impl_intersects!(IndexedGeometryCollectionArray<2>); +impl_intersects!(IndexedLineStringArray); +impl_intersects!(IndexedPolygonArray); +impl_intersects!(IndexedMultiPointArray); +impl_intersects!(IndexedMultiLineStringArray); +impl_intersects!(IndexedMultiPolygonArray); +impl_intersects!(IndexedMixedGeometryArray); +impl_intersects!(IndexedGeometryCollectionArray); impl> IntersectsGeometryCollection - for IndexedChunkedPointArray<2> + for IndexedChunkedPointArray { type Output = ChunkedArray; @@ -738,10 +727,10 @@ macro_rules! impl_intersects { }; } -impl_intersects!(IndexedChunkedLineStringArray<2>); -impl_intersects!(IndexedChunkedPolygonArray<2>); -impl_intersects!(IndexedChunkedMultiPointArray<2>); -impl_intersects!(IndexedChunkedMultiLineStringArray<2>); -impl_intersects!(IndexedChunkedMultiPolygonArray<2>); -impl_intersects!(IndexedChunkedMixedGeometryArray<2>); -impl_intersects!(IndexedChunkedGeometryCollectionArray<2>); +impl_intersects!(IndexedChunkedLineStringArray); +impl_intersects!(IndexedChunkedPolygonArray); +impl_intersects!(IndexedChunkedMultiPointArray); +impl_intersects!(IndexedChunkedMultiLineStringArray); +impl_intersects!(IndexedChunkedMultiPolygonArray); +impl_intersects!(IndexedChunkedMixedGeometryArray); +impl_intersects!(IndexedChunkedGeometryCollectionArray); diff --git a/rust/geoarrow/src/algorithm/geo/line_interpolate_point.rs b/rust/geoarrow/src/algorithm/geo/line_interpolate_point.rs index fb1bd58b..18dd289d 100644 --- a/rust/geoarrow/src/algorithm/geo/line_interpolate_point.rs +++ b/rust/geoarrow/src/algorithm/geo/line_interpolate_point.rs @@ -43,8 +43,8 @@ pub trait LineInterpolatePoint { fn line_interpolate_point(&self, fraction: Rhs) -> Self::Output; } -impl LineInterpolatePoint<&Float64Array> for LineStringArray<2> { - type Output = PointArray<2>; +impl LineInterpolatePoint<&Float64Array> for LineStringArray { + type Output = PointArray; fn line_interpolate_point(&self, p: &Float64Array) -> Self::Output { let mut output_array = PointBuilder::with_capacity(self.len()); @@ -67,21 +67,21 @@ impl LineInterpolatePoint<&Float64Array> for LineStringArray<2> { } impl LineInterpolatePoint<&Float64Array> for &dyn NativeArray { - type Output = Result>; + type Output = Result; fn line_interpolate_point(&self, fraction: &Float64Array) -> Self::Output { use Dimension::*; use NativeType::*; match self.data_type() { - LineString(_, XY) => Ok(self.as_line_string::<2>().line_interpolate_point(fraction)), + LineString(_, XY) => Ok(self.as_line_string().line_interpolate_point(fraction)), _ => Err(GeoArrowError::IncorrectType("".into())), } } } -impl LineInterpolatePoint<&[Float64Array]> for ChunkedLineStringArray<2> { - type Output = ChunkedPointArray<2>; +impl LineInterpolatePoint<&[Float64Array]> for ChunkedLineStringArray { + type Output = ChunkedPointArray; fn line_interpolate_point(&self, p: &[Float64Array]) -> Self::Output { ChunkedPointArray::new( @@ -91,21 +91,21 @@ impl LineInterpolatePoint<&[Float64Array]> for ChunkedLineStringArray<2> { } impl LineInterpolatePoint<&[Float64Array]> for &dyn ChunkedNativeArray { - type Output = Result>; + type Output = Result; fn line_interpolate_point(&self, fraction: &[Float64Array]) -> Self::Output { use Dimension::*; use NativeType::*; match self.data_type() { - LineString(_, XY) => Ok(self.as_line_string::<2>().line_interpolate_point(fraction)), + LineString(_, XY) => Ok(self.as_line_string().line_interpolate_point(fraction)), _ => Err(GeoArrowError::IncorrectType("".into())), } } } -impl LineInterpolatePoint for LineStringArray<2> { - type Output = PointArray<2>; +impl LineInterpolatePoint for LineStringArray { + type Output = PointArray; fn line_interpolate_point(&self, p: f64) -> Self::Output { let mut output_array = PointBuilder::with_capacity(self.len()); @@ -127,21 +127,21 @@ impl LineInterpolatePoint for LineStringArray<2> { } impl LineInterpolatePoint for &dyn NativeArray { - type Output = Result>; + type Output = Result; fn line_interpolate_point(&self, fraction: f64) -> Self::Output { use Dimension::*; use NativeType::*; match self.data_type() { - LineString(_, XY) => Ok(self.as_line_string::<2>().line_interpolate_point(fraction)), + LineString(_, XY) => Ok(self.as_line_string().line_interpolate_point(fraction)), _ => Err(GeoArrowError::IncorrectType("".into())), } } } -impl LineInterpolatePoint for ChunkedLineStringArray<2> { - type Output = ChunkedPointArray<2>; +impl LineInterpolatePoint for ChunkedLineStringArray { + type Output = ChunkedPointArray; fn line_interpolate_point(&self, fraction: f64) -> Self::Output { ChunkedPointArray::new(self.map(|chunk| chunk.line_interpolate_point(fraction))) @@ -149,14 +149,14 @@ impl LineInterpolatePoint for ChunkedLineStringArray<2> { } impl LineInterpolatePoint for &dyn ChunkedNativeArray { - type Output = Result>; + type Output = Result; fn line_interpolate_point(&self, fraction: f64) -> Self::Output { use Dimension::*; use NativeType::*; match self.data_type() { - LineString(_, XY) => Ok(self.as_line_string::<2>().line_interpolate_point(fraction)), + LineString(_, XY) => Ok(self.as_line_string().line_interpolate_point(fraction)), _ => Err(GeoArrowError::IncorrectType("".into())), } } diff --git a/rust/geoarrow/src/algorithm/geo/line_locate_point.rs b/rust/geoarrow/src/algorithm/geo/line_locate_point.rs index 488899fc..3b8d369d 100644 --- a/rust/geoarrow/src/algorithm/geo/line_locate_point.rs +++ b/rust/geoarrow/src/algorithm/geo/line_locate_point.rs @@ -25,10 +25,10 @@ pub trait LineLocatePoint { fn line_locate_point(&self, rhs: Rhs) -> Self::Output; } -impl LineLocatePoint<&PointArray<2>> for LineStringArray<2> { +impl LineLocatePoint<&PointArray> for LineStringArray { type Output = Float64Array; - fn line_locate_point(&self, rhs: &PointArray<2>) -> Float64Array { + fn line_locate_point(&self, rhs: &PointArray) -> Float64Array { let mut output_array = Float64Builder::with_capacity(self.len()); self.iter_geo() @@ -57,7 +57,7 @@ impl LineLocatePoint<&dyn NativeArray> for &dyn NativeArray { let result = match (self.data_type(), rhs.data_type()) { (LineString(_, XY), Point(_, XY)) => { - LineLocatePoint::line_locate_point(self.as_line_string::<2>(), rhs.as_point::<2>()) + LineLocatePoint::line_locate_point(self.as_line_string(), rhs.as_point()) } _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -65,10 +65,10 @@ impl LineLocatePoint<&dyn NativeArray> for &dyn NativeArray { } } -impl LineLocatePoint<&[PointArray<2>]> for ChunkedLineStringArray<2> { +impl LineLocatePoint<&[PointArray]> for ChunkedLineStringArray { type Output = ChunkedArray; - fn line_locate_point(&self, rhs: &[PointArray<2>]) -> ChunkedArray { + fn line_locate_point(&self, rhs: &[PointArray]) -> ChunkedArray { let chunks = self.binary_map(rhs, |(left, right)| { LineLocatePoint::line_locate_point(left, right) }); @@ -85,8 +85,8 @@ impl LineLocatePoint<&dyn ChunkedNativeArray> for &dyn ChunkedNativeArray { let result = match (self.data_type(), rhs.data_type()) { (LineString(_, XY), Point(_, XY)) => LineLocatePoint::line_locate_point( - self.as_line_string::<2>(), - &rhs.as_point::<2>().chunks, + self.as_line_string(), + &rhs.as_point().chunks, ), _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -100,7 +100,7 @@ pub trait LineLocatePointScalar { fn line_locate_point(&self, rhs: Rhs) -> Self::Output; } -impl> LineLocatePointScalar for LineStringArray<2> { +impl> LineLocatePointScalar for LineStringArray { type Output = Float64Array; fn line_locate_point(&self, rhs: G) -> Self::Output { @@ -131,7 +131,7 @@ impl> LineLocatePointScalar for &dyn NativeArray { let result = match self.data_type() { LineString(_, XY) => { - LineLocatePointScalar::line_locate_point(self.as_line_string::<2>(), rhs) + LineLocatePointScalar::line_locate_point(self.as_line_string(), rhs) } _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -139,7 +139,7 @@ impl> LineLocatePointScalar for &dyn NativeArray { } } -impl> LineLocatePointScalar for ChunkedLineStringArray<2> { +impl> LineLocatePointScalar for ChunkedLineStringArray { type Output = ChunkedArray; fn line_locate_point(&self, rhs: G) -> Self::Output { @@ -158,7 +158,7 @@ impl> LineLocatePointScalar for &dyn ChunkedNativeArra let result = match self.data_type() { LineString(_, XY) => { - LineLocatePointScalar::line_locate_point(self.as_line_string::<2>(), rhs) + LineLocatePointScalar::line_locate_point(self.as_line_string(), rhs) } _ => return Err(GeoArrowError::IncorrectType("".into())), }; diff --git a/rust/geoarrow/src/algorithm/geo/minimum_rotated_rect.rs b/rust/geoarrow/src/algorithm/geo/minimum_rotated_rect.rs index 6638349d..bc941aff 100644 --- a/rust/geoarrow/src/algorithm/geo/minimum_rotated_rect.rs +++ b/rust/geoarrow/src/algorithm/geo/minimum_rotated_rect.rs @@ -41,7 +41,7 @@ pub trait MinimumRotatedRect { macro_rules! iter_geo_impl { ($type:ty) => { impl MinimumRotatedRect for $type { - type Output = PolygonArray<2>; + type Output = PolygonArray; fn minimum_rotated_rect(&self) -> Self::Output { // The number of output geoms is the same as the input @@ -69,31 +69,31 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(PointArray<2>); -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(PolygonArray<2>); -iter_geo_impl!(MultiPointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>); -iter_geo_impl!(MixedGeometryArray<2>); -iter_geo_impl!(GeometryCollectionArray<2>); +iter_geo_impl!(PointArray); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(PolygonArray); +iter_geo_impl!(MultiPointArray); +iter_geo_impl!(MultiLineStringArray); +iter_geo_impl!(MultiPolygonArray); +iter_geo_impl!(MixedGeometryArray); +iter_geo_impl!(GeometryCollectionArray); impl MinimumRotatedRect for &dyn NativeArray { - type Output = Result>; + type Output = Result; fn minimum_rotated_rect(&self) -> Self::Output { use Dimension::*; use NativeType::*; let result = match self.data_type() { - Point(_, XY) => self.as_point::<2>().minimum_rotated_rect(), - LineString(_, XY) => self.as_line_string::<2>().minimum_rotated_rect(), - Polygon(_, XY) => self.as_polygon::<2>().minimum_rotated_rect(), - MultiPoint(_, XY) => self.as_multi_point::<2>().minimum_rotated_rect(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().minimum_rotated_rect(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().minimum_rotated_rect(), - Mixed(_, XY) => self.as_mixed::<2>().minimum_rotated_rect(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().minimum_rotated_rect(), + Point(_, XY) => self.as_point().minimum_rotated_rect(), + LineString(_, XY) => self.as_line_string().minimum_rotated_rect(), + Polygon(_, XY) => self.as_polygon().minimum_rotated_rect(), + MultiPoint(_, XY) => self.as_multi_point().minimum_rotated_rect(), + MultiLineString(_, XY) => self.as_multi_line_string().minimum_rotated_rect(), + MultiPolygon(_, XY) => self.as_multi_polygon().minimum_rotated_rect(), + Mixed(_, XY) => self.as_mixed().minimum_rotated_rect(), + GeometryCollection(_, XY) => self.as_geometry_collection().minimum_rotated_rect(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -101,7 +101,7 @@ impl MinimumRotatedRect for &dyn NativeArray { } impl MinimumRotatedRect for ChunkedGeometryArray { - type Output = Result>>; + type Output = Result>; fn minimum_rotated_rect(&self) -> Self::Output { self.try_map(|chunk| chunk.as_ref().minimum_rotated_rect())? @@ -110,21 +110,21 @@ impl MinimumRotatedRect for ChunkedGeometryArray { } impl MinimumRotatedRect for &dyn ChunkedNativeArray { - type Output = Result>; + type Output = Result; fn minimum_rotated_rect(&self) -> Self::Output { use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().minimum_rotated_rect(), - LineString(_, XY) => self.as_line_string::<2>().minimum_rotated_rect(), - Polygon(_, XY) => self.as_polygon::<2>().minimum_rotated_rect(), - MultiPoint(_, XY) => self.as_multi_point::<2>().minimum_rotated_rect(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().minimum_rotated_rect(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().minimum_rotated_rect(), - Mixed(_, XY) => self.as_mixed::<2>().minimum_rotated_rect(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().minimum_rotated_rect(), + Point(_, XY) => self.as_point().minimum_rotated_rect(), + LineString(_, XY) => self.as_line_string().minimum_rotated_rect(), + Polygon(_, XY) => self.as_polygon().minimum_rotated_rect(), + MultiPoint(_, XY) => self.as_multi_point().minimum_rotated_rect(), + MultiLineString(_, XY) => self.as_multi_line_string().minimum_rotated_rect(), + MultiPolygon(_, XY) => self.as_multi_polygon().minimum_rotated_rect(), + Mixed(_, XY) => self.as_mixed().minimum_rotated_rect(), + GeometryCollection(_, XY) => self.as_geometry_collection().minimum_rotated_rect(), _ => Err(GeoArrowError::IncorrectType("".into())), } } diff --git a/rust/geoarrow/src/algorithm/geo/remove_repeated_points.rs b/rust/geoarrow/src/algorithm/geo/remove_repeated_points.rs index 5d52a565..847618bc 100644 --- a/rust/geoarrow/src/algorithm/geo/remove_repeated_points.rs +++ b/rust/geoarrow/src/algorithm/geo/remove_repeated_points.rs @@ -26,7 +26,7 @@ pub trait RemoveRepeatedPoints { } // Note: this implementation is outside the macro because it is not generic over O -impl RemoveRepeatedPoints for PointArray<2> { +impl RemoveRepeatedPoints for PointArray { type Output = Self; fn remove_repeated_points(&self) -> Self::Output { @@ -55,21 +55,21 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, LineStringBuilder<2>, push_line_string); -iter_geo_impl!(PolygonArray<2>, PolygonBuilder<2>, push_polygon); -iter_geo_impl!(MultiPointArray<2>, MultiPointBuilder<2>, push_multi_point); +iter_geo_impl!(LineStringArray, LineStringBuilder, push_line_string); +iter_geo_impl!(PolygonArray, PolygonBuilder, push_polygon); +iter_geo_impl!(MultiPointArray, MultiPointBuilder, push_multi_point); iter_geo_impl!( - MultiLineStringArray<2>, - MultiLineStringBuilder<2>, + MultiLineStringArray, + MultiLineStringBuilder, push_multi_line_string ); iter_geo_impl!( - MultiPolygonArray<2>, - MultiPolygonBuilder<2>, + MultiPolygonArray, + MultiPolygonBuilder, push_multi_polygon ); -// iter_geo_impl!(MixedGeometryArray<2>, MixedGeometryBuilder<2>, push_geometry); -// iter_geo_impl!(GeometryCollectionArray<2>, geo::GeometryCollection); +// iter_geo_impl!(MixedGeometryArray, MixedGeometryBuilder, push_geometry); +// iter_geo_impl!(GeometryCollectionArray, geo::GeometryCollection); impl RemoveRepeatedPoints for &dyn NativeArray { type Output = Result>; @@ -79,23 +79,23 @@ impl RemoveRepeatedPoints for &dyn NativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().remove_repeated_points()), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().remove_repeated_points()), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().remove_repeated_points()), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().remove_repeated_points()), + Point(_, XY) => Arc::new(self.as_point().remove_repeated_points()), + LineString(_, XY) => Arc::new(self.as_line_string().remove_repeated_points()), + Polygon(_, XY) => Arc::new(self.as_polygon().remove_repeated_points()), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().remove_repeated_points()), MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string::<2>().remove_repeated_points()) + Arc::new(self.as_multi_line_string().remove_repeated_points()) } - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().remove_repeated_points()), - // Mixed(_, XY) => self.as_mixed::<2>().remove_repeated_points(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().remove_repeated_points(), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().remove_repeated_points()), + // Mixed(_, XY) => self.as_mixed().remove_repeated_points(), + // GeometryCollection(_, XY) => self.as_geometry_collection().remove_repeated_points(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) } } -impl RemoveRepeatedPoints for ChunkedPointArray<2> { +impl RemoveRepeatedPoints for ChunkedPointArray { type Output = Self; fn remove_repeated_points(&self) -> Self::Output { @@ -117,11 +117,11 @@ macro_rules! impl_chunked { }; } -impl_chunked!(ChunkedLineStringArray<2>); -impl_chunked!(ChunkedPolygonArray<2>); -impl_chunked!(ChunkedMultiPointArray<2>); -impl_chunked!(ChunkedMultiLineStringArray<2>); -impl_chunked!(ChunkedMultiPolygonArray<2>); +impl_chunked!(ChunkedLineStringArray); +impl_chunked!(ChunkedPolygonArray); +impl_chunked!(ChunkedMultiPointArray); +impl_chunked!(ChunkedMultiLineStringArray); +impl_chunked!(ChunkedMultiPolygonArray); impl RemoveRepeatedPoints for &dyn ChunkedNativeArray { type Output = Result>; @@ -131,16 +131,16 @@ impl RemoveRepeatedPoints for &dyn ChunkedNativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().remove_repeated_points()), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().remove_repeated_points()), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().remove_repeated_points()), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().remove_repeated_points()), + Point(_, XY) => Arc::new(self.as_point().remove_repeated_points()), + LineString(_, XY) => Arc::new(self.as_line_string().remove_repeated_points()), + Polygon(_, XY) => Arc::new(self.as_polygon().remove_repeated_points()), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().remove_repeated_points()), MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string::<2>().remove_repeated_points()) + Arc::new(self.as_multi_line_string().remove_repeated_points()) } - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().remove_repeated_points()), - // Mixed(_, XY) => self.as_mixed::<2>().remove_repeated_points(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().remove_repeated_points(), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().remove_repeated_points()), + // Mixed(_, XY) => self.as_mixed().remove_repeated_points(), + // GeometryCollection(_, XY) => self.as_geometry_collection().remove_repeated_points(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) diff --git a/rust/geoarrow/src/algorithm/geo/rotate.rs b/rust/geoarrow/src/algorithm/geo/rotate.rs index d2976ee3..9aca1547 100644 --- a/rust/geoarrow/src/algorithm/geo/rotate.rs +++ b/rust/geoarrow/src/algorithm/geo/rotate.rs @@ -98,7 +98,7 @@ pub trait Rotate { // └────────────────────────────────┘ // Note: this can't (easily) be parameterized in the macro because PointArray is not generic over O -impl Rotate for PointArray<2> { +impl Rotate for PointArray { type Output = Self; fn rotate_around_centroid(&self, degrees: &Float64Array) -> Self { @@ -169,18 +169,18 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(PolygonArray<2>); -iter_geo_impl!(MultiPointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(PolygonArray); +iter_geo_impl!(MultiPointArray); +iter_geo_impl!(MultiLineStringArray); +iter_geo_impl!(MultiPolygonArray); // ┌─────────────────────────────────┐ // │ Implementations for RHS scalars │ // └─────────────────────────────────┘ // Note: this can't (easily) be parameterized in the macro because PointArray is not generic over O -impl Rotate for PointArray<2> { +impl Rotate for PointArray { type Output = Self; fn rotate_around_centroid(&self, degrees: &f64) -> Self { @@ -239,11 +239,11 @@ macro_rules! iter_geo_impl_scalar { }; } -iter_geo_impl_scalar!(LineStringArray<2>); -iter_geo_impl_scalar!(PolygonArray<2>); -iter_geo_impl_scalar!(MultiPointArray<2>); -iter_geo_impl_scalar!(MultiLineStringArray<2>); -iter_geo_impl_scalar!(MultiPolygonArray<2>); +iter_geo_impl_scalar!(LineStringArray); +iter_geo_impl_scalar!(PolygonArray); +iter_geo_impl_scalar!(MultiPointArray); +iter_geo_impl_scalar!(MultiLineStringArray); +iter_geo_impl_scalar!(MultiPolygonArray); impl Rotate for &dyn NativeArray { type Output = Result>; diff --git a/rust/geoarrow/src/algorithm/geo/scale.rs b/rust/geoarrow/src/algorithm/geo/scale.rs index d8a677ff..25e7d615 100644 --- a/rust/geoarrow/src/algorithm/geo/scale.rs +++ b/rust/geoarrow/src/algorithm/geo/scale.rs @@ -100,7 +100,7 @@ pub trait Scale: Sized { } // Note: this can't (easily) be parameterized in the macro because PointArray is not generic over O -impl Scale for PointArray<2> { +impl Scale for PointArray { type Output = Self; fn scale_xy( @@ -209,17 +209,17 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, LineStringBuilder<2>, push_line_string); -iter_geo_impl!(PolygonArray<2>, PolygonBuilder<2>, push_polygon); -iter_geo_impl!(MultiPointArray<2>, MultiPointBuilder<2>, push_multi_point); +iter_geo_impl!(LineStringArray, LineStringBuilder, push_line_string); +iter_geo_impl!(PolygonArray, PolygonBuilder, push_polygon); +iter_geo_impl!(MultiPointArray, MultiPointBuilder, push_multi_point); iter_geo_impl!( - MultiLineStringArray<2>, - MultiLineStringBuilder<2>, + MultiLineStringArray, + MultiLineStringBuilder, push_multi_line_string ); iter_geo_impl!( - MultiPolygonArray<2>, - MultiPolygonBuilder<2>, + MultiPolygonArray, + MultiPolygonBuilder, push_multi_polygon ); diff --git a/rust/geoarrow/src/algorithm/geo/simplify.rs b/rust/geoarrow/src/algorithm/geo/simplify.rs index c6638e35..d96328da 100644 --- a/rust/geoarrow/src/algorithm/geo/simplify.rs +++ b/rust/geoarrow/src/algorithm/geo/simplify.rs @@ -38,7 +38,7 @@ pub trait Simplify { /// (x: 17.3, y: 3.2), /// (x: 27.8, y: 0.1), /// ]; - /// let line_string_array: LineStringArray<2> = vec![line_string].as_slice().into(); + /// let line_string_array: LineStringArray = vec![line_string].as_slice().into(); /// /// let simplified_array = line_string_array.simplify(&1.0); /// @@ -67,8 +67,8 @@ macro_rules! identity_impl { }; } -identity_impl!(PointArray<2>); -identity_impl!(MultiPointArray<2>); +identity_impl!(PointArray); +identity_impl!(MultiPointArray); /// Implementation that iterates over geo objects macro_rules! iter_geo_impl { @@ -88,12 +88,12 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, geo::LineString); -iter_geo_impl!(PolygonArray<2>, geo::Polygon); -iter_geo_impl!(MultiLineStringArray<2>, geo::MultiLineString); -iter_geo_impl!(MultiPolygonArray<2>, geo::MultiPolygon); -// iter_geo_impl!(MixedGeometryArray<2>, geo::Geometry); -// iter_geo_impl!(GeometryCollectionArray<2>, geo::GeometryCollection); +iter_geo_impl!(LineStringArray, geo::LineString); +iter_geo_impl!(PolygonArray, geo::Polygon); +iter_geo_impl!(MultiLineStringArray, geo::MultiLineString); +iter_geo_impl!(MultiPolygonArray, geo::MultiPolygon); +// iter_geo_impl!(MixedGeometryArray, geo::Geometry); +// iter_geo_impl!(GeometryCollectionArray, geo::GeometryCollection); impl Simplify for &dyn NativeArray { type Output = Result>; @@ -103,21 +103,21 @@ impl Simplify for &dyn NativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().simplify(epsilon)), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().simplify(epsilon)), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().simplify(epsilon)), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().simplify(epsilon)), - MultiLineString(_, XY) => Arc::new(self.as_multi_line_string::<2>().simplify(epsilon)), - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().simplify(epsilon)), - // Mixed(_, XY) => self.as_mixed::<2>().simplify(epsilon), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().simplify(), + Point(_, XY) => Arc::new(self.as_point().simplify(epsilon)), + LineString(_, XY) => Arc::new(self.as_line_string().simplify(epsilon)), + Polygon(_, XY) => Arc::new(self.as_polygon().simplify(epsilon)), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().simplify(epsilon)), + MultiLineString(_, XY) => Arc::new(self.as_multi_line_string().simplify(epsilon)), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().simplify(epsilon)), + // Mixed(_, XY) => self.as_mixed().simplify(epsilon), + // GeometryCollection(_, XY) => self.as_geometry_collection().simplify(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) } } -impl Simplify for ChunkedGeometryArray> { +impl Simplify for ChunkedGeometryArray { type Output = Self; fn simplify(&self, epsilon: &f64) -> Self::Output { @@ -142,11 +142,11 @@ macro_rules! chunked_impl { }; } -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); impl Simplify for &dyn ChunkedNativeArray { type Output = Result>; @@ -156,14 +156,14 @@ impl Simplify for &dyn ChunkedNativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().simplify(epsilon)), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().simplify(epsilon)), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().simplify(epsilon)), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().simplify(epsilon)), - MultiLineString(_, XY) => Arc::new(self.as_multi_line_string::<2>().simplify(epsilon)), - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().simplify(epsilon)), - // Mixed(_, XY) => self.as_mixed::<2>().simplify(epsilon), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().simplify(), + Point(_, XY) => Arc::new(self.as_point().simplify(epsilon)), + LineString(_, XY) => Arc::new(self.as_line_string().simplify(epsilon)), + Polygon(_, XY) => Arc::new(self.as_polygon().simplify(epsilon)), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().simplify(epsilon)), + MultiLineString(_, XY) => Arc::new(self.as_multi_line_string().simplify(epsilon)), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().simplify(epsilon)), + // Mixed(_, XY) => self.as_mixed().simplify(epsilon), + // GeometryCollection(_, XY) => self.as_geometry_collection().simplify(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -186,7 +186,7 @@ mod tests { (x: 17.3, y: 3.2 ), (x: 27.8, y: 0.1 ), ]; - let input_array: LineStringArray<2> = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = vec![input_geom].as_slice().into(); let result_array = input_array.simplify(&1.0); let expected = line_string![ @@ -209,7 +209,7 @@ mod tests { (x: 10., y: 0.), (x: 0., y: 0.), ]; - let input_array: PolygonArray<2> = vec![input_geom].as_slice().into(); + let input_array: PolygonArray = vec![input_geom].as_slice().into(); let result_array = input_array.simplify(&2.0); let expected = polygon![ diff --git a/rust/geoarrow/src/algorithm/geo/simplify_vw.rs b/rust/geoarrow/src/algorithm/geo/simplify_vw.rs index d2c45f9b..f94defa8 100644 --- a/rust/geoarrow/src/algorithm/geo/simplify_vw.rs +++ b/rust/geoarrow/src/algorithm/geo/simplify_vw.rs @@ -37,7 +37,7 @@ pub trait SimplifyVw { /// (x: 7.0, y: 25.0), /// (x: 10.0, y: 10.0), /// ]; - /// let line_string_array: LineStringArray<2> = vec![line_string].as_slice().into(); + /// let line_string_array: LineStringArray = vec![line_string].as_slice().into(); /// /// let simplified_array = line_string_array.simplify_vw(&30.0); /// @@ -65,8 +65,8 @@ macro_rules! identity_impl { }; } -identity_impl!(PointArray<2>); -identity_impl!(MultiPointArray<2>); +identity_impl!(PointArray); +identity_impl!(MultiPointArray); /// Implementation that iterates over geo objects macro_rules! iter_geo_impl { @@ -86,12 +86,12 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, geo::LineString); -iter_geo_impl!(PolygonArray<2>, geo::Polygon); -iter_geo_impl!(MultiLineStringArray<2>, geo::MultiLineString); -iter_geo_impl!(MultiPolygonArray<2>, geo::MultiPolygon); -// iter_geo_impl!(MixedGeometryArray<2>, geo::Geometry); -// iter_geo_impl!(GeometryCollectionArray<2>, geo::GeometryCollection); +iter_geo_impl!(LineStringArray, geo::LineString); +iter_geo_impl!(PolygonArray, geo::Polygon); +iter_geo_impl!(MultiLineStringArray, geo::MultiLineString); +iter_geo_impl!(MultiPolygonArray, geo::MultiPolygon); +// iter_geo_impl!(MixedGeometryArray, geo::Geometry); +// iter_geo_impl!(GeometryCollectionArray, geo::GeometryCollection); impl SimplifyVw for &dyn NativeArray { type Output = Result>; @@ -101,23 +101,23 @@ impl SimplifyVw for &dyn NativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().simplify_vw(epsilon)), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().simplify_vw(epsilon)), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().simplify_vw(epsilon)), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().simplify_vw(epsilon)), + Point(_, XY) => Arc::new(self.as_point().simplify_vw(epsilon)), + LineString(_, XY) => Arc::new(self.as_line_string().simplify_vw(epsilon)), + Polygon(_, XY) => Arc::new(self.as_polygon().simplify_vw(epsilon)), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().simplify_vw(epsilon)), MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string::<2>().simplify_vw(epsilon)) + Arc::new(self.as_multi_line_string().simplify_vw(epsilon)) } - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().simplify_vw(epsilon)), - // Mixed(_, XY) => self.as_mixed::<2>().simplify_vw(epsilon), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().simplify_vw(), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().simplify_vw(epsilon)), + // Mixed(_, XY) => self.as_mixed().simplify_vw(epsilon), + // GeometryCollection(_, XY) => self.as_geometry_collection().simplify_vw(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) } } -impl SimplifyVw for ChunkedGeometryArray> { +impl SimplifyVw for ChunkedGeometryArray { type Output = Self; fn simplify_vw(&self, epsilon: &f64) -> Self::Output { @@ -142,11 +142,11 @@ macro_rules! chunked_impl { }; } -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); impl SimplifyVw for &dyn ChunkedNativeArray { type Output = Result>; @@ -156,16 +156,16 @@ impl SimplifyVw for &dyn ChunkedNativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().simplify_vw(epsilon)), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().simplify_vw(epsilon)), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().simplify_vw(epsilon)), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().simplify_vw(epsilon)), + Point(_, XY) => Arc::new(self.as_point().simplify_vw(epsilon)), + LineString(_, XY) => Arc::new(self.as_line_string().simplify_vw(epsilon)), + Polygon(_, XY) => Arc::new(self.as_polygon().simplify_vw(epsilon)), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().simplify_vw(epsilon)), MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string::<2>().simplify_vw(epsilon)) + Arc::new(self.as_multi_line_string().simplify_vw(epsilon)) } - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().simplify_vw(epsilon)), - // Mixed(_, XY) => self.as_mixed::<2>().simplify_vw(epsilon), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().simplify_vw(), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().simplify_vw(epsilon)), + // Mixed(_, XY) => self.as_mixed().simplify_vw(epsilon), + // GeometryCollection(_, XY) => self.as_geometry_collection().simplify_vw(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) diff --git a/rust/geoarrow/src/algorithm/geo/simplify_vw_preserve.rs b/rust/geoarrow/src/algorithm/geo/simplify_vw_preserve.rs index ebc8005c..c79e775f 100644 --- a/rust/geoarrow/src/algorithm/geo/simplify_vw_preserve.rs +++ b/rust/geoarrow/src/algorithm/geo/simplify_vw_preserve.rs @@ -59,8 +59,8 @@ macro_rules! identity_impl { }; } -identity_impl!(PointArray<2>); -identity_impl!(MultiPointArray<2>); +identity_impl!(PointArray); +identity_impl!(MultiPointArray); /// Implementation that iterates over geo objects macro_rules! iter_geo_impl { @@ -80,12 +80,12 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, geo::LineString); -iter_geo_impl!(PolygonArray<2>, geo::Polygon); -iter_geo_impl!(MultiLineStringArray<2>, geo::MultiLineString); -iter_geo_impl!(MultiPolygonArray<2>, geo::MultiPolygon); -// iter_geo_impl!(MixedGeometryArray<2>, geo::Geometry); -// iter_geo_impl!(GeometryCollectionArray<2>, geo::GeometryCollection); +iter_geo_impl!(LineStringArray, geo::LineString); +iter_geo_impl!(PolygonArray, geo::Polygon); +iter_geo_impl!(MultiLineStringArray, geo::MultiLineString); +iter_geo_impl!(MultiPolygonArray, geo::MultiPolygon); +// iter_geo_impl!(MixedGeometryArray, geo::Geometry); +// iter_geo_impl!(GeometryCollectionArray, geo::GeometryCollection); impl SimplifyVwPreserve for &dyn NativeArray { type Output = Result>; @@ -95,26 +95,26 @@ impl SimplifyVwPreserve for &dyn NativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().simplify_vw_preserve(epsilon)), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().simplify_vw_preserve(epsilon)), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().simplify_vw_preserve(epsilon)), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().simplify_vw_preserve(epsilon)), + Point(_, XY) => Arc::new(self.as_point().simplify_vw_preserve(epsilon)), + LineString(_, XY) => Arc::new(self.as_line_string().simplify_vw_preserve(epsilon)), + Polygon(_, XY) => Arc::new(self.as_polygon().simplify_vw_preserve(epsilon)), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().simplify_vw_preserve(epsilon)), MultiLineString(_, XY) => Arc::new( - self.as_multi_line_string::<2>() + self.as_multi_line_string() .simplify_vw_preserve(epsilon), ), MultiPolygon(_, XY) => { - Arc::new(self.as_multi_polygon::<2>().simplify_vw_preserve(epsilon)) + Arc::new(self.as_multi_polygon().simplify_vw_preserve(epsilon)) } - // Mixed(_, XY) => self.as_mixed::<2>().simplify_vw_preserve(epsilon), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().simplify_vw_preserve(), + // Mixed(_, XY) => self.as_mixed().simplify_vw_preserve(epsilon), + // GeometryCollection(_, XY) => self.as_geometry_collection().simplify_vw_preserve(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) } } -impl SimplifyVwPreserve for ChunkedGeometryArray> { +impl SimplifyVwPreserve for ChunkedGeometryArray { type Output = Self; fn simplify_vw_preserve(&self, epsilon: &f64) -> Self::Output { @@ -139,11 +139,11 @@ macro_rules! chunked_impl { }; } -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); impl SimplifyVwPreserve for &dyn ChunkedNativeArray { type Output = Result>; @@ -153,19 +153,19 @@ impl SimplifyVwPreserve for &dyn ChunkedNativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().simplify_vw_preserve(epsilon)), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().simplify_vw_preserve(epsilon)), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().simplify_vw_preserve(epsilon)), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().simplify_vw_preserve(epsilon)), + Point(_, XY) => Arc::new(self.as_point().simplify_vw_preserve(epsilon)), + LineString(_, XY) => Arc::new(self.as_line_string().simplify_vw_preserve(epsilon)), + Polygon(_, XY) => Arc::new(self.as_polygon().simplify_vw_preserve(epsilon)), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().simplify_vw_preserve(epsilon)), MultiLineString(_, XY) => Arc::new( - self.as_multi_line_string::<2>() + self.as_multi_line_string() .simplify_vw_preserve(epsilon), ), MultiPolygon(_, XY) => { - Arc::new(self.as_multi_polygon::<2>().simplify_vw_preserve(epsilon)) + Arc::new(self.as_multi_polygon().simplify_vw_preserve(epsilon)) } - // Mixed(_, XY) => self.as_mixed::<2>().simplify_vw_preserve(epsilon), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().simplify_vw_preserve(), + // Mixed(_, XY) => self.as_mixed().simplify_vw_preserve(epsilon), + // GeometryCollection(_, XY) => self.as_geometry_collection().simplify_vw_preserve(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) diff --git a/rust/geoarrow/src/algorithm/geo/skew.rs b/rust/geoarrow/src/algorithm/geo/skew.rs index b9972ace..1de7d3d8 100644 --- a/rust/geoarrow/src/algorithm/geo/skew.rs +++ b/rust/geoarrow/src/algorithm/geo/skew.rs @@ -126,7 +126,7 @@ pub trait Skew { } // Note: this can't (easily) be parameterized in the macro because PointArray is not generic over O -impl Skew for PointArray<2> { +impl Skew for PointArray { type Output = Self; fn skew_xy( @@ -235,17 +235,17 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, LineStringBuilder<2>, push_line_string); -iter_geo_impl!(PolygonArray<2>, PolygonBuilder<2>, push_polygon); -iter_geo_impl!(MultiPointArray<2>, MultiPointBuilder<2>, push_multi_point); +iter_geo_impl!(LineStringArray, LineStringBuilder, push_line_string); +iter_geo_impl!(PolygonArray, PolygonBuilder, push_polygon); +iter_geo_impl!(MultiPointArray, MultiPointBuilder, push_multi_point); iter_geo_impl!( - MultiLineStringArray<2>, - MultiLineStringBuilder<2>, + MultiLineStringArray, + MultiLineStringBuilder, push_multi_line_string ); iter_geo_impl!( - MultiPolygonArray<2>, - MultiPolygonBuilder<2>, + MultiPolygonArray, + MultiPolygonBuilder, push_multi_polygon ); diff --git a/rust/geoarrow/src/algorithm/geo/translate.rs b/rust/geoarrow/src/algorithm/geo/translate.rs index fa2dcaf1..7d15ab71 100644 --- a/rust/geoarrow/src/algorithm/geo/translate.rs +++ b/rust/geoarrow/src/algorithm/geo/translate.rs @@ -52,7 +52,7 @@ pub trait Translate { } // Note: this can't (easily) be parameterized in the macro because PointArray is not generic over O -impl Translate for PointArray<2> { +impl Translate for PointArray { type Output = Self; fn translate( @@ -110,17 +110,17 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, LineStringBuilder<2>, push_line_string); -iter_geo_impl!(PolygonArray<2>, PolygonBuilder<2>, push_polygon); -iter_geo_impl!(MultiPointArray<2>, MultiPointBuilder<2>, push_multi_point); +iter_geo_impl!(LineStringArray, LineStringBuilder, push_line_string); +iter_geo_impl!(PolygonArray, PolygonBuilder, push_polygon); +iter_geo_impl!(MultiPointArray, MultiPointBuilder, push_multi_point); iter_geo_impl!( - MultiLineStringArray<2>, - MultiLineStringBuilder<2>, + MultiLineStringArray, + MultiLineStringBuilder, push_multi_line_string ); iter_geo_impl!( - MultiPolygonArray<2>, - MultiPolygonBuilder<2>, + MultiPolygonArray, + MultiPolygonBuilder, push_multi_polygon ); diff --git a/rust/geoarrow/src/algorithm/geo/vincenty_length.rs b/rust/geoarrow/src/algorithm/geo/vincenty_length.rs index fff2564f..eb2f11ef 100644 --- a/rust/geoarrow/src/algorithm/geo/vincenty_length.rs +++ b/rust/geoarrow/src/algorithm/geo/vincenty_length.rs @@ -36,7 +36,7 @@ pub trait VincentyLength { /// // Osaka /// (135.5244559, 34.687455) /// ]); - /// let linestring_array: LineStringArray<2> = vec![linestring].as_slice().into(); + /// let linestring_array: LineStringArray = vec![linestring].as_slice().into(); /// /// let length_array = linestring_array.vincenty_length().unwrap(); /// @@ -63,8 +63,8 @@ macro_rules! zero_impl { }; } -zero_impl!(PointArray<2>); -zero_impl!(MultiPointArray<2>); +zero_impl!(PointArray); +zero_impl!(MultiPointArray); /// Implementation that iterates over geo objects macro_rules! iter_geo_impl { @@ -79,8 +79,8 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>); -iter_geo_impl!(MultiLineStringArray<2>); +iter_geo_impl!(LineStringArray); +iter_geo_impl!(MultiLineStringArray); impl VincentyLength for &dyn NativeArray { type Output = Result; @@ -90,20 +90,20 @@ impl VincentyLength for &dyn NativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().vincenty_length(), - LineString(_, XY) => self.as_line_string::<2>().vincenty_length(), - // Polygon(_, XY) => self.as_polygon::<2>().vincenty_length(), - MultiPoint(_, XY) => self.as_multi_point::<2>().vincenty_length(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().vincenty_length(), - // MultiPolygon(_, XY) => self.as_multi_polygon::<2>().vincenty_length(), - // Mixed(_, XY) => self.as_mixed::<2>().vincenty_length(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().vincenty_length(), + Point(_, XY) => self.as_point().vincenty_length(), + LineString(_, XY) => self.as_line_string().vincenty_length(), + // Polygon(_, XY) => self.as_polygon().vincenty_length(), + MultiPoint(_, XY) => self.as_multi_point().vincenty_length(), + MultiLineString(_, XY) => self.as_multi_line_string().vincenty_length(), + // MultiPolygon(_, XY) => self.as_multi_polygon().vincenty_length(), + // Mixed(_, XY) => self.as_mixed().vincenty_length(), + // GeometryCollection(_, XY) => self.as_geometry_collection().vincenty_length(), _ => Err(GeoArrowError::IncorrectType("".into())), } } } -impl VincentyLength for ChunkedGeometryArray> { +impl VincentyLength for ChunkedGeometryArray { type Output = Result>; fn vincenty_length(&self) -> Self::Output { @@ -124,9 +124,9 @@ macro_rules! chunked_impl { }; } -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); impl VincentyLength for &dyn ChunkedNativeArray { type Output = Result>; @@ -136,14 +136,14 @@ impl VincentyLength for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().vincenty_length(), - LineString(_, XY) => self.as_line_string::<2>().vincenty_length(), - // Polygon(_, XY) => self.as_polygon::<2>().vincenty_length(), - MultiPoint(_, XY) => self.as_multi_point::<2>().vincenty_length(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().vincenty_length(), - // MultiPolygon(_, XY) => self.as_multi_polygon::<2>().vincenty_length(), - // Mixed(_, XY) => self.as_mixed::<2>().vincenty_length(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().vincenty_length(), + Point(_, XY) => self.as_point().vincenty_length(), + LineString(_, XY) => self.as_line_string().vincenty_length(), + // Polygon(_, XY) => self.as_polygon().vincenty_length(), + MultiPoint(_, XY) => self.as_multi_point().vincenty_length(), + MultiLineString(_, XY) => self.as_multi_line_string().vincenty_length(), + // MultiPolygon(_, XY) => self.as_multi_polygon().vincenty_length(), + // Mixed(_, XY) => self.as_mixed().vincenty_length(), + // GeometryCollection(_, XY) => self.as_geometry_collection().vincenty_length(), _ => Err(GeoArrowError::IncorrectType("".into())), } } @@ -164,7 +164,7 @@ mod tests { // London (x: -0.1278, y: 51.5074), ]; - let input_array: LineStringArray<2> = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = vec![input_geom].as_slice().into(); let result_array = input_array.vincenty_length().unwrap(); // Meters diff --git a/rust/geoarrow/src/algorithm/geo/within.rs b/rust/geoarrow/src/algorithm/geo/within.rs index ae542eab..d7be79af 100644 --- a/rust/geoarrow/src/algorithm/geo/within.rs +++ b/rust/geoarrow/src/algorithm/geo/within.rs @@ -49,7 +49,7 @@ pub trait Within { // └────────────────────────────────┘ // Note: this implementation is outside the macro because it is not generic over O -impl Within for PointArray<2> { +impl Within for PointArray { fn is_within(&self, rhs: &Self) -> BooleanArray { assert_eq!(self.len(), rhs.len()); @@ -91,58 +91,58 @@ macro_rules! iter_geo_impl { } // Implementations on PointArray -iter_geo_impl!(PointArray<2>, LineStringArray<2>); -iter_geo_impl!(PointArray<2>, PolygonArray<2>); -iter_geo_impl!(PointArray<2>, MultiPointArray<2>); -iter_geo_impl!(PointArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(PointArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(PointArray, LineStringArray); +iter_geo_impl!(PointArray, PolygonArray); +iter_geo_impl!(PointArray, MultiPointArray); +iter_geo_impl!(PointArray, MultiLineStringArray); +iter_geo_impl!(PointArray, MultiPolygonArray); // Implementations on LineStringArray -iter_geo_impl!(LineStringArray<2>, PointArray<2>); -iter_geo_impl!(LineStringArray<2>, LineStringArray<2>); -iter_geo_impl!(LineStringArray<2>, PolygonArray<2>); -iter_geo_impl!(LineStringArray<2>, MultiPointArray<2>); -iter_geo_impl!(LineStringArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(LineStringArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(LineStringArray, PointArray); +iter_geo_impl!(LineStringArray, LineStringArray); +iter_geo_impl!(LineStringArray, PolygonArray); +iter_geo_impl!(LineStringArray, MultiPointArray); +iter_geo_impl!(LineStringArray, MultiLineStringArray); +iter_geo_impl!(LineStringArray, MultiPolygonArray); // Implementations on PolygonArray -iter_geo_impl!(PolygonArray<2>, PointArray<2>); -iter_geo_impl!(PolygonArray<2>, LineStringArray<2>); -iter_geo_impl!(PolygonArray<2>, PolygonArray<2>); -iter_geo_impl!(PolygonArray<2>, MultiPointArray<2>); -iter_geo_impl!(PolygonArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(PolygonArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(PolygonArray, PointArray); +iter_geo_impl!(PolygonArray, LineStringArray); +iter_geo_impl!(PolygonArray, PolygonArray); +iter_geo_impl!(PolygonArray, MultiPointArray); +iter_geo_impl!(PolygonArray, MultiLineStringArray); +iter_geo_impl!(PolygonArray, MultiPolygonArray); // Implementations on MultiPointArray -iter_geo_impl!(MultiPointArray<2>, PointArray<2>); -iter_geo_impl!(MultiPointArray<2>, LineStringArray<2>); -iter_geo_impl!(MultiPointArray<2>, PolygonArray<2>); -iter_geo_impl!(MultiPointArray<2>, MultiPointArray<2>); -iter_geo_impl!(MultiPointArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(MultiPointArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(MultiPointArray, PointArray); +iter_geo_impl!(MultiPointArray, LineStringArray); +iter_geo_impl!(MultiPointArray, PolygonArray); +iter_geo_impl!(MultiPointArray, MultiPointArray); +iter_geo_impl!(MultiPointArray, MultiLineStringArray); +iter_geo_impl!(MultiPointArray, MultiPolygonArray); // Implementations on MultiLineStringArray -iter_geo_impl!(MultiLineStringArray<2>, PointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>, LineStringArray<2>); -iter_geo_impl!(MultiLineStringArray<2>, PolygonArray<2>); -iter_geo_impl!(MultiLineStringArray<2>, MultiPointArray<2>); -iter_geo_impl!(MultiLineStringArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(MultiLineStringArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(MultiLineStringArray, PointArray); +iter_geo_impl!(MultiLineStringArray, LineStringArray); +iter_geo_impl!(MultiLineStringArray, PolygonArray); +iter_geo_impl!(MultiLineStringArray, MultiPointArray); +iter_geo_impl!(MultiLineStringArray, MultiLineStringArray); +iter_geo_impl!(MultiLineStringArray, MultiPolygonArray); // Implementations on MultiPolygonArray -iter_geo_impl!(MultiPolygonArray<2>, PointArray<2>); -iter_geo_impl!(MultiPolygonArray<2>, LineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>, PolygonArray<2>); -iter_geo_impl!(MultiPolygonArray<2>, MultiPointArray<2>); -iter_geo_impl!(MultiPolygonArray<2>, MultiLineStringArray<2>); -iter_geo_impl!(MultiPolygonArray<2>, MultiPolygonArray<2>); +iter_geo_impl!(MultiPolygonArray, PointArray); +iter_geo_impl!(MultiPolygonArray, LineStringArray); +iter_geo_impl!(MultiPolygonArray, PolygonArray); +iter_geo_impl!(MultiPolygonArray, MultiPointArray); +iter_geo_impl!(MultiPolygonArray, MultiLineStringArray); +iter_geo_impl!(MultiPolygonArray, MultiPolygonArray); // ┌──────────────────────────────────────────┐ // │ Implementations for RHS geoarrow scalars │ // └──────────────────────────────────────────┘ // Note: this implementation is outside the macro because it is not generic over O -impl<'a> Within> for PointArray<2> { +impl<'a> Within> for PointArray { fn is_within(&self, rhs: &Point<'a, 2>) -> BooleanArray { let mut output_array = BooleanBuilder::with_capacity(self.len()); @@ -175,51 +175,51 @@ macro_rules! iter_geo_impl_geoarrow_scalar { } // Implementations on PointArray -iter_geo_impl_geoarrow_scalar!(PointArray<2>, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PointArray<2>, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PointArray<2>, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PointArray<2>, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PointArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PointArray, LineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PointArray, Polygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PointArray, MultiPoint<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PointArray, MultiLineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PointArray, MultiPolygon<'a, 2>); // Implementations on LineStringArray -iter_geo_impl_geoarrow_scalar!(LineStringArray<2>, Point<'a, 2>); -iter_geo_impl_geoarrow_scalar!(LineStringArray<2>, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(LineStringArray<2>, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(LineStringArray<2>, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(LineStringArray<2>, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(LineStringArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, Point<'a, 2>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, LineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, Polygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiPoint<'a, 2>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiLineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiPolygon<'a, 2>); // Implementations on PolygonArray -iter_geo_impl_geoarrow_scalar!(PolygonArray<2>, Point<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PolygonArray<2>, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PolygonArray<2>, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PolygonArray<2>, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PolygonArray<2>, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PolygonArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, Point<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, LineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, Polygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiPoint<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiLineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiPolygon<'a, 2>); // Implementations on MultiPointArray -iter_geo_impl_geoarrow_scalar!(MultiPointArray<2>, Point<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPointArray<2>, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPointArray<2>, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPointArray<2>, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPointArray<2>, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPointArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, Point<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, LineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, Polygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiPoint<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiLineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiPolygon<'a, 2>); // Implementations on MultiLineStringArray -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray<2>, Point<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray<2>, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray<2>, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray<2>, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray<2>, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, Point<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, LineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, Polygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiPoint<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiLineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiPolygon<'a, 2>); // Implementations on MultiPolygonArray -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray<2>, Point<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray<2>, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray<2>, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray<2>, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray<2>, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray<2>, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, Point<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, LineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, Polygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiPoint<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiLineString<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiPolygon<'a, 2>); // ┌─────────────────────────────────────┐ // │ Implementations for RHS geo scalars │ @@ -243,12 +243,12 @@ macro_rules! non_generic_iter_geo_impl_geo_scalar { } // Implementations on PointArray -non_generic_iter_geo_impl_geo_scalar!(PointArray<2>, geo::Point); -non_generic_iter_geo_impl_geo_scalar!(PointArray<2>, geo::LineString); -non_generic_iter_geo_impl_geo_scalar!(PointArray<2>, geo::Polygon); -non_generic_iter_geo_impl_geo_scalar!(PointArray<2>, geo::MultiPoint); -non_generic_iter_geo_impl_geo_scalar!(PointArray<2>, geo::MultiLineString); -non_generic_iter_geo_impl_geo_scalar!(PointArray<2>, geo::MultiPolygon); +non_generic_iter_geo_impl_geo_scalar!(PointArray, geo::Point); +non_generic_iter_geo_impl_geo_scalar!(PointArray, geo::LineString); +non_generic_iter_geo_impl_geo_scalar!(PointArray, geo::Polygon); +non_generic_iter_geo_impl_geo_scalar!(PointArray, geo::MultiPoint); +non_generic_iter_geo_impl_geo_scalar!(PointArray, geo::MultiLineString); +non_generic_iter_geo_impl_geo_scalar!(PointArray, geo::MultiPolygon); macro_rules! iter_geo_impl_geo_scalar { ($first:ty, $second:ty) => { @@ -268,41 +268,41 @@ macro_rules! iter_geo_impl_geo_scalar { } // Implementations on LineStringArray -iter_geo_impl_geo_scalar!(LineStringArray<2>, geo::Point); -iter_geo_impl_geo_scalar!(LineStringArray<2>, geo::LineString); -iter_geo_impl_geo_scalar!(LineStringArray<2>, geo::Polygon); -iter_geo_impl_geo_scalar!(LineStringArray<2>, geo::MultiPoint); -iter_geo_impl_geo_scalar!(LineStringArray<2>, geo::MultiLineString); -iter_geo_impl_geo_scalar!(LineStringArray<2>, geo::MultiPolygon); +iter_geo_impl_geo_scalar!(LineStringArray, geo::Point); +iter_geo_impl_geo_scalar!(LineStringArray, geo::LineString); +iter_geo_impl_geo_scalar!(LineStringArray, geo::Polygon); +iter_geo_impl_geo_scalar!(LineStringArray, geo::MultiPoint); +iter_geo_impl_geo_scalar!(LineStringArray, geo::MultiLineString); +iter_geo_impl_geo_scalar!(LineStringArray, geo::MultiPolygon); // Implementations on PolygonArray -iter_geo_impl_geo_scalar!(PolygonArray<2>, geo::Point); -iter_geo_impl_geo_scalar!(PolygonArray<2>, geo::LineString); -iter_geo_impl_geo_scalar!(PolygonArray<2>, geo::Polygon); -iter_geo_impl_geo_scalar!(PolygonArray<2>, geo::MultiPoint); -iter_geo_impl_geo_scalar!(PolygonArray<2>, geo::MultiLineString); -iter_geo_impl_geo_scalar!(PolygonArray<2>, geo::MultiPolygon); +iter_geo_impl_geo_scalar!(PolygonArray, geo::Point); +iter_geo_impl_geo_scalar!(PolygonArray, geo::LineString); +iter_geo_impl_geo_scalar!(PolygonArray, geo::Polygon); +iter_geo_impl_geo_scalar!(PolygonArray, geo::MultiPoint); +iter_geo_impl_geo_scalar!(PolygonArray, geo::MultiLineString); +iter_geo_impl_geo_scalar!(PolygonArray, geo::MultiPolygon); // Implementations on MultiPointArray -iter_geo_impl_geo_scalar!(MultiPointArray<2>, geo::Point); -iter_geo_impl_geo_scalar!(MultiPointArray<2>, geo::LineString); -iter_geo_impl_geo_scalar!(MultiPointArray<2>, geo::Polygon); -iter_geo_impl_geo_scalar!(MultiPointArray<2>, geo::MultiPoint); -iter_geo_impl_geo_scalar!(MultiPointArray<2>, geo::MultiLineString); -iter_geo_impl_geo_scalar!(MultiPointArray<2>, geo::MultiPolygon); +iter_geo_impl_geo_scalar!(MultiPointArray, geo::Point); +iter_geo_impl_geo_scalar!(MultiPointArray, geo::LineString); +iter_geo_impl_geo_scalar!(MultiPointArray, geo::Polygon); +iter_geo_impl_geo_scalar!(MultiPointArray, geo::MultiPoint); +iter_geo_impl_geo_scalar!(MultiPointArray, geo::MultiLineString); +iter_geo_impl_geo_scalar!(MultiPointArray, geo::MultiPolygon); // Implementations on MultiLineStringArray -iter_geo_impl_geo_scalar!(MultiLineStringArray<2>, geo::Point); -iter_geo_impl_geo_scalar!(MultiLineStringArray<2>, geo::LineString); -iter_geo_impl_geo_scalar!(MultiLineStringArray<2>, geo::Polygon); -iter_geo_impl_geo_scalar!(MultiLineStringArray<2>, geo::MultiPoint); -iter_geo_impl_geo_scalar!(MultiLineStringArray<2>, geo::MultiLineString); -iter_geo_impl_geo_scalar!(MultiLineStringArray<2>, geo::MultiPolygon); +iter_geo_impl_geo_scalar!(MultiLineStringArray, geo::Point); +iter_geo_impl_geo_scalar!(MultiLineStringArray, geo::LineString); +iter_geo_impl_geo_scalar!(MultiLineStringArray, geo::Polygon); +iter_geo_impl_geo_scalar!(MultiLineStringArray, geo::MultiPoint); +iter_geo_impl_geo_scalar!(MultiLineStringArray, geo::MultiLineString); +iter_geo_impl_geo_scalar!(MultiLineStringArray, geo::MultiPolygon); // Implementations on MultiPolygonArray -iter_geo_impl_geo_scalar!(MultiPolygonArray<2>, geo::Point); -iter_geo_impl_geo_scalar!(MultiPolygonArray<2>, geo::LineString); -iter_geo_impl_geo_scalar!(MultiPolygonArray<2>, geo::Polygon); -iter_geo_impl_geo_scalar!(MultiPolygonArray<2>, geo::MultiPoint); -iter_geo_impl_geo_scalar!(MultiPolygonArray<2>, geo::MultiLineString); -iter_geo_impl_geo_scalar!(MultiPolygonArray<2>, geo::MultiPolygon); +iter_geo_impl_geo_scalar!(MultiPolygonArray, geo::Point); +iter_geo_impl_geo_scalar!(MultiPolygonArray, geo::LineString); +iter_geo_impl_geo_scalar!(MultiPolygonArray, geo::Polygon); +iter_geo_impl_geo_scalar!(MultiPolygonArray, geo::MultiPoint); +iter_geo_impl_geo_scalar!(MultiPolygonArray, geo::MultiLineString); +iter_geo_impl_geo_scalar!(MultiPolygonArray, geo::MultiPolygon); diff --git a/rust/geoarrow/src/algorithm/geo_index/rtree.rs b/rust/geoarrow/src/algorithm/geo_index/rtree.rs index a9bbac08..9b8a981b 100644 --- a/rust/geoarrow/src/algorithm/geo_index/rtree.rs +++ b/rust/geoarrow/src/algorithm/geo_index/rtree.rs @@ -5,7 +5,7 @@ use crate::algorithm::native::bounding_rect::{ }; use crate::array::*; use crate::chunked_array::*; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::error::Result; use crate::trait_::ArrayAccessor; use crate::NativeArray; @@ -24,7 +24,7 @@ pub trait RTree { macro_rules! impl_rtree { ($struct_name:ty, $bounding_rect_fn:ident) => { - impl RTree for $struct_name { + impl RTree for $struct_name { type Output = OwnedRTree; fn create_rtree_with_node_size(&self, node_size: usize) -> Self::Output { @@ -42,52 +42,38 @@ macro_rules! impl_rtree { }; } -impl_rtree!(PointArray, bounding_rect_point); -impl_rtree!(LineStringArray, bounding_rect_linestring); -impl_rtree!(PolygonArray, bounding_rect_polygon); -impl_rtree!(MultiPointArray, bounding_rect_multipoint); -impl_rtree!(MultiLineStringArray, bounding_rect_multilinestring); -impl_rtree!(MultiPolygonArray, bounding_rect_multipolygon); -impl_rtree!(MixedGeometryArray, bounding_rect_geometry); -impl_rtree!( - GeometryCollectionArray, - bounding_rect_geometry_collection -); -impl_rtree!(RectArray, bounding_rect_rect); +impl_rtree!(PointArray, bounding_rect_point); +impl_rtree!(LineStringArray, bounding_rect_linestring); +impl_rtree!(PolygonArray, bounding_rect_polygon); +impl_rtree!(MultiPointArray, bounding_rect_multipoint); +impl_rtree!(MultiLineStringArray, bounding_rect_multilinestring); +impl_rtree!(MultiPolygonArray, bounding_rect_multipolygon); +impl_rtree!(MixedGeometryArray, bounding_rect_geometry); +impl_rtree!(GeometryCollectionArray, bounding_rect_geometry_collection); +impl_rtree!(RectArray, bounding_rect_rect); impl RTree for &dyn NativeArray { type Output = OwnedRTree; fn create_rtree_with_node_size(&self, node_size: usize) -> Self::Output { - use Dimension::*; use NativeType::*; macro_rules! impl_method { - ($method:ident, $dim:expr) => { - self.$method::<$dim>() - .create_rtree_with_node_size(node_size) + ($method:ident) => { + self.$method().create_rtree_with_node_size(node_size) }; } match self.data_type() { - Point(_, XY) => impl_method!(as_point, 2), - LineString(_, XY) => impl_method!(as_line_string, 2), - Polygon(_, XY) => impl_method!(as_polygon, 2), - MultiPoint(_, XY) => impl_method!(as_multi_point, 2), - MultiLineString(_, XY) => impl_method!(as_multi_line_string, 2), - MultiPolygon(_, XY) => impl_method!(as_multi_polygon, 2), - Mixed(_, XY) => impl_method!(as_mixed, 2), - GeometryCollection(_, XY) => impl_method!(as_geometry_collection, 2), - Rect(XY) => impl_method!(as_rect, 2), - Point(_, XYZ) => impl_method!(as_point, 3), - LineString(_, XYZ) => impl_method!(as_line_string, 3), - Polygon(_, XYZ) => impl_method!(as_polygon, 3), - MultiPoint(_, XYZ) => impl_method!(as_multi_point, 3), - MultiLineString(_, XYZ) => impl_method!(as_multi_line_string, 3), - MultiPolygon(_, XYZ) => impl_method!(as_multi_polygon, 3), - Mixed(_, XYZ) => impl_method!(as_mixed, 3), - GeometryCollection(_, XYZ) => impl_method!(as_geometry_collection, 3), - Rect(XYZ) => impl_method!(as_rect, 3), + Point(_, _) => impl_method!(as_point), + LineString(_, _) => impl_method!(as_line_string), + Polygon(_, _) => impl_method!(as_polygon), + MultiPoint(_, _) => impl_method!(as_multi_point), + MultiLineString(_, _) => impl_method!(as_multi_line_string), + MultiPolygon(_, _) => impl_method!(as_multi_polygon), + Mixed(_, _) => impl_method!(as_mixed), + GeometryCollection(_, _) => impl_method!(as_geometry_collection), + Rect(_) => impl_method!(as_rect), } } } @@ -104,35 +90,24 @@ impl RTree for &dyn ChunkedNativeArray { type Output = Result>>; fn create_rtree_with_node_size(&self, node_size: usize) -> Self::Output { - use Dimension::*; use NativeType::*; macro_rules! impl_method { - ($method:ident, $dim:expr) => { - self.$method::<$dim>() - .create_rtree_with_node_size(node_size) + ($method:ident) => { + self.$method().create_rtree_with_node_size(node_size) }; } let result = match self.data_type() { - Point(_, XY) => impl_method!(as_point, 2), - LineString(_, XY) => impl_method!(as_line_string, 2), - Polygon(_, XY) => impl_method!(as_polygon, 2), - MultiPoint(_, XY) => impl_method!(as_multi_point, 2), - MultiLineString(_, XY) => impl_method!(as_multi_line_string, 2), - MultiPolygon(_, XY) => impl_method!(as_multi_polygon, 2), - Mixed(_, XY) => impl_method!(as_mixed, 2), - GeometryCollection(_, XY) => impl_method!(as_geometry_collection, 2), - Rect(XY) => impl_method!(as_rect, 2), - Point(_, XYZ) => impl_method!(as_point, 3), - LineString(_, XYZ) => impl_method!(as_line_string, 3), - Polygon(_, XYZ) => impl_method!(as_polygon, 3), - MultiPoint(_, XYZ) => impl_method!(as_multi_point, 3), - MultiLineString(_, XYZ) => impl_method!(as_multi_line_string, 3), - MultiPolygon(_, XYZ) => impl_method!(as_multi_polygon, 3), - Mixed(_, XYZ) => impl_method!(as_mixed, 3), - GeometryCollection(_, XYZ) => impl_method!(as_geometry_collection, 3), - Rect(XYZ) => impl_method!(as_rect, 3), + Point(_, _) => impl_method!(as_point), + LineString(_, _) => impl_method!(as_line_string), + Polygon(_, _) => impl_method!(as_polygon), + MultiPoint(_, _) => impl_method!(as_multi_point), + MultiLineString(_, _) => impl_method!(as_multi_line_string), + MultiPolygon(_, _) => impl_method!(as_multi_polygon), + Mixed(_, _) => impl_method!(as_mixed), + GeometryCollection(_, _) => impl_method!(as_geometry_collection), + Rect(_) => impl_method!(as_rect), }; Ok(result) } diff --git a/rust/geoarrow/src/algorithm/geos/area.rs b/rust/geoarrow/src/algorithm/geos/area.rs index e942d3ab..ce9c6a67 100644 --- a/rust/geoarrow/src/algorithm/geos/area.rs +++ b/rust/geoarrow/src/algorithm/geos/area.rs @@ -2,7 +2,7 @@ use crate::algorithm::geo::utils::zeroes; use crate::algorithm::native::Unary; use crate::array::*; use crate::chunked_array::{ChunkedArray, ChunkedGeometryArray}; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::error::Result; use crate::trait_::NativeScalar; use crate::NativeArray; @@ -19,7 +19,7 @@ pub trait Area { /// Implementation where the result is zero. macro_rules! zero_impl { ($type:ty) => { - impl Area for $type { + impl Area for $type { type Output = Result; fn area(&self) -> Self::Output { @@ -29,14 +29,14 @@ macro_rules! zero_impl { }; } -zero_impl!(PointArray); -zero_impl!(LineStringArray); -zero_impl!(MultiPointArray); -zero_impl!(MultiLineStringArray); +zero_impl!(PointArray); +zero_impl!(LineStringArray); +zero_impl!(MultiPointArray); +zero_impl!(MultiLineStringArray); macro_rules! iter_geos_impl { ($type:ty) => { - impl Area for $type { + impl Area for $type { type Output = Result; fn area(&self) -> Self::Output { @@ -46,38 +46,28 @@ macro_rules! iter_geos_impl { }; } -iter_geos_impl!(PolygonArray); -iter_geos_impl!(MultiPolygonArray); -iter_geos_impl!(MixedGeometryArray); -iter_geos_impl!(GeometryCollectionArray); -iter_geos_impl!(RectArray); +iter_geos_impl!(PolygonArray); +iter_geos_impl!(MultiPolygonArray); +iter_geos_impl!(MixedGeometryArray); +iter_geos_impl!(GeometryCollectionArray); +iter_geos_impl!(RectArray); impl Area for &dyn NativeArray { type Output = Result; fn area(&self) -> Self::Output { - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().area(), - LineString(_, XY) => self.as_line_string::<2>().area(), - Polygon(_, XY) => self.as_polygon::<2>().area(), - MultiPoint(_, XY) => self.as_multi_point::<2>().area(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().area(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().area(), - Mixed(_, XY) => self.as_mixed::<2>().area(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().area(), - Rect(XY) => self.as_rect::<2>().area(), - Point(_, XYZ) => self.as_point::<3>().area(), - LineString(_, XYZ) => self.as_line_string::<3>().area(), - Polygon(_, XYZ) => self.as_polygon::<3>().area(), - MultiPoint(_, XYZ) => self.as_multi_point::<3>().area(), - MultiLineString(_, XYZ) => self.as_multi_line_string::<3>().area(), - MultiPolygon(_, XYZ) => self.as_multi_polygon::<3>().area(), - Mixed(_, XYZ) => self.as_mixed::<3>().area(), - GeometryCollection(_, XYZ) => self.as_geometry_collection::<3>().area(), - Rect(XYZ) => self.as_rect::<3>().area(), + Point(_, _) => self.as_point().area(), + LineString(_, _) => self.as_line_string().area(), + Polygon(_, _) => self.as_polygon().area(), + MultiPoint(_, _) => self.as_multi_point().area(), + MultiLineString(_, _) => self.as_multi_line_string().area(), + MultiPolygon(_, _) => self.as_multi_polygon().area(), + Mixed(_, _) => self.as_mixed().area(), + GeometryCollection(_, _) => self.as_geometry_collection().area(), + Rect(_) => self.as_rect().area(), } } } diff --git a/rust/geoarrow/src/algorithm/geos/buffer.rs b/rust/geoarrow/src/algorithm/geos/buffer.rs index 4678d587..32829a9c 100644 --- a/rust/geoarrow/src/algorithm/geos/buffer.rs +++ b/rust/geoarrow/src/algorithm/geos/buffer.rs @@ -11,8 +11,8 @@ pub trait Buffer { fn buffer_with_params(&self, width: f64, buffer_params: &BufferParams) -> Self::Output; } -impl Buffer for PointArray { - type Output = Result>; +impl Buffer for PointArray { + type Output = Result; fn buffer(&self, width: f64, quadsegs: i32) -> Self::Output { try_unary_polygon(self, |g| g.buffer(width, quadsegs)) @@ -31,7 +31,7 @@ mod test { #[test] fn point_buffer() { let arr = point_array(); - let buffered: PolygonArray<2> = arr.buffer(1., 8).unwrap(); + let buffered: PolygonArray = arr.buffer(1., 8).unwrap(); dbg!(buffered); } } diff --git a/rust/geoarrow/src/algorithm/geos/is_empty.rs b/rust/geoarrow/src/algorithm/geos/is_empty.rs index 6d737bcb..ef815ed9 100644 --- a/rust/geoarrow/src/algorithm/geos/is_empty.rs +++ b/rust/geoarrow/src/algorithm/geos/is_empty.rs @@ -1,7 +1,7 @@ use crate::algorithm::native::Unary; use crate::array::*; use crate::chunked_array::{ChunkedArray, ChunkedGeometryArray}; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::error::Result; use crate::trait_::NativeScalar; use crate::NativeArray; @@ -17,7 +17,7 @@ pub trait IsEmpty { macro_rules! iter_geos_impl { ($type:ty) => { - impl IsEmpty for $type { + impl IsEmpty for $type { type Output = Result; fn is_empty(&self) -> Self::Output { @@ -27,42 +27,32 @@ macro_rules! iter_geos_impl { }; } -iter_geos_impl!(PointArray); -iter_geos_impl!(LineStringArray); -iter_geos_impl!(MultiPointArray); -iter_geos_impl!(MultiLineStringArray); -iter_geos_impl!(PolygonArray); -iter_geos_impl!(MultiPolygonArray); -iter_geos_impl!(MixedGeometryArray); -iter_geos_impl!(GeometryCollectionArray); -iter_geos_impl!(RectArray); +iter_geos_impl!(PointArray); +iter_geos_impl!(LineStringArray); +iter_geos_impl!(MultiPointArray); +iter_geos_impl!(MultiLineStringArray); +iter_geos_impl!(PolygonArray); +iter_geos_impl!(MultiPolygonArray); +iter_geos_impl!(MixedGeometryArray); +iter_geos_impl!(GeometryCollectionArray); +iter_geos_impl!(RectArray); impl IsEmpty for &dyn NativeArray { type Output = Result; fn is_empty(&self) -> Self::Output { - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => IsEmpty::is_empty(self.as_point::<2>()), - LineString(_, XY) => IsEmpty::is_empty(self.as_line_string::<2>()), - Polygon(_, XY) => IsEmpty::is_empty(self.as_polygon::<2>()), - MultiPoint(_, XY) => IsEmpty::is_empty(self.as_multi_point::<2>()), - MultiLineString(_, XY) => IsEmpty::is_empty(self.as_multi_line_string::<2>()), - MultiPolygon(_, XY) => IsEmpty::is_empty(self.as_multi_polygon::<2>()), - Mixed(_, XY) => IsEmpty::is_empty(self.as_mixed::<2>()), - GeometryCollection(_, XY) => IsEmpty::is_empty(self.as_geometry_collection::<2>()), - Rect(XY) => IsEmpty::is_empty(self.as_rect::<2>()), - Point(_, XYZ) => IsEmpty::is_empty(self.as_point::<3>()), - LineString(_, XYZ) => IsEmpty::is_empty(self.as_line_string::<3>()), - Polygon(_, XYZ) => IsEmpty::is_empty(self.as_polygon::<3>()), - MultiPoint(_, XYZ) => IsEmpty::is_empty(self.as_multi_point::<3>()), - MultiLineString(_, XYZ) => IsEmpty::is_empty(self.as_multi_line_string::<3>()), - MultiPolygon(_, XYZ) => IsEmpty::is_empty(self.as_multi_polygon::<3>()), - Mixed(_, XYZ) => IsEmpty::is_empty(self.as_mixed::<3>()), - GeometryCollection(_, XYZ) => IsEmpty::is_empty(self.as_geometry_collection::<3>()), - Rect(XYZ) => IsEmpty::is_empty(self.as_rect::<3>()), + Point(_, _) => IsEmpty::is_empty(self.as_point()), + LineString(_, _) => IsEmpty::is_empty(self.as_line_string()), + Polygon(_, _) => IsEmpty::is_empty(self.as_polygon()), + MultiPoint(_, _) => IsEmpty::is_empty(self.as_multi_point()), + MultiLineString(_, _) => IsEmpty::is_empty(self.as_multi_line_string()), + MultiPolygon(_, _) => IsEmpty::is_empty(self.as_multi_polygon()), + Mixed(_, _) => IsEmpty::is_empty(self.as_mixed()), + GeometryCollection(_, _) => IsEmpty::is_empty(self.as_geometry_collection()), + Rect(_) => IsEmpty::is_empty(self.as_rect()), } } } diff --git a/rust/geoarrow/src/algorithm/geos/is_ring.rs b/rust/geoarrow/src/algorithm/geos/is_ring.rs index 54d8a55a..11a3302d 100644 --- a/rust/geoarrow/src/algorithm/geos/is_ring.rs +++ b/rust/geoarrow/src/algorithm/geos/is_ring.rs @@ -1,7 +1,7 @@ use crate::algorithm::native::Unary; use crate::array::*; use crate::chunked_array::{ChunkedArray, ChunkedGeometryArray}; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::error::Result; use crate::trait_::NativeScalar; use crate::NativeArray; @@ -17,7 +17,7 @@ pub trait IsRing { macro_rules! iter_geos_impl { ($type:ty) => { - impl IsRing for $type { + impl IsRing for $type { type Output = Result; fn is_ring(&self) -> Self::Output { @@ -27,42 +27,32 @@ macro_rules! iter_geos_impl { }; } -iter_geos_impl!(PointArray); -iter_geos_impl!(LineStringArray); -iter_geos_impl!(MultiPointArray); -iter_geos_impl!(MultiLineStringArray); -iter_geos_impl!(PolygonArray); -iter_geos_impl!(MultiPolygonArray); -iter_geos_impl!(MixedGeometryArray); -iter_geos_impl!(GeometryCollectionArray); -iter_geos_impl!(RectArray); +iter_geos_impl!(PointArray); +iter_geos_impl!(LineStringArray); +iter_geos_impl!(MultiPointArray); +iter_geos_impl!(MultiLineStringArray); +iter_geos_impl!(PolygonArray); +iter_geos_impl!(MultiPolygonArray); +iter_geos_impl!(MixedGeometryArray); +iter_geos_impl!(GeometryCollectionArray); +iter_geos_impl!(RectArray); impl IsRing for &dyn NativeArray { type Output = Result; fn is_ring(&self) -> Self::Output { - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().is_ring(), - LineString(_, XY) => self.as_line_string::<2>().is_ring(), - Polygon(_, XY) => self.as_polygon::<2>().is_ring(), - MultiPoint(_, XY) => self.as_multi_point::<2>().is_ring(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().is_ring(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().is_ring(), - Mixed(_, XY) => self.as_mixed::<2>().is_ring(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().is_ring(), - Rect(XY) => self.as_rect::<2>().is_ring(), - Point(_, XYZ) => self.as_point::<3>().is_ring(), - LineString(_, XYZ) => self.as_line_string::<3>().is_ring(), - Polygon(_, XYZ) => self.as_polygon::<3>().is_ring(), - MultiPoint(_, XYZ) => self.as_multi_point::<3>().is_ring(), - MultiLineString(_, XYZ) => self.as_multi_line_string::<3>().is_ring(), - MultiPolygon(_, XYZ) => self.as_multi_polygon::<3>().is_ring(), - Mixed(_, XYZ) => self.as_mixed::<3>().is_ring(), - GeometryCollection(_, XYZ) => self.as_geometry_collection::<3>().is_ring(), - Rect(XYZ) => self.as_rect::<3>().is_ring(), + Point(_, _) => self.as_point().is_ring(), + LineString(_, _) => self.as_line_string().is_ring(), + Polygon(_, _) => self.as_polygon().is_ring(), + MultiPoint(_, _) => self.as_multi_point().is_ring(), + MultiLineString(_, _) => self.as_multi_line_string().is_ring(), + MultiPolygon(_, _) => self.as_multi_polygon().is_ring(), + Mixed(_, _) => self.as_mixed().is_ring(), + GeometryCollection(_, _) => self.as_geometry_collection().is_ring(), + Rect(_) => self.as_rect().is_ring(), } } } diff --git a/rust/geoarrow/src/algorithm/geos/is_simple.rs b/rust/geoarrow/src/algorithm/geos/is_simple.rs index a923b311..f2cd65f6 100644 --- a/rust/geoarrow/src/algorithm/geos/is_simple.rs +++ b/rust/geoarrow/src/algorithm/geos/is_simple.rs @@ -1,7 +1,7 @@ use crate::algorithm::native::Unary; use crate::array::*; use crate::chunked_array::{ChunkedArray, ChunkedGeometryArray}; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::error::Result; use crate::trait_::NativeScalar; use crate::NativeArray; @@ -17,7 +17,7 @@ pub trait IsSimple { macro_rules! iter_geos_impl { ($type:ty) => { - impl IsSimple for $type { + impl IsSimple for $type { type Output = Result; fn is_simple(&self) -> Self::Output { @@ -27,42 +27,32 @@ macro_rules! iter_geos_impl { }; } -iter_geos_impl!(PointArray); -iter_geos_impl!(LineStringArray); -iter_geos_impl!(MultiPointArray); -iter_geos_impl!(MultiLineStringArray); -iter_geos_impl!(PolygonArray); -iter_geos_impl!(MultiPolygonArray); -iter_geos_impl!(MixedGeometryArray); -iter_geos_impl!(GeometryCollectionArray); -iter_geos_impl!(RectArray); +iter_geos_impl!(PointArray); +iter_geos_impl!(LineStringArray); +iter_geos_impl!(MultiPointArray); +iter_geos_impl!(MultiLineStringArray); +iter_geos_impl!(PolygonArray); +iter_geos_impl!(MultiPolygonArray); +iter_geos_impl!(MixedGeometryArray); +iter_geos_impl!(GeometryCollectionArray); +iter_geos_impl!(RectArray); impl IsSimple for &dyn NativeArray { type Output = Result; fn is_simple(&self) -> Self::Output { - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().is_simple(), - LineString(_, XY) => self.as_line_string::<2>().is_simple(), - Polygon(_, XY) => self.as_polygon::<2>().is_simple(), - MultiPoint(_, XY) => self.as_multi_point::<2>().is_simple(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().is_simple(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().is_simple(), - Mixed(_, XY) => self.as_mixed::<2>().is_simple(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().is_simple(), - Rect(XY) => self.as_rect::<2>().is_simple(), - Point(_, XYZ) => self.as_point::<3>().is_simple(), - LineString(_, XYZ) => self.as_line_string::<3>().is_simple(), - Polygon(_, XYZ) => self.as_polygon::<3>().is_simple(), - MultiPoint(_, XYZ) => self.as_multi_point::<3>().is_simple(), - MultiLineString(_, XYZ) => self.as_multi_line_string::<3>().is_simple(), - MultiPolygon(_, XYZ) => self.as_multi_polygon::<3>().is_simple(), - Mixed(_, XYZ) => self.as_mixed::<3>().is_simple(), - GeometryCollection(_, XYZ) => self.as_geometry_collection::<3>().is_simple(), - Rect(XYZ) => self.as_rect::<3>().is_simple(), + Point(_, _) => self.as_point().is_simple(), + LineString(_, _) => self.as_line_string().is_simple(), + Polygon(_, _) => self.as_polygon().is_simple(), + MultiPoint(_, _) => self.as_multi_point().is_simple(), + MultiLineString(_, _) => self.as_multi_line_string().is_simple(), + MultiPolygon(_, _) => self.as_multi_polygon().is_simple(), + Mixed(_, _) => self.as_mixed().is_simple(), + GeometryCollection(_, _) => self.as_geometry_collection().is_simple(), + Rect(_) => self.as_rect().is_simple(), } } } diff --git a/rust/geoarrow/src/algorithm/geos/is_valid.rs b/rust/geoarrow/src/algorithm/geos/is_valid.rs index a42d474d..f678e9c6 100644 --- a/rust/geoarrow/src/algorithm/geos/is_valid.rs +++ b/rust/geoarrow/src/algorithm/geos/is_valid.rs @@ -1,7 +1,7 @@ use crate::algorithm::native::Unary; use crate::array::*; use crate::chunked_array::{ChunkedArray, ChunkedGeometryArray}; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::error::Result; use crate::trait_::NativeScalar; use crate::NativeArray; @@ -17,7 +17,7 @@ pub trait IsValid { macro_rules! iter_geos_impl { ($type:ty) => { - impl IsValid for $type { + impl IsValid for $type { type Output = Result; fn is_valid(&self) -> Self::Output { @@ -28,42 +28,32 @@ macro_rules! iter_geos_impl { }; } -iter_geos_impl!(PointArray); -iter_geos_impl!(LineStringArray); -iter_geos_impl!(MultiPointArray); -iter_geos_impl!(MultiLineStringArray); -iter_geos_impl!(PolygonArray); -iter_geos_impl!(MultiPolygonArray); -iter_geos_impl!(MixedGeometryArray); -iter_geos_impl!(GeometryCollectionArray); -iter_geos_impl!(RectArray); +iter_geos_impl!(PointArray); +iter_geos_impl!(LineStringArray); +iter_geos_impl!(MultiPointArray); +iter_geos_impl!(MultiLineStringArray); +iter_geos_impl!(PolygonArray); +iter_geos_impl!(MultiPolygonArray); +iter_geos_impl!(MixedGeometryArray); +iter_geos_impl!(GeometryCollectionArray); +iter_geos_impl!(RectArray); impl IsValid for &dyn NativeArray { type Output = Result; fn is_valid(&self) -> Self::Output { - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => IsValid::is_valid(self.as_point::<2>()), - LineString(_, XY) => IsValid::is_valid(self.as_line_string::<2>()), - Polygon(_, XY) => IsValid::is_valid(self.as_polygon::<2>()), - MultiPoint(_, XY) => IsValid::is_valid(self.as_multi_point::<2>()), - MultiLineString(_, XY) => IsValid::is_valid(self.as_multi_line_string::<2>()), - MultiPolygon(_, XY) => IsValid::is_valid(self.as_multi_polygon::<2>()), - Mixed(_, XY) => IsValid::is_valid(self.as_mixed::<2>()), - GeometryCollection(_, XY) => IsValid::is_valid(self.as_geometry_collection::<2>()), - Rect(XY) => IsValid::is_valid(self.as_rect::<2>()), - Point(_, XYZ) => IsValid::is_valid(self.as_point::<3>()), - LineString(_, XYZ) => IsValid::is_valid(self.as_line_string::<3>()), - Polygon(_, XYZ) => IsValid::is_valid(self.as_polygon::<3>()), - MultiPoint(_, XYZ) => IsValid::is_valid(self.as_multi_point::<3>()), - MultiLineString(_, XYZ) => IsValid::is_valid(self.as_multi_line_string::<3>()), - MultiPolygon(_, XYZ) => IsValid::is_valid(self.as_multi_polygon::<3>()), - Mixed(_, XYZ) => IsValid::is_valid(self.as_mixed::<3>()), - GeometryCollection(_, XYZ) => IsValid::is_valid(self.as_geometry_collection::<3>()), - Rect(XYZ) => IsValid::is_valid(self.as_rect::<3>()), + Point(_, _) => IsValid::is_valid(self.as_point()), + LineString(_, _) => IsValid::is_valid(self.as_line_string()), + Polygon(_, _) => IsValid::is_valid(self.as_polygon()), + MultiPoint(_, _) => IsValid::is_valid(self.as_multi_point()), + MultiLineString(_, _) => IsValid::is_valid(self.as_multi_line_string()), + MultiPolygon(_, _) => IsValid::is_valid(self.as_multi_polygon()), + Mixed(_, _) => IsValid::is_valid(self.as_mixed()), + GeometryCollection(_, _) => IsValid::is_valid(self.as_geometry_collection()), + Rect(_) => IsValid::is_valid(self.as_rect()), } } } diff --git a/rust/geoarrow/src/algorithm/geos/length.rs b/rust/geoarrow/src/algorithm/geos/length.rs index dd0e8f61..a53c4a13 100644 --- a/rust/geoarrow/src/algorithm/geos/length.rs +++ b/rust/geoarrow/src/algorithm/geos/length.rs @@ -2,7 +2,7 @@ use crate::algorithm::geo::utils::zeroes; use crate::algorithm::native::Unary; use crate::array::*; use crate::chunked_array::{ChunkedArray, ChunkedGeometryArray}; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::error::Result; use crate::trait_::NativeScalar; use crate::NativeArray; @@ -16,7 +16,7 @@ pub trait Length { fn length(&self) -> Self::Output; } -impl Length for PointArray { +impl Length for PointArray { type Output = Result; fn length(&self) -> Self::Output { @@ -26,7 +26,7 @@ impl Length for PointArray { macro_rules! iter_geos_impl { ($type:ty) => { - impl Length for $type { + impl Length for $type { type Output = Result; fn length(&self) -> Self::Output { @@ -36,41 +36,31 @@ macro_rules! iter_geos_impl { }; } -iter_geos_impl!(LineStringArray); -iter_geos_impl!(MultiPointArray); -iter_geos_impl!(MultiLineStringArray); -iter_geos_impl!(PolygonArray); -iter_geos_impl!(MultiPolygonArray); -iter_geos_impl!(MixedGeometryArray); -iter_geos_impl!(GeometryCollectionArray); -iter_geos_impl!(RectArray); +iter_geos_impl!(LineStringArray); +iter_geos_impl!(MultiPointArray); +iter_geos_impl!(MultiLineStringArray); +iter_geos_impl!(PolygonArray); +iter_geos_impl!(MultiPolygonArray); +iter_geos_impl!(MixedGeometryArray); +iter_geos_impl!(GeometryCollectionArray); +iter_geos_impl!(RectArray); impl Length for &dyn NativeArray { type Output = Result; fn length(&self) -> Self::Output { - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().length(), - LineString(_, XY) => self.as_line_string::<2>().length(), - Polygon(_, XY) => self.as_polygon::<2>().length(), - MultiPoint(_, XY) => self.as_multi_point::<2>().length(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().length(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().length(), - Mixed(_, XY) => self.as_mixed::<2>().length(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().length(), - Rect(XY) => self.as_rect::<2>().length(), - Point(_, XYZ) => self.as_point::<3>().length(), - LineString(_, XYZ) => self.as_line_string::<3>().length(), - Polygon(_, XYZ) => self.as_polygon::<3>().length(), - MultiPoint(_, XYZ) => self.as_multi_point::<3>().length(), - MultiLineString(_, XYZ) => self.as_multi_line_string::<3>().length(), - MultiPolygon(_, XYZ) => self.as_multi_polygon::<3>().length(), - Mixed(_, XYZ) => self.as_mixed::<3>().length(), - GeometryCollection(_, XYZ) => self.as_geometry_collection::<3>().length(), - Rect(XYZ) => self.as_rect::<3>().length(), + Point(_, _) => self.as_point().length(), + LineString(_, _) => self.as_line_string().length(), + Polygon(_, _) => self.as_polygon().length(), + MultiPoint(_, _) => self.as_multi_point().length(), + MultiLineString(_, _) => self.as_multi_line_string().length(), + MultiPolygon(_, _) => self.as_multi_polygon().length(), + Mixed(_, _) => self.as_mixed().length(), + GeometryCollection(_, _) => self.as_geometry_collection().length(), + Rect(_) => self.as_rect().length(), } } } diff --git a/rust/geoarrow/src/algorithm/geos/util.rs b/rust/geoarrow/src/algorithm/geos/util.rs index 6776408d..3c56d11a 100644 --- a/rust/geoarrow/src/algorithm/geos/util.rs +++ b/rust/geoarrow/src/algorithm/geos/util.rs @@ -39,10 +39,10 @@ where Ok(PrimitiveArray::new(values, nulls)) } -pub(super) fn try_unary_polygon<'a, const D: usize, F>( +pub(super) fn try_unary_polygon<'a, F>( array: &'a dyn NativeGEOSGeometryAccessor<'a>, op: F, -) -> std::result::Result, GeoArrowError> +) -> std::result::Result where F: Fn(geos::Geometry) -> std::result::Result, { diff --git a/rust/geoarrow/src/algorithm/native/binary.rs b/rust/geoarrow/src/algorithm/native/binary.rs index 53c44607..55490c8b 100644 --- a/rust/geoarrow/src/algorithm/native/binary.rs +++ b/rust/geoarrow/src/algorithm/native/binary.rs @@ -118,90 +118,90 @@ pub trait Binary<'a, Rhs: ArrayAccessor<'a> = Self>: ArrayAccessor<'a> { } } -// Implementations on PointArray<2> -impl<'a> Binary<'a, PointArray<2>> for PointArray<2> {} -impl<'a> Binary<'a, PointArray<2>> for RectArray<2> {} -impl<'a> Binary<'a, PointArray<2>> for LineStringArray<2> {} -impl<'a> Binary<'a, PointArray<2>> for PolygonArray<2> {} -impl<'a> Binary<'a, PointArray<2>> for MultiPointArray<2> {} -impl<'a> Binary<'a, PointArray<2>> for MultiLineStringArray<2> {} -impl<'a> Binary<'a, PointArray<2>> for MultiPolygonArray<2> {} -impl<'a> Binary<'a, PointArray<2>> for MixedGeometryArray<2> {} -impl<'a> Binary<'a, PointArray<2>> for GeometryCollectionArray<2> {} +// Implementations on PointArray +impl<'a> Binary<'a, PointArray> for PointArray {} +impl<'a> Binary<'a, PointArray> for RectArray {} +impl<'a> Binary<'a, PointArray> for LineStringArray {} +impl<'a> Binary<'a, PointArray> for PolygonArray {} +impl<'a> Binary<'a, PointArray> for MultiPointArray {} +impl<'a> Binary<'a, PointArray> for MultiLineStringArray {} +impl<'a> Binary<'a, PointArray> for MultiPolygonArray {} +impl<'a> Binary<'a, PointArray> for MixedGeometryArray {} +impl<'a> Binary<'a, PointArray> for GeometryCollectionArray {} // Implementations on LineStringArray -impl<'a> Binary<'a, LineStringArray<2>> for PointArray<2> {} -impl<'a> Binary<'a, LineStringArray<2>> for RectArray<2> {} -impl<'a> Binary<'a, LineStringArray<2>> for LineStringArray<2> {} -impl<'a> Binary<'a, LineStringArray<2>> for PolygonArray<2> {} -impl<'a> Binary<'a, LineStringArray<2>> for MultiPointArray<2> {} -impl<'a> Binary<'a, LineStringArray<2>> for MultiLineStringArray<2> {} -impl<'a> Binary<'a, LineStringArray<2>> for MultiPolygonArray<2> {} -impl<'a> Binary<'a, LineStringArray<2>> for MixedGeometryArray<2> {} -impl<'a> Binary<'a, LineStringArray<2>> for GeometryCollectionArray<2> {} +impl<'a> Binary<'a, LineStringArray> for PointArray {} +impl<'a> Binary<'a, LineStringArray> for RectArray {} +impl<'a> Binary<'a, LineStringArray> for LineStringArray {} +impl<'a> Binary<'a, LineStringArray> for PolygonArray {} +impl<'a> Binary<'a, LineStringArray> for MultiPointArray {} +impl<'a> Binary<'a, LineStringArray> for MultiLineStringArray {} +impl<'a> Binary<'a, LineStringArray> for MultiPolygonArray {} +impl<'a> Binary<'a, LineStringArray> for MixedGeometryArray {} +impl<'a> Binary<'a, LineStringArray> for GeometryCollectionArray {} // Implementations on PolygonArray -impl<'a> Binary<'a, PolygonArray<2>> for PointArray<2> {} -impl<'a> Binary<'a, PolygonArray<2>> for RectArray<2> {} -impl<'a> Binary<'a, PolygonArray<2>> for LineStringArray<2> {} -impl<'a> Binary<'a, PolygonArray<2>> for PolygonArray<2> {} -impl<'a> Binary<'a, PolygonArray<2>> for MultiPointArray<2> {} -impl<'a> Binary<'a, PolygonArray<2>> for MultiLineStringArray<2> {} -impl<'a> Binary<'a, PolygonArray<2>> for MultiPolygonArray<2> {} -impl<'a> Binary<'a, PolygonArray<2>> for MixedGeometryArray<2> {} -impl<'a> Binary<'a, PolygonArray<2>> for GeometryCollectionArray<2> {} +impl<'a> Binary<'a, PolygonArray> for PointArray {} +impl<'a> Binary<'a, PolygonArray> for RectArray {} +impl<'a> Binary<'a, PolygonArray> for LineStringArray {} +impl<'a> Binary<'a, PolygonArray> for PolygonArray {} +impl<'a> Binary<'a, PolygonArray> for MultiPointArray {} +impl<'a> Binary<'a, PolygonArray> for MultiLineStringArray {} +impl<'a> Binary<'a, PolygonArray> for MultiPolygonArray {} +impl<'a> Binary<'a, PolygonArray> for MixedGeometryArray {} +impl<'a> Binary<'a, PolygonArray> for GeometryCollectionArray {} // Implementations on MultiPointArray -impl<'a> Binary<'a, MultiPointArray<2>> for PointArray<2> {} -impl<'a> Binary<'a, MultiPointArray<2>> for RectArray<2> {} -impl<'a> Binary<'a, MultiPointArray<2>> for LineStringArray<2> {} -impl<'a> Binary<'a, MultiPointArray<2>> for PolygonArray<2> {} -impl<'a> Binary<'a, MultiPointArray<2>> for MultiPointArray<2> {} -impl<'a> Binary<'a, MultiPointArray<2>> for MultiLineStringArray<2> {} -impl<'a> Binary<'a, MultiPointArray<2>> for MultiPolygonArray<2> {} -impl<'a> Binary<'a, MultiPointArray<2>> for MixedGeometryArray<2> {} -impl<'a> Binary<'a, MultiPointArray<2>> for GeometryCollectionArray<2> {} +impl<'a> Binary<'a, MultiPointArray> for PointArray {} +impl<'a> Binary<'a, MultiPointArray> for RectArray {} +impl<'a> Binary<'a, MultiPointArray> for LineStringArray {} +impl<'a> Binary<'a, MultiPointArray> for PolygonArray {} +impl<'a> Binary<'a, MultiPointArray> for MultiPointArray {} +impl<'a> Binary<'a, MultiPointArray> for MultiLineStringArray {} +impl<'a> Binary<'a, MultiPointArray> for MultiPolygonArray {} +impl<'a> Binary<'a, MultiPointArray> for MixedGeometryArray {} +impl<'a> Binary<'a, MultiPointArray> for GeometryCollectionArray {} // Implementations on MultiLineStringArray -impl<'a> Binary<'a, MultiLineStringArray<2>> for PointArray<2> {} -impl<'a> Binary<'a, MultiLineStringArray<2>> for RectArray<2> {} -impl<'a> Binary<'a, MultiLineStringArray<2>> for LineStringArray<2> {} -impl<'a> Binary<'a, MultiLineStringArray<2>> for PolygonArray<2> {} -impl<'a> Binary<'a, MultiLineStringArray<2>> for MultiPointArray<2> {} -impl<'a> Binary<'a, MultiLineStringArray<2>> for MultiLineStringArray<2> {} -impl<'a> Binary<'a, MultiLineStringArray<2>> for MultiPolygonArray<2> {} -impl<'a> Binary<'a, MultiLineStringArray<2>> for MixedGeometryArray<2> {} -impl<'a> Binary<'a, MultiLineStringArray<2>> for GeometryCollectionArray<2> {} +impl<'a> Binary<'a, MultiLineStringArray> for PointArray {} +impl<'a> Binary<'a, MultiLineStringArray> for RectArray {} +impl<'a> Binary<'a, MultiLineStringArray> for LineStringArray {} +impl<'a> Binary<'a, MultiLineStringArray> for PolygonArray {} +impl<'a> Binary<'a, MultiLineStringArray> for MultiPointArray {} +impl<'a> Binary<'a, MultiLineStringArray> for MultiLineStringArray {} +impl<'a> Binary<'a, MultiLineStringArray> for MultiPolygonArray {} +impl<'a> Binary<'a, MultiLineStringArray> for MixedGeometryArray {} +impl<'a> Binary<'a, MultiLineStringArray> for GeometryCollectionArray {} // Implementations on MultiPolygonArray -impl<'a> Binary<'a, MultiPolygonArray<2>> for PointArray<2> {} -impl<'a> Binary<'a, MultiPolygonArray<2>> for RectArray<2> {} -impl<'a> Binary<'a, MultiPolygonArray<2>> for LineStringArray<2> {} -impl<'a> Binary<'a, MultiPolygonArray<2>> for PolygonArray<2> {} -impl<'a> Binary<'a, MultiPolygonArray<2>> for MultiPointArray<2> {} -impl<'a> Binary<'a, MultiPolygonArray<2>> for MultiLineStringArray<2> {} -impl<'a> Binary<'a, MultiPolygonArray<2>> for MultiPolygonArray<2> {} -impl<'a> Binary<'a, MultiPolygonArray<2>> for MixedGeometryArray<2> {} -impl<'a> Binary<'a, MultiPolygonArray<2>> for GeometryCollectionArray<2> {} +impl<'a> Binary<'a, MultiPolygonArray> for PointArray {} +impl<'a> Binary<'a, MultiPolygonArray> for RectArray {} +impl<'a> Binary<'a, MultiPolygonArray> for LineStringArray {} +impl<'a> Binary<'a, MultiPolygonArray> for PolygonArray {} +impl<'a> Binary<'a, MultiPolygonArray> for MultiPointArray {} +impl<'a> Binary<'a, MultiPolygonArray> for MultiLineStringArray {} +impl<'a> Binary<'a, MultiPolygonArray> for MultiPolygonArray {} +impl<'a> Binary<'a, MultiPolygonArray> for MixedGeometryArray {} +impl<'a> Binary<'a, MultiPolygonArray> for GeometryCollectionArray {} // Implementations on MixedGeometryArray -impl<'a> Binary<'a, MixedGeometryArray<2>> for PointArray<2> {} -impl<'a> Binary<'a, MixedGeometryArray<2>> for RectArray<2> {} -impl<'a> Binary<'a, MixedGeometryArray<2>> for LineStringArray<2> {} -impl<'a> Binary<'a, MixedGeometryArray<2>> for PolygonArray<2> {} -impl<'a> Binary<'a, MixedGeometryArray<2>> for MultiPointArray<2> {} -impl<'a> Binary<'a, MixedGeometryArray<2>> for MultiLineStringArray<2> {} -impl<'a> Binary<'a, MixedGeometryArray<2>> for MultiPolygonArray<2> {} -impl<'a> Binary<'a, MixedGeometryArray<2>> for MixedGeometryArray<2> {} -impl<'a> Binary<'a, MixedGeometryArray<2>> for GeometryCollectionArray<2> {} +impl<'a> Binary<'a, MixedGeometryArray> for PointArray {} +impl<'a> Binary<'a, MixedGeometryArray> for RectArray {} +impl<'a> Binary<'a, MixedGeometryArray> for LineStringArray {} +impl<'a> Binary<'a, MixedGeometryArray> for PolygonArray {} +impl<'a> Binary<'a, MixedGeometryArray> for MultiPointArray {} +impl<'a> Binary<'a, MixedGeometryArray> for MultiLineStringArray {} +impl<'a> Binary<'a, MixedGeometryArray> for MultiPolygonArray {} +impl<'a> Binary<'a, MixedGeometryArray> for MixedGeometryArray {} +impl<'a> Binary<'a, MixedGeometryArray> for GeometryCollectionArray {} // Implementations on GeometryCollectionArray -impl<'a> Binary<'a, GeometryCollectionArray<2>> for PointArray<2> {} -impl<'a> Binary<'a, GeometryCollectionArray<2>> for RectArray<2> {} -impl<'a> Binary<'a, GeometryCollectionArray<2>> for LineStringArray<2> {} -impl<'a> Binary<'a, GeometryCollectionArray<2>> for PolygonArray<2> {} -impl<'a> Binary<'a, GeometryCollectionArray<2>> for MultiPointArray<2> {} -impl<'a> Binary<'a, GeometryCollectionArray<2>> for MultiLineStringArray<2> {} -impl<'a> Binary<'a, GeometryCollectionArray<2>> for MultiPolygonArray<2> {} -impl<'a> Binary<'a, GeometryCollectionArray<2>> for MixedGeometryArray<2> {} -impl<'a> Binary<'a, GeometryCollectionArray<2>> for GeometryCollectionArray<2> {} +impl<'a> Binary<'a, GeometryCollectionArray> for PointArray {} +impl<'a> Binary<'a, GeometryCollectionArray> for RectArray {} +impl<'a> Binary<'a, GeometryCollectionArray> for LineStringArray {} +impl<'a> Binary<'a, GeometryCollectionArray> for PolygonArray {} +impl<'a> Binary<'a, GeometryCollectionArray> for MultiPointArray {} +impl<'a> Binary<'a, GeometryCollectionArray> for MultiLineStringArray {} +impl<'a> Binary<'a, GeometryCollectionArray> for MultiPolygonArray {} +impl<'a> Binary<'a, GeometryCollectionArray> for MixedGeometryArray {} +impl<'a> Binary<'a, GeometryCollectionArray> for GeometryCollectionArray {} diff --git a/rust/geoarrow/src/algorithm/native/cast.rs b/rust/geoarrow/src/algorithm/native/cast.rs index d513e110..e005c692 100644 --- a/rust/geoarrow/src/algorithm/native/cast.rs +++ b/rust/geoarrow/src/algorithm/native/cast.rs @@ -54,7 +54,7 @@ pub trait Cast { fn cast(&self, to_type: &NativeType) -> Self::Output; } -impl Cast for PointArray { +impl Cast for PointArray { type Output = Result>; fn cast(&self, to_type: &NativeType) -> Self::Output { @@ -63,9 +63,9 @@ impl Cast for PointArray { let array = self.to_coord_type(to_type.coord_type()); match to_type { Point(_, _) => Ok(Arc::new(array)), - MultiPoint(_, _) => Ok(Arc::new(MultiPointArray::::from(array))), - Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::::from(array))), - GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::::from(array))), + MultiPoint(_, _) => Ok(Arc::new(MultiPointArray::from(array))), + Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::from(array))), + GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::from(array))), dt => Err(GeoArrowError::General(format!( "invalid cast to type {dt:?}" ))), @@ -73,7 +73,7 @@ impl Cast for PointArray { } } -impl Cast for LineStringArray { +impl Cast for LineStringArray { type Output = Result>; fn cast(&self, to_type: &NativeType) -> Self::Output { @@ -83,9 +83,9 @@ impl Cast for LineStringArray { match to_type { LineString(_, _) => Ok(Arc::new(array)), - MultiLineString(_, _) => Ok(Arc::new(MultiLineStringArray::::from(array))), - Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::::from(array))), - GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::::from(array))), + MultiLineString(_, _) => Ok(Arc::new(MultiLineStringArray::from(array))), + Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::from(array))), + GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::from(array))), dt => Err(GeoArrowError::General(format!( "invalid cast to type {dt:?}" ))), @@ -93,7 +93,7 @@ impl Cast for LineStringArray { } } -impl Cast for PolygonArray { +impl Cast for PolygonArray { type Output = Result>; fn cast(&self, to_type: &NativeType) -> Self::Output { @@ -103,9 +103,9 @@ impl Cast for PolygonArray { match to_type { Polygon(_, _) => Ok(Arc::new(array)), - MultiPolygon(_, _) => Ok(Arc::new(MultiPolygonArray::::from(array))), - Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::::from(array))), - GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::::from(array))), + MultiPolygon(_, _) => Ok(Arc::new(MultiPolygonArray::from(array))), + Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::from(array))), + GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::from(array))), dt => Err(GeoArrowError::General(format!( "invalid cast to type {dt:?}" ))), @@ -113,7 +113,7 @@ impl Cast for PolygonArray { } } -impl Cast for MultiPointArray { +impl Cast for MultiPointArray { type Output = Result>; fn cast(&self, to_type: &NativeType) -> Self::Output { @@ -122,10 +122,10 @@ impl Cast for MultiPointArray { let array = self.to_coord_type(to_type.coord_type()); match to_type { - Point(_, _) => Ok(Arc::new(PointArray::::try_from(array)?)), + Point(_, _) => Ok(Arc::new(PointArray::try_from(array)?)), MultiPoint(_, _) => Ok(Arc::new(array)), - Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::::from(array))), - GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::::from(array))), + Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::from(array))), + GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::from(array))), dt => Err(GeoArrowError::General(format!( "invalid cast to type {dt:?}" ))), @@ -133,7 +133,7 @@ impl Cast for MultiPointArray { } } -impl Cast for MultiLineStringArray { +impl Cast for MultiLineStringArray { type Output = Result>; fn cast(&self, to_type: &NativeType) -> Self::Output { @@ -142,9 +142,9 @@ impl Cast for MultiLineStringArray { let array = self.to_coord_type(to_type.coord_type()); match to_type { - LineString(_, _) => Ok(Arc::new(LineStringArray::::try_from(array)?)), - Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::::from(array))), - GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::::from(array))), + LineString(_, _) => Ok(Arc::new(LineStringArray::try_from(array)?)), + Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::from(array))), + GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::from(array))), dt => Err(GeoArrowError::General(format!( "invalid cast to type {dt:?}" ))), @@ -152,7 +152,7 @@ impl Cast for MultiLineStringArray { } } -impl Cast for MultiPolygonArray { +impl Cast for MultiPolygonArray { type Output = Result>; fn cast(&self, to_type: &NativeType) -> Self::Output { @@ -161,9 +161,9 @@ impl Cast for MultiPolygonArray { let array = self.to_coord_type(to_type.coord_type()); match to_type { - Polygon(_, _) => Ok(Arc::new(PolygonArray::::try_from(array)?)), - Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::::from(array))), - GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::::from(array))), + Polygon(_, _) => Ok(Arc::new(PolygonArray::try_from(array)?)), + Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::from(array))), + GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::from(array))), dt => Err(GeoArrowError::General(format!( "invalid cast to type {dt:?}" ))), @@ -171,7 +171,7 @@ impl Cast for MultiPolygonArray { } } -impl Cast for MixedGeometryArray { +impl Cast for MixedGeometryArray { type Output = Result>; fn cast(&self, to_type: &NativeType) -> Self::Output { @@ -181,13 +181,13 @@ impl Cast for MixedGeometryArray { match to_type { Point(_, _) => Ok(Arc::new(PointArray::try_from(array)?)), - LineString(_, _) => Ok(Arc::new(LineStringArray::::try_from(array)?)), - Polygon(_, _) => Ok(Arc::new(PolygonArray::::try_from(array)?)), - MultiPoint(_, _) => Ok(Arc::new(MultiPointArray::::try_from(array)?)), - MultiLineString(_, _) => Ok(Arc::new(MultiLineStringArray::::try_from(array)?)), - MultiPolygon(_, _) => Ok(Arc::new(MultiPolygonArray::::try_from(array)?)), + LineString(_, _) => Ok(Arc::new(LineStringArray::try_from(array)?)), + Polygon(_, _) => Ok(Arc::new(PolygonArray::try_from(array)?)), + MultiPoint(_, _) => Ok(Arc::new(MultiPointArray::try_from(array)?)), + MultiLineString(_, _) => Ok(Arc::new(MultiLineStringArray::try_from(array)?)), + MultiPolygon(_, _) => Ok(Arc::new(MultiPolygonArray::try_from(array)?)), Mixed(_, _) => Ok(Arc::new(array)), - GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::::from(array))), + GeometryCollection(_, _) => Ok(Arc::new(GeometryCollectionArray::from(array))), dt => Err(GeoArrowError::General(format!( "invalid cast to type {dt:?}" ))), @@ -195,7 +195,7 @@ impl Cast for MixedGeometryArray { } } -impl Cast for GeometryCollectionArray { +impl Cast for GeometryCollectionArray { type Output = Result>; fn cast(&self, to_type: &NativeType) -> Self::Output { @@ -205,12 +205,12 @@ impl Cast for GeometryCollectionArray { match to_type { Point(_, _) => Ok(Arc::new(PointArray::try_from(array)?)), - LineString(_, _) => Ok(Arc::new(LineStringArray::::try_from(array)?)), - Polygon(_, _) => Ok(Arc::new(PolygonArray::::try_from(array)?)), - MultiPoint(_, _) => Ok(Arc::new(MultiPointArray::::try_from(array)?)), - MultiLineString(_, _) => Ok(Arc::new(MultiLineStringArray::::try_from(array)?)), - MultiPolygon(_, _) => Ok(Arc::new(MultiPolygonArray::::try_from(array)?)), - Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::::try_from(array)?)), + LineString(_, _) => Ok(Arc::new(LineStringArray::try_from(array)?)), + Polygon(_, _) => Ok(Arc::new(PolygonArray::try_from(array)?)), + MultiPoint(_, _) => Ok(Arc::new(MultiPointArray::try_from(array)?)), + MultiLineString(_, _) => Ok(Arc::new(MultiLineStringArray::try_from(array)?)), + MultiPolygon(_, _) => Ok(Arc::new(MultiPolygonArray::try_from(array)?)), + Mixed(_, _) => Ok(Arc::new(MixedGeometryArray::try_from(array)?)), GeometryCollection(_, _) => Ok(Arc::new(array)), dt => Err(GeoArrowError::General(format!( "invalid cast to type {dt:?}" @@ -232,22 +232,22 @@ impl Cast for &dyn NativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_ref().as_point::<2>().cast(to_type), - LineString(_, XY) => self.as_ref().as_line_string::<2>().cast(to_type), - Polygon(_, XY) => self.as_ref().as_polygon::<2>().cast(to_type), - MultiPoint(_, XY) => self.as_ref().as_multi_point::<2>().cast(to_type), - MultiLineString(_, XY) => self.as_ref().as_multi_line_string::<2>().cast(to_type), - MultiPolygon(_, XY) => self.as_ref().as_multi_polygon::<2>().cast(to_type), - Mixed(_, XY) => self.as_ref().as_mixed::<2>().cast(to_type), - GeometryCollection(_, XY) => self.as_ref().as_geometry_collection::<2>().cast(to_type), - Point(_, XYZ) => self.as_ref().as_point::<3>().cast(to_type), - LineString(_, XYZ) => self.as_ref().as_line_string::<3>().cast(to_type), - Polygon(_, XYZ) => self.as_ref().as_polygon::<3>().cast(to_type), - MultiPoint(_, XYZ) => self.as_ref().as_multi_point::<3>().cast(to_type), - MultiLineString(_, XYZ) => self.as_ref().as_multi_line_string::<3>().cast(to_type), - MultiPolygon(_, XYZ) => self.as_ref().as_multi_polygon::<3>().cast(to_type), - Mixed(_, XYZ) => self.as_ref().as_mixed::<3>().cast(to_type), - GeometryCollection(_, XYZ) => self.as_ref().as_geometry_collection::<3>().cast(to_type), + Point(_, XY) => self.as_ref().as_point().cast(to_type), + LineString(_, XY) => self.as_ref().as_line_string().cast(to_type), + Polygon(_, XY) => self.as_ref().as_polygon().cast(to_type), + MultiPoint(_, XY) => self.as_ref().as_multi_point().cast(to_type), + MultiLineString(_, XY) => self.as_ref().as_multi_line_string().cast(to_type), + MultiPolygon(_, XY) => self.as_ref().as_multi_polygon().cast(to_type), + Mixed(_, XY) => self.as_ref().as_mixed().cast(to_type), + GeometryCollection(_, XY) => self.as_ref().as_geometry_collection().cast(to_type), + Point(_, XYZ) => self.as_ref().as_point().cast(to_type), + LineString(_, XYZ) => self.as_ref().as_line_string().cast(to_type), + Polygon(_, XYZ) => self.as_ref().as_polygon().cast(to_type), + MultiPoint(_, XYZ) => self.as_ref().as_multi_point().cast(to_type), + MultiLineString(_, XYZ) => self.as_ref().as_multi_line_string().cast(to_type), + MultiPolygon(_, XYZ) => self.as_ref().as_multi_polygon().cast(to_type), + Mixed(_, XYZ) => self.as_ref().as_mixed().cast(to_type), + GeometryCollection(_, XYZ) => self.as_ref().as_geometry_collection().cast(to_type), _ => todo!(), } } @@ -379,22 +379,22 @@ macro_rules! impl_chunked_cast_generic { }; } -impl_chunked_cast_non_generic!(ChunkedPointArray<2>); -impl_chunked_cast_non_generic!(ChunkedRectArray<2>); +impl_chunked_cast_non_generic!(ChunkedPointArray); +impl_chunked_cast_non_generic!(ChunkedRectArray); impl_chunked_cast_non_generic!(&dyn ChunkedNativeArray); -impl_chunked_cast_generic!(ChunkedLineStringArray<2>); -impl_chunked_cast_generic!(ChunkedPolygonArray<2>); -impl_chunked_cast_generic!(ChunkedMultiPointArray<2>); -impl_chunked_cast_generic!(ChunkedMultiLineStringArray<2>); -impl_chunked_cast_generic!(ChunkedMultiPolygonArray<2>); -impl_chunked_cast_generic!(ChunkedMixedGeometryArray<2>); -impl_chunked_cast_generic!(ChunkedGeometryCollectionArray<2>); -impl_chunked_cast_non_generic!(ChunkedPointArray<3>); -impl_chunked_cast_non_generic!(ChunkedRectArray<3>); -impl_chunked_cast_generic!(ChunkedLineStringArray<3>); -impl_chunked_cast_generic!(ChunkedPolygonArray<3>); -impl_chunked_cast_generic!(ChunkedMultiPointArray<3>); -impl_chunked_cast_generic!(ChunkedMultiLineStringArray<3>); -impl_chunked_cast_generic!(ChunkedMultiPolygonArray<3>); -impl_chunked_cast_generic!(ChunkedMixedGeometryArray<3>); -impl_chunked_cast_generic!(ChunkedGeometryCollectionArray<3>); +impl_chunked_cast_generic!(ChunkedLineStringArray); +impl_chunked_cast_generic!(ChunkedPolygonArray); +impl_chunked_cast_generic!(ChunkedMultiPointArray); +impl_chunked_cast_generic!(ChunkedMultiLineStringArray); +impl_chunked_cast_generic!(ChunkedMultiPolygonArray); +impl_chunked_cast_generic!(ChunkedMixedGeometryArray); +impl_chunked_cast_generic!(ChunkedGeometryCollectionArray); +impl_chunked_cast_non_generic!(ChunkedPointArray); +impl_chunked_cast_non_generic!(ChunkedRectArray); +impl_chunked_cast_generic!(ChunkedLineStringArray); +impl_chunked_cast_generic!(ChunkedPolygonArray); +impl_chunked_cast_generic!(ChunkedMultiPointArray); +impl_chunked_cast_generic!(ChunkedMultiLineStringArray); +impl_chunked_cast_generic!(ChunkedMultiPolygonArray); +impl_chunked_cast_generic!(ChunkedMixedGeometryArray); +impl_chunked_cast_generic!(ChunkedGeometryCollectionArray); diff --git a/rust/geoarrow/src/algorithm/native/map_coords.rs b/rust/geoarrow/src/algorithm/native/map_coords.rs index f8e776fe..ff7299f6 100644 --- a/rust/geoarrow/src/algorithm/native/map_coords.rs +++ b/rust/geoarrow/src/algorithm/native/map_coords.rs @@ -43,7 +43,7 @@ impl MapCoords for Coord<'_> { } } -impl MapCoords for Point<'_, 2> { +impl MapCoords for Point<'_> { type Output = geo::Point; fn try_map_coords(&self, map_op: F) -> Result @@ -55,7 +55,7 @@ impl MapCoords for Point<'_, 2> { } } -impl MapCoords for LineString<'_, 2> { +impl MapCoords for LineString<'_> { type Output = geo::LineString; fn try_map_coords(&self, map_op: F) -> Result @@ -71,7 +71,7 @@ impl MapCoords for LineString<'_, 2> { } } -impl MapCoords for Polygon<'_, 2> { +impl MapCoords for Polygon<'_> { type Output = geo::Polygon; fn try_map_coords(&self, map_op: F) -> Result @@ -93,7 +93,7 @@ impl MapCoords for Polygon<'_, 2> { } } -impl MapCoords for MultiPoint<'_, 2> { +impl MapCoords for MultiPoint<'_> { type Output = geo::MultiPoint; fn try_map_coords(&self, map_op: F) -> Result @@ -109,7 +109,7 @@ impl MapCoords for MultiPoint<'_, 2> { } } -impl MapCoords for MultiLineString<'_, 2> { +impl MapCoords for MultiLineString<'_> { type Output = geo::MultiLineString; fn try_map_coords(&self, map_op: F) -> Result @@ -125,7 +125,7 @@ impl MapCoords for MultiLineString<'_, 2> { } } -impl MapCoords for MultiPolygon<'_, 2> { +impl MapCoords for MultiPolygon<'_> { // TODO: support empty polygons within a multi polygon type Output = geo::MultiPolygon; @@ -142,7 +142,7 @@ impl MapCoords for MultiPolygon<'_, 2> { } } -impl MapCoords for Geometry<'_, 2> { +impl MapCoords for Geometry<'_> { type Output = geo::Geometry; fn try_map_coords(&self, map_op: F) -> Result @@ -170,7 +170,7 @@ impl MapCoords for Geometry<'_, 2> { } } -impl MapCoords for GeometryCollection<'_, 2> { +impl MapCoords for GeometryCollection<'_> { type Output = geo::GeometryCollection; fn try_map_coords(&self, map_op: F) -> Result @@ -186,7 +186,7 @@ impl MapCoords for GeometryCollection<'_, 2> { } } -impl MapCoords for Rect<'_, 2> { +impl MapCoords for Rect<'_> { type Output = geo::Rect; fn try_map_coords(&self, map_op: F) -> Result @@ -212,8 +212,8 @@ impl MapCoords for Rect<'_, 2> { } } -impl MapCoords for PointArray<2> { - type Output = PointArray<2>; +impl MapCoords for PointArray { + type Output = PointArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -237,8 +237,8 @@ impl MapCoords for PointArray<2> { } } -impl MapCoords for LineStringArray<2> { - type Output = LineStringArray<2>; +impl MapCoords for LineStringArray { + type Output = LineStringArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -262,8 +262,8 @@ impl MapCoords for LineStringArray<2> { } } -impl MapCoords for PolygonArray<2> { - type Output = PolygonArray<2>; +impl MapCoords for PolygonArray { + type Output = PolygonArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -287,8 +287,8 @@ impl MapCoords for PolygonArray<2> { } } -impl MapCoords for MultiPointArray<2> { - type Output = MultiPointArray<2>; +impl MapCoords for MultiPointArray { + type Output = MultiPointArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -312,8 +312,8 @@ impl MapCoords for MultiPointArray<2> { } } -impl MapCoords for MultiLineStringArray<2> { - type Output = MultiLineStringArray<2>; +impl MapCoords for MultiLineStringArray { + type Output = MultiLineStringArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -337,8 +337,8 @@ impl MapCoords for MultiLineStringArray<2> { } } -impl MapCoords for MultiPolygonArray<2> { - type Output = MultiPolygonArray<2>; +impl MapCoords for MultiPolygonArray { + type Output = MultiPolygonArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -362,8 +362,8 @@ impl MapCoords for MultiPolygonArray<2> { } } -impl MapCoords for MixedGeometryArray<2> { - type Output = MixedGeometryArray<2>; +impl MapCoords for MixedGeometryArray { + type Output = MixedGeometryArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -388,8 +388,8 @@ impl MapCoords for MixedGeometryArray<2> { } } -impl MapCoords for GeometryCollectionArray<2> { - type Output = GeometryCollectionArray<2>; +impl MapCoords for GeometryCollectionArray { + type Output = GeometryCollectionArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -414,8 +414,8 @@ impl MapCoords for GeometryCollectionArray<2> { } } -impl MapCoords for RectArray<2> { - type Output = RectArray<2>; +impl MapCoords for RectArray { + type Output = RectArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -447,27 +447,25 @@ impl MapCoords for &dyn NativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().try_map_coords(map_op)?), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().try_map_coords(map_op)?), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().try_map_coords(map_op)?), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().try_map_coords(map_op)?), - MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string::<2>().try_map_coords(map_op)?) - } - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().try_map_coords(map_op)?), - Mixed(_, XY) => Arc::new(self.as_mixed::<2>().try_map_coords(map_op)?), + Point(_, XY) => Arc::new(self.as_point().try_map_coords(map_op)?), + LineString(_, XY) => Arc::new(self.as_line_string().try_map_coords(map_op)?), + Polygon(_, XY) => Arc::new(self.as_polygon().try_map_coords(map_op)?), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().try_map_coords(map_op)?), + MultiLineString(_, XY) => Arc::new(self.as_multi_line_string().try_map_coords(map_op)?), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().try_map_coords(map_op)?), + Mixed(_, XY) => Arc::new(self.as_mixed().try_map_coords(map_op)?), GeometryCollection(_, XY) => { - Arc::new(self.as_geometry_collection::<2>().try_map_coords(map_op)?) + Arc::new(self.as_geometry_collection().try_map_coords(map_op)?) } - Rect(XY) => Arc::new(self.as_rect::<2>().try_map_coords(map_op)?), + Rect(XY) => Arc::new(self.as_rect().try_map_coords(map_op)?), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) } } -impl MapCoords for ChunkedPointArray<2> { - type Output = ChunkedPointArray<2>; +impl MapCoords for ChunkedPointArray { + type Output = ChunkedPointArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -480,8 +478,8 @@ impl MapCoords for ChunkedPointArray<2> { } } -impl MapCoords for ChunkedLineStringArray<2> { - type Output = ChunkedLineStringArray<2>; +impl MapCoords for ChunkedLineStringArray { + type Output = ChunkedLineStringArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -494,8 +492,8 @@ impl MapCoords for ChunkedLineStringArray<2> { } } -impl MapCoords for ChunkedPolygonArray<2> { - type Output = ChunkedPolygonArray<2>; +impl MapCoords for ChunkedPolygonArray { + type Output = ChunkedPolygonArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -508,8 +506,8 @@ impl MapCoords for ChunkedPolygonArray<2> { } } -impl MapCoords for ChunkedMultiPointArray<2> { - type Output = ChunkedMultiPointArray<2>; +impl MapCoords for ChunkedMultiPointArray { + type Output = ChunkedMultiPointArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -522,8 +520,8 @@ impl MapCoords for ChunkedMultiPointArray<2> { } } -impl MapCoords for ChunkedMultiLineStringArray<2> { - type Output = ChunkedMultiLineStringArray<2>; +impl MapCoords for ChunkedMultiLineStringArray { + type Output = ChunkedMultiLineStringArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -536,8 +534,8 @@ impl MapCoords for ChunkedMultiLineStringArray<2> { } } -impl MapCoords for ChunkedMultiPolygonArray<2> { - type Output = ChunkedMultiPolygonArray<2>; +impl MapCoords for ChunkedMultiPolygonArray { + type Output = ChunkedMultiPolygonArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -550,8 +548,8 @@ impl MapCoords for ChunkedMultiPolygonArray<2> { } } -impl MapCoords for ChunkedMixedGeometryArray<2> { - type Output = ChunkedMixedGeometryArray<2>; +impl MapCoords for ChunkedMixedGeometryArray { + type Output = ChunkedMixedGeometryArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -564,8 +562,8 @@ impl MapCoords for ChunkedMixedGeometryArray<2> { } } -impl MapCoords for ChunkedGeometryCollectionArray<2> { - type Output = ChunkedGeometryCollectionArray<2>; +impl MapCoords for ChunkedGeometryCollectionArray { + type Output = ChunkedGeometryCollectionArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -578,8 +576,8 @@ impl MapCoords for ChunkedGeometryCollectionArray<2> { } } -impl MapCoords for ChunkedRectArray<2> { - type Output = ChunkedRectArray<2>; +impl MapCoords for ChunkedRectArray { + type Output = ChunkedRectArray; fn try_map_coords(&self, map_op: F) -> Result where @@ -604,19 +602,17 @@ impl MapCoords for &dyn ChunkedNativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().try_map_coords(map_op)?), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().try_map_coords(map_op)?), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().try_map_coords(map_op)?), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().try_map_coords(map_op)?), - MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string::<2>().try_map_coords(map_op)?) - } - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().try_map_coords(map_op)?), - Mixed(_, XY) => Arc::new(self.as_mixed::<2>().try_map_coords(map_op)?), + Point(_, XY) => Arc::new(self.as_point().try_map_coords(map_op)?), + LineString(_, XY) => Arc::new(self.as_line_string().try_map_coords(map_op)?), + Polygon(_, XY) => Arc::new(self.as_polygon().try_map_coords(map_op)?), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().try_map_coords(map_op)?), + MultiLineString(_, XY) => Arc::new(self.as_multi_line_string().try_map_coords(map_op)?), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().try_map_coords(map_op)?), + Mixed(_, XY) => Arc::new(self.as_mixed().try_map_coords(map_op)?), GeometryCollection(_, XY) => { - Arc::new(self.as_geometry_collection::<2>().try_map_coords(map_op)?) + Arc::new(self.as_geometry_collection().try_map_coords(map_op)?) } - Rect(XY) => Arc::new(self.as_rect::<2>().try_map_coords(map_op)?), + Rect(XY) => Arc::new(self.as_rect().try_map_coords(map_op)?), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) diff --git a/rust/geoarrow/src/algorithm/native/rechunk.rs b/rust/geoarrow/src/algorithm/native/rechunk.rs index 6623925e..ddd58f20 100644 --- a/rust/geoarrow/src/algorithm/native/rechunk.rs +++ b/rust/geoarrow/src/algorithm/native/rechunk.rs @@ -16,8 +16,8 @@ pub trait Rechunk { // } } -impl Rechunk for PointArray<2> { - type Output = ChunkedGeometryArray>; +impl Rechunk for PointArray { + type Output = ChunkedGeometryArray; fn rechunk(&self, ranges: &[Range]) -> Self::Output { let mut output_arrays = Vec::with_capacity(ranges.len()); @@ -56,15 +56,15 @@ macro_rules! rechunk_impl { }; } -rechunk_impl!(LineStringArray<2>); -rechunk_impl!(PolygonArray<2>); -rechunk_impl!(MultiPointArray<2>); -rechunk_impl!(MultiLineStringArray<2>); -rechunk_impl!(MultiPolygonArray<2>); -rechunk_impl!(MixedGeometryArray<2>); -rechunk_impl!(GeometryCollectionArray<2>); +rechunk_impl!(LineStringArray); +rechunk_impl!(PolygonArray); +rechunk_impl!(MultiPointArray); +rechunk_impl!(MultiLineStringArray); +rechunk_impl!(MultiPolygonArray); +rechunk_impl!(MixedGeometryArray); +rechunk_impl!(GeometryCollectionArray); -// impl Rechunk for LineStringArray<2> { +// impl Rechunk for LineStringArray { // type Output = Result>; // fn rechunk(&self, ranges: &[Range]) -> Self::Output { diff --git a/rust/geoarrow/src/algorithm/native/take.rs b/rust/geoarrow/src/algorithm/native/take.rs index 9ffa7694..ed6384fe 100644 --- a/rust/geoarrow/src/algorithm/native/take.rs +++ b/rust/geoarrow/src/algorithm/native/take.rs @@ -20,7 +20,7 @@ pub trait Take { fn take_range(&self, range: &Range) -> Self::Output; } -impl Take for PointArray<2> { +impl Take for PointArray { type Output = Self; fn take(&self, indices: &UInt32Array) -> Self::Output { @@ -108,37 +108,37 @@ macro_rules! take_impl { } take_impl!( - LineStringArray<2>, + LineStringArray, LineStringCapacity, - LineStringBuilder<2>, + LineStringBuilder, add_line_string, push_line_string ); take_impl!( - PolygonArray<2>, + PolygonArray, PolygonCapacity, - PolygonBuilder<2>, + PolygonBuilder, add_polygon, push_polygon ); take_impl!( - MultiPointArray<2>, + MultiPointArray, MultiPointCapacity, - MultiPointBuilder<2>, + MultiPointBuilder, add_multi_point, push_multi_point ); take_impl!( - MultiLineStringArray<2>, + MultiLineStringArray, MultiLineStringCapacity, - MultiLineStringBuilder<2>, + MultiLineStringBuilder, add_multi_line_string, push_multi_line_string ); take_impl!( - MultiPolygonArray<2>, + MultiPolygonArray, MultiPolygonCapacity, - MultiPolygonBuilder<2>, + MultiPolygonBuilder, add_multi_polygon, push_multi_polygon ); @@ -198,16 +198,16 @@ macro_rules! take_impl_fallible { } take_impl_fallible!( - MixedGeometryArray<2>, + MixedGeometryArray, MixedCapacity, - MixedGeometryBuilder<2>, + MixedGeometryBuilder, add_geometry, push_geometry ); take_impl_fallible!( - GeometryCollectionArray<2>, + GeometryCollectionArray, GeometryCollectionCapacity, - GeometryCollectionBuilder<2>, + GeometryCollectionBuilder, add_geometry_collection, push_geometry_collection ); @@ -220,16 +220,14 @@ impl Take for &dyn NativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().take(indices)), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().take(indices)?), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().take(indices)?), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().take(indices)?), - MultiLineString(_, XY) => Arc::new(self.as_multi_line_string::<2>().take(indices)?), - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().take(indices)?), - Mixed(_, XY) => Arc::new(self.as_mixed::<2>().take(indices)?), - GeometryCollection(_, XY) => { - Arc::new(self.as_geometry_collection::<2>().take(indices)?) - } + Point(_, XY) => Arc::new(self.as_point().take(indices)), + LineString(_, XY) => Arc::new(self.as_line_string().take(indices)?), + Polygon(_, XY) => Arc::new(self.as_polygon().take(indices)?), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().take(indices)?), + MultiLineString(_, XY) => Arc::new(self.as_multi_line_string().take(indices)?), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().take(indices)?), + Mixed(_, XY) => Arc::new(self.as_mixed().take(indices)?), + GeometryCollection(_, XY) => Arc::new(self.as_geometry_collection().take(indices)?), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -240,24 +238,22 @@ impl Take for &dyn NativeArray { use NativeType::*; let result: Arc = match self.data_type() { - Point(_, XY) => Arc::new(self.as_point::<2>().take_range(range)), - LineString(_, XY) => Arc::new(self.as_line_string::<2>().take_range(range)?), - Polygon(_, XY) => Arc::new(self.as_polygon::<2>().take_range(range)?), - MultiPoint(_, XY) => Arc::new(self.as_multi_point::<2>().take_range(range)?), - MultiLineString(_, XY) => Arc::new(self.as_multi_line_string::<2>().take_range(range)?), - MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon::<2>().take_range(range)?), - Mixed(_, XY) => Arc::new(self.as_mixed::<2>().take_range(range)?), - GeometryCollection(_, XY) => { - Arc::new(self.as_geometry_collection::<2>().take_range(range)?) - } + Point(_, XY) => Arc::new(self.as_point().take_range(range)), + LineString(_, XY) => Arc::new(self.as_line_string().take_range(range)?), + Polygon(_, XY) => Arc::new(self.as_polygon().take_range(range)?), + MultiPoint(_, XY) => Arc::new(self.as_multi_point().take_range(range)?), + MultiLineString(_, XY) => Arc::new(self.as_multi_line_string().take_range(range)?), + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().take_range(range)?), + Mixed(_, XY) => Arc::new(self.as_mixed().take_range(range)?), + GeometryCollection(_, XY) => Arc::new(self.as_geometry_collection().take_range(range)?), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) } } -impl Take for ChunkedGeometryArray> { - type Output = Result>>; +impl Take for ChunkedGeometryArray { + type Output = Result>; fn take(&self, indices: &UInt32Array) -> Self::Output { let mut output_chunks = Vec::with_capacity(self.chunks.len()); @@ -305,10 +301,10 @@ macro_rules! chunked_impl { }; } -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); -chunked_impl!(ChunkedGeometryArray>); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); +chunked_impl!(ChunkedGeometryArray); diff --git a/rust/geoarrow/src/algorithm/native/total_bounds.rs b/rust/geoarrow/src/algorithm/native/total_bounds.rs index 57857dd6..bad85a0f 100644 --- a/rust/geoarrow/src/algorithm/native/total_bounds.rs +++ b/rust/geoarrow/src/algorithm/native/total_bounds.rs @@ -10,7 +10,7 @@ pub trait TotalBounds { fn total_bounds(&self) -> BoundingRect; } -impl TotalBounds for PointArray { +impl TotalBounds for PointArray { fn total_bounds(&self) -> BoundingRect { let mut bounds = BoundingRect::new(); for geom in self.iter().flatten() { @@ -20,7 +20,7 @@ impl TotalBounds for PointArray { } } -impl TotalBounds for RectArray { +impl TotalBounds for RectArray { fn total_bounds(&self) -> BoundingRect { let mut bounds = BoundingRect::new(); for geom in self.iter().flatten() { @@ -32,7 +32,7 @@ impl TotalBounds for RectArray { macro_rules! impl_array { ($type:ty, $func:ident) => { - impl TotalBounds for $type { + impl TotalBounds for $type { fn total_bounds(&self) -> BoundingRect { let mut bounds = BoundingRect::new(); for geom in self.iter().flatten() { @@ -44,13 +44,13 @@ macro_rules! impl_array { }; } -impl_array!(LineStringArray, add_line_string); -impl_array!(PolygonArray, add_polygon); -impl_array!(MultiPointArray, add_multi_point); -impl_array!(MultiLineStringArray, add_multi_line_string); -impl_array!(MultiPolygonArray, add_multi_polygon); -impl_array!(MixedGeometryArray, add_geometry); -impl_array!(GeometryCollectionArray, add_geometry_collection); +impl_array!(LineStringArray, add_line_string); +impl_array!(PolygonArray, add_polygon); +impl_array!(MultiPointArray, add_multi_point); +impl_array!(MultiLineStringArray, add_multi_line_string); +impl_array!(MultiPolygonArray, add_multi_polygon); +impl_array!(MixedGeometryArray, add_geometry); +impl_array!(GeometryCollectionArray, add_geometry_collection); // impl TotalBounds for WKBArray { // fn total_bounds(&self) -> BoundingRect { diff --git a/rust/geoarrow/src/algorithm/native/unary.rs b/rust/geoarrow/src/algorithm/native/unary.rs index 0bed51e1..11ea9e39 100644 --- a/rust/geoarrow/src/algorithm/native/unary.rs +++ b/rust/geoarrow/src/algorithm/native/unary.rs @@ -86,20 +86,20 @@ pub trait Unary<'a>: ArrayAccessor<'a> { } } -impl<'a, const D: usize> Unary<'a> for PointArray {} -impl<'a, const D: usize> Unary<'a> for LineStringArray {} -impl<'a, const D: usize> Unary<'a> for PolygonArray {} -impl<'a, const D: usize> Unary<'a> for MultiPointArray {} -impl<'a, const D: usize> Unary<'a> for MultiLineStringArray {} -impl<'a, const D: usize> Unary<'a> for MultiPolygonArray {} -impl<'a, const D: usize> Unary<'a> for MixedGeometryArray {} -impl<'a, const D: usize> Unary<'a> for GeometryCollectionArray {} -impl<'a, const D: usize> Unary<'a> for RectArray {} +impl<'a> Unary<'a> for PointArray {} +impl<'a> Unary<'a> for LineStringArray {} +impl<'a> Unary<'a> for PolygonArray {} +impl<'a> Unary<'a> for MultiPointArray {} +impl<'a> Unary<'a> for MultiLineStringArray {} +impl<'a> Unary<'a> for MultiPolygonArray {} +impl<'a> Unary<'a> for MixedGeometryArray {} +impl<'a> Unary<'a> for GeometryCollectionArray {} +impl<'a> Unary<'a> for RectArray {} impl<'a, O: OffsetSizeTrait> Unary<'a> for WKBArray {} #[allow(dead_code)] pub trait UnaryPoint<'a>: ArrayAccessor<'a> + NativeArray { - fn unary_point(&'a self, op: F) -> PointArray<2> + fn unary_point(&'a self, op: F) -> PointArray where G: PointTrait + 'a, F: Fn(Self::Item) -> &'a G, @@ -113,7 +113,7 @@ pub trait UnaryPoint<'a>: ArrayAccessor<'a> + NativeArray { result } - fn try_unary_point(&'a self, op: F) -> std::result::Result, E> + fn try_unary_point(&'a self, op: F) -> std::result::Result where G: PointTrait + 'a, F: Fn(Self::Item) -> std::result::Result, @@ -133,12 +133,12 @@ pub trait UnaryPoint<'a>: ArrayAccessor<'a> + NativeArray { } } -impl<'a> UnaryPoint<'a> for PointArray<2> {} -impl<'a> UnaryPoint<'a> for LineStringArray<2> {} -impl<'a> UnaryPoint<'a> for PolygonArray<2> {} -impl<'a> UnaryPoint<'a> for MultiPointArray<2> {} -impl<'a> UnaryPoint<'a> for MultiLineStringArray<2> {} -impl<'a> UnaryPoint<'a> for MultiPolygonArray<2> {} -impl<'a> UnaryPoint<'a> for MixedGeometryArray<2> {} -impl<'a> UnaryPoint<'a> for GeometryCollectionArray<2> {} -impl<'a> UnaryPoint<'a> for RectArray<2> {} +impl<'a> UnaryPoint<'a> for PointArray {} +impl<'a> UnaryPoint<'a> for LineStringArray {} +impl<'a> UnaryPoint<'a> for PolygonArray {} +impl<'a> UnaryPoint<'a> for MultiPointArray {} +impl<'a> UnaryPoint<'a> for MultiLineStringArray {} +impl<'a> UnaryPoint<'a> for MultiPolygonArray {} +impl<'a> UnaryPoint<'a> for MixedGeometryArray {} +impl<'a> UnaryPoint<'a> for GeometryCollectionArray {} +impl<'a> UnaryPoint<'a> for RectArray {} diff --git a/rust/geoarrow/src/algorithm/polylabel.rs b/rust/geoarrow/src/algorithm/polylabel.rs index e265d47b..b3ff8de2 100644 --- a/rust/geoarrow/src/algorithm/polylabel.rs +++ b/rust/geoarrow/src/algorithm/polylabel.rs @@ -25,8 +25,8 @@ pub trait Polylabel { fn polylabel(&self, tolerance: f64) -> Self::Output; } -impl Polylabel for PolygonArray<2> { - type Output = Result>; +impl Polylabel for PolygonArray { + type Output = Result; fn polylabel(&self, tolerance: f64) -> Self::Output { Ok(self.try_unary_point(|geom| polylabel(&geom.to_geo(), &tolerance))?) @@ -34,18 +34,18 @@ impl Polylabel for PolygonArray<2> { } impl Polylabel for &dyn NativeArray { - type Output = Result>; + type Output = Result; fn polylabel(&self, tolerance: f64) -> Self::Output { match self.data_type() { - NativeType::Polygon(_, Dimension::XY) => self.as_polygon::<2>().polylabel(tolerance), + NativeType::Polygon(_, Dimension::XY) => self.as_polygon().polylabel(tolerance), _ => Err(GeoArrowError::IncorrectType("".into())), } } } -impl Polylabel for ChunkedPolygonArray<2> { - type Output = Result>; +impl Polylabel for ChunkedPolygonArray { + type Output = Result; fn polylabel(&self, tolerance: f64) -> Self::Output { let chunks = self.try_map(|chunk| chunk.polylabel(tolerance))?; @@ -54,11 +54,11 @@ impl Polylabel for ChunkedPolygonArray<2> { } impl Polylabel for &dyn ChunkedNativeArray { - type Output = Result>; + type Output = Result; fn polylabel(&self, tolerance: f64) -> Self::Output { match self.data_type() { - NativeType::Polygon(_, Dimension::XY) => self.as_polygon::<2>().polylabel(tolerance), + NativeType::Polygon(_, Dimension::XY) => self.as_polygon().polylabel(tolerance), _ => Err(GeoArrowError::IncorrectType("".into())), } } diff --git a/rust/geoarrow/src/algorithm/proj.rs b/rust/geoarrow/src/algorithm/proj.rs index c87e48f0..d9b65f6e 100644 --- a/rust/geoarrow/src/algorithm/proj.rs +++ b/rust/geoarrow/src/algorithm/proj.rs @@ -12,7 +12,7 @@ pub trait Reproject { Self: Sized; } -impl Reproject for PointArray<2> { +impl Reproject for PointArray { fn reproject(&self, proj: &Proj) -> Result { let mut output_array = PointBuilder::with_capacity(self.len()); @@ -50,19 +50,15 @@ macro_rules! iter_geo_impl { }; } -iter_geo_impl!(LineStringArray<2>, LineStringBuilder<2>, push_line_string); -iter_geo_impl!(PolygonArray<2>, PolygonBuilder<2>, push_polygon); -iter_geo_impl!(MultiPointArray<2>, MultiPointBuilder<2>, push_multi_point); +iter_geo_impl!(LineStringArray, LineStringBuilder, push_line_string); +iter_geo_impl!(PolygonArray, PolygonBuilder, push_polygon); +iter_geo_impl!(MultiPointArray, MultiPointBuilder, push_multi_point); iter_geo_impl!( - MultiLineStringArray<2>, - MultiLineStringBuilder<2>, + MultiLineStringArray, + MultiLineStringBuilder, push_multi_line_string ); -iter_geo_impl!( - MultiPolygonArray<2>, - MultiPolygonBuilder<2>, - push_multi_polygon -); +iter_geo_impl!(MultiPolygonArray, MultiPolygonBuilder, push_multi_polygon); #[cfg(test)] mod test { @@ -74,7 +70,7 @@ mod test { #[test] fn point_round_trip() { - let point_array: PointArray<2> = vec![Some(p0()), Some(p1()), Some(p2())].into(); + let point_array: PointArray = vec![Some(p0()), Some(p1()), Some(p2())].into(); let proj = Proj::new_known_crs("EPSG:4326", "EPSG:3857", None).unwrap(); // You can verify this with PROJ on the command line: diff --git a/rust/geoarrow/src/algorithm/rstar.rs b/rust/geoarrow/src/algorithm/rstar.rs index 7af7574e..3cac54cb 100644 --- a/rust/geoarrow/src/algorithm/rstar.rs +++ b/rust/geoarrow/src/algorithm/rstar.rs @@ -13,8 +13,8 @@ pub trait RTree<'a> { fn rstar_tree(&'a self) -> rstar::RTree; } -impl<'a> RTree<'a> for PointArray<2> { - type RTreeObject = crate::scalar::Point<'a, 2>; +impl<'a> RTree<'a> for PointArray { + type RTreeObject = crate::scalar::Point<'a>; fn rstar_tree(&'a self) -> rstar::RTree { // Note: for points we don't memoize with CachedEnvelope @@ -22,8 +22,8 @@ impl<'a> RTree<'a> for PointArray<2> { } } -impl<'a> RTree<'a> for RectArray<2> { - type RTreeObject = crate::scalar::Rect<'a, 2>; +impl<'a> RTree<'a> for RectArray { + type RTreeObject = crate::scalar::Rect<'a>; fn rstar_tree(&'a self) -> rstar::RTree { // Note: for rects we don't memoize with CachedEnvelope @@ -43,16 +43,13 @@ macro_rules! iter_cached_impl { }; } -iter_cached_impl!(LineStringArray<2>, crate::scalar::LineString<'a, 2>); -iter_cached_impl!(PolygonArray<2>, crate::scalar::Polygon<'a, 2>); -iter_cached_impl!(MultiPointArray<2>, crate::scalar::MultiPoint<'a, 2>); +iter_cached_impl!(LineStringArray, crate::scalar::LineString<'a>); +iter_cached_impl!(PolygonArray, crate::scalar::Polygon<'a>); +iter_cached_impl!(MultiPointArray, crate::scalar::MultiPoint<'a>); +iter_cached_impl!(MultiLineStringArray, crate::scalar::MultiLineString<'a>); +iter_cached_impl!(MultiPolygonArray, crate::scalar::MultiPolygon<'a>); +iter_cached_impl!(MixedGeometryArray, crate::scalar::Geometry<'a>); iter_cached_impl!( - MultiLineStringArray<2>, - crate::scalar::MultiLineString<'a, 2> -); -iter_cached_impl!(MultiPolygonArray<2>, crate::scalar::MultiPolygon<'a, 2>); -iter_cached_impl!(MixedGeometryArray<2>, crate::scalar::Geometry<'a, 2>); -iter_cached_impl!( - GeometryCollectionArray<2>, - crate::scalar::GeometryCollection<'a, 2> + GeometryCollectionArray, + crate::scalar::GeometryCollection<'a> ); diff --git a/rust/geoarrow/src/array/cast.rs b/rust/geoarrow/src/array/cast.rs index df0f2166..51cb6b7a 100644 --- a/rust/geoarrow/src/array/cast.rs +++ b/rust/geoarrow/src/array/cast.rs @@ -4,135 +4,135 @@ use crate::chunked_array::*; /// Helpers for downcasting a [`NativeArray`] to a concrete implementation. pub trait AsNativeArray { /// Downcast this to a [`PointArray`] returning `None` if not possible - fn as_point_opt(&self) -> Option<&PointArray>; + fn as_point_opt(&self) -> Option<&PointArray>; /// Downcast this to a [`PointArray`] panicking if not possible #[inline] - fn as_point(&self) -> &PointArray { - self.as_point_opt::().unwrap() + fn as_point(&self) -> &PointArray { + self.as_point_opt().unwrap() } /// Downcast this to a [`LineStringArray`] with `i32` offsets returning `None` if not possible - fn as_line_string_opt(&self) -> Option<&LineStringArray>; + fn as_line_string_opt(&self) -> Option<&LineStringArray>; /// Downcast this to a [`LineStringArray`] with `i32` offsets panicking if not possible #[inline] - fn as_line_string(&self) -> &LineStringArray { - self.as_line_string_opt::().unwrap() + fn as_line_string(&self) -> &LineStringArray { + self.as_line_string_opt().unwrap() } /// Downcast this to a [`PolygonArray`] with `i32` offsets returning `None` if not possible - fn as_polygon_opt(&self) -> Option<&PolygonArray>; + fn as_polygon_opt(&self) -> Option<&PolygonArray>; /// Downcast this to a [`PolygonArray`] with `i32` offsets panicking if not possible #[inline] - fn as_polygon(&self) -> &PolygonArray { - self.as_polygon_opt::().unwrap() + fn as_polygon(&self) -> &PolygonArray { + self.as_polygon_opt().unwrap() } /// Downcast this to a [`MultiPointArray`] with `i32` offsets returning `None` if not possible - fn as_multi_point_opt(&self) -> Option<&MultiPointArray>; + fn as_multi_point_opt(&self) -> Option<&MultiPointArray>; /// Downcast this to a [`MultiPointArray`] with `i32` offsets panicking if not possible #[inline] - fn as_multi_point(&self) -> &MultiPointArray { - self.as_multi_point_opt::().unwrap() + fn as_multi_point(&self) -> &MultiPointArray { + self.as_multi_point_opt().unwrap() } /// Downcast this to a [`MultiLineStringArray`] with `i32` offsets returning `None` if not /// possible - fn as_multi_line_string_opt(&self) -> Option<&MultiLineStringArray>; + fn as_multi_line_string_opt(&self) -> Option<&MultiLineStringArray>; /// Downcast this to a [`MultiLineStringArray`] with `i32` offsets panicking if not possible #[inline] - fn as_multi_line_string(&self) -> &MultiLineStringArray { - self.as_multi_line_string_opt::().unwrap() + fn as_multi_line_string(&self) -> &MultiLineStringArray { + self.as_multi_line_string_opt().unwrap() } /// Downcast this to a [`MultiPolygonArray`] with `i32` offsets returning `None` if not /// possible - fn as_multi_polygon_opt(&self) -> Option<&MultiPolygonArray>; + fn as_multi_polygon_opt(&self) -> Option<&MultiPolygonArray>; /// Downcast this to a [`MultiPolygonArray`] with `i32` offsets panicking if not possible #[inline] - fn as_multi_polygon(&self) -> &MultiPolygonArray { - self.as_multi_polygon_opt::().unwrap() + fn as_multi_polygon(&self) -> &MultiPolygonArray { + self.as_multi_polygon_opt().unwrap() } /// Downcast this to a [`MixedGeometryArray`] with `i32` offsets returning `None` if not /// possible - fn as_mixed_opt(&self) -> Option<&MixedGeometryArray>; + fn as_mixed_opt(&self) -> Option<&MixedGeometryArray>; /// Downcast this to a [`MixedGeometryArray`] with `i32` offsets panicking if not possible #[inline] - fn as_mixed(&self) -> &MixedGeometryArray { - self.as_mixed_opt::().unwrap() + fn as_mixed(&self) -> &MixedGeometryArray { + self.as_mixed_opt().unwrap() } /// Downcast this to a [`GeometryCollectionArray`] with `i32` offsets returning `None` if not /// possible - fn as_geometry_collection_opt(&self) -> Option<&GeometryCollectionArray>; + fn as_geometry_collection_opt(&self) -> Option<&GeometryCollectionArray>; /// Downcast this to a [`GeometryCollectionArray`] with `i32` offsets panicking if not possible #[inline] - fn as_geometry_collection(&self) -> &GeometryCollectionArray { - self.as_geometry_collection_opt::().unwrap() + fn as_geometry_collection(&self) -> &GeometryCollectionArray { + self.as_geometry_collection_opt().unwrap() } /// Downcast this to a [`RectArray`] returning `None` if not possible - fn as_rect_opt(&self) -> Option<&RectArray>; + fn as_rect_opt(&self) -> Option<&RectArray>; /// Downcast this to a [`RectArray`] panicking if not possible #[inline] - fn as_rect(&self) -> &RectArray { - self.as_rect_opt::().unwrap() + fn as_rect(&self) -> &RectArray { + self.as_rect_opt().unwrap() } } impl AsNativeArray for &dyn NativeArray { #[inline] - fn as_point_opt(&self) -> Option<&PointArray> { - self.as_any().downcast_ref::>() + fn as_point_opt(&self) -> Option<&PointArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_line_string_opt(&self) -> Option<&LineStringArray> { - self.as_any().downcast_ref::>() + fn as_line_string_opt(&self) -> Option<&LineStringArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_polygon_opt(&self) -> Option<&PolygonArray> { - self.as_any().downcast_ref::>() + fn as_polygon_opt(&self) -> Option<&PolygonArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_multi_point_opt(&self) -> Option<&MultiPointArray> { - self.as_any().downcast_ref::>() + fn as_multi_point_opt(&self) -> Option<&MultiPointArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_multi_line_string_opt(&self) -> Option<&MultiLineStringArray> { - self.as_any().downcast_ref::>() + fn as_multi_line_string_opt(&self) -> Option<&MultiLineStringArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_multi_polygon_opt(&self) -> Option<&MultiPolygonArray> { - self.as_any().downcast_ref::>() + fn as_multi_polygon_opt(&self) -> Option<&MultiPolygonArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_mixed_opt(&self) -> Option<&MixedGeometryArray> { - self.as_any().downcast_ref::>() + fn as_mixed_opt(&self) -> Option<&MixedGeometryArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_geometry_collection_opt(&self) -> Option<&GeometryCollectionArray> { - self.as_any().downcast_ref::>() + fn as_geometry_collection_opt(&self) -> Option<&GeometryCollectionArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_rect_opt(&self) -> Option<&RectArray> { - self.as_any().downcast_ref::>() + fn as_rect_opt(&self) -> Option<&RectArray> { + self.as_any().downcast_ref::() } } @@ -171,141 +171,136 @@ impl AsSerializedArray for &dyn SerializedArray { /// Helpers for downcasting a [`ChunkedNativeArray`] to a concrete implementation. pub trait AsChunkedNativeArray { /// Downcast this to a [`ChunkedPointArray`] returning `None` if not possible - fn as_point_opt(&self) -> Option<&ChunkedPointArray>; + fn as_point_opt(&self) -> Option<&ChunkedPointArray>; /// Downcast this to a [`ChunkedPointArray`] panicking if not possible #[inline] - fn as_point(&self) -> &ChunkedPointArray { - self.as_point_opt::().unwrap() + fn as_point(&self) -> &ChunkedPointArray { + self.as_point_opt().unwrap() } /// Downcast this to a [`ChunkedLineStringArray`] with `i32` offsets returning `None` if not possible - fn as_line_string_opt(&self) -> Option<&ChunkedLineStringArray>; + fn as_line_string_opt(&self) -> Option<&ChunkedLineStringArray>; /// Downcast this to a [`ChunkedLineStringArray`] with `i32` offsets panicking if not possible #[inline] - fn as_line_string(&self) -> &ChunkedLineStringArray { - self.as_line_string_opt::().unwrap() + fn as_line_string(&self) -> &ChunkedLineStringArray { + self.as_line_string_opt().unwrap() } /// Downcast this to a [`ChunkedPolygonArray`] with `i32` offsets returning `None` if not possible - fn as_polygon_opt(&self) -> Option<&ChunkedPolygonArray>; + fn as_polygon_opt(&self) -> Option<&ChunkedPolygonArray>; /// Downcast this to a [`ChunkedPolygonArray`] with `i32` offsets panicking if not possible #[inline] - fn as_polygon(&self) -> &ChunkedPolygonArray { - self.as_polygon_opt::().unwrap() + fn as_polygon(&self) -> &ChunkedPolygonArray { + self.as_polygon_opt().unwrap() } /// Downcast this to a [`ChunkedMultiPointArray`] with `i32` offsets returning `None` if not possible - fn as_multi_point_opt(&self) -> Option<&ChunkedMultiPointArray>; + fn as_multi_point_opt(&self) -> Option<&ChunkedMultiPointArray>; /// Downcast this to a [`ChunkedMultiPointArray`] with `i32` offsets panicking if not possible #[inline] - fn as_multi_point(&self) -> &ChunkedMultiPointArray { - self.as_multi_point_opt::().unwrap() + fn as_multi_point(&self) -> &ChunkedMultiPointArray { + self.as_multi_point_opt().unwrap() } /// Downcast this to a [`ChunkedMultiLineStringArray`] with `i32` offsets returning `None` if not /// possible - fn as_multi_line_string_opt(&self) -> Option<&ChunkedMultiLineStringArray>; + fn as_multi_line_string_opt(&self) -> Option<&ChunkedMultiLineStringArray>; /// Downcast this to a [`ChunkedMultiLineStringArray`] with `i32` offsets panicking if not possible #[inline] - fn as_multi_line_string(&self) -> &ChunkedMultiLineStringArray { - self.as_multi_line_string_opt::().unwrap() + fn as_multi_line_string(&self) -> &ChunkedMultiLineStringArray { + self.as_multi_line_string_opt().unwrap() } /// Downcast this to a [`ChunkedMultiPolygonArray`] with `i32` offsets returning `None` if not /// possible - fn as_multi_polygon_opt(&self) -> Option<&ChunkedMultiPolygonArray>; + fn as_multi_polygon_opt(&self) -> Option<&ChunkedMultiPolygonArray>; /// Downcast this to a [`ChunkedMultiPolygonArray`] with `i32` offsets panicking if not possible #[inline] - fn as_multi_polygon(&self) -> &ChunkedMultiPolygonArray { - self.as_multi_polygon_opt::().unwrap() + fn as_multi_polygon(&self) -> &ChunkedMultiPolygonArray { + self.as_multi_polygon_opt().unwrap() } /// Downcast this to a [`ChunkedMixedGeometryArray`] with `i32` offsets returning `None` if not /// possible - fn as_mixed_opt(&self) -> Option<&ChunkedMixedGeometryArray>; + fn as_mixed_opt(&self) -> Option<&ChunkedMixedGeometryArray>; /// Downcast this to a [`ChunkedMixedGeometryArray`] with `i32` offsets panicking if not possible #[inline] - fn as_mixed(&self) -> &ChunkedMixedGeometryArray { - self.as_mixed_opt::().unwrap() + fn as_mixed(&self) -> &ChunkedMixedGeometryArray { + self.as_mixed_opt().unwrap() } /// Downcast this to a [`ChunkedGeometryCollectionArray`] with `i32` offsets returning `None` if not /// possible - fn as_geometry_collection_opt( - &self, - ) -> Option<&ChunkedGeometryCollectionArray>; + fn as_geometry_collection_opt(&self) -> Option<&ChunkedGeometryCollectionArray>; /// Downcast this to a [`ChunkedGeometryCollectionArray`] with `i32` offsets panicking if not possible #[inline] - fn as_geometry_collection(&self) -> &ChunkedGeometryCollectionArray { - self.as_geometry_collection_opt::().unwrap() + fn as_geometry_collection(&self) -> &ChunkedGeometryCollectionArray { + self.as_geometry_collection_opt().unwrap() } /// Downcast this to a [`ChunkedRectArray`] returning `None` if not possible - fn as_rect_opt(&self) -> Option<&ChunkedRectArray>; + fn as_rect_opt(&self) -> Option<&ChunkedRectArray>; /// Downcast this to a [`ChunkedRectArray`] panicking if not possible #[inline] - fn as_rect(&self) -> &ChunkedRectArray { - self.as_rect_opt::().unwrap() + fn as_rect(&self) -> &ChunkedRectArray { + self.as_rect_opt().unwrap() } } impl AsChunkedNativeArray for &dyn ChunkedNativeArray { #[inline] - fn as_point_opt(&self) -> Option<&ChunkedPointArray> { - self.as_any().downcast_ref::>() + fn as_point_opt(&self) -> Option<&ChunkedPointArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_line_string_opt(&self) -> Option<&ChunkedLineStringArray> { - self.as_any().downcast_ref::>() + fn as_line_string_opt(&self) -> Option<&ChunkedLineStringArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_polygon_opt(&self) -> Option<&ChunkedPolygonArray> { - self.as_any().downcast_ref::>() + fn as_polygon_opt(&self) -> Option<&ChunkedPolygonArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_multi_point_opt(&self) -> Option<&ChunkedMultiPointArray> { - self.as_any().downcast_ref::>() + fn as_multi_point_opt(&self) -> Option<&ChunkedMultiPointArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_multi_line_string_opt(&self) -> Option<&ChunkedMultiLineStringArray> { - self.as_any() - .downcast_ref::>() + fn as_multi_line_string_opt(&self) -> Option<&ChunkedMultiLineStringArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_multi_polygon_opt(&self) -> Option<&ChunkedMultiPolygonArray> { - self.as_any().downcast_ref::>() + fn as_multi_polygon_opt(&self) -> Option<&ChunkedMultiPolygonArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_mixed_opt(&self) -> Option<&ChunkedMixedGeometryArray> { - self.as_any().downcast_ref::>() + fn as_mixed_opt(&self) -> Option<&ChunkedMixedGeometryArray> { + self.as_any().downcast_ref::() } #[inline] - fn as_geometry_collection_opt( - &self, - ) -> Option<&ChunkedGeometryCollectionArray> { + fn as_geometry_collection_opt(&self) -> Option<&ChunkedGeometryCollectionArray> { self.as_any() - .downcast_ref::>() + .downcast_ref::() } #[inline] - fn as_rect_opt(&self) -> Option<&ChunkedRectArray> { - self.as_any().downcast_ref::>() + fn as_rect_opt(&self) -> Option<&ChunkedRectArray> { + self.as_any().downcast_ref::() } } diff --git a/rust/geoarrow/src/array/dynamic.rs b/rust/geoarrow/src/array/dynamic.rs index 0b4cc1a7..3afe16d6 100644 --- a/rust/geoarrow/src/array/dynamic.rs +++ b/rust/geoarrow/src/array/dynamic.rs @@ -33,39 +33,39 @@ impl NativeArrayDyn { use NativeType::*; let geo_arr: Arc = match data_type { Point(_, dim) => match dim { - XY => Arc::new(PointArray::<2>::try_from((array, field))?), + XY => Arc::new(PointArray::try_from((array, field))?), XYZ => Arc::new(PointArray::<3>::try_from((array, field))?), }, LineString(_, dim) => match dim { - XY => Arc::new(LineStringArray::<2>::try_from((array, field))?), + XY => Arc::new(LineStringArray::try_from((array, field))?), XYZ => Arc::new(LineStringArray::<3>::try_from((array, field))?), }, Polygon(_, dim) => match dim { - XY => Arc::new(PolygonArray::<2>::try_from((array, field))?), + XY => Arc::new(PolygonArray::try_from((array, field))?), XYZ => Arc::new(PolygonArray::<3>::try_from((array, field))?), }, MultiPoint(_, dim) => match dim { - XY => Arc::new(MultiPointArray::<2>::try_from((array, field))?), + XY => Arc::new(MultiPointArray::try_from((array, field))?), XYZ => Arc::new(MultiPointArray::<3>::try_from((array, field))?), }, MultiLineString(_, dim) => match dim { - XY => Arc::new(MultiLineStringArray::<2>::try_from((array, field))?), + XY => Arc::new(MultiLineStringArray::try_from((array, field))?), XYZ => Arc::new(MultiLineStringArray::<3>::try_from((array, field))?), }, MultiPolygon(_, dim) => match dim { - XY => Arc::new(MultiPolygonArray::<2>::try_from((array, field))?), + XY => Arc::new(MultiPolygonArray::try_from((array, field))?), XYZ => Arc::new(MultiPolygonArray::<3>::try_from((array, field))?), }, Mixed(_, dim) => match dim { - XY => Arc::new(MixedGeometryArray::<2>::try_from((array, field))?), + XY => Arc::new(MixedGeometryArray::try_from((array, field))?), XYZ => Arc::new(MixedGeometryArray::<3>::try_from((array, field))?), }, GeometryCollection(_, dim) => match dim { - XY => Arc::new(GeometryCollectionArray::<2>::try_from((array, field))?), + XY => Arc::new(GeometryCollectionArray::try_from((array, field))?), XYZ => Arc::new(GeometryCollectionArray::<3>::try_from((array, field))?), }, Rect(dim) => match dim { - XY => Arc::new(RectArray::<2>::try_from((array, field))?), + XY => Arc::new(RectArray::try_from((array, field))?), XYZ => Arc::new(RectArray::<3>::try_from((array, field))?), }, }; diff --git a/rust/geoarrow/src/array/geometry/array.rs b/rust/geoarrow/src/array/geometry/array.rs index 70d81dd6..f3d81749 100644 --- a/rust/geoarrow/src/array/geometry/array.rs +++ b/rust/geoarrow/src/array/geometry/array.rs @@ -15,7 +15,7 @@ use crate::array::{ use crate::datatypes::NativeType; use crate::error::GeoArrowError; use crate::scalar::Geometry; -use crate::trait_::{GeometryArraySelfMethods, IntoArrow, ArrayAccessor}; +use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow}; use crate::NativeArray; /// A GeometryArray is an enum over the various underlying _zero copy_ GeoArrow array types. @@ -173,7 +173,7 @@ impl NativeArray for GeometryArray { } impl GeometryArraySelfMethods for GeometryArray { - fn with_coords(self, coords: crate::array::CoordBuffer<2>) -> Self { + fn with_coords(self, coords: crate::array::CoordBuffer) -> Self { match self { GeometryArray::Point(arr) => GeometryArray::Point(arr.with_coords(coords)), GeometryArray::LineString(arr) => GeometryArray::LineString(arr.with_coords(coords)), diff --git a/rust/geoarrow/src/array/geometrycollection/array.rs b/rust/geoarrow/src/array/geometrycollection/array.rs index ac7e5b37..062a0af9 100644 --- a/rust/geoarrow/src/array/geometrycollection/array.rs +++ b/rust/geoarrow/src/array/geometrycollection/array.rs @@ -25,13 +25,13 @@ use geo_traits::GeometryCollectionTrait; /// This is semantically equivalent to `Vec>` due to the internal /// validity bitmap. #[derive(Debug, Clone)] -pub struct GeometryCollectionArray { +pub struct GeometryCollectionArray { // Always NativeType::GeometryCollection or NativeType::LargeGeometryCollection data_type: NativeType, metadata: Arc, - pub(crate) array: MixedGeometryArray, + pub(crate) array: MixedGeometryArray, /// Offsets into the mixed geometry array where each geometry starts pub(crate) geom_offsets: OffsetBuffer, @@ -40,21 +40,20 @@ pub struct GeometryCollectionArray { pub(crate) validity: Option, } -impl GeometryCollectionArray { +impl GeometryCollectionArray { /// Create a new GeometryCollectionArray from parts /// /// # Implementation /// /// This function is `O(1)`. pub fn new( - array: MixedGeometryArray, + array: MixedGeometryArray, geom_offsets: OffsetBuffer, validity: Option, metadata: Arc, ) -> Self { let coord_type = array.coord_type(); - let data_type = NativeType::GeometryCollection(coord_type, D.try_into().unwrap()); - + let data_type = NativeType::GeometryCollection(coord_type, array.dim()); Self { data_type, array, @@ -134,7 +133,7 @@ impl GeometryCollectionArray { } } -impl ArrayBase for GeometryCollectionArray { +impl ArrayBase for GeometryCollectionArray { fn as_any(&self) -> &dyn std::any::Any { self } @@ -179,7 +178,7 @@ impl ArrayBase for GeometryCollectionArray { } } -impl NativeArray for GeometryCollectionArray { +impl NativeArray for GeometryCollectionArray { fn data_type(&self) -> NativeType { self.data_type } @@ -211,7 +210,7 @@ impl NativeArray for GeometryCollectionArray { } } -impl GeometryArraySelfMethods for GeometryCollectionArray { +impl GeometryArraySelfMethods for GeometryCollectionArray { fn with_coords(self, _coords: CoordBuffer) -> Self { todo!() } @@ -221,8 +220,8 @@ impl GeometryArraySelfMethods for GeometryCollectionArray } } -impl NativeGeometryAccessor for GeometryCollectionArray { - unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { +impl NativeGeometryAccessor for GeometryCollectionArray { + unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { Geometry::GeometryCollection(GeometryCollection::new( &self.array, &self.geom_offsets, @@ -232,9 +231,7 @@ impl NativeGeometryAccessor for GeometryCollectionArray { } #[cfg(feature = "geos")] -impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> - for GeometryCollectionArray -{ +impl<'a> crate::trait_::NativeGEOSGeometryAccessor<'a> for GeometryCollectionArray { unsafe fn value_as_geometry_unchecked( &'a self, index: usize, @@ -244,8 +241,8 @@ impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> } } -impl<'a, const D: usize> ArrayAccessor<'a> for GeometryCollectionArray { - type Item = GeometryCollection<'a, D>; +impl<'a> ArrayAccessor<'a> for GeometryCollectionArray { + type Item = GeometryCollection<'a>; type ItemGeo = geo::GeometryCollection; unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item { @@ -253,7 +250,7 @@ impl<'a, const D: usize> ArrayAccessor<'a> for GeometryCollectionArray { } } -impl IntoArrow for GeometryCollectionArray { +impl IntoArrow for GeometryCollectionArray { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { @@ -264,11 +261,11 @@ impl IntoArrow for GeometryCollectionArray { } } -impl TryFrom<&GenericListArray> for GeometryCollectionArray { +impl TryFrom<&GenericListArray> for GeometryCollectionArray { type Error = GeoArrowError; fn try_from(value: &GenericListArray) -> Result { - let geoms: MixedGeometryArray = value.values().as_ref().try_into()?; + let geoms: MixedGeometryArray = value.values().as_ref().try_into()?; let geom_offsets = value.offsets(); let validity = value.nulls(); @@ -281,11 +278,11 @@ impl TryFrom<&GenericListArray> for GeometryCollectionArray } } -impl TryFrom<&GenericListArray> for GeometryCollectionArray { +impl TryFrom<&GenericListArray> for GeometryCollectionArray { type Error = GeoArrowError; fn try_from(value: &GenericListArray) -> Result { - let geoms: MixedGeometryArray = value.values().as_ref().try_into()?; + let geoms: MixedGeometryArray = value.values().as_ref().try_into()?; let geom_offsets = offsets_buffer_i64_to_i32(value.offsets())?; let validity = value.nulls(); @@ -298,7 +295,7 @@ impl TryFrom<&GenericListArray> for GeometryCollectionArray } } -impl TryFrom<&dyn Array> for GeometryCollectionArray { +impl TryFrom<&dyn Array> for GeometryCollectionArray { type Error = GeoArrowError; fn try_from(value: &dyn Array) -> Result { @@ -319,7 +316,7 @@ impl TryFrom<&dyn Array> for GeometryCollectionArray { } } -impl TryFrom<(&dyn Array, &Field)> for GeometryCollectionArray { +impl TryFrom<(&dyn Array, &Field)> for GeometryCollectionArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { @@ -329,37 +326,37 @@ impl TryFrom<(&dyn Array, &Field)> for GeometryCollectionArray> From<&[G]> for GeometryCollectionArray<2> { +impl> From<&[G]> for GeometryCollectionArray { fn from(other: &[G]) -> Self { - let mut_arr: GeometryCollectionBuilder<2> = other.into(); + let mut_arr: GeometryCollectionBuilder = other.into(); mut_arr.into() } } -impl> From>> for GeometryCollectionArray<2> { +impl> From>> for GeometryCollectionArray { fn from(other: Vec>) -> Self { - let mut_arr: GeometryCollectionBuilder<2> = other.into(); + let mut_arr: GeometryCollectionBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for GeometryCollectionArray<2> { +impl TryFrom> for GeometryCollectionArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { - let mut_arr: GeometryCollectionBuilder<2> = value.try_into()?; + let mut_arr: GeometryCollectionBuilder = value.try_into()?; Ok(mut_arr.into()) } } /// Default to an empty array -impl Default for GeometryCollectionArray { +impl Default for GeometryCollectionArray { fn default() -> Self { GeometryCollectionBuilder::default().into() } } -impl PartialEq for GeometryCollectionArray { +impl PartialEq for GeometryCollectionArray { fn eq(&self, other: &Self) -> bool { if self.validity != other.validity { return false; @@ -377,42 +374,42 @@ impl PartialEq for GeometryCollectionArray { } } -impl From> for GeometryCollectionArray { - fn from(value: PointArray) -> Self { - MixedGeometryArray::::from(value).into() +impl From for GeometryCollectionArray { + fn from(value: PointArray) -> Self { + MixedGeometryArray::from(value).into() } } -impl From> for GeometryCollectionArray { - fn from(value: LineStringArray) -> Self { - MixedGeometryArray::::from(value).into() +impl From for GeometryCollectionArray { + fn from(value: LineStringArray) -> Self { + MixedGeometryArray::from(value).into() } } -impl From> for GeometryCollectionArray { - fn from(value: PolygonArray) -> Self { - MixedGeometryArray::::from(value).into() +impl From for GeometryCollectionArray { + fn from(value: PolygonArray) -> Self { + MixedGeometryArray::from(value).into() } } -impl From> for GeometryCollectionArray { - fn from(value: MultiPointArray) -> Self { - MixedGeometryArray::::from(value).into() +impl From for GeometryCollectionArray { + fn from(value: MultiPointArray) -> Self { + MixedGeometryArray::from(value).into() } } -impl From> for GeometryCollectionArray { - fn from(value: MultiLineStringArray) -> Self { - MixedGeometryArray::::from(value).into() +impl From for GeometryCollectionArray { + fn from(value: MultiLineStringArray) -> Self { + MixedGeometryArray::from(value).into() } } -impl From> for GeometryCollectionArray { - fn from(value: MultiPolygonArray) -> Self { - MixedGeometryArray::::from(value).into() +impl From for GeometryCollectionArray { + fn from(value: MultiPolygonArray) -> Self { + MixedGeometryArray::from(value).into() } } -impl From> for GeometryCollectionArray { +impl From for GeometryCollectionArray { // TODO: We should construct the correct validity buffer from the union's underlying arrays. - fn from(value: MixedGeometryArray) -> Self { + fn from(value: MixedGeometryArray) -> Self { let metadata = value.metadata.clone(); let geom_offsets = OffsetBuffer::from_lengths(vec![1; value.len()]); GeometryCollectionArray::new(value, geom_offsets, None, metadata) diff --git a/rust/geoarrow/src/array/geometrycollection/builder.rs b/rust/geoarrow/src/array/geometrycollection/builder.rs index 093aa0ca..d4305c9a 100644 --- a/rust/geoarrow/src/array/geometrycollection/builder.rs +++ b/rust/geoarrow/src/array/geometrycollection/builder.rs @@ -21,17 +21,17 @@ use geo_traits::{ /// /// Converting an [`GeometryCollectionBuilder`] into a [`GeometryCollectionArray`] is `O(1)`. #[derive(Debug)] -pub struct GeometryCollectionBuilder { +pub struct GeometryCollectionBuilder { metadata: Arc, - pub(crate) geoms: MixedGeometryBuilder, + pub(crate) geoms: MixedGeometryBuilder, pub(crate) geom_offsets: OffsetsBuilder, pub(crate) validity: NullBufferBuilder, } -impl<'a, const D: usize> GeometryCollectionBuilder { +impl<'a> GeometryCollectionBuilder { /// Creates a new empty [`GeometryCollectionBuilder`]. pub fn new() -> Self { Self::new_with_options(Default::default(), Default::default(), DEFAULT_PREFER_MULTI) @@ -102,17 +102,11 @@ impl<'a, const D: usize> GeometryCollectionBuilder { } /// Extract the low-level APIs from the [`GeometryCollectionBuilder`]. - pub fn into_inner( - self, - ) -> ( - MixedGeometryBuilder, - OffsetsBuilder, - NullBufferBuilder, - ) { + pub fn into_inner(self) -> (MixedGeometryBuilder, OffsetsBuilder, NullBufferBuilder) { (self.geoms, self.geom_offsets, self.validity) } - pub fn finish(self) -> GeometryCollectionArray { + pub fn finish(self) -> GeometryCollectionArray { self.into() } @@ -376,7 +370,7 @@ impl<'a, const D: usize> GeometryCollectionBuilder { } } -impl GeometryArrayBuilder for GeometryCollectionBuilder { +impl GeometryArrayBuilder for GeometryCollectionBuilder { fn new() -> Self { Self::new() } @@ -423,23 +417,23 @@ impl GeometryArrayBuilder for GeometryCollectionBuilder { } } -impl IntoArrow for GeometryCollectionBuilder { +impl IntoArrow for GeometryCollectionBuilder { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { - let linestring_arr: GeometryCollectionArray = self.into(); + let linestring_arr: GeometryCollectionArray = self.into(); linestring_arr.into_arrow() } } -impl Default for GeometryCollectionBuilder { +impl Default for GeometryCollectionBuilder { fn default() -> Self { Self::new() } } -impl From> for GeometryCollectionArray { - fn from(mut other: GeometryCollectionBuilder) -> Self { +impl From for GeometryCollectionArray { + fn from(mut other: GeometryCollectionBuilder) -> Self { let validity = other.validity.finish(); Self::new( other.geoms.into(), @@ -450,20 +444,20 @@ impl From> for GeometryCollectionAr } } -impl From> for GenericListArray { - fn from(arr: GeometryCollectionBuilder) -> Self { +impl From for GenericListArray { + fn from(arr: GeometryCollectionBuilder) -> Self { arr.into_arrow() } } -impl> From<&[G]> for GeometryCollectionBuilder<2> { +impl> From<&[G]> for GeometryCollectionBuilder { fn from(geoms: &[G]) -> Self { Self::from_geometry_collections(geoms, Default::default(), Default::default(), true) .unwrap() } } -impl> From>> for GeometryCollectionBuilder<2> { +impl> From>> for GeometryCollectionBuilder { fn from(geoms: Vec>) -> Self { Self::from_nullable_geometry_collections( &geoms, @@ -475,7 +469,7 @@ impl> From>> for GeometryColle } } -impl TryFrom> for GeometryCollectionBuilder<2> { +impl TryFrom> for GeometryCollectionBuilder { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { diff --git a/rust/geoarrow/src/array/linestring/array.rs b/rust/geoarrow/src/array/linestring/array.rs index 5c06769f..d969cd46 100644 --- a/rust/geoarrow/src/array/linestring/array.rs +++ b/rust/geoarrow/src/array/linestring/array.rs @@ -29,7 +29,7 @@ use super::LineStringBuilder; /// This is semantically equivalent to `Vec>` due to the internal validity /// bitmap. #[derive(Debug, Clone)] -pub struct LineStringArray { +pub struct LineStringArray { // Always NativeType::LineString or NativeType::LargeLineString data_type: NativeType, @@ -64,7 +64,7 @@ pub(super) fn check( Ok(()) } -impl LineStringArray { +impl LineStringArray { /// Create a new LineStringArray from parts /// /// # Implementation @@ -101,10 +101,7 @@ impl LineStringArray { metadata: Arc, ) -> Result { check(&coords, validity.as_ref().map(|v| v.len()), &geom_offsets)?; - - let coord_type = coords.coord_type(); - let data_type = NativeType::LineString(coord_type, D.try_into()?); - + let data_type = NativeType::LineString(coords.coord_type(), coords.dim()); Ok(Self { data_type, coords, @@ -211,7 +208,7 @@ impl LineStringArray { } } -impl ArrayBase for LineStringArray { +impl ArrayBase for LineStringArray { fn as_any(&self) -> &dyn std::any::Any { self } @@ -264,7 +261,7 @@ impl ArrayBase for LineStringArray { } } -impl NativeArray for LineStringArray { +impl NativeArray for LineStringArray { fn data_type(&self) -> NativeType { self.data_type } @@ -296,7 +293,7 @@ impl NativeArray for LineStringArray { } } -impl GeometryArraySelfMethods for LineStringArray { +impl GeometryArraySelfMethods for LineStringArray { fn with_coords(self, coords: CoordBuffer) -> Self { assert_eq!(coords.len(), self.coords.len()); Self::new(coords, self.geom_offsets, self.validity, self.metadata) @@ -312,25 +309,25 @@ impl GeometryArraySelfMethods for LineStringArray { } } -impl NativeGeometryAccessor for LineStringArray { - unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { +impl NativeGeometryAccessor for LineStringArray { + unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { Geometry::LineString(LineString::new(&self.coords, &self.geom_offsets, index)) } } #[cfg(feature = "geos")] -impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> for LineStringArray { +impl<'a> crate::trait_::NativeGEOSGeometryAccessor<'a> for LineStringArray { unsafe fn value_as_geometry_unchecked( &'a self, index: usize, ) -> std::result::Result { - let geom = LineString::::new(&self.coords, &self.geom_offsets, index); + let geom = LineString::new(&self.coords, &self.geom_offsets, index); (&geom).try_into() } } -impl<'a, const D: usize> ArrayAccessor<'a> for LineStringArray { - type Item = LineString<'a, D>; +impl<'a> ArrayAccessor<'a> for LineStringArray { + type Item = LineString<'a>; type ItemGeo = geo::LineString; unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item { @@ -338,7 +335,7 @@ impl<'a, const D: usize> ArrayAccessor<'a> for LineStringArray { } } -impl IntoArrow for LineStringArray { +impl IntoArrow for LineStringArray { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { @@ -349,7 +346,7 @@ impl IntoArrow for LineStringArray { } } -impl TryFrom<&GenericListArray> for LineStringArray { +impl TryFrom<&GenericListArray> for LineStringArray { type Error = GeoArrowError; fn try_from(value: &GenericListArray) -> Result { @@ -366,7 +363,7 @@ impl TryFrom<&GenericListArray> for LineStringArray { } } -impl TryFrom<&GenericListArray> for LineStringArray { +impl TryFrom<&GenericListArray> for LineStringArray { type Error = GeoArrowError; fn try_from(value: &GenericListArray) -> Result { @@ -382,7 +379,7 @@ impl TryFrom<&GenericListArray> for LineStringArray { )) } } -impl TryFrom<&dyn Array> for LineStringArray { +impl TryFrom<&dyn Array> for LineStringArray { type Error = GeoArrowError; fn try_from(value: &dyn Array) -> Result { @@ -403,7 +400,7 @@ impl TryFrom<&dyn Array> for LineStringArray { } } -impl TryFrom<(&dyn Array, &Field)> for LineStringArray { +impl TryFrom<(&dyn Array, &Field)> for LineStringArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { @@ -413,24 +410,24 @@ impl TryFrom<(&dyn Array, &Field)> for LineStringArray { } } -impl, const D: usize> From>> for LineStringArray { +impl> From>> for LineStringArray { fn from(other: Vec>) -> Self { - let mut_arr: LineStringBuilder = other.into(); + let mut_arr: LineStringBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From<&[G]> for LineStringArray { +impl> From<&[G]> for LineStringArray { fn from(other: &[G]) -> Self { - let mut_arr: LineStringBuilder = other.into(); + let mut_arr: LineStringBuilder = other.into(); mut_arr.into() } } /// LineString and MultiPoint have the same layout, so enable conversions between the two to change /// the semantic type -impl From> for MultiPointArray { - fn from(value: LineStringArray) -> Self { +impl From for MultiPointArray { + fn from(value: LineStringArray) -> Self { Self::new( value.coords, value.geom_offsets, @@ -440,23 +437,23 @@ impl From> for MultiPointArray { } } -impl TryFrom> for LineStringArray { +impl TryFrom> for LineStringArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { - let mut_arr: LineStringBuilder = value.try_into()?; + let mut_arr: LineStringBuilder = value.try_into()?; Ok(mut_arr.into()) } } /// Default to an empty array -impl Default for LineStringArray { +impl Default for LineStringArray { fn default() -> Self { LineStringBuilder::default().into() } } -impl PartialEq for LineStringArray { +impl PartialEq for LineStringArray { fn eq(&self, other: &Self) -> bool { if self.validity != other.validity { return false; @@ -474,10 +471,10 @@ impl PartialEq for LineStringArray { } } -impl TryFrom> for LineStringArray { +impl TryFrom for LineStringArray { type Error = GeoArrowError; - fn try_from(value: MultiLineStringArray) -> Result { + fn try_from(value: MultiLineStringArray) -> Result { if !can_downcast_multi(&value.geom_offsets) { return Err(GeoArrowError::General("Unable to cast".to_string())); } @@ -491,10 +488,10 @@ impl TryFrom> for LineStringArray { } } -impl TryFrom> for LineStringArray { +impl TryFrom for LineStringArray { type Error = GeoArrowError; - fn try_from(value: MixedGeometryArray) -> Result { + fn try_from(value: MixedGeometryArray) -> Result { if value.has_points() || value.has_polygons() || value.has_multi_points() @@ -516,7 +513,7 @@ impl TryFrom> for LineStringArray { capacity.coord_capacity += buffer_lengths.coord_capacity; capacity.geom_capacity += buffer_lengths.ring_capacity; - let mut builder = LineStringBuilder::::with_capacity_and_options( + let mut builder = LineStringBuilder::with_capacity_and_options( capacity, value.coord_type(), value.metadata(), @@ -528,10 +525,10 @@ impl TryFrom> for LineStringArray { } } -impl TryFrom> for LineStringArray { +impl TryFrom for LineStringArray { type Error = GeoArrowError; - fn try_from(value: GeometryCollectionArray) -> Result { + fn try_from(value: GeometryCollectionArray) -> Result { MixedGeometryArray::try_from(value)?.try_into() } } @@ -547,14 +544,14 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: LineStringArray<2> = vec![ls0(), ls1()].as_slice().into(); + let arr: LineStringArray = vec![ls0(), ls1()].as_slice().into(); assert_eq!(arr.value_as_geo(0), ls0()); assert_eq!(arr.value_as_geo(1), ls1()); } #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: LineStringArray<2> = vec![Some(ls0()), Some(ls1()), None].into(); + let arr: LineStringArray = vec![Some(ls0()), Some(ls1()), None].into(); assert_eq!(arr.get_as_geo(0), Some(ls0())); assert_eq!(arr.get_as_geo(1), Some(ls1())); assert_eq!(arr.get_as_geo(2), None); @@ -578,7 +575,7 @@ mod test { #[test] fn slice() { - let arr: LineStringArray<2> = vec![ls0(), ls1()].as_slice().into(); + let arr: LineStringArray = vec![ls0(), ls1()].as_slice().into(); let sliced = arr.slice(1, 1); assert_eq!(sliced.len(), 1); assert_eq!(sliced.get_as_geo(0), Some(ls1())); @@ -586,7 +583,7 @@ mod test { #[test] fn owned_slice() { - let arr: LineStringArray<2> = vec![ls0(), ls1()].as_slice().into(); + let arr: LineStringArray = vec![ls0(), ls1()].as_slice().into(); let sliced = arr.owned_slice(1, 1); // assert!( @@ -603,7 +600,7 @@ mod test { let linestring_arr = example_linestring_interleaved(); let wkb_arr = example_linestring_wkb(); - let parsed_linestring_arr: LineStringArray<2> = wkb_arr.try_into().unwrap(); + let parsed_linestring_arr: LineStringArray = wkb_arr.try_into().unwrap(); assert_eq!(linestring_arr, parsed_linestring_arr); } @@ -613,7 +610,7 @@ mod test { let linestring_arr = example_linestring_separated().into_coord_type(CoordType::Interleaved); let wkb_arr = example_linestring_wkb(); - let parsed_linestring_arr: LineStringArray<2> = wkb_arr.try_into().unwrap(); + let parsed_linestring_arr: LineStringArray = wkb_arr.try_into().unwrap(); assert_eq!(linestring_arr, parsed_linestring_arr); } diff --git a/rust/geoarrow/src/array/linestring/builder.rs b/rust/geoarrow/src/array/linestring/builder.rs index 4f7c312c..05b8c941 100644 --- a/rust/geoarrow/src/array/linestring/builder.rs +++ b/rust/geoarrow/src/array/linestring/builder.rs @@ -19,7 +19,7 @@ use std::sync::Arc; /// /// Converting an [`LineStringBuilder`] into a [`LineStringArray`] is `O(1)`. #[derive(Debug)] -pub struct LineStringBuilder { +pub struct LineStringBuilder { metadata: Arc, pub(crate) coords: CoordBufferBuilder, @@ -31,7 +31,7 @@ pub struct LineStringBuilder { pub(crate) validity: NullBufferBuilder, } -impl LineStringBuilder { +impl LineStringBuilder { /// Creates a new empty [`LineStringBuilder`]. pub fn new() -> Self { Self::new_with_options(Default::default(), Default::default()) @@ -155,7 +155,7 @@ impl LineStringBuilder { Arc::new(self.into_arrow()) } - pub fn finish(self) -> LineStringArray { + pub fn finish(self) -> LineStringArray { self.into() } @@ -314,7 +314,7 @@ impl LineStringBuilder { } } -impl GeometryArrayBuilder for LineStringBuilder { +impl GeometryArrayBuilder for LineStringBuilder { fn new() -> Self { Self::new() } @@ -361,23 +361,23 @@ impl GeometryArrayBuilder for LineStringBuilder { } } -impl IntoArrow for LineStringBuilder { +impl IntoArrow for LineStringBuilder { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { - let linestring_arr: LineStringArray = self.into(); + let linestring_arr: LineStringArray = self.into(); linestring_arr.into_arrow() } } -impl Default for LineStringBuilder { +impl Default for LineStringBuilder { fn default() -> Self { Self::new() } } -impl From> for LineStringArray { - fn from(mut other: LineStringBuilder) -> Self { +impl From for LineStringArray { + fn from(mut other: LineStringBuilder) -> Self { let validity = other.validity.finish(); Self::new( other.coords.into(), @@ -388,25 +388,25 @@ impl From> for LineStringArray { } } -impl From> for GenericListArray { - fn from(arr: LineStringBuilder) -> Self { +impl From for GenericListArray { + fn from(arr: LineStringBuilder) -> Self { arr.into_arrow() } } -impl, const D: usize> From<&[G]> for LineStringBuilder { +impl> From<&[G]> for LineStringBuilder { fn from(geoms: &[G]) -> Self { Self::from_line_strings(geoms, Default::default(), Default::default()) } } -impl, const D: usize> From>> for LineStringBuilder { +impl> From>> for LineStringBuilder { fn from(geoms: Vec>) -> Self { Self::from_nullable_line_strings(&geoms, Default::default(), Default::default()) } } -impl TryFrom> for LineStringBuilder { +impl TryFrom> for LineStringBuilder { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { @@ -418,8 +418,8 @@ impl TryFrom> for LineStringBuil /// LineString and MultiPoint have the same layout, so enable conversions between the two to change /// the semantic type -impl From> for MultiPointBuilder { - fn from(value: LineStringBuilder) -> Self { +impl From for MultiPointBuilder { + fn from(value: LineStringBuilder) -> Self { Self::try_new( value.coords, value.geom_offsets, diff --git a/rust/geoarrow/src/array/mixed/array.rs b/rust/geoarrow/src/array/mixed/array.rs index b15a15ab..560a4ab2 100644 --- a/rust/geoarrow/src/array/mixed/array.rs +++ b/rust/geoarrow/src/array/mixed/array.rs @@ -13,7 +13,7 @@ use crate::array::{ CoordType, GeometryCollectionArray, LineStringArray, MultiLineStringArray, MultiPointArray, MultiPolygonArray, PointArray, PolygonArray, WKBArray, }; -use crate::datatypes::NativeType; +use crate::datatypes::{Dimension, NativeType}; use crate::error::{GeoArrowError, Result}; use crate::scalar::Geometry; use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor}; @@ -54,7 +54,7 @@ use geo_traits::GeometryTrait; /// - 36: MultiPolygon ZM /// - 37: GeometryCollection ZM #[derive(Debug, Clone, PartialEq)] -pub struct MixedGeometryArray { +pub struct MixedGeometryArray { /// Always NativeType::Mixed or NativeType::LargeMixed data_type: NativeType, @@ -67,12 +67,12 @@ pub struct MixedGeometryArray { pub(crate) offsets: ScalarBuffer, /// Invariant: Any of these arrays that are `Some()` must have length >0 - pub(crate) points: PointArray, - pub(crate) line_strings: LineStringArray, - pub(crate) polygons: PolygonArray, - pub(crate) multi_points: MultiPointArray, - pub(crate) multi_line_strings: MultiLineStringArray, - pub(crate) multi_polygons: MultiPolygonArray, + pub(crate) points: PointArray, + pub(crate) line_strings: LineStringArray, + pub(crate) polygons: PolygonArray, + pub(crate) multi_points: MultiPointArray, + pub(crate) multi_line_strings: MultiLineStringArray, + pub(crate) multi_polygons: MultiPolygonArray, /// An offset used for slicing into this array. The offset will be 0 if the array has not been /// sliced. @@ -134,7 +134,7 @@ impl From<&String> for GeometryType { } } -impl MixedGeometryArray { +impl MixedGeometryArray { /// Create a new MixedGeometryArray from parts /// /// # Implementation @@ -149,12 +149,12 @@ impl MixedGeometryArray { pub fn new( type_ids: ScalarBuffer, offsets: ScalarBuffer, - points: PointArray, - line_strings: LineStringArray, - polygons: PolygonArray, - multi_points: MultiPointArray, - multi_line_strings: MultiLineStringArray, - multi_polygons: MultiPolygonArray, + points: PointArray, + line_strings: LineStringArray, + polygons: PolygonArray, + multi_points: MultiPointArray, + multi_line_strings: MultiLineStringArray, + multi_polygons: MultiPolygonArray, metadata: Arc, ) -> Self { let mut coord_types = HashSet::new(); @@ -274,6 +274,10 @@ impl MixedGeometryArray { && self.has_multi_polygons() } + pub fn dim(&self) -> Dimension { + todo!() + } + /// The number of bytes occupied by this array. pub fn num_bytes(&self) -> usize { self.buffer_lengths().num_bytes() @@ -332,7 +336,7 @@ impl MixedGeometryArray { } } -impl ArrayBase for MixedGeometryArray { +impl ArrayBase for MixedGeometryArray { fn as_any(&self) -> &dyn std::any::Any { self } @@ -378,7 +382,7 @@ impl ArrayBase for MixedGeometryArray { } } -impl NativeArray for MixedGeometryArray { +impl NativeArray for MixedGeometryArray { fn data_type(&self) -> NativeType { self.data_type } @@ -410,7 +414,7 @@ impl NativeArray for MixedGeometryArray { } } -impl GeometryArraySelfMethods for MixedGeometryArray { +impl GeometryArraySelfMethods for MixedGeometryArray { fn with_coords(self, _coords: crate::array::CoordBuffer) -> Self { todo!(); } @@ -420,8 +424,8 @@ impl GeometryArraySelfMethods for MixedGeometryArray { } } -impl NativeGeometryAccessor for MixedGeometryArray { - unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { +impl NativeGeometryAccessor for MixedGeometryArray { + unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { let type_id = self.type_ids[index]; let offset = self.offsets[index] as usize; @@ -450,7 +454,7 @@ impl NativeGeometryAccessor for MixedGeometryArray { } #[cfg(feature = "geos")] -impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> for MixedGeometryArray { +impl<'a> crate::trait_::NativeGEOSGeometryAccessor<'a> for MixedGeometryArray { unsafe fn value_as_geometry_unchecked( &'a self, index: usize, @@ -484,8 +488,8 @@ impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> for Mixed } } -impl<'a, const D: usize> ArrayAccessor<'a> for MixedGeometryArray { - type Item = Geometry<'a, D>; +impl<'a> ArrayAccessor<'a> for MixedGeometryArray { + type Item = Geometry<'a>; type ItemGeo = geo::Geometry; unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item { @@ -516,7 +520,7 @@ impl<'a, const D: usize> ArrayAccessor<'a> for MixedGeometryArray { } } -impl IntoArrow for MixedGeometryArray { +impl IntoArrow for MixedGeometryArray { type ArrowArray = UnionArray; fn into_arrow(self) -> Self::ArrowArray { @@ -544,16 +548,16 @@ impl IntoArrow for MixedGeometryArray { } } -impl TryFrom<&UnionArray> for MixedGeometryArray { +impl TryFrom<&UnionArray> for MixedGeometryArray { type Error = GeoArrowError; fn try_from(value: &UnionArray) -> std::result::Result { - let mut points: Option> = None; - let mut line_strings: Option> = None; - let mut polygons: Option> = None; - let mut multi_points: Option> = None; - let mut multi_line_strings: Option> = None; - let mut multi_polygons: Option> = None; + let mut points: Option = None; + let mut line_strings: Option = None; + let mut polygons: Option = None; + let mut multi_points: Option = None; + let mut multi_line_strings: Option = None; + let mut multi_polygons: Option = None; match value.data_type() { DataType::Union(fields, mode) => { if !matches!(mode, UnionMode::Dense) { @@ -652,7 +656,7 @@ impl TryFrom<&UnionArray> for MixedGeometryArray { } } -impl TryFrom<&dyn Array> for MixedGeometryArray { +impl TryFrom<&dyn Array> for MixedGeometryArray { type Error = GeoArrowError; fn try_from(value: &dyn Array) -> Result { @@ -669,7 +673,7 @@ impl TryFrom<&dyn Array> for MixedGeometryArray { } } -impl TryFrom<(&dyn Array, &Field)> for MixedGeometryArray { +impl TryFrom<(&dyn Array, &Field)> for MixedGeometryArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { @@ -679,35 +683,35 @@ impl TryFrom<(&dyn Array, &Field)> for MixedGeometryArray { } } -impl, const D: usize> TryFrom<&[G]> for MixedGeometryArray { +impl> TryFrom<&[G]> for MixedGeometryArray { type Error = GeoArrowError; fn try_from(geoms: &[G]) -> Result { - let mut_arr: MixedGeometryBuilder = geoms.try_into()?; + let mut_arr: MixedGeometryBuilder = geoms.try_into()?; Ok(mut_arr.into()) } } -impl, const D: usize> TryFrom>> for MixedGeometryArray { +impl> TryFrom>> for MixedGeometryArray { type Error = GeoArrowError; fn try_from(geoms: Vec>) -> Result { - let mut_arr: MixedGeometryBuilder = geoms.try_into()?; + let mut_arr: MixedGeometryBuilder = geoms.try_into()?; Ok(mut_arr.into()) } } -impl TryFrom> for MixedGeometryArray { +impl TryFrom> for MixedGeometryArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { - let mut_arr: MixedGeometryBuilder = value.try_into()?; + let mut_arr: MixedGeometryBuilder = value.try_into()?; Ok(mut_arr.into()) } } -impl From> for MixedGeometryArray { - fn from(value: PointArray) -> Self { +impl From for MixedGeometryArray { + fn from(value: PointArray) -> Self { let type_ids = match D { 2 => vec![1; value.len()], 3 => vec![11; value.len()], @@ -728,8 +732,8 @@ impl From> for MixedGeometryArray { } } -impl From> for MixedGeometryArray { - fn from(value: LineStringArray) -> Self { +impl From for MixedGeometryArray { + fn from(value: LineStringArray) -> Self { let type_ids = match D { 2 => vec![2; value.len()], 3 => vec![12; value.len()], @@ -750,8 +754,8 @@ impl From> for MixedGeometryArray { } } -impl From> for MixedGeometryArray { - fn from(value: PolygonArray) -> Self { +impl From for MixedGeometryArray { + fn from(value: PolygonArray) -> Self { let type_ids = match D { 2 => vec![3; value.len()], 3 => vec![13; value.len()], @@ -772,8 +776,8 @@ impl From> for MixedGeometryArray { } } -impl From> for MixedGeometryArray { - fn from(value: MultiPointArray) -> Self { +impl From for MixedGeometryArray { + fn from(value: MultiPointArray) -> Self { let type_ids = match D { 2 => vec![4; value.len()], 3 => vec![14; value.len()], @@ -794,8 +798,8 @@ impl From> for MixedGeometryArray { } } -impl From> for MixedGeometryArray { - fn from(value: MultiLineStringArray) -> Self { +impl From for MixedGeometryArray { + fn from(value: MultiLineStringArray) -> Self { let type_ids = match D { 2 => vec![5; value.len()], 3 => vec![15; value.len()], @@ -816,8 +820,8 @@ impl From> for MixedGeometryArray { } } -impl From> for MixedGeometryArray { - fn from(value: MultiPolygonArray) -> Self { +impl From for MixedGeometryArray { + fn from(value: MultiPolygonArray) -> Self { let type_ids = match D { 2 => vec![6; value.len()], 3 => vec![16; value.len()], @@ -838,10 +842,10 @@ impl From> for MixedGeometryArray { } } -impl TryFrom> for MixedGeometryArray { +impl TryFrom for MixedGeometryArray { type Error = GeoArrowError; - fn try_from(value: GeometryCollectionArray) -> std::result::Result { + fn try_from(value: GeometryCollectionArray) -> std::result::Result { if !can_downcast_multi(&value.geom_offsets) { return Err(GeoArrowError::General("Unable to cast".to_string())); } @@ -857,7 +861,7 @@ impl TryFrom> for MixedGeometryArray< } /// Default to an empty array -impl Default for MixedGeometryArray { +impl Default for MixedGeometryArray { fn default() -> Self { MixedGeometryBuilder::default().into() } @@ -876,7 +880,7 @@ mod test { geo::Geometry::Point(point::p1()), geo::Geometry::Point(point::p2()), ]; - let arr: MixedGeometryArray<2> = geoms.as_slice().try_into().unwrap(); + let arr: MixedGeometryArray = geoms.as_slice().try_into().unwrap(); assert_eq!( arr.value_as_geo(0), @@ -902,7 +906,7 @@ mod test { geo::Geometry::MultiLineString(multilinestring::ml0()), geo::Geometry::MultiPolygon(multipolygon::mp0()), ]; - let arr: MixedGeometryArray<2> = geoms.as_slice().try_into().unwrap(); + let arr: MixedGeometryArray = geoms.as_slice().try_into().unwrap(); assert_eq!( arr.value_as_geo(0), @@ -931,11 +935,11 @@ mod test { geo::Geometry::MultiLineString(multilinestring::ml0()), geo::Geometry::MultiPolygon(multipolygon::mp0()), ]; - let arr: MixedGeometryArray<2> = geoms.as_slice().try_into().unwrap(); + let arr: MixedGeometryArray = geoms.as_slice().try_into().unwrap(); // Round trip to/from arrow-rs let arrow_array = arr.into_arrow(); - let round_trip_arr: MixedGeometryArray<2> = (&arrow_array).try_into().unwrap(); + let round_trip_arr: MixedGeometryArray = (&arrow_array).try_into().unwrap(); assert_eq!( round_trip_arr.value_as_geo(0), @@ -961,11 +965,11 @@ mod test { geo::Geometry::MultiLineString(multilinestring::ml0()), geo::Geometry::MultiPolygon(multipolygon::mp0()), ]; - let arr: MixedGeometryArray<2> = geoms.as_slice().try_into().unwrap(); + let arr: MixedGeometryArray = geoms.as_slice().try_into().unwrap(); // Round trip to/from arrow-rs let arrow_array = arr.into_arrow(); - let round_trip_arr: MixedGeometryArray<2> = (&arrow_array).try_into().unwrap(); + let round_trip_arr: MixedGeometryArray = (&arrow_array).try_into().unwrap(); assert_eq!(round_trip_arr.value_as_geo(0), geoms[0]); assert_eq!(round_trip_arr.value_as_geo(1), geoms[1]); @@ -978,11 +982,11 @@ mod test { geo::Geometry::MultiPoint(multipoint::mp0()), geo::Geometry::MultiPolygon(multipolygon::mp0()), ]; - let arr: MixedGeometryArray<2> = geoms.as_slice().try_into().unwrap(); + let arr: MixedGeometryArray = geoms.as_slice().try_into().unwrap(); // Round trip to/from arrow-rs let arrow_array = arr.into_arrow(); - let round_trip_arr: MixedGeometryArray<2> = (&arrow_array).try_into().unwrap(); + let round_trip_arr: MixedGeometryArray = (&arrow_array).try_into().unwrap(); assert_eq!(round_trip_arr.value_as_geo(0), geoms[0]); assert_eq!(round_trip_arr.value_as_geo(1), geoms[1]); diff --git a/rust/geoarrow/src/array/mixed/builder.rs b/rust/geoarrow/src/array/mixed/builder.rs index 204eda06..3bc4d3f8 100644 --- a/rust/geoarrow/src/array/mixed/builder.rs +++ b/rust/geoarrow/src/array/mixed/builder.rs @@ -28,18 +28,18 @@ pub(crate) const DEFAULT_PREFER_MULTI: bool = false; /// - All arrays must have the same dimension /// - All arrays must have the same coordinate layout (interleaved or separated) #[derive(Debug)] -pub struct MixedGeometryBuilder { +pub struct MixedGeometryBuilder { metadata: Arc, // Invariant: every item in `types` is `> 0 && < fields.len()` types: Vec, - pub(crate) points: PointBuilder, - pub(crate) line_strings: LineStringBuilder, - pub(crate) polygons: PolygonBuilder, - pub(crate) multi_points: MultiPointBuilder, - pub(crate) multi_line_strings: MultiLineStringBuilder, - pub(crate) multi_polygons: MultiPolygonBuilder, + pub(crate) points: PointBuilder, + pub(crate) line_strings: LineStringBuilder, + pub(crate) polygons: PolygonBuilder, + pub(crate) multi_points: MultiPointBuilder, + pub(crate) multi_line_strings: MultiLineStringBuilder, + pub(crate) multi_polygons: MultiPolygonBuilder, // Invariant: `offsets.len() == types.len()` offsets: Vec, @@ -54,7 +54,7 @@ pub struct MixedGeometryBuilder { pub(crate) prefer_multi: bool, } -impl<'a, const D: usize> MixedGeometryBuilder { +impl<'a> MixedGeometryBuilder { /// Creates a new empty [`MixedGeometryBuilder`]. pub fn new() -> Self { Self::new_with_options(Default::default(), Default::default(), DEFAULT_PREFER_MULTI) @@ -177,7 +177,7 @@ impl<'a, const D: usize> MixedGeometryBuilder { // }) // } - pub fn finish(self) -> MixedGeometryArray { + pub fn finish(self) -> MixedGeometryArray { self.into() } @@ -464,13 +464,13 @@ impl<'a, const D: usize> MixedGeometryBuilder { } } -impl Default for MixedGeometryBuilder { +impl Default for MixedGeometryBuilder { fn default() -> Self { Self::new() } } -impl IntoArrow for MixedGeometryBuilder { +impl IntoArrow for MixedGeometryBuilder { type ArrowArray = UnionArray; fn into_arrow(self) -> Self::ArrowArray { @@ -478,8 +478,8 @@ impl IntoArrow for MixedGeometryBuilder { } } -impl From> for MixedGeometryArray { - fn from(other: MixedGeometryBuilder) -> Self { +impl From for MixedGeometryArray { + fn from(other: MixedGeometryBuilder) -> Self { Self::new( other.types.into(), other.offsets.into(), @@ -494,7 +494,7 @@ impl From> for MixedGeometryArray { } } -impl, const D: usize> TryFrom<&[G]> for MixedGeometryBuilder { +impl> TryFrom<&[G]> for MixedGeometryBuilder { type Error = GeoArrowError; fn try_from(geoms: &[G]) -> Result { @@ -502,9 +502,7 @@ impl, const D: usize> TryFrom<&[G]> for MixedGeometryB } } -impl, const D: usize> TryFrom>> - for MixedGeometryBuilder -{ +impl> TryFrom>> for MixedGeometryBuilder { type Error = GeoArrowError; fn try_from(geoms: Vec>) -> Result { @@ -512,7 +510,7 @@ impl, const D: usize> TryFrom>> } } -impl TryFrom> for MixedGeometryBuilder { +impl TryFrom> for MixedGeometryBuilder { type Error = GeoArrowError; fn try_from(value: WKBArray) -> std::result::Result { @@ -528,7 +526,7 @@ impl TryFrom> for MixedGeometryB } } -impl GeometryArrayBuilder for MixedGeometryBuilder { +impl GeometryArrayBuilder for MixedGeometryBuilder { fn len(&self) -> usize { self.types.len() } diff --git a/rust/geoarrow/src/array/multilinestring/array.rs b/rust/geoarrow/src/array/multilinestring/array.rs index ff339a51..ce2c54c5 100644 --- a/rust/geoarrow/src/array/multilinestring/array.rs +++ b/rust/geoarrow/src/array/multilinestring/array.rs @@ -27,7 +27,7 @@ use super::MultiLineStringBuilder; /// This is semantically equivalent to `Vec>` due to the internal validity /// bitmap. #[derive(Debug, Clone)] -pub struct MultiLineStringArray { +pub struct MultiLineStringArray { // Always NativeType::MultiLineString or NativeType::LargeMultiLineString data_type: NativeType, @@ -72,7 +72,7 @@ pub(super) fn check( Ok(()) } -impl MultiLineStringArray { +impl MultiLineStringArray { /// Create a new MultiLineStringArray from parts /// /// # Implementation @@ -118,10 +118,7 @@ impl MultiLineStringArray { &ring_offsets, validity.as_ref().map(|v| v.len()), )?; - - let coord_type = coords.coord_type(); - let data_type = NativeType::MultiLineString(coord_type, D.try_into()?); - + let data_type = NativeType::MultiLineString(coords.coord_type(), coords.dim()); Ok(Self { data_type, coords, @@ -240,7 +237,7 @@ impl MultiLineStringArray { } } -impl ArrayBase for MultiLineStringArray { +impl ArrayBase for MultiLineStringArray { fn as_any(&self) -> &dyn std::any::Any { self } @@ -284,7 +281,7 @@ impl ArrayBase for MultiLineStringArray { } } -impl NativeArray for MultiLineStringArray { +impl NativeArray for MultiLineStringArray { fn data_type(&self) -> NativeType { self.data_type } @@ -316,7 +313,7 @@ impl NativeArray for MultiLineStringArray { } } -impl GeometryArraySelfMethods for MultiLineStringArray { +impl GeometryArraySelfMethods for MultiLineStringArray { fn with_coords(self, coords: CoordBuffer) -> Self { assert_eq!(coords.len(), self.coords.len()); Self::new( @@ -339,8 +336,8 @@ impl GeometryArraySelfMethods for MultiLineStringArray { } } -impl NativeGeometryAccessor for MultiLineStringArray { - unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { +impl NativeGeometryAccessor for MultiLineStringArray { + unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { Geometry::MultiLineString(MultiLineString::new( &self.coords, &self.geom_offsets, @@ -351,19 +348,19 @@ impl NativeGeometryAccessor for MultiLineStringArray { } #[cfg(feature = "geos")] -impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> for MultiLineStringArray { +impl<'a> crate::trait_::NativeGEOSGeometryAccessor<'a> for MultiLineStringArray { unsafe fn value_as_geometry_unchecked( &'a self, index: usize, ) -> std::result::Result { let geom = - MultiLineString::::new(&self.coords, &self.geom_offsets, &self.ring_offsets, index); + MultiLineString::new(&self.coords, &self.geom_offsets, &self.ring_offsets, index); (&geom).try_into() } } -impl<'a, const D: usize> ArrayAccessor<'a> for MultiLineStringArray { - type Item = MultiLineString<'a, D>; +impl<'a> ArrayAccessor<'a> for MultiLineStringArray { + type Item = MultiLineString<'a>; type ItemGeo = geo::MultiLineString; unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item { @@ -371,7 +368,7 @@ impl<'a, const D: usize> ArrayAccessor<'a> for MultiLineStringArray { } } -impl IntoArrow for MultiLineStringArray { +impl IntoArrow for MultiLineStringArray { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { @@ -389,7 +386,7 @@ impl IntoArrow for MultiLineStringArray { } } -impl TryFrom<&GenericListArray> for MultiLineStringArray { +impl TryFrom<&GenericListArray> for MultiLineStringArray { type Error = GeoArrowError; fn try_from(geom_array: &GenericListArray) -> Result { @@ -412,7 +409,7 @@ impl TryFrom<&GenericListArray> for MultiLineStringArray } } -impl TryFrom<&GenericListArray> for MultiLineStringArray { +impl TryFrom<&GenericListArray> for MultiLineStringArray { type Error = GeoArrowError; fn try_from(geom_array: &GenericListArray) -> Result { @@ -435,7 +432,7 @@ impl TryFrom<&GenericListArray> for MultiLineStringArray } } -impl TryFrom<&dyn Array> for MultiLineStringArray { +impl TryFrom<&dyn Array> for MultiLineStringArray { type Error = GeoArrowError; fn try_from(value: &dyn Array) -> Result { @@ -456,7 +453,7 @@ impl TryFrom<&dyn Array> for MultiLineStringArray { } } -impl TryFrom<(&dyn Array, &Field)> for MultiLineStringArray { +impl TryFrom<(&dyn Array, &Field)> for MultiLineStringArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { @@ -467,25 +464,25 @@ impl TryFrom<(&dyn Array, &Field)> for MultiLineStringArray { } impl, const D: usize> From>> - for MultiLineStringArray + for MultiLineStringArray { fn from(other: Vec>) -> Self { - let mut_arr: MultiLineStringBuilder = other.into(); + let mut_arr: MultiLineStringBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From<&[G]> for MultiLineStringArray { +impl, const D: usize> From<&[G]> for MultiLineStringArray { fn from(other: &[G]) -> Self { - let mut_arr: MultiLineStringBuilder = other.into(); + let mut_arr: MultiLineStringBuilder = other.into(); mut_arr.into() } } /// Polygon and MultiLineString have the same layout, so enable conversions between the two to /// change the semantic type -impl From> for PolygonArray { - fn from(value: MultiLineStringArray) -> Self { +impl From for PolygonArray { + fn from(value: MultiLineStringArray) -> Self { Self::new( value.coords, value.geom_offsets, @@ -496,17 +493,17 @@ impl From> for PolygonArray { } } -impl TryFrom> for MultiLineStringArray { +impl TryFrom> for MultiLineStringArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { - let mut_arr: MultiLineStringBuilder = value.try_into()?; + let mut_arr: MultiLineStringBuilder = value.try_into()?; Ok(mut_arr.into()) } } -impl From> for MultiLineStringArray { - fn from(value: LineStringArray) -> Self { +impl From for MultiLineStringArray { + fn from(value: LineStringArray) -> Self { let coords = value.coords; let geom_offsets = OffsetBuffer::from_lengths(vec![1; coords.len()]); let ring_offsets = value.geom_offsets; @@ -516,13 +513,13 @@ impl From> for MultiLineStringArray { } /// Default to an empty array -impl Default for MultiLineStringArray { +impl Default for MultiLineStringArray { fn default() -> Self { MultiLineStringBuilder::default().into() } } -impl PartialEq for MultiLineStringArray { +impl PartialEq for MultiLineStringArray { fn eq(&self, other: &Self) -> bool { if self.validity != other.validity { return false; @@ -544,10 +541,10 @@ impl PartialEq for MultiLineStringArray { } } -impl TryFrom> for MultiLineStringArray { +impl TryFrom for MultiLineStringArray { type Error = GeoArrowError; - fn try_from(value: MixedGeometryArray) -> Result { + fn try_from(value: MixedGeometryArray) -> Result { if value.has_points() || value.has_polygons() || value.has_multi_points() @@ -567,7 +564,7 @@ impl TryFrom> for MultiLineStringArray let mut capacity = value.multi_line_strings.buffer_lengths(); capacity += value.line_strings.buffer_lengths(); - let mut builder = MultiLineStringBuilder::::with_capacity_and_options( + let mut builder = MultiLineStringBuilder::with_capacity_and_options( capacity, value.coord_type(), value.metadata(), @@ -579,10 +576,10 @@ impl TryFrom> for MultiLineStringArray } } -impl TryFrom> for MultiLineStringArray { +impl TryFrom for MultiLineStringArray { type Error = GeoArrowError; - fn try_from(value: GeometryCollectionArray) -> Result { + fn try_from(value: GeometryCollectionArray) -> Result { MixedGeometryArray::try_from(value)?.try_into() } } @@ -599,14 +596,14 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: MultiLineStringArray<2> = vec![ml0(), ml1()].as_slice().into(); + let arr: MultiLineStringArray = vec![ml0(), ml1()].as_slice().into(); assert_eq!(arr.value_as_geo(0), ml0()); assert_eq!(arr.value_as_geo(1), ml1()); } #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: MultiLineStringArray<2> = vec![Some(ml0()), Some(ml1()), None].into(); + let arr: MultiLineStringArray = vec![Some(ml0()), Some(ml1()), None].into(); assert_eq!(arr.get_as_geo(0), Some(ml0())); assert_eq!(arr.get_as_geo(1), Some(ml1())); assert_eq!(arr.get_as_geo(2), None); @@ -614,7 +611,7 @@ mod test { #[test] fn slice() { - let arr: MultiLineStringArray<2> = vec![ml0(), ml1()].as_slice().into(); + let arr: MultiLineStringArray = vec![ml0(), ml1()].as_slice().into(); let sliced = arr.slice(1, 1); assert_eq!(sliced.len(), 1); assert_eq!(sliced.get_as_geo(0), Some(ml1())); @@ -622,7 +619,7 @@ mod test { #[test] fn owned_slice() { - let arr: MultiLineStringArray<2> = vec![ml0(), ml1()].as_slice().into(); + let arr: MultiLineStringArray = vec![ml0(), ml1()].as_slice().into(); let sliced = arr.owned_slice(1, 1); // assert!( @@ -643,7 +640,7 @@ mod test { let geom_arr = example_multilinestring_interleaved(); let wkb_arr = example_multilinestring_wkb(); - let parsed_geom_arr: MultiLineStringArray<2> = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiLineStringArray = wkb_arr.try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } @@ -653,7 +650,7 @@ mod test { let geom_arr = example_multilinestring_separated().into_coord_type(CoordType::Interleaved); let wkb_arr = example_multilinestring_wkb(); - let parsed_geom_arr: MultiLineStringArray<2> = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiLineStringArray = wkb_arr.try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } diff --git a/rust/geoarrow/src/array/multilinestring/builder.rs b/rust/geoarrow/src/array/multilinestring/builder.rs index b9cce2da..64d05367 100644 --- a/rust/geoarrow/src/array/multilinestring/builder.rs +++ b/rust/geoarrow/src/array/multilinestring/builder.rs @@ -8,6 +8,7 @@ use crate::array::{ CoordBufferBuilder, CoordType, InterleavedCoordBufferBuilder, MultiLineStringArray, PolygonBuilder, SeparatedCoordBufferBuilder, WKBArray, }; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::scalar::WKB; use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow}; @@ -20,7 +21,7 @@ use geo_traits::{CoordTrait, GeometryTrait, GeometryType, LineStringTrait, Multi /// /// Converting an [`MultiLineStringBuilder`] into a [`MultiLineStringArray`] is `O(1)`. #[derive(Debug)] -pub struct MultiLineStringBuilder { +pub struct MultiLineStringBuilder { metadata: Arc, pub(crate) coords: CoordBufferBuilder, @@ -35,46 +36,45 @@ pub struct MultiLineStringBuilder { pub(crate) validity: NullBufferBuilder, } -pub type MultiLineStringInner = ( +pub type MultiLineStringInner = ( CoordBufferBuilder, OffsetsBuilder, OffsetsBuilder, NullBufferBuilder, ); -impl MultiLineStringBuilder { +impl MultiLineStringBuilder { /// Creates a new empty [`MultiLineStringBuilder`]. - pub fn new() -> Self { - Self::new_with_options(Default::default(), Default::default()) + pub fn new(dim: Dimension) -> Self { + Self::new_with_options(dim, Default::default(), Default::default()) } - pub fn new_with_options(coord_type: CoordType, metadata: Arc) -> Self { - Self::with_capacity_and_options(Default::default(), coord_type, metadata) + pub fn new_with_options( + dim: Dimension, + coord_type: CoordType, + metadata: Arc, + ) -> Self { + Self::with_capacity_and_options(dim, Default::default(), coord_type, metadata) } /// Creates a new [`MultiLineStringBuilder`] with a capacity. - pub fn with_capacity(capacity: MultiLineStringCapacity) -> Self { + pub fn with_capacity(dim: Dimension, capacity: MultiLineStringCapacity) -> Self { Self::with_capacity_and_options(capacity, Default::default(), Default::default()) } pub fn with_capacity_and_options( + dim: Dimension, capacity: MultiLineStringCapacity, coord_type: CoordType, metadata: Arc, ) -> Self { let coords = match coord_type { - CoordType::Interleaved => { - CoordBufferBuilder::Interleaved(InterleavedCoordBufferBuilder::with_capacity( - capacity.coord_capacity, - D.try_into().unwrap(), - )) - } - CoordType::Separated => { - CoordBufferBuilder::Separated(SeparatedCoordBufferBuilder::with_capacity( - capacity.coord_capacity, - D.try_into().unwrap(), - )) - } + CoordType::Interleaved => CoordBufferBuilder::Interleaved( + InterleavedCoordBufferBuilder::with_capacity(capacity.coord_capacity, dim), + ), + CoordType::Separated => CoordBufferBuilder::Separated( + SeparatedCoordBufferBuilder::with_capacity(capacity.coord_capacity, dim), + ), }; Self { coords, @@ -149,7 +149,7 @@ impl MultiLineStringBuilder { } /// Extract the low-level APIs from the [`MultiLineStringBuilder`]. - pub fn into_inner(self) -> MultiLineStringInner { + pub fn into_inner(self) -> MultiLineStringInner { ( self.coords, self.geom_offsets, @@ -187,7 +187,7 @@ impl MultiLineStringBuilder { Ok(()) } - pub fn finish(self) -> MultiLineStringArray { + pub fn finish(self) -> MultiLineStringArray { self.into() } @@ -400,7 +400,7 @@ impl MultiLineStringBuilder { } } -impl GeometryArrayBuilder for MultiLineStringBuilder { +impl GeometryArrayBuilder for MultiLineStringBuilder { fn new() -> Self { Self::new() } @@ -447,23 +447,23 @@ impl GeometryArrayBuilder for MultiLineStringBuilder { } } -impl IntoArrow for MultiLineStringBuilder { +impl IntoArrow for MultiLineStringBuilder { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { - let arr: MultiLineStringArray = self.into(); + let arr: MultiLineStringArray = self.into(); arr.into_arrow() } } -impl Default for MultiLineStringBuilder { +impl Default for MultiLineStringBuilder { fn default() -> Self { Self::new() } } -impl From> for MultiLineStringArray { - fn from(mut other: MultiLineStringBuilder) -> Self { +impl From for MultiLineStringArray { + fn from(mut other: MultiLineStringBuilder) -> Self { let validity = other.validity.finish(); let geom_offsets: OffsetBuffer = other.geom_offsets.into(); @@ -479,21 +479,19 @@ impl From> for MultiLineStringArray } } -impl, const D: usize> From<&[G]> for MultiLineStringBuilder { +impl> From<&[G]> for MultiLineStringBuilder { fn from(geoms: &[G]) -> Self { Self::from_multi_line_strings(geoms, Default::default(), Default::default()) } } -impl, const D: usize> From>> - for MultiLineStringBuilder -{ +impl> From>> for MultiLineStringBuilder { fn from(geoms: Vec>) -> Self { Self::from_nullable_multi_line_strings(&geoms, Default::default(), Default::default()) } } -impl TryFrom> for MultiLineStringBuilder { +impl TryFrom> for MultiLineStringBuilder { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { @@ -505,8 +503,8 @@ impl TryFrom> for MultiLineStrin /// Polygon and MultiLineString have the same layout, so enable conversions between the two to /// change the semantic type -impl From> for PolygonBuilder { - fn from(value: MultiLineStringBuilder) -> Self { +impl From for PolygonBuilder { + fn from(value: MultiLineStringBuilder) -> Self { Self::try_new( value.coords, value.geom_offsets, diff --git a/rust/geoarrow/src/array/multipoint/array.rs b/rust/geoarrow/src/array/multipoint/array.rs index a5303801..37c9421c 100644 --- a/rust/geoarrow/src/array/multipoint/array.rs +++ b/rust/geoarrow/src/array/multipoint/array.rs @@ -26,7 +26,7 @@ use geo_traits::MultiPointTrait; /// This is semantically equivalent to `Vec>` due to the internal validity /// bitmap. #[derive(Debug, Clone)] -pub struct MultiPointArray { +pub struct MultiPointArray { // Always NativeType::MultiPoint or NativeType::LargeMultiPoint data_type: NativeType, @@ -61,7 +61,7 @@ pub(super) fn check( Ok(()) } -impl MultiPointArray { +impl MultiPointArray { /// Create a new MultiPointArray from parts /// /// # Implementation @@ -98,10 +98,7 @@ impl MultiPointArray { metadata: Arc, ) -> Result { check(&coords, validity.as_ref().map(|v| v.len()), &geom_offsets)?; - - let coord_type = coords.coord_type(); - let data_type = NativeType::MultiPoint(coord_type, D.try_into()?); - + let data_type = NativeType::MultiPoint(coords.coord_type(), coords.dim()); Ok(Self { data_type, coords, @@ -207,7 +204,7 @@ impl MultiPointArray { } } -impl ArrayBase for MultiPointArray { +impl ArrayBase for MultiPointArray { fn as_any(&self) -> &dyn std::any::Any { self } @@ -251,7 +248,7 @@ impl ArrayBase for MultiPointArray { } } -impl NativeArray for MultiPointArray { +impl NativeArray for MultiPointArray { fn data_type(&self) -> NativeType { self.data_type } @@ -283,7 +280,7 @@ impl NativeArray for MultiPointArray { } } -impl GeometryArraySelfMethods for MultiPointArray { +impl GeometryArraySelfMethods for MultiPointArray { fn with_coords(self, coords: CoordBuffer) -> Self { assert_eq!(coords.len(), self.coords.len()); Self::new(coords, self.geom_offsets, self.validity, self.metadata) @@ -299,25 +296,25 @@ impl GeometryArraySelfMethods for MultiPointArray { } } -impl NativeGeometryAccessor for MultiPointArray { - unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { +impl NativeGeometryAccessor for MultiPointArray { + unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { Geometry::MultiPoint(MultiPoint::new(&self.coords, &self.geom_offsets, index)) } } #[cfg(feature = "geos")] -impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> for MultiPointArray { +impl<'a> crate::trait_::NativeGEOSGeometryAccessor<'a> for MultiPointArray { unsafe fn value_as_geometry_unchecked( &'a self, index: usize, ) -> std::result::Result { - let geom = MultiPoint::::new(&self.coords, &self.geom_offsets, index); + let geom = MultiPoint::new(&self.coords, &self.geom_offsets, index); (&geom).try_into() } } -impl<'a, const D: usize> ArrayAccessor<'a> for MultiPointArray { - type Item = MultiPoint<'a, D>; +impl<'a> ArrayAccessor<'a> for MultiPointArray { + type Item = MultiPoint<'a>; type ItemGeo = geo::MultiPoint; unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item { @@ -325,7 +322,7 @@ impl<'a, const D: usize> ArrayAccessor<'a> for MultiPointArray { } } -impl IntoArrow for MultiPointArray { +impl IntoArrow for MultiPointArray { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { @@ -336,7 +333,7 @@ impl IntoArrow for MultiPointArray { } } -impl TryFrom<&GenericListArray> for MultiPointArray { +impl TryFrom<&GenericListArray> for MultiPointArray { type Error = GeoArrowError; fn try_from(value: &GenericListArray) -> Result { @@ -353,7 +350,7 @@ impl TryFrom<&GenericListArray> for MultiPointArray { } } -impl TryFrom<&GenericListArray> for MultiPointArray { +impl TryFrom<&GenericListArray> for MultiPointArray { type Error = GeoArrowError; fn try_from(value: &GenericListArray) -> Result { @@ -370,7 +367,7 @@ impl TryFrom<&GenericListArray> for MultiPointArray { } } -impl TryFrom<&dyn Array> for MultiPointArray { +impl TryFrom<&dyn Array> for MultiPointArray { type Error = GeoArrowError; fn try_from(value: &dyn Array) -> Result { @@ -391,7 +388,7 @@ impl TryFrom<&dyn Array> for MultiPointArray { } } -impl TryFrom<(&dyn Array, &Field)> for MultiPointArray { +impl TryFrom<(&dyn Array, &Field)> for MultiPointArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { @@ -401,33 +398,33 @@ impl TryFrom<(&dyn Array, &Field)> for MultiPointArray { } } -impl, const D: usize> From>> for MultiPointArray { +impl, const D: usize> From>> for MultiPointArray { fn from(other: Vec>) -> Self { - let mut_arr: MultiPointBuilder = other.into(); + let mut_arr: MultiPointBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From<&[G]> for MultiPointArray { +impl, const D: usize> From<&[G]> for MultiPointArray { fn from(other: &[G]) -> Self { - let mut_arr: MultiPointBuilder = other.into(); + let mut_arr: MultiPointBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for MultiPointArray { +impl TryFrom> for MultiPointArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { - let mut_arr: MultiPointBuilder = value.try_into()?; + let mut_arr: MultiPointBuilder = value.try_into()?; Ok(mut_arr.into()) } } /// LineString and MultiPoint have the same layout, so enable conversions between the two to change /// the semantic type -impl From> for LineStringArray { - fn from(value: MultiPointArray) -> Self { +impl From for LineStringArray { + fn from(value: MultiPointArray) -> Self { Self::new( value.coords, value.geom_offsets, @@ -437,8 +434,8 @@ impl From> for LineStringArray { } } -impl From> for MultiPointArray { - fn from(value: PointArray) -> Self { +impl From for MultiPointArray { + fn from(value: PointArray) -> Self { let coords = value.coords; let geom_offsets = OffsetBuffer::from_lengths(vec![1; coords.len()]); let validity = value.validity; @@ -447,13 +444,13 @@ impl From> for MultiPointArray { } /// Default to an empty array -impl Default for MultiPointArray { +impl Default for MultiPointArray { fn default() -> Self { MultiPointBuilder::default().into() } } -impl PartialEq for MultiPointArray { +impl PartialEq for MultiPointArray { fn eq(&self, other: &Self) -> bool { if self.validity != other.validity { return false; @@ -471,10 +468,10 @@ impl PartialEq for MultiPointArray { } } -impl TryFrom> for MultiPointArray { +impl TryFrom for MultiPointArray { type Error = GeoArrowError; - fn try_from(value: MixedGeometryArray) -> Result { + fn try_from(value: MixedGeometryArray) -> Result { if value.has_line_strings() || value.has_polygons() || value.has_multi_line_strings() @@ -496,7 +493,7 @@ impl TryFrom> for MultiPointArray { capacity.coord_capacity += value.points.buffer_lengths(); capacity.geom_capacity += value.points.buffer_lengths(); - let mut builder = MultiPointBuilder::::with_capacity_and_options( + let mut builder = MultiPointBuilder::with_capacity_and_options( capacity, value.coord_type(), value.metadata(), @@ -508,10 +505,10 @@ impl TryFrom> for MultiPointArray { } } -impl TryFrom> for MultiPointArray { +impl TryFrom for MultiPointArray { type Error = GeoArrowError; - fn try_from(value: GeometryCollectionArray) -> Result { + fn try_from(value: GeometryCollectionArray) -> Result { MixedGeometryArray::try_from(value)?.try_into() } } @@ -526,14 +523,14 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: MultiPointArray<2> = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPointArray = vec![mp0(), mp1()].as_slice().into(); assert_eq!(arr.value_as_geo(0), mp0()); assert_eq!(arr.value_as_geo(1), mp1()); } #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: MultiPointArray<2> = vec![Some(mp0()), Some(mp1()), None].into(); + let arr: MultiPointArray = vec![Some(mp0()), Some(mp1()), None].into(); assert_eq!(arr.get_as_geo(0), Some(mp0())); assert_eq!(arr.get_as_geo(1), Some(mp1())); assert_eq!(arr.get_as_geo(2), None); @@ -541,7 +538,7 @@ mod test { #[test] fn slice() { - let arr: MultiPointArray<2> = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPointArray = vec![mp0(), mp1()].as_slice().into(); let sliced = arr.slice(1, 1); assert_eq!(sliced.len(), 1); assert_eq!(sliced.get_as_geo(0), Some(mp1())); @@ -549,7 +546,7 @@ mod test { #[test] fn owned_slice() { - let arr: MultiPointArray<2> = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPointArray = vec![mp0(), mp1()].as_slice().into(); let sliced = arr.owned_slice(1, 1); // assert!( @@ -566,7 +563,7 @@ mod test { let geom_arr = example_multipoint_interleaved(); let wkb_arr = example_multipoint_wkb(); - let parsed_geom_arr: MultiPointArray<2> = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiPointArray = wkb_arr.try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } @@ -577,7 +574,7 @@ mod test { let geom_arr = example_multipoint_separated().into_coord_type(CoordType::Interleaved); let wkb_arr = example_multipoint_wkb(); - let parsed_geom_arr: MultiPointArray<2> = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiPointArray = wkb_arr.try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } diff --git a/rust/geoarrow/src/array/multipoint/builder.rs b/rust/geoarrow/src/array/multipoint/builder.rs index 572397fb..aa0b533e 100644 --- a/rust/geoarrow/src/array/multipoint/builder.rs +++ b/rust/geoarrow/src/array/multipoint/builder.rs @@ -19,7 +19,7 @@ use geo_traits::{CoordTrait, GeometryTrait, GeometryType, MultiPointTrait, Point /// /// Converting an [`MultiPointBuilder`] into a [`MultiPointArray`] is `O(1)`. #[derive(Debug)] -pub struct MultiPointBuilder { +pub struct MultiPointBuilder { metadata: Arc, coords: CoordBufferBuilder, @@ -30,7 +30,7 @@ pub struct MultiPointBuilder { validity: NullBufferBuilder, } -impl MultiPointBuilder { +impl MultiPointBuilder { /// Creates a new empty [`MultiPointBuilder`]. pub fn new() -> Self { Self::new_with_options(Default::default(), Default::default()) @@ -140,7 +140,7 @@ impl MultiPointBuilder { Arc::new(self.into_arrow()) } - pub fn finish(self) -> MultiPointArray { + pub fn finish(self) -> MultiPointArray { self.into() } @@ -340,13 +340,13 @@ impl MultiPointBuilder { } } -impl Default for MultiPointBuilder { +impl Default for MultiPointBuilder { fn default() -> Self { Self::new() } } -impl GeometryArrayBuilder for MultiPointBuilder { +impl GeometryArrayBuilder for MultiPointBuilder { fn new() -> Self { Self::new() } @@ -393,17 +393,17 @@ impl GeometryArrayBuilder for MultiPointBuilder { } } -impl IntoArrow for MultiPointBuilder { +impl IntoArrow for MultiPointBuilder { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { - let arr: MultiPointArray = self.into(); + let arr: MultiPointArray = self.into(); arr.into_arrow() } } -impl From> for MultiPointArray { - fn from(mut other: MultiPointBuilder) -> Self { +impl From for MultiPointArray { + fn from(mut other: MultiPointBuilder) -> Self { let validity = other.validity.finish(); // TODO: impl shrink_to_fit for all mutable -> * impls @@ -419,25 +419,25 @@ impl From> for MultiPointArray { } } -impl From> for GenericListArray { - fn from(arr: MultiPointBuilder) -> Self { +impl From for GenericListArray { + fn from(arr: MultiPointBuilder) -> Self { arr.into_arrow() } } -impl, const D: usize> From<&[G]> for MultiPointBuilder { +impl, const D: usize> From<&[G]> for MultiPointBuilder { fn from(geoms: &[G]) -> Self { Self::from_multi_points(geoms, Default::default(), Default::default()) } } -impl, const D: usize> From>> for MultiPointBuilder { +impl, const D: usize> From>> for MultiPointBuilder { fn from(geoms: Vec>) -> Self { Self::from_nullable_multi_points(&geoms, Default::default(), Default::default()) } } -impl TryFrom> for MultiPointBuilder { +impl TryFrom> for MultiPointBuilder { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { @@ -449,8 +449,8 @@ impl TryFrom> for MultiPointBuil /// LineString and MultiPoint have the same layout, so enable conversions between the two to change /// the semantic type -impl From> for LineStringBuilder { - fn from(value: MultiPointBuilder) -> Self { +impl From for LineStringBuilder { + fn from(value: MultiPointBuilder) -> Self { Self::try_new( value.coords, value.geom_offsets, diff --git a/rust/geoarrow/src/array/multipolygon/array.rs b/rust/geoarrow/src/array/multipolygon/array.rs index ddcde59f..5fe8a981 100644 --- a/rust/geoarrow/src/array/multipolygon/array.rs +++ b/rust/geoarrow/src/array/multipolygon/array.rs @@ -27,7 +27,7 @@ use super::MultiPolygonBuilder; /// This is semantically equivalent to `Vec>` due to the internal validity /// bitmap. #[derive(Debug, Clone)] -pub struct MultiPolygonArray { +pub struct MultiPolygonArray { // Always NativeType::MultiPolygon or NativeType::LargeMultiPolygon data_type: NativeType, @@ -81,7 +81,7 @@ pub(super) fn check( Ok(()) } -impl MultiPolygonArray { +impl MultiPolygonArray { /// Create a new MultiPolygonArray from parts /// /// # Implementation @@ -140,10 +140,7 @@ impl MultiPolygonArray { &ring_offsets, validity.as_ref().map(|v| v.len()), )?; - - let coord_type = coords.coord_type(); - let data_type = NativeType::MultiPolygon(coord_type, D.try_into()?); - + let data_type = NativeType::MultiPolygon(coords.coord_type(), coords.dim()); Ok(Self { data_type, coords, @@ -302,7 +299,7 @@ impl MultiPolygonArray { } } -impl ArrayBase for MultiPolygonArray { +impl ArrayBase for MultiPolygonArray { fn as_any(&self) -> &dyn std::any::Any { self } @@ -346,7 +343,7 @@ impl ArrayBase for MultiPolygonArray { } } -impl NativeArray for MultiPolygonArray { +impl NativeArray for MultiPolygonArray { fn data_type(&self) -> NativeType { self.data_type } @@ -378,7 +375,7 @@ impl NativeArray for MultiPolygonArray { } } -impl GeometryArraySelfMethods for MultiPolygonArray { +impl GeometryArraySelfMethods for MultiPolygonArray { fn with_coords(self, coords: CoordBuffer) -> Self { assert_eq!(coords.len(), self.coords.len()); Self::new( @@ -403,8 +400,8 @@ impl GeometryArraySelfMethods for MultiPolygonArray { } } -impl NativeGeometryAccessor for MultiPolygonArray { - unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { +impl NativeGeometryAccessor for MultiPolygonArray { + unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { Geometry::MultiPolygon(MultiPolygon::new( &self.coords, &self.geom_offsets, @@ -416,12 +413,12 @@ impl NativeGeometryAccessor for MultiPolygonArray { } #[cfg(feature = "geos")] -impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> for MultiPolygonArray { +impl<'a> crate::trait_::NativeGEOSGeometryAccessor<'a> for MultiPolygonArray { unsafe fn value_as_geometry_unchecked( &'a self, index: usize, ) -> std::result::Result { - let geom = MultiPolygon::::new( + let geom = MultiPolygon::new( &self.coords, &self.geom_offsets, &self.polygon_offsets, @@ -432,8 +429,8 @@ impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> for Multi } } -impl<'a, const D: usize> ArrayAccessor<'a> for MultiPolygonArray { - type Item = MultiPolygon<'a, D>; +impl<'a> ArrayAccessor<'a> for MultiPolygonArray { + type Item = MultiPolygon<'a>; type ItemGeo = geo::MultiPolygon; unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item { @@ -447,7 +444,7 @@ impl<'a, const D: usize> ArrayAccessor<'a> for MultiPolygonArray { } } -impl IntoArrow for MultiPolygonArray { +impl IntoArrow for MultiPolygonArray { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { @@ -473,7 +470,7 @@ impl IntoArrow for MultiPolygonArray { } } -impl TryFrom<&GenericListArray> for MultiPolygonArray { +impl TryFrom<&GenericListArray> for MultiPolygonArray { type Error = GeoArrowError; fn try_from(geom_array: &GenericListArray) -> Result { @@ -501,7 +498,7 @@ impl TryFrom<&GenericListArray> for MultiPolygonArray { } } -impl TryFrom<&GenericListArray> for MultiPolygonArray { +impl TryFrom<&GenericListArray> for MultiPolygonArray { type Error = GeoArrowError; fn try_from(geom_array: &GenericListArray) -> Result { @@ -529,7 +526,7 @@ impl TryFrom<&GenericListArray> for MultiPolygonArray { } } -impl TryFrom<&dyn Array> for MultiPolygonArray { +impl TryFrom<&dyn Array> for MultiPolygonArray { type Error = GeoArrowError; fn try_from(value: &dyn Array) -> Result { @@ -550,7 +547,7 @@ impl TryFrom<&dyn Array> for MultiPolygonArray { } } -impl TryFrom<(&dyn Array, &Field)> for MultiPolygonArray { +impl TryFrom<(&dyn Array, &Field)> for MultiPolygonArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { @@ -560,31 +557,31 @@ impl TryFrom<(&dyn Array, &Field)> for MultiPolygonArray { } } -impl, const D: usize> From>> for MultiPolygonArray { +impl, const D: usize> From>> for MultiPolygonArray { fn from(other: Vec>) -> Self { - let mut_arr: MultiPolygonBuilder = other.into(); + let mut_arr: MultiPolygonBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From<&[G]> for MultiPolygonArray { +impl, const D: usize> From<&[G]> for MultiPolygonArray { fn from(other: &[G]) -> Self { - let mut_arr: MultiPolygonBuilder = other.into(); + let mut_arr: MultiPolygonBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for MultiPolygonArray { +impl TryFrom> for MultiPolygonArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { - let mut_arr: MultiPolygonBuilder = value.try_into()?; + let mut_arr: MultiPolygonBuilder = value.try_into()?; Ok(mut_arr.into()) } } -impl From> for MultiPolygonArray { - fn from(value: PolygonArray) -> Self { +impl From for MultiPolygonArray { + fn from(value: PolygonArray) -> Self { let coords = value.coords; let geom_offsets = OffsetBuffer::from_lengths(vec![1; coords.len()]); let ring_offsets = value.ring_offsets; @@ -602,13 +599,13 @@ impl From> for MultiPolygonArray { } /// Default to an empty array -impl Default for MultiPolygonArray { +impl Default for MultiPolygonArray { fn default() -> Self { MultiPolygonBuilder::default().into() } } -impl PartialEq for MultiPolygonArray { +impl PartialEq for MultiPolygonArray { fn eq(&self, other: &Self) -> bool { if self.validity != other.validity { return false; @@ -634,10 +631,10 @@ impl PartialEq for MultiPolygonArray { } } -impl TryFrom> for MultiPolygonArray { +impl TryFrom for MultiPolygonArray { type Error = GeoArrowError; - fn try_from(value: MixedGeometryArray) -> Result { + fn try_from(value: MixedGeometryArray) -> Result { if value.has_points() || value.has_line_strings() || value.has_multi_points() @@ -657,7 +654,7 @@ impl TryFrom> for MultiPolygonArray { let mut capacity = value.multi_polygons.buffer_lengths(); capacity += value.polygons.buffer_lengths(); - let mut builder = MultiPolygonBuilder::::with_capacity_and_options( + let mut builder = MultiPolygonBuilder::with_capacity_and_options( capacity, value.coord_type(), value.metadata(), @@ -669,10 +666,10 @@ impl TryFrom> for MultiPolygonArray { } } -impl TryFrom> for MultiPolygonArray { +impl TryFrom for MultiPolygonArray { type Error = GeoArrowError; - fn try_from(value: GeometryCollectionArray) -> Result { + fn try_from(value: GeometryCollectionArray) -> Result { MixedGeometryArray::try_from(value)?.try_into() } } @@ -687,14 +684,14 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: MultiPolygonArray<2> = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPolygonArray = vec![mp0(), mp1()].as_slice().into(); assert_eq!(arr.value_as_geo(0), mp0()); assert_eq!(arr.value_as_geo(1), mp1()); } #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: MultiPolygonArray<2> = vec![Some(mp0()), Some(mp1()), None].into(); + let arr: MultiPolygonArray = vec![Some(mp0()), Some(mp1()), None].into(); assert_eq!(arr.get_as_geo(0), Some(mp0())); assert_eq!(arr.get_as_geo(1), Some(mp1())); assert_eq!(arr.get_as_geo(2), None); @@ -702,7 +699,7 @@ mod test { #[test] fn slice() { - let arr: MultiPolygonArray<2> = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPolygonArray = vec![mp0(), mp1()].as_slice().into(); let sliced = arr.slice(1, 1); assert_eq!(sliced.len(), 1); assert_eq!(sliced.get_as_geo(0), Some(mp1())); @@ -710,7 +707,7 @@ mod test { #[test] fn owned_slice() { - let arr: MultiPolygonArray<2> = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPolygonArray = vec![mp0(), mp1()].as_slice().into(); let sliced = arr.owned_slice(1, 1); // assert!( @@ -731,7 +728,7 @@ mod test { let geom_arr = example_multipolygon_interleaved(); let wkb_arr = example_multipolygon_wkb(); - let parsed_geom_arr: MultiPolygonArray<2> = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiPolygonArray = wkb_arr.try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } @@ -742,7 +739,7 @@ mod test { let geom_arr = example_multipolygon_separated().into_coord_type(CoordType::Interleaved); let wkb_arr = example_multipolygon_wkb(); - let parsed_geom_arr: MultiPolygonArray<2> = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiPolygonArray = wkb_arr.try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } diff --git a/rust/geoarrow/src/array/multipolygon/builder.rs b/rust/geoarrow/src/array/multipolygon/builder.rs index 40684084..0acf5338 100644 --- a/rust/geoarrow/src/array/multipolygon/builder.rs +++ b/rust/geoarrow/src/array/multipolygon/builder.rs @@ -17,7 +17,7 @@ use geo_traits::{ CoordTrait, GeometryTrait, GeometryType, LineStringTrait, MultiPolygonTrait, PolygonTrait, }; -pub type MutableMultiPolygonParts = ( +pub type MutableMultiPolygonParts = ( CoordBufferBuilder, OffsetsBuilder, OffsetsBuilder, @@ -29,7 +29,7 @@ pub type MutableMultiPolygonParts = ( /// /// Converting an [`MultiPolygonBuilder`] into a [`MultiPolygonArray`] is `O(1)`. #[derive(Debug)] -pub struct MultiPolygonBuilder { +pub struct MultiPolygonBuilder { metadata: Arc, pub(crate) coords: CoordBufferBuilder, @@ -47,7 +47,7 @@ pub struct MultiPolygonBuilder { pub(crate) validity: NullBufferBuilder, } -impl MultiPolygonBuilder { +impl MultiPolygonBuilder { /// Creates a new empty [`MultiPolygonBuilder`]. pub fn new() -> Self { Self::new_with_options(Default::default(), Default::default()) @@ -163,7 +163,7 @@ impl MultiPolygonBuilder { } /// Extract the low-level APIs from the [`MultiPolygonBuilder`]. - pub fn into_inner(self) -> MutableMultiPolygonParts { + pub fn into_inner(self) -> MutableMultiPolygonParts { ( self.coords, self.geom_offsets, @@ -177,7 +177,7 @@ impl MultiPolygonBuilder { Arc::new(self.into_arrow()) } - pub fn finish(self) -> MultiPolygonArray { + pub fn finish(self) -> MultiPolygonArray { self.into() } @@ -460,13 +460,13 @@ impl MultiPolygonBuilder { } } -impl Default for MultiPolygonBuilder { +impl Default for MultiPolygonBuilder { fn default() -> Self { Self::new() } } -impl GeometryArrayBuilder for MultiPolygonBuilder { +impl GeometryArrayBuilder for MultiPolygonBuilder { fn new() -> Self { Self::new() } @@ -518,17 +518,17 @@ impl GeometryArrayBuilder for MultiPolygonBuilder { } } -impl IntoArrow for MultiPolygonBuilder { +impl IntoArrow for MultiPolygonBuilder { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { - let arr: MultiPolygonArray = self.into(); + let arr: MultiPolygonArray = self.into(); arr.into_arrow() } } -impl From> for MultiPolygonArray { - fn from(mut other: MultiPolygonBuilder) -> Self { +impl From for MultiPolygonArray { + fn from(mut other: MultiPolygonBuilder) -> Self { let validity = other.validity.finish(); let geom_offsets: OffsetBuffer = other.geom_offsets.into(); @@ -546,21 +546,19 @@ impl From> for MultiPolygonArray { } } -impl, const D: usize> From<&[G]> for MultiPolygonBuilder { +impl, const D: usize> From<&[G]> for MultiPolygonBuilder { fn from(geoms: &[G]) -> Self { Self::from_multi_polygons(geoms, Default::default(), Default::default()) } } -impl, const D: usize> From>> - for MultiPolygonBuilder -{ +impl, const D: usize> From>> for MultiPolygonBuilder { fn from(geoms: Vec>) -> Self { Self::from_nullable_multi_polygons(&geoms, Default::default(), Default::default()) } } -impl TryFrom> for MultiPolygonBuilder { +impl TryFrom> for MultiPolygonBuilder { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { diff --git a/rust/geoarrow/src/array/point/array.rs b/rust/geoarrow/src/array/point/array.rs index a628a65a..f188b924 100644 --- a/rust/geoarrow/src/array/point/array.rs +++ b/rust/geoarrow/src/array/point/array.rs @@ -23,7 +23,7 @@ use arrow_schema::{DataType, Field}; /// /// This is semantically equivalent to `Vec>` due to the internal validity bitmap. #[derive(Debug, Clone)] -pub struct PointArray { +pub struct PointArray { // Always NativeType::Point data_type: NativeType, pub(crate) metadata: Arc, @@ -41,7 +41,7 @@ pub(super) fn check(coords: &CoordBuffer, validity_len: Option) -> Result Ok(()) } -impl PointArray { +impl PointArray { /// Create a new PointArray from parts /// /// # Implementation @@ -74,7 +74,7 @@ impl PointArray { metadata: Arc, ) -> Result { check(&coords, validity.as_ref().map(|v| v.len()))?; - let data_type = NativeType::Point(coords.coord_type(), D.try_into()?); + let data_type = NativeType::Point(coords.coord_type(), coords.dim()); Ok(Self { data_type, coords, @@ -146,7 +146,7 @@ impl PointArray { } } -impl ArrayBase for PointArray { +impl ArrayBase for PointArray { fn as_any(&self) -> &dyn std::any::Any { self } @@ -190,7 +190,7 @@ impl ArrayBase for PointArray { } } -impl NativeArray for PointArray { +impl NativeArray for PointArray { fn data_type(&self) -> NativeType { self.data_type } @@ -222,7 +222,7 @@ impl NativeArray for PointArray { } } -impl GeometryArraySelfMethods for PointArray { +impl GeometryArraySelfMethods for PointArray { fn with_coords(self, coords: CoordBuffer) -> Self { assert_eq!(coords.len(), self.coords.len()); Self::new(coords, self.validity, self.metadata) @@ -233,25 +233,25 @@ impl GeometryArraySelfMethods for PointArray { } } -impl NativeGeometryAccessor for PointArray { - unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { +impl NativeGeometryAccessor for PointArray { + unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { Geometry::Point(Point::new(&self.coords, index)) } } #[cfg(feature = "geos")] -impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> for PointArray { +impl<'a> crate::trait_::NativeGEOSGeometryAccessor<'a> for PointArray { unsafe fn value_as_geometry_unchecked( &'a self, index: usize, ) -> std::result::Result { - let geom = Point::::new(&self.coords, index); + let geom = Point::new(&self.coords, index); (&geom).try_into() } } -impl<'a, const D: usize> ArrayAccessor<'a> for PointArray { - type Item = Point<'a, D>; +impl<'a> ArrayAccessor<'a> for PointArray { + type Item = Point<'a>; type ItemGeo = geo::Point; unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item { @@ -259,7 +259,7 @@ impl<'a, const D: usize> ArrayAccessor<'a> for PointArray { } } -impl IntoArrow for PointArray { +impl IntoArrow for PointArray { type ArrowArray = Arc; fn into_arrow(self) -> Self::ArrowArray { @@ -279,7 +279,7 @@ impl IntoArrow for PointArray { } } -impl TryFrom<&FixedSizeListArray> for PointArray { +impl TryFrom<&FixedSizeListArray> for PointArray { type Error = GeoArrowError; fn try_from(value: &FixedSizeListArray) -> Result { @@ -293,7 +293,7 @@ impl TryFrom<&FixedSizeListArray> for PointArray { } } -impl TryFrom<&StructArray> for PointArray { +impl TryFrom<&StructArray> for PointArray { type Error = GeoArrowError; fn try_from(value: &StructArray) -> Result { @@ -307,7 +307,7 @@ impl TryFrom<&StructArray> for PointArray { } } -impl TryFrom<&dyn Array> for PointArray { +impl TryFrom<&dyn Array> for PointArray { type Error = GeoArrowError; fn try_from(value: &dyn Array) -> Result { @@ -327,7 +327,7 @@ impl TryFrom<&dyn Array> for PointArray { } } -impl TryFrom<(&dyn Array, &Field)> for PointArray { +impl TryFrom<(&dyn Array, &Field)> for PointArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { @@ -337,31 +337,31 @@ impl TryFrom<(&dyn Array, &Field)> for PointArray { } } -impl, const D: usize> From>> for PointArray { +impl, const D: usize> From>> for PointArray { fn from(other: Vec>) -> Self { - let mut_arr: PointBuilder = other.into(); + let mut_arr: PointBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From<&[G]> for PointArray { +impl, const D: usize> From<&[G]> for PointArray { fn from(other: &[G]) -> Self { - let mut_arr: PointBuilder = other.into(); + let mut_arr: PointBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for PointArray { +impl TryFrom> for PointArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { - let mut_arr: PointBuilder = value.try_into()?; + let mut_arr: PointBuilder = value.try_into()?; Ok(mut_arr.into()) } } /// Default to an empty array -impl Default for PointArray { +impl Default for PointArray { fn default() -> Self { PointBuilder::default().into() } @@ -369,7 +369,7 @@ impl Default for PointArray { // Implement a custom PartialEq for PointArray to allow Point(EMPTY) comparisons, which is stored // as (NaN, NaN). By default, these resolve to false -impl PartialEq for PointArray { +impl PartialEq for PointArray { fn eq(&self, other: &Self) -> bool { if self.validity != other.validity { return false; @@ -398,10 +398,10 @@ impl PartialEq for PointArray { } } -impl TryFrom> for PointArray { +impl TryFrom for PointArray { type Error = GeoArrowError; - fn try_from(value: MultiPointArray) -> Result { + fn try_from(value: MultiPointArray) -> Result { if !can_downcast_multi(&value.geom_offsets) { return Err(GeoArrowError::General("Unable to cast".to_string())); } @@ -414,10 +414,10 @@ impl TryFrom> for PointArray { } } -impl TryFrom> for PointArray { +impl TryFrom for PointArray { type Error = GeoArrowError; - fn try_from(value: MixedGeometryArray) -> Result { + fn try_from(value: MixedGeometryArray) -> Result { if value.has_line_strings() || value.has_polygons() || value.has_multi_line_strings() @@ -434,7 +434,7 @@ impl TryFrom> for PointArray { return value.multi_points.try_into(); } - let mut builder = PointBuilder::::with_capacity_and_options( + let mut builder = PointBuilder::with_capacity_and_options( value.len(), value.coord_type(), value.metadata(), @@ -446,10 +446,10 @@ impl TryFrom> for PointArray { } } -impl TryFrom> for PointArray { +impl TryFrom for PointArray { type Error = GeoArrowError; - fn try_from(value: GeometryCollectionArray) -> Result { + fn try_from(value: GeometryCollectionArray) -> Result { MixedGeometryArray::try_from(value)?.try_into() } } @@ -466,7 +466,7 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: PointArray<2> = vec![p0(), p1(), p2()].as_slice().into(); + let arr: PointArray = vec![p0(), p1(), p2()].as_slice().into(); assert_eq!(arr.value_as_geo(0), p0()); assert_eq!(arr.value_as_geo(1), p1()); assert_eq!(arr.value_as_geo(2), p2()); @@ -474,7 +474,7 @@ mod test { #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: PointArray<2> = vec![Some(p0()), Some(p1()), Some(p2()), None].into(); + let arr: PointArray = vec![Some(p0()), Some(p1()), Some(p2()), None].into(); assert_eq!(arr.get_as_geo(0), Some(p0())); assert_eq!(arr.get_as_geo(1), Some(p1())); assert_eq!(arr.get_as_geo(2), Some(p2())); @@ -484,7 +484,7 @@ mod test { #[test] fn slice() { let points: Vec = vec![p0(), p1(), p2()]; - let point_array: PointArray<2> = points.as_slice().into(); + let point_array: PointArray = points.as_slice().into(); let sliced = point_array.slice(1, 1); assert_eq!(sliced.len(), 1); assert_eq!(sliced.get_as_geo(0), Some(p1())); @@ -493,7 +493,7 @@ mod test { #[test] fn owned_slice() { let points: Vec = vec![p0(), p1(), p2()]; - let point_array: PointArray<2> = points.as_slice().into(); + let point_array: PointArray = points.as_slice().into(); let sliced = point_array.owned_slice(1, 1); assert_eq!(point_array.len(), 3); @@ -507,7 +507,7 @@ mod test { let geom_arr = example_point_interleaved(); let wkb_arr = example_point_wkb(); - let parsed_geom_arr: PointArray<2> = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: PointArray = wkb_arr.try_into().unwrap(); // Comparisons on the point array directly currently fail because of NaN values in // coordinate 1. @@ -520,7 +520,7 @@ mod test { let geom_arr = example_point_separated(); let wkb_arr = example_point_wkb(); - let parsed_geom_arr: PointArray<2> = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: PointArray = wkb_arr.try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } diff --git a/rust/geoarrow/src/array/point/builder.rs b/rust/geoarrow/src/array/point/builder.rs index 78a53c2e..3bff24fe 100644 --- a/rust/geoarrow/src/array/point/builder.rs +++ b/rust/geoarrow/src/array/point/builder.rs @@ -18,13 +18,13 @@ use geo_traits::{CoordTrait, GeometryTrait, GeometryType, MultiPointTrait, Point /// /// Converting an [`PointBuilder`] into a [`PointArray`] is `O(1)`. #[derive(Debug)] -pub struct PointBuilder { +pub struct PointBuilder { metadata: Arc, pub coords: CoordBufferBuilder, pub validity: NullBufferBuilder, } -impl PointBuilder { +impl PointBuilder { /// Creates a new empty [`PointBuilder`]. pub fn new() -> Self { Self::new_with_options(Default::default(), Default::default()) @@ -114,7 +114,7 @@ impl PointBuilder { (self.coords, self.validity) } - pub fn finish(self) -> PointArray { + pub fn finish(self) -> PointArray { self.into() } @@ -272,7 +272,7 @@ impl PointBuilder { } } -impl GeometryArrayBuilder for PointBuilder { +impl GeometryArrayBuilder for PointBuilder { fn new() -> Self { Self::new() } @@ -318,41 +318,41 @@ impl GeometryArrayBuilder for PointBuilder { } } -impl Default for PointBuilder { +impl Default for PointBuilder { fn default() -> Self { Self::new() } } -impl IntoArrow for PointBuilder { +impl IntoArrow for PointBuilder { type ArrowArray = Arc; fn into_arrow(self) -> Self::ArrowArray { - let point_array: PointArray = self.into(); + let point_array: PointArray = self.into(); point_array.into_arrow() } } -impl From> for PointArray { - fn from(mut other: PointBuilder) -> Self { +impl From for PointArray { + fn from(mut other: PointBuilder) -> Self { let validity = other.validity.finish(); Self::new(other.coords.into(), validity, other.metadata) } } -impl From> for Arc { - fn from(arr: PointBuilder) -> Self { +impl From for Arc { + fn from(arr: PointBuilder) -> Self { arr.into_array_ref() } } -impl> From<&[G]> for PointBuilder { +impl> From<&[G]> for PointBuilder { fn from(value: &[G]) -> Self { PointBuilder::from_points(value.iter(), Default::default(), Default::default()) } } -impl> From>> for PointBuilder { +impl> From>> for PointBuilder { fn from(geoms: Vec>) -> Self { PointBuilder::from_nullable_points( geoms.iter().map(|x| x.as_ref()), @@ -362,7 +362,7 @@ impl> From>> for PointBuild } } -impl TryFrom> for PointBuilder { +impl TryFrom> for PointBuilder { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { diff --git a/rust/geoarrow/src/array/polygon/array.rs b/rust/geoarrow/src/array/polygon/array.rs index d2eef407..92150ceb 100644 --- a/rust/geoarrow/src/array/polygon/array.rs +++ b/rust/geoarrow/src/array/polygon/array.rs @@ -30,7 +30,7 @@ use super::PolygonBuilder; /// This is semantically equivalent to `Vec>` due to the internal validity bitmap. #[derive(Debug, Clone)] // #[derive(Debug, Clone, PartialEq)] -pub struct PolygonArray { +pub struct PolygonArray { // Always NativeType::Polygon or NativeType::LargePolygon data_type: NativeType, @@ -75,7 +75,7 @@ pub(super) fn check( Ok(()) } -impl PolygonArray { +impl PolygonArray { /// Create a new PolygonArray from parts /// /// # Implementation @@ -121,10 +121,7 @@ impl PolygonArray { &ring_offsets, validity.as_ref().map(|v| v.len()), )?; - - let coord_type = coords.coord_type(); - let data_type = NativeType::Polygon(coord_type, D.try_into()?); - + let data_type = NativeType::Polygon(coords.coord_type(), coords.dim()); Ok(Self { data_type, coords, @@ -244,7 +241,7 @@ impl PolygonArray { } } -impl ArrayBase for PolygonArray { +impl ArrayBase for PolygonArray { fn as_any(&self) -> &dyn std::any::Any { self } @@ -288,7 +285,7 @@ impl ArrayBase for PolygonArray { } } -impl NativeArray for PolygonArray { +impl NativeArray for PolygonArray { fn data_type(&self) -> NativeType { self.data_type } @@ -320,7 +317,7 @@ impl NativeArray for PolygonArray { } } -impl GeometryArraySelfMethods for PolygonArray { +impl GeometryArraySelfMethods for PolygonArray { fn with_coords(self, coords: CoordBuffer) -> Self { assert_eq!(coords.len(), self.coords.len()); Self::new( @@ -343,8 +340,8 @@ impl GeometryArraySelfMethods for PolygonArray { } } -impl NativeGeometryAccessor for PolygonArray { - unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { +impl NativeGeometryAccessor for PolygonArray { + unsafe fn value_as_geometry_unchecked(&self, index: usize) -> crate::scalar::Geometry { Geometry::Polygon(Polygon::new( &self.coords, &self.geom_offsets, @@ -355,18 +352,18 @@ impl NativeGeometryAccessor for PolygonArray { } #[cfg(feature = "geos")] -impl<'a, const D: usize> crate::trait_::NativeGEOSGeometryAccessor<'a> for PolygonArray { +impl<'a> crate::trait_::NativeGEOSGeometryAccessor<'a> for PolygonArray { unsafe fn value_as_geometry_unchecked( &'a self, index: usize, ) -> std::result::Result { - let geom = Polygon::::new(&self.coords, &self.geom_offsets, &self.ring_offsets, index); + let geom = Polygon::new(&self.coords, &self.geom_offsets, &self.ring_offsets, index); (&geom).try_into() } } -impl<'a, const D: usize> ArrayAccessor<'a> for PolygonArray { - type Item = Polygon<'a, D>; +impl<'a> ArrayAccessor<'a> for PolygonArray { + type Item = Polygon<'a>; type ItemGeo = geo::Polygon; unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item { @@ -374,7 +371,7 @@ impl<'a, const D: usize> ArrayAccessor<'a> for PolygonArray { } } -impl IntoArrow for PolygonArray { +impl IntoArrow for PolygonArray { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { @@ -392,7 +389,7 @@ impl IntoArrow for PolygonArray { } } -impl TryFrom<&GenericListArray> for PolygonArray { +impl TryFrom<&GenericListArray> for PolygonArray { type Error = GeoArrowError; fn try_from(geom_array: &GenericListArray) -> Result { @@ -415,7 +412,7 @@ impl TryFrom<&GenericListArray> for PolygonArray { } } -impl TryFrom<&GenericListArray> for PolygonArray { +impl TryFrom<&GenericListArray> for PolygonArray { type Error = GeoArrowError; fn try_from(geom_array: &GenericListArray) -> Result { @@ -437,7 +434,7 @@ impl TryFrom<&GenericListArray> for PolygonArray { )) } } -impl TryFrom<&dyn Array> for PolygonArray { +impl TryFrom<&dyn Array> for PolygonArray { type Error = GeoArrowError; fn try_from(value: &dyn Array) -> Result { @@ -458,7 +455,7 @@ impl TryFrom<&dyn Array> for PolygonArray { } } -impl TryFrom<(&dyn Array, &Field)> for PolygonArray { +impl TryFrom<(&dyn Array, &Field)> for PolygonArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { @@ -468,33 +465,33 @@ impl TryFrom<(&dyn Array, &Field)> for PolygonArray { } } -impl, const D: usize> From>> for PolygonArray { +impl> From>> for PolygonArray { fn from(other: Vec>) -> Self { - let mut_arr: PolygonBuilder = other.into(); + let mut_arr: PolygonBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From<&[G]> for PolygonArray { +impl> From<&[G]> for PolygonArray { fn from(other: &[G]) -> Self { - let mut_arr: PolygonBuilder = other.into(); + let mut_arr: PolygonBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for PolygonArray { +impl TryFrom> for PolygonArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { - let mut_arr: PolygonBuilder = value.try_into()?; + let mut_arr: PolygonBuilder = value.try_into()?; Ok(mut_arr.into()) } } /// Polygon and MultiLineString have the same layout, so enable conversions between the two to /// change the semantic type -impl From> for MultiLineStringArray { - fn from(value: PolygonArray) -> Self { +impl From for MultiLineStringArray { + fn from(value: PolygonArray) -> Self { Self::new( value.coords, value.geom_offsets, @@ -505,8 +502,8 @@ impl From> for MultiLineStringArray { } } -impl From> for PolygonArray<2> { - fn from(value: RectArray<2>) -> Self { +impl From for PolygonArray { + fn from(value: RectArray) -> Self { // The number of output geoms is the same as the input let geom_capacity = value.len(); @@ -531,13 +528,13 @@ impl From> for PolygonArray<2> { } /// Default to an empty array -impl Default for PolygonArray { +impl Default for PolygonArray { fn default() -> Self { PolygonBuilder::default().into() } } -impl PartialEq for PolygonArray { +impl PartialEq for PolygonArray { fn eq(&self, other: &Self) -> bool { if self.validity != other.validity { return false; @@ -559,10 +556,10 @@ impl PartialEq for PolygonArray { } } -impl TryFrom> for PolygonArray { +impl TryFrom for PolygonArray { type Error = GeoArrowError; - fn try_from(value: MultiPolygonArray) -> Result { + fn try_from(value: MultiPolygonArray) -> Result { if !can_downcast_multi(&value.geom_offsets) { return Err(GeoArrowError::General("Unable to cast".to_string())); } @@ -577,10 +574,10 @@ impl TryFrom> for PolygonArray { } } -impl TryFrom> for PolygonArray { +impl TryFrom for PolygonArray { type Error = GeoArrowError; - fn try_from(value: MixedGeometryArray) -> Result { + fn try_from(value: MixedGeometryArray) -> Result { if value.has_points() || value.has_line_strings() || value.has_multi_points() @@ -603,7 +600,7 @@ impl TryFrom> for PolygonArray { capacity.ring_capacity += buffer_lengths.ring_capacity; capacity.geom_capacity += buffer_lengths.polygon_capacity; - let mut builder = PolygonBuilder::::with_capacity_and_options( + let mut builder = PolygonBuilder::with_capacity_and_options( capacity, value.coord_type(), value.metadata(), @@ -615,10 +612,10 @@ impl TryFrom> for PolygonArray { } } -impl TryFrom> for PolygonArray { +impl TryFrom for PolygonArray { type Error = GeoArrowError; - fn try_from(value: GeometryCollectionArray) -> Result { + fn try_from(value: GeometryCollectionArray) -> Result { MixedGeometryArray::try_from(value)?.try_into() } } @@ -634,14 +631,14 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: PolygonArray<2> = vec![p0(), p1()].as_slice().into(); + let arr: PolygonArray = vec![p0(), p1()].as_slice().into(); assert_eq!(arr.value_as_geo(0), p0()); assert_eq!(arr.value_as_geo(1), p1()); } #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: PolygonArray<2> = vec![Some(p0()), Some(p1()), None].into(); + let arr: PolygonArray = vec![Some(p0()), Some(p1()), None].into(); assert_eq!(arr.get_as_geo(0), Some(p0())); assert_eq!(arr.get_as_geo(1), Some(p1())); assert_eq!(arr.get_as_geo(2), None); @@ -649,7 +646,7 @@ mod test { #[test] fn slice() { - let arr: PolygonArray<2> = vec![p0(), p1()].as_slice().into(); + let arr: PolygonArray = vec![p0(), p1()].as_slice().into(); let sliced = arr.slice(1, 1); assert_eq!(sliced.len(), 1); @@ -661,7 +658,7 @@ mod test { #[test] fn owned_slice() { - let arr: PolygonArray<2> = vec![p0(), p1()].as_slice().into(); + let arr: PolygonArray = vec![p0(), p1()].as_slice().into(); let sliced = arr.owned_slice(1, 1); // assert!( @@ -682,7 +679,7 @@ mod test { let geom_arr = example_polygon_interleaved(); let wkb_arr = example_polygon_wkb(); - let parsed_geom_arr: PolygonArray<2> = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: PolygonArray = wkb_arr.try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } @@ -693,7 +690,7 @@ mod test { let geom_arr = example_polygon_separated().into_coord_type(CoordType::Interleaved); let wkb_arr = example_polygon_wkb(); - let parsed_geom_arr: PolygonArray<2> = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: PolygonArray = wkb_arr.try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } diff --git a/rust/geoarrow/src/array/polygon/builder.rs b/rust/geoarrow/src/array/polygon/builder.rs index 6651e507..f250bffc 100644 --- a/rust/geoarrow/src/array/polygon/builder.rs +++ b/rust/geoarrow/src/array/polygon/builder.rs @@ -18,7 +18,7 @@ use geo_traits::{ RectTrait, }; -pub type MutablePolygonParts = ( +pub type MutablePolygonParts = ( CoordBufferBuilder, OffsetsBuilder, OffsetsBuilder, @@ -29,7 +29,7 @@ pub type MutablePolygonParts = ( /// /// Converting an [`PolygonBuilder`] into a [`PolygonArray`] is `O(1)`. #[derive(Debug)] -pub struct PolygonBuilder { +pub struct PolygonBuilder { metadata: Arc, pub(crate) coords: CoordBufferBuilder, @@ -44,7 +44,7 @@ pub struct PolygonBuilder { pub(crate) validity: NullBufferBuilder, } -impl PolygonBuilder { +impl PolygonBuilder { /// Creates a new empty [`PolygonBuilder`]. pub fn new() -> Self { Self::new_with_options(Default::default(), Default::default()) @@ -166,7 +166,7 @@ impl PolygonBuilder { } /// Extract the low-level APIs from the [`PolygonBuilder`]. - pub fn into_inner(self) -> MutablePolygonParts { + pub fn into_inner(self) -> MutablePolygonParts { ( self.coords, self.geom_offsets, @@ -204,7 +204,7 @@ impl PolygonBuilder { Ok(()) } - pub fn finish(self) -> PolygonArray { + pub fn finish(self) -> PolygonArray { self.into() } @@ -426,13 +426,13 @@ impl PolygonBuilder { } } -impl Default for PolygonBuilder { +impl Default for PolygonBuilder { fn default() -> Self { Self::new() } } -impl GeometryArrayBuilder for PolygonBuilder { +impl GeometryArrayBuilder for PolygonBuilder { fn new() -> Self { Self::new() } @@ -479,17 +479,17 @@ impl GeometryArrayBuilder for PolygonBuilder { } } -impl IntoArrow for PolygonBuilder { +impl IntoArrow for PolygonBuilder { type ArrowArray = GenericListArray; fn into_arrow(self) -> Self::ArrowArray { - let polygon_array: PolygonArray = self.into(); + let polygon_array: PolygonArray = self.into(); polygon_array.into_arrow() } } -impl From> for PolygonArray { - fn from(mut other: PolygonBuilder) -> Self { +impl From for PolygonArray { + fn from(mut other: PolygonBuilder) -> Self { let validity = other.validity.finish(); let geom_offsets: OffsetBuffer = other.geom_offsets.into(); @@ -505,19 +505,19 @@ impl From> for PolygonArray { } } -impl, const D: usize> From<&[G]> for PolygonBuilder { +impl, const D: usize> From<&[G]> for PolygonBuilder { fn from(geoms: &[G]) -> Self { Self::from_polygons(geoms, Default::default(), Default::default()) } } -impl, const D: usize> From>> for PolygonBuilder { +impl, const D: usize> From>> for PolygonBuilder { fn from(geoms: Vec>) -> Self { Self::from_nullable_polygons(&geoms, Default::default(), Default::default()) } } -impl TryFrom> for PolygonBuilder { +impl TryFrom> for PolygonBuilder { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { @@ -529,8 +529,8 @@ impl TryFrom> for PolygonBuilder /// Polygon and MultiLineString have the same layout, so enable conversions between the two to /// change the semantic type -impl From> for MultiLineStringBuilder { - fn from(value: PolygonBuilder) -> Self { +impl From for MultiLineStringBuilder { + fn from(value: PolygonBuilder) -> Self { Self::try_new( value.coords, value.geom_offsets, diff --git a/rust/geoarrow/src/array/rect/array.rs b/rust/geoarrow/src/array/rect/array.rs index 5e84709a..844acfe5 100644 --- a/rust/geoarrow/src/array/rect/array.rs +++ b/rust/geoarrow/src/array/rect/array.rs @@ -25,7 +25,7 @@ use geo_traits::RectTrait; /// /// Internally this is implemented as a FixedSizeList, laid out as minx, miny, maxx, maxy. #[derive(Debug, Clone, PartialEq)] -pub struct RectArray { +pub struct RectArray { // Always NativeType::Rect data_type: NativeType, @@ -40,7 +40,7 @@ pub struct RectArray { validity: Option, } -impl RectArray { +impl RectArray { pub fn new( lower: SeparatedCoordBuffer, upper: SeparatedCoordBuffer, @@ -92,7 +92,7 @@ impl RectArray { } } -impl ArrayBase for RectArray { +impl ArrayBase for RectArray { fn as_any(&self) -> &dyn std::any::Any { self } @@ -136,7 +136,7 @@ impl ArrayBase for RectArray { } } -impl NativeArray for RectArray { +impl NativeArray for RectArray { fn data_type(&self) -> NativeType { self.data_type } @@ -168,7 +168,7 @@ impl NativeArray for RectArray { } } -impl GeometryArraySelfMethods for RectArray { +impl GeometryArraySelfMethods for RectArray { fn with_coords(self, _coords: CoordBuffer) -> Self { unimplemented!() } @@ -178,8 +178,8 @@ impl GeometryArraySelfMethods for RectArray { } } -impl<'a, const D: usize> ArrayAccessor<'a> for RectArray { - type Item = Rect<'a, D>; +impl<'a> ArrayAccessor<'a> for RectArray { + type Item = Rect<'a>; type ItemGeo = geo::Rect; unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item { @@ -187,7 +187,7 @@ impl<'a, const D: usize> ArrayAccessor<'a> for RectArray { } } -impl IntoArrow for RectArray { +impl IntoArrow for RectArray { type ArrowArray = StructArray; fn into_arrow(self) -> Self::ArrowArray { @@ -205,7 +205,7 @@ impl IntoArrow for RectArray { } } -impl TryFrom<&StructArray> for RectArray { +impl TryFrom<&StructArray> for RectArray { type Error = GeoArrowError; fn try_from(value: &StructArray) -> Result { @@ -241,7 +241,7 @@ impl TryFrom<&StructArray> for RectArray { } } -impl TryFrom<&dyn Array> for RectArray { +impl TryFrom<&dyn Array> for RectArray { type Error = GeoArrowError; fn try_from(value: &dyn Array) -> Result { @@ -257,7 +257,7 @@ impl TryFrom<&dyn Array> for RectArray { } } -impl TryFrom<(&dyn Array, &Field)> for RectArray { +impl TryFrom<(&dyn Array, &Field)> for RectArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { @@ -267,16 +267,16 @@ impl TryFrom<(&dyn Array, &Field)> for RectArray { } } -impl, const D: usize> From<&[G]> for RectArray { +impl, const D: usize> From<&[G]> for RectArray { fn from(other: &[G]) -> Self { - let mut_arr: RectBuilder = other.into(); + let mut_arr: RectBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From>> for RectArray { +impl, const D: usize> From>> for RectArray { fn from(other: Vec>) -> Self { - let mut_arr: RectBuilder = other.into(); + let mut_arr: RectBuilder = other.into(); mut_arr.into() } } diff --git a/rust/geoarrow/src/array/rect/builder.rs b/rust/geoarrow/src/array/rect/builder.rs index a701da9e..8abb52da 100644 --- a/rust/geoarrow/src/array/rect/builder.rs +++ b/rust/geoarrow/src/array/rect/builder.rs @@ -12,14 +12,14 @@ use std::sync::Arc; /// /// Converting an [`RectBuilder`] into a [`RectArray`] is `O(1)`. #[derive(Debug)] -pub struct RectBuilder { +pub struct RectBuilder { pub metadata: Arc, pub lower: SeparatedCoordBufferBuilder, pub upper: SeparatedCoordBufferBuilder, pub validity: NullBufferBuilder, } -impl RectBuilder { +impl RectBuilder { /// Creates a new empty [`RectBuilder`]. pub fn new() -> Self { Self::new_with_options(Default::default()) @@ -116,7 +116,7 @@ impl RectBuilder { Arc::new(self.into_arrow()) } - pub fn finish(self) -> RectArray { + pub fn finish(self) -> RectArray { self.into() } @@ -141,7 +141,7 @@ impl RectBuilder { /// Add a new null value to the end of this builder. #[inline] pub fn push_null(&mut self) { - self.push_rect(None::<&Rect>); + self.push_rect(None::<&Rect>); } /// Create this builder from a iterator of Rects. @@ -169,23 +169,23 @@ impl RectBuilder { } } -impl Default for RectBuilder { +impl Default for RectBuilder { fn default() -> Self { Self::new() } } -impl IntoArrow for RectBuilder { +impl IntoArrow for RectBuilder { type ArrowArray = StructArray; fn into_arrow(self) -> Self::ArrowArray { - let rect_array: RectArray = self.into(); + let rect_array: RectArray = self.into(); rect_array.into_arrow() } } -impl From> for RectArray { - fn from(mut other: RectBuilder) -> Self { +impl From for RectArray { + fn from(mut other: RectBuilder) -> Self { RectArray::new( other.lower.into(), other.upper.into(), @@ -195,13 +195,13 @@ impl From> for RectArray { } } -impl, const D: usize> From<&[G]> for RectBuilder { +impl, const D: usize> From<&[G]> for RectBuilder { fn from(geoms: &[G]) -> Self { RectBuilder::from_rects(geoms.iter(), Default::default()) } } -impl, const D: usize> From>> for RectBuilder { +impl, const D: usize> From>> for RectBuilder { fn from(geoms: Vec>) -> Self { RectBuilder::from_nullable_rects(geoms.iter().map(|x| x.as_ref()), Default::default()) } diff --git a/rust/geoarrow/src/chunked_array/mod.rs b/rust/geoarrow/src/chunked_array/mod.rs index 61567f4f..087f6dee 100644 --- a/rust/geoarrow/src/chunked_array/mod.rs +++ b/rust/geoarrow/src/chunked_array/mod.rs @@ -568,25 +568,25 @@ impl TryFrom> for ChunkedGeometryArray { } /// A chunked point array. -pub type ChunkedPointArray = ChunkedGeometryArray>; +pub type ChunkedPointArray = ChunkedGeometryArray>; /// A chunked line string array. -pub type ChunkedLineStringArray = ChunkedGeometryArray>; +pub type ChunkedLineStringArray = ChunkedGeometryArray>; /// A chunked polygon array. -pub type ChunkedPolygonArray = ChunkedGeometryArray>; +pub type ChunkedPolygonArray = ChunkedGeometryArray>; /// A chunked multi-point array. -pub type ChunkedMultiPointArray = ChunkedGeometryArray>; +pub type ChunkedMultiPointArray = ChunkedGeometryArray>; /// A chunked mutli-line string array. -pub type ChunkedMultiLineStringArray = +pub type ChunkedMultiLineStringArray = ChunkedGeometryArray>; /// A chunked multi-polygon array. -pub type ChunkedMultiPolygonArray = ChunkedGeometryArray>; +pub type ChunkedMultiPolygonArray = ChunkedGeometryArray>; /// A chunked mixed geometry array. -pub type ChunkedMixedGeometryArray = ChunkedGeometryArray>; +pub type ChunkedMixedGeometryArray = ChunkedGeometryArray>; /// A chunked geometry collection array. -pub type ChunkedGeometryCollectionArray = +pub type ChunkedGeometryCollectionArray = ChunkedGeometryArray>; /// A chunked rect array. -pub type ChunkedRectArray = ChunkedGeometryArray>; +pub type ChunkedRectArray = ChunkedGeometryArray>; /// A chunked unknown geometry array. #[allow(dead_code)] pub type ChunkedUnknownGeometryArray = ChunkedGeometryArray>; @@ -797,7 +797,7 @@ pub trait ChunkedNativeArray: ChunkedArrayBase { } } -impl ChunkedArrayBase for ChunkedPointArray { +impl ChunkedArrayBase for ChunkedPointArray { fn as_any(&self) -> &dyn Any { self } @@ -823,7 +823,7 @@ impl ChunkedArrayBase for ChunkedPointArray { } } -impl ChunkedNativeArray for ChunkedPointArray { +impl ChunkedNativeArray for ChunkedPointArray { fn data_type(&self) -> NativeType { self.chunks.first().unwrap().data_type() } @@ -884,7 +884,7 @@ impl ChunkedArrayBase for ChunkedWKBArray { macro_rules! impl_trait { ($chunked_array:ty) => { - impl ChunkedArrayBase for $chunked_array { + impl ChunkedArrayBase for $chunked_array { fn as_any(&self) -> &dyn Any { self } @@ -911,7 +911,7 @@ macro_rules! impl_trait { } } - impl ChunkedNativeArray for $chunked_array { + impl ChunkedNativeArray for $chunked_array { fn data_type(&self) -> NativeType { self.chunks.first().unwrap().data_type() } @@ -938,7 +938,7 @@ impl_trait!(ChunkedMultiPolygonArray); impl_trait!(ChunkedMixedGeometryArray); impl_trait!(ChunkedGeometryCollectionArray); -impl ChunkedArrayBase for ChunkedRectArray { +impl ChunkedArrayBase for ChunkedRectArray { fn as_any(&self) -> &dyn Any { self } @@ -965,7 +965,7 @@ impl ChunkedArrayBase for ChunkedRectArray { } } -impl ChunkedNativeArray for ChunkedRectArray { +impl ChunkedNativeArray for ChunkedRectArray { fn data_type(&self) -> NativeType { self.chunks.first().unwrap().data_type() } diff --git a/rust/geoarrow/src/indexed/array.rs b/rust/geoarrow/src/indexed/array.rs index 0ec5dfe7..72976db8 100644 --- a/rust/geoarrow/src/indexed/array.rs +++ b/rust/geoarrow/src/indexed/array.rs @@ -125,20 +125,20 @@ impl<'a, G: NativeArray + ArrayAccessor<'a>> IndexedGeometryArray { } } -pub type IndexedPointArray = IndexedGeometryArray>; -pub type IndexedLineStringArray = IndexedGeometryArray>; -pub type IndexedPolygonArray = IndexedGeometryArray>; -pub type IndexedMultiPointArray = IndexedGeometryArray>; -pub type IndexedMultiLineStringArray = +pub type IndexedPointArray = IndexedGeometryArray>; +pub type IndexedLineStringArray = IndexedGeometryArray>; +pub type IndexedPolygonArray = IndexedGeometryArray>; +pub type IndexedMultiPointArray = IndexedGeometryArray>; +pub type IndexedMultiLineStringArray = IndexedGeometryArray>; -pub type IndexedMultiPolygonArray = IndexedGeometryArray>; -pub type IndexedMixedGeometryArray = IndexedGeometryArray>; -pub type IndexedGeometryCollectionArray = +pub type IndexedMultiPolygonArray = IndexedGeometryArray>; +pub type IndexedMixedGeometryArray = IndexedGeometryArray>; +pub type IndexedGeometryCollectionArray = IndexedGeometryArray>; #[allow(dead_code)] pub type IndexedWKBArray = IndexedGeometryArray>; #[allow(dead_code)] -pub type IndexedRectArray = IndexedGeometryArray>; +pub type IndexedRectArray = IndexedGeometryArray>; #[allow(dead_code)] pub type IndexedUnknownGeometryArray = IndexedGeometryArray>; diff --git a/rust/geoarrow/src/indexed/chunked.rs b/rust/geoarrow/src/indexed/chunked.rs index 4cbff78d..7fe2d44e 100644 --- a/rust/geoarrow/src/indexed/chunked.rs +++ b/rust/geoarrow/src/indexed/chunked.rs @@ -42,24 +42,24 @@ impl IndexedChunkedGeometryArray { } } -pub type IndexedChunkedPointArray = IndexedChunkedGeometryArray>; -pub type IndexedChunkedLineStringArray = +pub type IndexedChunkedPointArray = IndexedChunkedGeometryArray>; +pub type IndexedChunkedLineStringArray = IndexedChunkedGeometryArray>; -pub type IndexedChunkedPolygonArray = IndexedChunkedGeometryArray>; -pub type IndexedChunkedMultiPointArray = +pub type IndexedChunkedPolygonArray = IndexedChunkedGeometryArray>; +pub type IndexedChunkedMultiPointArray = IndexedChunkedGeometryArray>; -pub type IndexedChunkedMultiLineStringArray = +pub type IndexedChunkedMultiLineStringArray = IndexedChunkedGeometryArray>; -pub type IndexedChunkedMultiPolygonArray = +pub type IndexedChunkedMultiPolygonArray = IndexedChunkedGeometryArray>; -pub type IndexedChunkedMixedGeometryArray = +pub type IndexedChunkedMixedGeometryArray = IndexedChunkedGeometryArray>; -pub type IndexedChunkedGeometryCollectionArray = +pub type IndexedChunkedGeometryCollectionArray = IndexedChunkedGeometryArray>; #[allow(dead_code)] pub type IndexedChunkedWKBArray = IndexedChunkedGeometryArray>; #[allow(dead_code)] -pub type IndexedChunkedRectArray = IndexedChunkedGeometryArray>; +pub type IndexedChunkedRectArray = IndexedChunkedGeometryArray>; #[allow(dead_code)] pub type IndexedChunkedUnknownGeometryArray = IndexedChunkedGeometryArray>; diff --git a/rust/geoarrow/src/io/display/scalar.rs b/rust/geoarrow/src/io/display/scalar.rs index 29b2acb6..1c359612 100644 --- a/rust/geoarrow/src/io/display/scalar.rs +++ b/rust/geoarrow/src/io/display/scalar.rs @@ -37,13 +37,13 @@ pub(crate) fn write_geometry( Ok(()) } -impl fmt::Display for Point<'_, 2> { +impl fmt::Display for Point<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write_geometry(f, self.to_geo_geometry(), 80) } } -impl fmt::Display for Rect<'_, 2> { +impl fmt::Display for Rect<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write_geometry(f, self.to_geo_geometry(), 80) } @@ -59,14 +59,14 @@ macro_rules! impl_fmt { }; } -impl_fmt!(LineString<'_, 2>); -impl_fmt!(Polygon<'_, 2>); -impl_fmt!(MultiPoint<'_, 2>); -impl_fmt!(MultiLineString<'_, 2>); -impl_fmt!(MultiPolygon<'_, 2>); -impl_fmt!(GeometryCollection<'_, 2>); +impl_fmt!(LineString<'_>); +impl_fmt!(Polygon<'_>); +impl_fmt!(MultiPoint<'_>); +impl_fmt!(MultiLineString<'_>); +impl_fmt!(MultiPolygon<'_>); +impl_fmt!(GeometryCollection<'_>); -impl fmt::Display for Geometry<'_, 2> { +impl fmt::Display for Geometry<'_> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write_geometry(f, self.to_geo_geometry(), 80) } diff --git a/rust/geoarrow/src/io/geos/array/geometrycollection.rs b/rust/geoarrow/src/io/geos/array/geometrycollection.rs index 180940b5..d88d1201 100644 --- a/rust/geoarrow/src/io/geos/array/geometrycollection.rs +++ b/rust/geoarrow/src/io/geos/array/geometrycollection.rs @@ -2,7 +2,7 @@ use crate::array::{GeometryCollectionArray, GeometryCollectionBuilder}; use crate::error::GeoArrowError; use crate::io::geos::scalar::GEOSGeometryCollection; -impl TryFrom> for GeometryCollectionBuilder { +impl TryFrom> for GeometryCollectionBuilder { type Error = GeoArrowError; fn try_from(value: Vec) -> std::result::Result { @@ -14,7 +14,7 @@ impl TryFrom> for GeometryCollectionBuilder< } } -impl TryFrom> for GeometryCollectionArray { +impl TryFrom> for GeometryCollectionArray { type Error = GeoArrowError; fn try_from(value: Vec) -> std::result::Result { diff --git a/rust/geoarrow/src/io/geos/array/linestring.rs b/rust/geoarrow/src/io/geos/array/linestring.rs index 063d187a..95909857 100644 --- a/rust/geoarrow/src/io/geos/array/linestring.rs +++ b/rust/geoarrow/src/io/geos/array/linestring.rs @@ -2,7 +2,7 @@ use crate::array::{LineStringArray, LineStringBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSLineString; -impl LineStringBuilder { +impl LineStringBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value @@ -13,7 +13,7 @@ impl LineStringBuilder { } } -impl LineStringArray { +impl LineStringArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = LineStringBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/geos/array/mixed.rs b/rust/geoarrow/src/io/geos/array/mixed.rs index 33b852a1..0afcfceb 100644 --- a/rust/geoarrow/src/io/geos/array/mixed.rs +++ b/rust/geoarrow/src/io/geos/array/mixed.rs @@ -2,7 +2,7 @@ use crate::array::{MixedGeometryArray, MixedGeometryBuilder}; use crate::error::GeoArrowError; use crate::io::geos::scalar::GEOSGeometry; -impl TryFrom> for MixedGeometryBuilder { +impl TryFrom> for MixedGeometryBuilder { type Error = GeoArrowError; fn try_from(value: Vec) -> std::result::Result { @@ -11,7 +11,7 @@ impl TryFrom> for MixedGeometryBuilder { } } -impl TryFrom> for MixedGeometryArray { +impl TryFrom> for MixedGeometryArray { type Error = GeoArrowError; fn try_from(value: Vec) -> std::result::Result { diff --git a/rust/geoarrow/src/io/geos/array/multilinestring.rs b/rust/geoarrow/src/io/geos/array/multilinestring.rs index 353ad991..42807e37 100644 --- a/rust/geoarrow/src/io/geos/array/multilinestring.rs +++ b/rust/geoarrow/src/io/geos/array/multilinestring.rs @@ -2,7 +2,7 @@ use crate::array::{MultiLineStringArray, MultiLineStringBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSMultiLineString; -impl MultiLineStringBuilder { +impl MultiLineStringBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value @@ -13,7 +13,7 @@ impl MultiLineStringBuilder { } } -impl MultiLineStringArray { +impl MultiLineStringArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = MultiLineStringBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/geos/array/multipoint.rs b/rust/geoarrow/src/io/geos/array/multipoint.rs index b4d2ca70..ae55055a 100644 --- a/rust/geoarrow/src/io/geos/array/multipoint.rs +++ b/rust/geoarrow/src/io/geos/array/multipoint.rs @@ -2,7 +2,7 @@ use crate::array::{MultiPointArray, MultiPointBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSMultiPoint; -impl MultiPointBuilder { +impl MultiPointBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value @@ -13,7 +13,7 @@ impl MultiPointBuilder { } } -impl MultiPointArray { +impl MultiPointArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = MultiPointBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/geos/array/multipolygon.rs b/rust/geoarrow/src/io/geos/array/multipolygon.rs index 4b37c763..ff2988d7 100644 --- a/rust/geoarrow/src/io/geos/array/multipolygon.rs +++ b/rust/geoarrow/src/io/geos/array/multipolygon.rs @@ -2,7 +2,7 @@ use crate::array::{MultiPolygonArray, MultiPolygonBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSMultiPolygon; -impl MultiPolygonBuilder { +impl MultiPolygonBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value @@ -13,7 +13,7 @@ impl MultiPolygonBuilder { } } -impl MultiPolygonArray { +impl MultiPolygonArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = MultiPolygonBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/geos/array/point.rs b/rust/geoarrow/src/io/geos/array/point.rs index bd4ac117..d0f1bf5d 100644 --- a/rust/geoarrow/src/io/geos/array/point.rs +++ b/rust/geoarrow/src/io/geos/array/point.rs @@ -2,7 +2,7 @@ use crate::array::{PointArray, PointBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSPoint; -impl PointBuilder { +impl PointBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_linestring_objects: Vec> = value @@ -13,7 +13,7 @@ impl PointBuilder { } } -impl PointArray { +impl PointArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = PointBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/geos/array/polygon.rs b/rust/geoarrow/src/io/geos/array/polygon.rs index 6fc3d160..54bec8b6 100644 --- a/rust/geoarrow/src/io/geos/array/polygon.rs +++ b/rust/geoarrow/src/io/geos/array/polygon.rs @@ -2,7 +2,7 @@ use crate::array::{PolygonArray, PolygonBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSPolygon; -impl PolygonBuilder { +impl PolygonBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value @@ -14,7 +14,7 @@ impl PolygonBuilder { } } -impl PolygonArray { +impl PolygonArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = PolygonBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/geos/scalar/geometry.rs b/rust/geoarrow/src/io/geos/scalar/geometry.rs index 0a80ca0e..a9616acc 100644 --- a/rust/geoarrow/src/io/geos/scalar/geometry.rs +++ b/rust/geoarrow/src/io/geos/scalar/geometry.rs @@ -10,10 +10,10 @@ use geo_traits::{ }; use geos::Geom; -impl<'a, const D: usize> TryFrom<&'a Geometry<'_, D>> for geos::Geometry { +impl<'a> TryFrom<&'a Geometry<'_>> for geos::Geometry { type Error = geos::Error; - fn try_from(value: &'a Geometry<'_, D>) -> std::result::Result { + fn try_from(value: &'a Geometry<'_>) -> std::result::Result { match value { Geometry::Point(g) => g.try_into(), Geometry::LineString(g) => g.try_into(), diff --git a/rust/geoarrow/src/io/geos/scalar/geometrycollection.rs b/rust/geoarrow/src/io/geos/scalar/geometrycollection.rs index f1e6fa83..8de919d8 100644 --- a/rust/geoarrow/src/io/geos/scalar/geometrycollection.rs +++ b/rust/geoarrow/src/io/geos/scalar/geometrycollection.rs @@ -3,11 +3,11 @@ use crate::scalar::GeometryCollection; use geo_traits::GeometryCollectionTrait; use geos::Geom; -impl<'a, const D: usize> TryFrom<&'a GeometryCollection<'_, D>> for geos::Geometry { +impl<'a> TryFrom<&'a GeometryCollection<'_>> for geos::Geometry { type Error = geos::Error; fn try_from( - value: &'a GeometryCollection<'_, D>, + value: &'a GeometryCollection<'_>, ) -> std::result::Result { geos::Geometry::create_geometry_collection( value diff --git a/rust/geoarrow/src/io/geos/scalar/linestring.rs b/rust/geoarrow/src/io/geos/scalar/linestring.rs index 99addd17..2a89e5f2 100644 --- a/rust/geoarrow/src/io/geos/scalar/linestring.rs +++ b/rust/geoarrow/src/io/geos/scalar/linestring.rs @@ -5,10 +5,10 @@ use crate::scalar::LineString; use geo_traits::LineStringTrait; use geos::{Geom, GeometryTypes}; -impl<'a, const D: usize> TryFrom<&'a LineString<'_, D>> for geos::Geometry { +impl<'a> TryFrom<&'a LineString<'_>> for geos::Geometry { type Error = geos::Error; - fn try_from(value: &'a LineString<'_, D>) -> std::result::Result { + fn try_from(value: &'a LineString<'_>) -> std::result::Result { let (start, end) = value.geom_offsets.start_end(value.geom_index); let sliced_coords = value.coords.clone().slice(start, end - start); @@ -17,7 +17,7 @@ impl<'a, const D: usize> TryFrom<&'a LineString<'_, D>> for geos::Geometry { } } -impl LineString<'_, D> { +impl LineString<'_> { pub fn to_geos_linear_ring(&self) -> std::result::Result { let (start, end) = self.geom_offsets.start_end(self.geom_index); diff --git a/rust/geoarrow/src/io/geos/scalar/multilinestring.rs b/rust/geoarrow/src/io/geos/scalar/multilinestring.rs index 91bce9de..facf55c7 100644 --- a/rust/geoarrow/src/io/geos/scalar/multilinestring.rs +++ b/rust/geoarrow/src/io/geos/scalar/multilinestring.rs @@ -4,11 +4,11 @@ use crate::scalar::MultiLineString; use geo_traits::MultiLineStringTrait; use geos::{Geom, GeometryTypes}; -impl<'a, const D: usize> TryFrom<&'a MultiLineString<'_, D>> for geos::Geometry { +impl<'a> TryFrom<&'a MultiLineString<'_>> for geos::Geometry { type Error = geos::Error; fn try_from( - value: &'a MultiLineString<'_, D>, + value: &'a MultiLineString<'_>, ) -> std::result::Result { geos::Geometry::create_multiline_string( value diff --git a/rust/geoarrow/src/io/geos/scalar/multipoint.rs b/rust/geoarrow/src/io/geos/scalar/multipoint.rs index ff173332..a87948e7 100644 --- a/rust/geoarrow/src/io/geos/scalar/multipoint.rs +++ b/rust/geoarrow/src/io/geos/scalar/multipoint.rs @@ -4,10 +4,10 @@ use crate::scalar::MultiPoint; use geo_traits::MultiPointTrait; use geos::{Geom, GeometryTypes}; -impl<'a, const D: usize> TryFrom<&'a MultiPoint<'_, D>> for geos::Geometry { +impl<'a> TryFrom<&'a MultiPoint<'_>> for geos::Geometry { type Error = geos::Error; - fn try_from(value: &'a MultiPoint<'_, D>) -> std::result::Result { + fn try_from(value: &'a MultiPoint<'_>) -> std::result::Result { geos::Geometry::create_multipoint( value .points() diff --git a/rust/geoarrow/src/io/geos/scalar/multipolygon.rs b/rust/geoarrow/src/io/geos/scalar/multipolygon.rs index bb187bde..02855bb9 100644 --- a/rust/geoarrow/src/io/geos/scalar/multipolygon.rs +++ b/rust/geoarrow/src/io/geos/scalar/multipolygon.rs @@ -4,11 +4,11 @@ use crate::scalar::MultiPolygon; use geo_traits::MultiPolygonTrait; use geos::{Geom, GeometryTypes}; -impl<'a, const D: usize> TryFrom<&'a MultiPolygon<'_, D>> for geos::Geometry { +impl<'a> TryFrom<&'a MultiPolygon<'_>> for geos::Geometry { type Error = geos::Error; fn try_from( - value: &'a MultiPolygon<'_, D>, + value: &'a MultiPolygon<'_>, ) -> std::result::Result { geos::Geometry::create_multipolygon( value diff --git a/rust/geoarrow/src/io/geos/scalar/point.rs b/rust/geoarrow/src/io/geos/scalar/point.rs index ef049881..adb69b46 100644 --- a/rust/geoarrow/src/io/geos/scalar/point.rs +++ b/rust/geoarrow/src/io/geos/scalar/point.rs @@ -4,10 +4,10 @@ use crate::scalar::Point; use geo_traits::PointTrait; use geos::{Geom, GeometryTypes}; -impl<'a, const D: usize> TryFrom<&'a Point<'_, D>> for geos::Geometry { +impl<'a> TryFrom<&'a Point<'_>> for geos::Geometry { type Error = geos::Error; - fn try_from(point: &'a Point<'_, D>) -> std::result::Result { + fn try_from(point: &'a Point<'_>) -> std::result::Result { if let Some(coord) = PointTrait::coord(&point) { let coord_seq = (&coord).try_into()?; Ok(geos::Geometry::create_point(coord_seq)?) diff --git a/rust/geoarrow/src/io/geos/scalar/polygon.rs b/rust/geoarrow/src/io/geos/scalar/polygon.rs index ff92a00a..bb70c3a0 100644 --- a/rust/geoarrow/src/io/geos/scalar/polygon.rs +++ b/rust/geoarrow/src/io/geos/scalar/polygon.rs @@ -4,10 +4,10 @@ use crate::scalar::Polygon; use geo_traits::PolygonTrait; use geos::{Geom, GeometryTypes}; -impl<'a, const D: usize> TryFrom<&'a Polygon<'_, D>> for geos::Geometry { +impl<'a> TryFrom<&'a Polygon<'_>> for geos::Geometry { type Error = geos::Error; - fn try_from(value: &'a Polygon<'_, D>) -> std::result::Result { + fn try_from(value: &'a Polygon<'_>) -> std::result::Result { if let Some(exterior) = value.exterior() { let exterior = exterior.to_geos_linear_ring()?; let interiors = value diff --git a/rust/geoarrow/src/io/geozero/array/geometrycollection.rs b/rust/geoarrow/src/io/geozero/array/geometrycollection.rs index 5ea0485e..44d000af 100644 --- a/rust/geoarrow/src/io/geozero/array/geometrycollection.rs +++ b/rust/geoarrow/src/io/geozero/array/geometrycollection.rs @@ -4,7 +4,7 @@ use crate::trait_::ArrayAccessor; use crate::ArrayBase; use geozero::{GeomProcessor, GeozeroGeometry}; -impl GeozeroGeometry for GeometryCollectionArray { +impl GeozeroGeometry for GeometryCollectionArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, diff --git a/rust/geoarrow/src/io/geozero/array/linestring.rs b/rust/geoarrow/src/io/geozero/array/linestring.rs index 80875549..c41ab84f 100644 --- a/rust/geoarrow/src/io/geozero/array/linestring.rs +++ b/rust/geoarrow/src/io/geozero/array/linestring.rs @@ -6,7 +6,7 @@ use crate::io::geozero::scalar::process_line_string; use crate::trait_::ArrayAccessor; use crate::ArrayBase; -impl GeozeroGeometry for LineStringArray { +impl GeozeroGeometry for LineStringArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -24,7 +24,7 @@ impl GeozeroGeometry for LineStringArray { } /// GeoZero trait to convert to GeoArrow LineStringArray. -pub trait ToLineStringArray { +pub trait ToLineStringArray { /// Convert to GeoArrow LineStringArray fn to_line_string_array(&self) -> geozero::error::Result>; @@ -45,7 +45,7 @@ impl ToLineStringArray for T { } #[allow(unused_variables)] -impl GeomProcessor for LineStringBuilder { +impl GeomProcessor for LineStringBuilder { fn geometrycollection_begin(&mut self, size: usize, idx: usize) -> geozero::error::Result<()> { let capacity = LineStringCapacity::new(0, size); self.reserve(capacity); diff --git a/rust/geoarrow/src/io/geozero/array/mixed.rs b/rust/geoarrow/src/io/geozero/array/mixed.rs index 6a258618..b301d8b1 100644 --- a/rust/geoarrow/src/io/geozero/array/mixed.rs +++ b/rust/geoarrow/src/io/geozero/array/mixed.rs @@ -9,7 +9,7 @@ use crate::ArrayBase; use crate::NativeArray; use geozero::{GeomProcessor, GeozeroGeometry}; -impl GeozeroGeometry for MixedGeometryArray { +impl GeozeroGeometry for MixedGeometryArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -28,7 +28,7 @@ impl GeozeroGeometry for MixedGeometryArray { // TODO: Add "promote to multi" here /// GeoZero trait to convert to GeoArrow MixedArray. -pub trait ToMixedArray { +pub trait ToMixedArray { /// Convert to GeoArrow MixedArray fn to_mixed_geometry_array(&self) -> geozero::error::Result>; @@ -55,7 +55,7 @@ impl ToMixedArray for T { /// /// Converting an [`MixedGeometryStreamBuilder`] into a [`MixedGeometryArray`] is `O(1)`. #[derive(Debug)] -pub struct MixedGeometryStreamBuilder { +pub struct MixedGeometryStreamBuilder { builder: MixedGeometryBuilder, // Note: we don't know if, when `linestring_end` is called, that means a ring of a polygon has // finished or if a tagged line string has finished. This means we can't have an "unknown" enum @@ -64,7 +64,7 @@ pub struct MixedGeometryStreamBuilder { current_geom_type: GeometryType, } -impl MixedGeometryStreamBuilder { +impl MixedGeometryStreamBuilder { pub fn new() -> Self { Self::new_with_options(Default::default(), Default::default(), true) } @@ -89,14 +89,14 @@ impl MixedGeometryStreamBuilder { } } -impl Default for MixedGeometryStreamBuilder { +impl Default for MixedGeometryStreamBuilder { fn default() -> Self { Self::new() } } #[allow(unused_variables)] -impl GeomProcessor for MixedGeometryStreamBuilder { +impl GeomProcessor for MixedGeometryStreamBuilder { fn xy(&mut self, x: f64, y: f64, idx: usize) -> geozero::error::Result<()> { match self.current_geom_type { GeometryType::Point => { @@ -258,7 +258,7 @@ impl GeomProcessor for MixedGeometryStreamBuilder { } } -impl GeometryArrayBuilder for MixedGeometryStreamBuilder { +impl GeometryArrayBuilder for MixedGeometryStreamBuilder { fn len(&self) -> usize { self.builder.len() } diff --git a/rust/geoarrow/src/io/geozero/array/multilinestring.rs b/rust/geoarrow/src/io/geozero/array/multilinestring.rs index 0b3588cf..fdf4cec9 100644 --- a/rust/geoarrow/src/io/geozero/array/multilinestring.rs +++ b/rust/geoarrow/src/io/geozero/array/multilinestring.rs @@ -6,7 +6,7 @@ use crate::io::geozero::scalar::process_multi_line_string; use crate::trait_::ArrayAccessor; use crate::ArrayBase; -impl GeozeroGeometry for MultiLineStringArray { +impl GeozeroGeometry for MultiLineStringArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -24,7 +24,7 @@ impl GeozeroGeometry for MultiLineStringArray { } /// GeoZero trait to convert to GeoArrow MultiLineStringArray. -pub trait ToMultiLineStringArray { +pub trait ToMultiLineStringArray { /// Convert to GeoArrow MultiLineStringArray fn to_line_string_array(&self) -> geozero::error::Result>; @@ -45,7 +45,7 @@ impl ToMultiLineStringArray for T { } #[allow(unused_variables)] -impl GeomProcessor for MultiLineStringBuilder { +impl GeomProcessor for MultiLineStringBuilder { fn geometrycollection_begin(&mut self, size: usize, idx: usize) -> geozero::error::Result<()> { // reserve `size` geometries let capacity = MultiLineStringCapacity::new(0, 0, size); diff --git a/rust/geoarrow/src/io/geozero/array/multipoint.rs b/rust/geoarrow/src/io/geozero/array/multipoint.rs index 011947fa..4fa32f77 100644 --- a/rust/geoarrow/src/io/geozero/array/multipoint.rs +++ b/rust/geoarrow/src/io/geozero/array/multipoint.rs @@ -5,7 +5,7 @@ use crate::trait_::ArrayAccessor; use crate::ArrayBase; use geozero::{GeomProcessor, GeozeroGeometry}; -impl GeozeroGeometry for MultiPointArray { +impl GeozeroGeometry for MultiPointArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -23,7 +23,7 @@ impl GeozeroGeometry for MultiPointArray { } /// GeoZero trait to convert to GeoArrow MultiPointArray. -pub trait ToMultiPointArray { +pub trait ToMultiPointArray { /// Convert to GeoArrow MultiPointArray fn to_multi_point_array(&self) -> geozero::error::Result>; @@ -44,7 +44,7 @@ impl ToMultiPointArray for T { } #[allow(unused_variables)] -impl GeomProcessor for MultiPointBuilder { +impl GeomProcessor for MultiPointBuilder { fn geometrycollection_begin(&mut self, size: usize, idx: usize) -> geozero::error::Result<()> { let capacity = MultiPointCapacity::new(0, size); self.reserve(capacity); diff --git a/rust/geoarrow/src/io/geozero/array/multipolygon.rs b/rust/geoarrow/src/io/geozero/array/multipolygon.rs index f82a6994..c1ca3a2b 100644 --- a/rust/geoarrow/src/io/geozero/array/multipolygon.rs +++ b/rust/geoarrow/src/io/geozero/array/multipolygon.rs @@ -6,7 +6,7 @@ use crate::io::geozero::scalar::process_multi_polygon; use crate::trait_::ArrayAccessor; use crate::ArrayBase; -impl GeozeroGeometry for MultiPolygonArray { +impl GeozeroGeometry for MultiPolygonArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -24,7 +24,7 @@ impl GeozeroGeometry for MultiPolygonArray { } /// GeoZero trait to convert to GeoArrow MultiPolygonArray. -pub trait ToMultiPolygonArray { +pub trait ToMultiPolygonArray { /// Convert to GeoArrow MultiPolygonArray fn to_line_string_array(&self) -> geozero::error::Result>; @@ -45,7 +45,7 @@ impl ToMultiPolygonArray for T { } #[allow(unused_variables)] -impl GeomProcessor for MultiPolygonBuilder { +impl GeomProcessor for MultiPolygonBuilder { fn geometrycollection_begin(&mut self, size: usize, idx: usize) -> geozero::error::Result<()> { // reserve `size` geometries let capacity = MultiPolygonCapacity::new(0, 0, 0, size); diff --git a/rust/geoarrow/src/io/geozero/array/point.rs b/rust/geoarrow/src/io/geozero/array/point.rs index 6fbfed4e..937c5cba 100644 --- a/rust/geoarrow/src/io/geozero/array/point.rs +++ b/rust/geoarrow/src/io/geozero/array/point.rs @@ -4,7 +4,7 @@ use crate::trait_::ArrayAccessor; use crate::ArrayBase; use geozero::{GeomProcessor, GeozeroGeometry}; -impl GeozeroGeometry for PointArray { +impl GeozeroGeometry for PointArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -22,7 +22,7 @@ impl GeozeroGeometry for PointArray { } /// GeoZero trait to convert to GeoArrow PointArray. -pub trait ToPointArray { +pub trait ToPointArray { /// Convert to GeoArrow PointArray fn to_point_array(&self) -> geozero::error::Result>; @@ -43,7 +43,7 @@ impl ToPointArray for T { } #[allow(unused_variables)] -impl GeomProcessor for PointBuilder { +impl GeomProcessor for PointBuilder { fn empty_point(&mut self, idx: usize) -> geozero::error::Result<()> { self.push_empty(); Ok(()) diff --git a/rust/geoarrow/src/io/geozero/array/polygon.rs b/rust/geoarrow/src/io/geozero/array/polygon.rs index 443b06fb..a8cbf35a 100644 --- a/rust/geoarrow/src/io/geozero/array/polygon.rs +++ b/rust/geoarrow/src/io/geozero/array/polygon.rs @@ -5,7 +5,7 @@ use crate::trait_::ArrayAccessor; use crate::ArrayBase; use geozero::{GeomProcessor, GeozeroGeometry}; -impl GeozeroGeometry for PolygonArray { +impl GeozeroGeometry for PolygonArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -23,7 +23,7 @@ impl GeozeroGeometry for PolygonArray { } /// GeoZero trait to convert to GeoArrow PolygonArray. -pub trait ToPolygonArray { +pub trait ToPolygonArray { /// Convert to GeoArrow PolygonArray fn to_line_string_array(&self) -> geozero::error::Result>; @@ -44,7 +44,7 @@ impl ToPolygonArray for T { } #[allow(unused_variables)] -impl GeomProcessor for PolygonBuilder { +impl GeomProcessor for PolygonBuilder { fn geometrycollection_begin(&mut self, size: usize, idx: usize) -> geozero::error::Result<()> { // reserve `size` geometries let capacity = PolygonCapacity::new(0, 0, size); diff --git a/rust/geoarrow/src/io/geozero/scalar/geometry.rs b/rust/geoarrow/src/io/geozero/scalar/geometry.rs index 4bd2d09c..63ada79d 100644 --- a/rust/geoarrow/src/io/geozero/scalar/geometry.rs +++ b/rust/geoarrow/src/io/geozero/scalar/geometry.rs @@ -35,7 +35,7 @@ pub(crate) fn process_geometry( Ok(()) } -impl GeozeroGeometry for Geometry<'_, D> { +impl GeozeroGeometry for Geometry<'_> { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, diff --git a/rust/geoarrow/src/io/geozero/scalar/geometry_collection.rs b/rust/geoarrow/src/io/geozero/scalar/geometry_collection.rs index d2587cfb..5c5bbe3e 100644 --- a/rust/geoarrow/src/io/geozero/scalar/geometry_collection.rs +++ b/rust/geoarrow/src/io/geozero/scalar/geometry_collection.rs @@ -18,7 +18,7 @@ pub(crate) fn process_geometry_collection( Ok(()) } -impl GeozeroGeometry for GeometryCollection<'_, D> { +impl GeozeroGeometry for GeometryCollection<'_> { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, diff --git a/rust/geoarrow/src/io/geozero/scalar/linestring.rs b/rust/geoarrow/src/io/geozero/scalar/linestring.rs index 49b88e61..7f7929bd 100644 --- a/rust/geoarrow/src/io/geozero/scalar/linestring.rs +++ b/rust/geoarrow/src/io/geozero/scalar/linestring.rs @@ -18,7 +18,7 @@ pub(crate) fn process_line_string( Ok(()) } -impl GeozeroGeometry for LineString<'_, D> { +impl GeozeroGeometry for LineString<'_> { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, diff --git a/rust/geoarrow/src/io/geozero/scalar/multilinestring.rs b/rust/geoarrow/src/io/geozero/scalar/multilinestring.rs index d4acc462..7ac53f47 100644 --- a/rust/geoarrow/src/io/geozero/scalar/multilinestring.rs +++ b/rust/geoarrow/src/io/geozero/scalar/multilinestring.rs @@ -24,7 +24,7 @@ pub(crate) fn process_multi_line_string( Ok(()) } -impl GeozeroGeometry for MultiLineString<'_, D> { +impl GeozeroGeometry for MultiLineString<'_> { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, diff --git a/rust/geoarrow/src/io/geozero/scalar/multipoint.rs b/rust/geoarrow/src/io/geozero/scalar/multipoint.rs index f9f7a6ca..c6e1f45e 100644 --- a/rust/geoarrow/src/io/geozero/scalar/multipoint.rs +++ b/rust/geoarrow/src/io/geozero/scalar/multipoint.rs @@ -18,7 +18,7 @@ pub(crate) fn process_multi_point( Ok(()) } -impl GeozeroGeometry for MultiPoint<'_, D> { +impl GeozeroGeometry for MultiPoint<'_> { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, diff --git a/rust/geoarrow/src/io/geozero/scalar/multipolygon.rs b/rust/geoarrow/src/io/geozero/scalar/multipolygon.rs index cb1a5678..7acc6121 100644 --- a/rust/geoarrow/src/io/geozero/scalar/multipolygon.rs +++ b/rust/geoarrow/src/io/geozero/scalar/multipolygon.rs @@ -18,7 +18,7 @@ pub(crate) fn process_multi_polygon( Ok(()) } -impl GeozeroGeometry for MultiPolygon<'_, D> { +impl GeozeroGeometry for MultiPolygon<'_> { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, diff --git a/rust/geoarrow/src/io/geozero/scalar/point.rs b/rust/geoarrow/src/io/geozero/scalar/point.rs index fb8d1b22..d9dfd3c1 100644 --- a/rust/geoarrow/src/io/geozero/scalar/point.rs +++ b/rust/geoarrow/src/io/geozero/scalar/point.rs @@ -62,7 +62,7 @@ pub(crate) fn process_point_as_coord( Ok(()) } -impl GeozeroGeometry for Point<'_, D> { +impl GeozeroGeometry for Point<'_> { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, diff --git a/rust/geoarrow/src/io/geozero/scalar/polygon.rs b/rust/geoarrow/src/io/geozero/scalar/polygon.rs index 2154e23d..251e7019 100644 --- a/rust/geoarrow/src/io/geozero/scalar/polygon.rs +++ b/rust/geoarrow/src/io/geozero/scalar/polygon.rs @@ -39,7 +39,7 @@ pub(crate) fn process_polygon( Ok(()) } -impl GeozeroGeometry for Polygon<'_, D> { +impl GeozeroGeometry for Polygon<'_> { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, diff --git a/rust/geoarrow/src/io/parquet/reader/parse.rs b/rust/geoarrow/src/io/parquet/reader/parse.rs index 09be1b3f..c9f9b497 100644 --- a/rust/geoarrow/src/io/parquet/reader/parse.rs +++ b/rust/geoarrow/src/io/parquet/reader/parse.rs @@ -226,14 +226,14 @@ fn parse_wkb_column(arr: &dyn Array, target_geo_data_type: NativeType) -> Result } } -fn parse_point_column(array: &dyn Array) -> Result> { +fn parse_point_column(array: &dyn Array) -> Result> { let geom_arr: PointArray = array.try_into()?; Ok(geom_arr.into_array_ref()) } macro_rules! impl_parse_fn { ($fn_name:ident, $geoarrow_type:ty) => { - fn $fn_name(array: &dyn Array) -> Result> { + fn $fn_name(array: &dyn Array) -> Result> { match array.data_type() { DataType::List(_) | DataType::LargeList(_) => { let geom_arr: $geoarrow_type = array.try_into()?; diff --git a/rust/geoarrow/src/scalar/geometry/owned.rs b/rust/geoarrow/src/scalar/geometry/owned.rs index de13f5cb..4a305e80 100644 --- a/rust/geoarrow/src/scalar/geometry/owned.rs +++ b/rust/geoarrow/src/scalar/geometry/owned.rs @@ -9,19 +9,19 @@ use geo_traits::{ #[derive(Clone, Debug)] // TODO: come back to this in #449 #[allow(clippy::large_enum_variant)] -pub enum OwnedGeometry { - Point(crate::scalar::OwnedPoint), - LineString(crate::scalar::OwnedLineString), - Polygon(crate::scalar::OwnedPolygon), - MultiPoint(crate::scalar::OwnedMultiPoint), - MultiLineString(crate::scalar::OwnedMultiLineString), - MultiPolygon(crate::scalar::OwnedMultiPolygon), - GeometryCollection(crate::scalar::OwnedGeometryCollection), - Rect(crate::scalar::OwnedRect), +pub enum OwnedGeometry { + Point(crate::scalar::OwnedPoint), + LineString(crate::scalar::OwnedLineString), + Polygon(crate::scalar::OwnedPolygon), + MultiPoint(crate::scalar::OwnedMultiPoint), + MultiLineString(crate::scalar::OwnedMultiLineString), + MultiPolygon(crate::scalar::OwnedMultiPolygon), + GeometryCollection(crate::scalar::OwnedGeometryCollection), + Rect(crate::scalar::OwnedRect), } -impl<'a, const D: usize> From<&'a OwnedGeometry> for Geometry<'a, D> { - fn from(value: &'a OwnedGeometry) -> Self { +impl<'a> From<&'a OwnedGeometry> for Geometry<'a> { + fn from(value: &'a OwnedGeometry) -> Self { use OwnedGeometry::*; match value { Point(geom) => Geometry::Point(geom.into()), @@ -43,8 +43,8 @@ impl<'a> From<&'a OwnedGeometry<2>> for geo::Geometry { } } -impl<'a, const D: usize> From> for OwnedGeometry { - fn from(value: Geometry<'a, D>) -> Self { +impl<'a> From> for OwnedGeometry { + fn from(value: Geometry<'a>) -> Self { use OwnedGeometry::*; match value { Geometry::Point(geom) => Point(geom.into()), @@ -66,16 +66,16 @@ impl<'a, const D: usize> From> for OwnedGeometry { // } // } -impl GeometryTrait for OwnedGeometry { +impl GeometryTrait for OwnedGeometry { type T = f64; - type PointType<'b> = OwnedPoint where Self: 'b; - type LineStringType<'b> = OwnedLineString where Self: 'b; - type PolygonType<'b> = OwnedPolygon where Self: 'b; - type MultiPointType<'b> = OwnedMultiPoint where Self: 'b; - type MultiLineStringType<'b> = OwnedMultiLineString where Self: 'b; - type MultiPolygonType<'b> = OwnedMultiPolygon where Self: 'b; - type GeometryCollectionType<'b> = OwnedGeometryCollection where Self: 'b; - type RectType<'b> = OwnedRect where Self: 'b; + type PointType<'b> = OwnedPoint where Self: 'b; + type LineStringType<'b> = OwnedLineString where Self: 'b; + type PolygonType<'b> = OwnedPolygon where Self: 'b; + type MultiPointType<'b> = OwnedMultiPoint where Self: 'b; + type MultiLineStringType<'b> = OwnedMultiLineString where Self: 'b; + type MultiPolygonType<'b> = OwnedMultiPolygon where Self: 'b; + type GeometryCollectionType<'b> = OwnedGeometryCollection where Self: 'b; + type RectType<'b> = OwnedRect where Self: 'b; type TriangleType<'b> = UnimplementedTriangle where Self: 'b; type LineType<'b> = UnimplementedLine where Self: 'b; @@ -96,14 +96,14 @@ impl GeometryTrait for OwnedGeometry { &self, ) -> geo_traits::GeometryType< '_, - OwnedPoint, - OwnedLineString, - OwnedPolygon, - OwnedMultiPoint, - OwnedMultiLineString, - OwnedMultiPolygon, - OwnedGeometryCollection, - OwnedRect, + OwnedPoint, + OwnedLineString, + OwnedPolygon, + OwnedMultiPoint, + OwnedMultiLineString, + OwnedMultiPolygon, + OwnedGeometryCollection, + OwnedRect, UnimplementedTriangle, UnimplementedLine, > { @@ -120,7 +120,7 @@ impl GeometryTrait for OwnedGeometry { } } -impl> PartialEq for OwnedGeometry<2> { +impl> PartialEq for OwnedGeometry { fn eq(&self, other: &G) -> bool { geometry_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/geometry/scalar.rs b/rust/geoarrow/src/scalar/geometry/scalar.rs index c6bda057..73715939 100644 --- a/rust/geoarrow/src/scalar/geometry/scalar.rs +++ b/rust/geoarrow/src/scalar/geometry/scalar.rs @@ -11,18 +11,18 @@ use rstar::{RTreeObject, AABB}; /// A Geometry is an enum over the various underlying _zero copy_ GeoArrow scalar types. #[derive(Debug)] -pub enum Geometry<'a, const D: usize> { - Point(crate::scalar::Point<'a, D>), - LineString(crate::scalar::LineString<'a, D>), - Polygon(crate::scalar::Polygon<'a, D>), - MultiPoint(crate::scalar::MultiPoint<'a, D>), - MultiLineString(crate::scalar::MultiLineString<'a, D>), - MultiPolygon(crate::scalar::MultiPolygon<'a, D>), - GeometryCollection(crate::scalar::GeometryCollection<'a, D>), - Rect(crate::scalar::Rect<'a, D>), +pub enum Geometry<'a> { + Point(crate::scalar::Point<'a>), + LineString(crate::scalar::LineString<'a>), + Polygon(crate::scalar::Polygon<'a>), + MultiPoint(crate::scalar::MultiPoint<'a>), + MultiLineString(crate::scalar::MultiLineString<'a>), + MultiPolygon(crate::scalar::MultiPolygon<'a>), + GeometryCollection(crate::scalar::GeometryCollection<'a>), + Rect(crate::scalar::Rect<'a>), } -impl<'a, const D: usize> NativeScalar for Geometry<'a, D> { +impl<'a> NativeScalar for Geometry<'a> { type ScalarGeo = geo::Geometry; fn to_geo(&self) -> Self::ScalarGeo { @@ -48,16 +48,16 @@ impl<'a, const D: usize> NativeScalar for Geometry<'a, D> { } } -impl<'a, const D: usize> GeometryTrait for Geometry<'a, D> { +impl<'a> GeometryTrait for Geometry<'a> { type T = f64; - type PointType<'b> = Point<'b, D> where Self: 'b; - type LineStringType<'b> = LineString<'b, D> where Self: 'b; - type PolygonType<'b> = Polygon<'b, D> where Self: 'b; - type MultiPointType<'b> = MultiPoint<'b, D> where Self: 'b; - type MultiLineStringType<'b> = MultiLineString<'b, D> where Self: 'b; - type MultiPolygonType<'b> = MultiPolygon<'b, D> where Self: 'b; - type GeometryCollectionType<'b> = GeometryCollection<'b, D> where Self: 'b; - type RectType<'b> = Rect<'b, D> where Self: 'b; + type PointType<'b> = Point<'b> where Self: 'b; + type LineStringType<'b> = LineString<'b> where Self: 'b; + type PolygonType<'b> = Polygon<'b> where Self: 'b; + type MultiPointType<'b> = MultiPoint<'b> where Self: 'b; + type MultiLineStringType<'b> = MultiLineString<'b> where Self: 'b; + type MultiPolygonType<'b> = MultiPolygon<'b> where Self: 'b; + type GeometryCollectionType<'b> = GeometryCollection<'b> where Self: 'b; + type RectType<'b> = Rect<'b> where Self: 'b; type LineType<'b> = UnimplementedLine where Self: 'b; type TriangleType<'b> = UnimplementedTriangle where Self: 'b; @@ -78,14 +78,14 @@ impl<'a, const D: usize> GeometryTrait for Geometry<'a, D> { &self, ) -> geo_traits::GeometryType< '_, - Point<'_, D>, - LineString<'_, D>, - Polygon<'_, D>, - MultiPoint<'_, D>, - MultiLineString<'_, D>, - MultiPolygon<'_, D>, - GeometryCollection<'_, D>, - Rect<'_, D>, + Point<'_>, + LineString<'_>, + Polygon<'_>, + MultiPoint<'_>, + MultiLineString<'_>, + MultiPolygon<'_>, + GeometryCollection<'_>, + Rect<'_>, UnimplementedTriangle, UnimplementedLine, > { @@ -102,16 +102,16 @@ impl<'a, const D: usize> GeometryTrait for Geometry<'a, D> { } } -impl<'a, const D: usize> GeometryTrait for &'a Geometry<'a, D> { +impl<'a> GeometryTrait for &'a Geometry<'a> { type T = f64; - type PointType<'b> = Point<'b, D> where Self: 'b; - type LineStringType<'b> = LineString<'b, D> where Self: 'b; - type PolygonType<'b> = Polygon<'b, D> where Self: 'b; - type MultiPointType<'b> = MultiPoint<'b, D> where Self: 'b; - type MultiLineStringType<'b> = MultiLineString<'b, D> where Self: 'b; - type MultiPolygonType<'b> = MultiPolygon<'b, D> where Self: 'b; - type GeometryCollectionType<'b> = GeometryCollection<'b, D> where Self: 'b; - type RectType<'b> = Rect<'b, D> where Self: 'b; + type PointType<'b> = Point<'b> where Self: 'b; + type LineStringType<'b> = LineString<'b> where Self: 'b; + type PolygonType<'b> = Polygon<'b> where Self: 'b; + type MultiPointType<'b> = MultiPoint<'b> where Self: 'b; + type MultiLineStringType<'b> = MultiLineString<'b> where Self: 'b; + type MultiPolygonType<'b> = MultiPolygon<'b> where Self: 'b; + type GeometryCollectionType<'b> = GeometryCollection<'b> where Self: 'b; + type RectType<'b> = Rect<'b> where Self: 'b; type LineType<'b> = UnimplementedLine where Self: 'b; type TriangleType<'b> = UnimplementedTriangle where Self: 'b; @@ -132,14 +132,14 @@ impl<'a, const D: usize> GeometryTrait for &'a Geometry<'a, D> { &self, ) -> geo_traits::GeometryType< 'a, - Point<'a, D>, - LineString<'a, D>, - Polygon<'a, D>, - MultiPoint<'a, D>, - MultiLineString<'a, D>, - MultiPolygon<'a, D>, - GeometryCollection<'a, D>, - Rect<'a, D>, + Point<'a>, + LineString<'a>, + Polygon<'a>, + MultiPoint<'a>, + MultiLineString<'a>, + MultiPolygon<'a>, + GeometryCollection<'a>, + Rect<'a>, UnimplementedTriangle, UnimplementedLine, > { @@ -156,7 +156,7 @@ impl<'a, const D: usize> GeometryTrait for &'a Geometry<'a, D> { } } -impl RTreeObject for Geometry<'_, 2> { +impl RTreeObject for Geometry<'_> { type Envelope = AABB<[f64; 2]>; fn envelope(&self) -> Self::Envelope { @@ -173,19 +173,19 @@ impl RTreeObject for Geometry<'_, 2> { } } -impl From> for geo::Geometry { - fn from(value: Geometry<'_, D>) -> Self { +impl From> for geo::Geometry { + fn from(value: Geometry<'_>) -> Self { geometry_to_geo(&value) } } -impl From<&Geometry<'_, D>> for geo::Geometry { - fn from(value: &Geometry<'_, D>) -> Self { +impl From<&Geometry<'_>> for geo::Geometry { + fn from(value: &Geometry<'_>) -> Self { geometry_to_geo(value) } } -impl> PartialEq for Geometry<'_, D> { +impl> PartialEq for Geometry<'_> { fn eq(&self, other: &G) -> bool { geometry_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/geometrycollection/owned.rs b/rust/geoarrow/src/scalar/geometrycollection/owned.rs index 2f9bdf9e..b534b2e1 100644 --- a/rust/geoarrow/src/scalar/geometrycollection/owned.rs +++ b/rust/geoarrow/src/scalar/geometrycollection/owned.rs @@ -1,11 +1,12 @@ use crate::algorithm::native::eq::geometry_collection_eq; use crate::array::{GeometryCollectionArray, MixedGeometryArray}; +use crate::datatypes::Dimension; use crate::scalar::{Geometry, GeometryCollection}; use arrow_buffer::OffsetBuffer; use geo_traits::GeometryCollectionTrait; #[derive(Clone, Debug)] -pub struct OwnedGeometryCollection { +pub struct OwnedGeometryCollection { array: MixedGeometryArray, /// Offsets into the geometry array where each geometry starts @@ -14,7 +15,7 @@ pub struct OwnedGeometryCollection { geom_index: usize, } -impl OwnedGeometryCollection { +impl OwnedGeometryCollection { pub fn new( array: MixedGeometryArray, geom_offsets: OffsetBuffer, @@ -28,7 +29,7 @@ impl OwnedGeometryCollection { } } -impl<'a, const D: usize> From<&'a OwnedGeometryCollection> for GeometryCollection<'a, D> { +impl<'a> From<&'a OwnedGeometryCollection> for GeometryCollection<'a> { fn from(value: &'a OwnedGeometryCollection) -> Self { Self::new(&value.array, &value.geom_offsets, value.geom_index) } @@ -41,29 +42,27 @@ impl<'a> From<&'a OwnedGeometryCollection<2>> for geo::GeometryCollection { } } -impl<'a, const D: usize> From> for OwnedGeometryCollection { - fn from(value: GeometryCollection<'a, D>) -> Self { +impl<'a> From> for OwnedGeometryCollection { + fn from(value: GeometryCollection<'a>) -> Self { let (array, geom_offsets, geom_index) = value.into_inner(); Self::new(array.clone(), geom_offsets.clone(), geom_index) } } -impl From> for GeometryCollectionArray { +impl From> for GeometryCollectionArray { fn from(value: OwnedGeometryCollection) -> Self { Self::new(value.array, value.geom_offsets, None, Default::default()) } } -impl GeometryCollectionTrait for OwnedGeometryCollection { +impl GeometryCollectionTrait for OwnedGeometryCollection { type T = f64; - type GeometryType<'b> = Geometry<'b, D> where Self: 'b; + type GeometryType<'b> = Geometry<'b> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } diff --git a/rust/geoarrow/src/scalar/geometrycollection/scalar.rs b/rust/geoarrow/src/scalar/geometrycollection/scalar.rs index 87736d83..a662b93b 100644 --- a/rust/geoarrow/src/scalar/geometrycollection/scalar.rs +++ b/rust/geoarrow/src/scalar/geometrycollection/scalar.rs @@ -1,6 +1,7 @@ use crate::algorithm::native::eq::geometry_collection_eq; use crate::array::util::OffsetBufferUtils; use crate::array::MixedGeometryArray; +use crate::datatypes::Dimension; use crate::io::geo::geometry_collection_to_geo; use crate::scalar::Geometry; use crate::trait_::ArrayAccessor; @@ -11,7 +12,7 @@ use rstar::{RTreeObject, AABB}; /// An Arrow equivalent of a GeometryCollection #[derive(Debug, Clone)] -pub struct GeometryCollection<'a, const D: usize> { +pub struct GeometryCollection<'a> { pub(crate) array: &'a MixedGeometryArray, /// Offsets into the geometry array where each geometry starts @@ -22,7 +23,7 @@ pub struct GeometryCollection<'a, const D: usize> { start_offset: usize, } -impl<'a, const D: usize> GeometryCollection<'a, D> { +impl<'a> GeometryCollection<'a> { pub fn new( array: &'a MixedGeometryArray, geom_offsets: &'a OffsetBuffer, @@ -42,7 +43,7 @@ impl<'a, const D: usize> GeometryCollection<'a, D> { } } -impl<'a, const D: usize> NativeScalar for GeometryCollection<'a, D> { +impl<'a> NativeScalar for GeometryCollection<'a> { type ScalarGeo = geo::GeometryCollection; fn to_geo(&self) -> Self::ScalarGeo { @@ -59,16 +60,14 @@ impl<'a, const D: usize> NativeScalar for GeometryCollection<'a, D> { } } -impl<'a, const D: usize> GeometryCollectionTrait for GeometryCollection<'a, D> { +impl<'a> GeometryCollectionTrait for GeometryCollection<'a> { type T = f64; - type GeometryType<'b> = Geometry<'a, D> where Self: 'b; + type GeometryType<'b> = Geometry<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } @@ -82,16 +81,14 @@ impl<'a, const D: usize> GeometryCollectionTrait for GeometryCollection<'a, D> { } } -impl<'a, const D: usize> GeometryCollectionTrait for &'a GeometryCollection<'a, D> { +impl<'a> GeometryCollectionTrait for &'a GeometryCollection<'a> { type T = f64; - type GeometryType<'b> = Geometry<'a, D> where Self: 'b; + type GeometryType<'b> = Geometry<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } @@ -105,20 +102,14 @@ impl<'a, const D: usize> GeometryCollectionTrait for &'a GeometryCollection<'a, } } -// impl From> for geo::GeometryCollection { -// fn from(value: GeometryCollection<'_, 2>) -> Self { -// (&value).into() -// } -// } - -impl From<&GeometryCollection<'_, D>> for geo::GeometryCollection { - fn from(value: &GeometryCollection<'_, D>) -> Self { +impl From<&GeometryCollection<'_>> for geo::GeometryCollection { + fn from(value: &GeometryCollection<'_>) -> Self { geometry_collection_to_geo(value) } } -impl From> for geo::Geometry { - fn from(value: GeometryCollection<'_, D>) -> Self { +impl From> for geo::Geometry { + fn from(value: GeometryCollection<'_>) -> Self { geo::Geometry::GeometryCollection(value.into()) } } @@ -133,9 +124,7 @@ impl RTreeObject for GeometryCollection<'_, 2> { } } -impl> PartialEq - for GeometryCollection<'_, D> -{ +impl> PartialEq for GeometryCollection<'_> { fn eq(&self, other: &G) -> bool { geometry_collection_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/linestring/owned.rs b/rust/geoarrow/src/scalar/linestring/owned.rs index 9a68f41b..9cfb1c18 100644 --- a/rust/geoarrow/src/scalar/linestring/owned.rs +++ b/rust/geoarrow/src/scalar/linestring/owned.rs @@ -5,7 +5,7 @@ use arrow_buffer::OffsetBuffer; use geo_traits::LineStringTrait; #[derive(Clone, Debug)] -pub struct OwnedLineString { +pub struct OwnedLineString { coords: CoordBuffer, /// Offsets into the coordinate array where each geometry starts @@ -14,7 +14,7 @@ pub struct OwnedLineString { geom_index: usize, } -impl OwnedLineString { +impl OwnedLineString { pub fn new(coords: CoordBuffer, geom_offsets: OffsetBuffer, geom_index: usize) -> Self { Self { coords, @@ -24,33 +24,33 @@ impl OwnedLineString { } } -impl<'a, const D: usize> From<&'a OwnedLineString> for LineString<'a, D> { - fn from(value: &'a OwnedLineString) -> Self { +impl<'a> From<&'a OwnedLineString> for LineString<'a> { + fn from(value: &'a OwnedLineString) -> Self { Self::new(&value.coords, &value.geom_offsets, value.geom_index) } } -impl From> for geo::LineString { - fn from(value: OwnedLineString<2>) -> Self { +impl From for geo::LineString { + fn from(value: OwnedLineString) -> Self { let geom = LineString::from(&value); geom.into() } } -impl<'a, const D: usize> From> for OwnedLineString { - fn from(value: LineString<'a, D>) -> Self { +impl<'a> From> for OwnedLineString { + fn from(value: LineString<'a>) -> Self { let (coords, geom_offsets, geom_index) = value.into_owned_inner(); Self::new(coords, geom_offsets, geom_index) } } -impl From> for LineStringArray { - fn from(value: OwnedLineString) -> Self { +impl From for LineStringArray { + fn from(value: OwnedLineString) -> Self { Self::new(value.coords, value.geom_offsets, None, Default::default()) } } -impl LineStringTrait for OwnedLineString { +impl LineStringTrait for OwnedLineString { type T = f64; type CoordType<'b> = Coord<'b> where Self: 'b; @@ -67,7 +67,7 @@ impl LineStringTrait for OwnedLineString { } } -impl> PartialEq for OwnedLineString<2> { +impl> PartialEq for OwnedLineString { fn eq(&self, other: &G) -> bool { line_string_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/linestring/scalar.rs b/rust/geoarrow/src/scalar/linestring/scalar.rs index abbdce0e..e76dfc86 100644 --- a/rust/geoarrow/src/scalar/linestring/scalar.rs +++ b/rust/geoarrow/src/scalar/linestring/scalar.rs @@ -11,7 +11,7 @@ use rstar::{RTreeObject, AABB}; /// An Arrow equivalent of a LineString #[derive(Debug, Clone)] -pub struct LineString<'a, const D: usize> { +pub struct LineString<'a> { pub(crate) coords: &'a CoordBuffer, /// Offsets into the coordinate array where each geometry starts @@ -22,7 +22,7 @@ pub struct LineString<'a, const D: usize> { start_offset: usize, } -impl<'a, const D: usize> LineString<'a, D> { +impl<'a> LineString<'a> { pub fn new( coords: &'a CoordBuffer, geom_offsets: &'a OffsetBuffer, @@ -38,7 +38,7 @@ impl<'a, const D: usize> LineString<'a, D> { } pub fn into_owned_inner(self) -> (CoordBuffer, OffsetBuffer, usize) { - let arr = LineStringArray::::new( + let arr = LineStringArray::new( self.coords.clone(), self.geom_offsets.clone(), None, @@ -50,7 +50,7 @@ impl<'a, const D: usize> LineString<'a, D> { } } -impl<'a, const D: usize> NativeScalar for LineString<'a, D> { +impl<'a> NativeScalar for LineString<'a> { type ScalarGeo = geo::LineString; fn to_geo(&self) -> Self::ScalarGeo { @@ -67,7 +67,7 @@ impl<'a, const D: usize> NativeScalar for LineString<'a, D> { } } -impl<'a, const D: usize> LineStringTrait for LineString<'a, D> { +impl<'a> LineStringTrait for LineString<'a> { type T = f64; type CoordType<'b> = Coord<'a> where Self: 'b; @@ -85,7 +85,7 @@ impl<'a, const D: usize> LineStringTrait for LineString<'a, D> { } } -impl<'a, const D: usize> LineStringTrait for &'a LineString<'a, D> { +impl<'a> LineStringTrait for &'a LineString<'a> { type T = f64; type CoordType<'b> = Coord<'a> where Self: 'b; @@ -103,25 +103,25 @@ impl<'a, const D: usize> LineStringTrait for &'a LineString<'a, D> { } } -impl From> for geo::LineString { - fn from(value: LineString<'_, D>) -> Self { +impl From> for geo::LineString { + fn from(value: LineString<'_>) -> Self { (&value).into() } } -impl From<&LineString<'_, D>> for geo::LineString { - fn from(value: &LineString<'_, D>) -> Self { +impl From<&LineString<'_>> for geo::LineString { + fn from(value: &LineString<'_>) -> Self { line_string_to_geo(value) } } -impl From> for geo::Geometry { - fn from(value: LineString<'_, D>) -> Self { +impl From> for geo::Geometry { + fn from(value: LineString<'_>) -> Self { geo::Geometry::LineString(value.into()) } } -impl RTreeObject for LineString<'_, 2> { +impl RTreeObject for LineString<'_> { type Envelope = AABB<[f64; 2]>; fn envelope(&self) -> Self::Envelope { @@ -130,7 +130,7 @@ impl RTreeObject for LineString<'_, 2> { } } -impl> PartialEq for LineString<'_, 2> { +impl> PartialEq for LineString<'_> { fn eq(&self, other: &G) -> bool { line_string_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/multilinestring/owned.rs b/rust/geoarrow/src/scalar/multilinestring/owned.rs index 32bb99d6..4676ec3c 100644 --- a/rust/geoarrow/src/scalar/multilinestring/owned.rs +++ b/rust/geoarrow/src/scalar/multilinestring/owned.rs @@ -1,11 +1,12 @@ use crate::algorithm::native::eq::multi_line_string_eq; use crate::array::{CoordBuffer, MultiLineStringArray}; +use crate::datatypes::Dimension; use crate::scalar::{LineString, MultiLineString}; use arrow_buffer::OffsetBuffer; use geo_traits::MultiLineStringTrait; #[derive(Clone, Debug)] -pub struct OwnedMultiLineString { +pub struct OwnedMultiLineString { coords: CoordBuffer, /// Offsets into the coordinate array where each geometry starts @@ -16,7 +17,7 @@ pub struct OwnedMultiLineString { geom_index: usize, } -impl OwnedMultiLineString { +impl OwnedMultiLineString { pub fn new( coords: CoordBuffer, geom_offsets: OffsetBuffer, @@ -32,8 +33,8 @@ impl OwnedMultiLineString { } } -impl<'a, const D: usize> From<&'a OwnedMultiLineString> for MultiLineString<'a, D> { - fn from(value: &'a OwnedMultiLineString) -> Self { +impl<'a> From<&'a OwnedMultiLineString> for MultiLineString<'a> { + fn from(value: &'a OwnedMultiLineString) -> Self { Self::new( &value.coords, &value.geom_offsets, @@ -50,15 +51,15 @@ impl From> for geo::MultiLineString { } } -impl<'a, const D: usize> From> for OwnedMultiLineString { - fn from(value: MultiLineString<'a, D>) -> Self { +impl<'a> From> for OwnedMultiLineString { + fn from(value: MultiLineString<'a>) -> Self { let (coords, geom_offsets, ring_offsets, geom_index) = value.into_owned_inner(); Self::new(coords, geom_offsets, ring_offsets, geom_index) } } -impl From> for MultiLineStringArray { - fn from(value: OwnedMultiLineString) -> Self { +impl From for MultiLineStringArray { + fn from(value: OwnedMultiLineString) -> Self { Self::new( value.coords, value.geom_offsets, @@ -69,16 +70,14 @@ impl From> for MultiLineStringArray { } } -impl MultiLineStringTrait for OwnedMultiLineString { +impl MultiLineStringTrait for OwnedMultiLineString { type T = f64; - type LineStringType<'b> = LineString<'b, D> where Self: 'b; + type LineStringType<'b> = LineString<'b> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } diff --git a/rust/geoarrow/src/scalar/multilinestring/scalar.rs b/rust/geoarrow/src/scalar/multilinestring/scalar.rs index 82c9bceb..12e63a8c 100644 --- a/rust/geoarrow/src/scalar/multilinestring/scalar.rs +++ b/rust/geoarrow/src/scalar/multilinestring/scalar.rs @@ -11,7 +11,7 @@ use rstar::{RTreeObject, AABB}; /// An Arrow equivalent of a MultiLineString #[derive(Debug, Clone)] -pub struct MultiLineString<'a, const D: usize> { +pub struct MultiLineString<'a> { pub(crate) coords: &'a CoordBuffer, /// Offsets into the ring array where each geometry starts @@ -25,7 +25,7 @@ pub struct MultiLineString<'a, const D: usize> { start_offset: usize, } -impl<'a, const D: usize> MultiLineString<'a, D> { +impl<'a> MultiLineString<'a> { pub fn new( coords: &'a CoordBuffer, geom_offsets: &'a OffsetBuffer, @@ -43,7 +43,7 @@ impl<'a, const D: usize> MultiLineString<'a, D> { } pub fn into_owned_inner(self) -> (CoordBuffer, OffsetBuffer, OffsetBuffer, usize) { - let arr = MultiLineStringArray::::new( + let arr = MultiLineStringArray::new( self.coords.clone(), self.geom_offsets.clone(), self.ring_offsets.clone(), @@ -60,7 +60,7 @@ impl<'a, const D: usize> MultiLineString<'a, D> { } } -impl<'a, const D: usize> NativeScalar for MultiLineString<'a, D> { +impl<'a> NativeScalar for MultiLineString<'a> { type ScalarGeo = geo::MultiLineString; fn to_geo(&self) -> Self::ScalarGeo { @@ -77,9 +77,9 @@ impl<'a, const D: usize> NativeScalar for MultiLineString<'a, D> { } } -impl<'a, const D: usize> MultiLineStringTrait for MultiLineString<'a, D> { +impl<'a> MultiLineStringTrait for MultiLineString<'a> { type T = f64; - type LineStringType<'b> = LineString<'a, D> where Self: 'b; + type LineStringType<'b> = LineString<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { self.coords.dim().into() @@ -95,9 +95,9 @@ impl<'a, const D: usize> MultiLineStringTrait for MultiLineString<'a, D> { } } -impl<'a, const D: usize> MultiLineStringTrait for &'a MultiLineString<'a, D> { +impl<'a> MultiLineStringTrait for &'a MultiLineString<'a> { type T = f64; - type LineStringType<'b> = LineString<'a, D> where Self: 'b; + type LineStringType<'b> = LineString<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { self.coords.dim().into() @@ -113,20 +113,20 @@ impl<'a, const D: usize> MultiLineStringTrait for &'a MultiLineString<'a, D> { } } -impl From> for geo::MultiLineString { - fn from(value: MultiLineString<'_, D>) -> Self { +impl From> for geo::MultiLineString { + fn from(value: MultiLineString<'_>) -> Self { (&value).into() } } -impl From<&MultiLineString<'_, D>> for geo::MultiLineString { - fn from(value: &MultiLineString<'_, D>) -> Self { +impl From<&MultiLineString<'_>> for geo::MultiLineString { + fn from(value: &MultiLineString<'_>) -> Self { multi_line_string_to_geo(value) } } -impl From> for geo::Geometry { - fn from(value: MultiLineString<'_, D>) -> Self { +impl From> for geo::Geometry { + fn from(value: MultiLineString<'_>) -> Self { geo::Geometry::MultiLineString(value.into()) } } diff --git a/rust/geoarrow/src/scalar/multipoint/owned.rs b/rust/geoarrow/src/scalar/multipoint/owned.rs index 985883c8..419641d4 100644 --- a/rust/geoarrow/src/scalar/multipoint/owned.rs +++ b/rust/geoarrow/src/scalar/multipoint/owned.rs @@ -1,11 +1,12 @@ use crate::algorithm::native::eq::multi_point_eq; use crate::array::{CoordBuffer, MultiPointArray}; +use crate::datatypes::Dimension; use crate::scalar::{MultiPoint, Point}; use arrow_buffer::OffsetBuffer; use geo_traits::MultiPointTrait; #[derive(Clone, Debug)] -pub struct OwnedMultiPoint { +pub struct OwnedMultiPoint { coords: CoordBuffer, /// Offsets into the coordinate array where each geometry starts @@ -14,7 +15,7 @@ pub struct OwnedMultiPoint { geom_index: usize, } -impl OwnedMultiPoint { +impl OwnedMultiPoint { pub fn new(coords: CoordBuffer, geom_offsets: OffsetBuffer, geom_index: usize) -> Self { Self { coords, @@ -24,42 +25,40 @@ impl OwnedMultiPoint { } } -impl<'a, const D: usize> From<&'a OwnedMultiPoint> for MultiPoint<'a, D> { - fn from(value: &'a OwnedMultiPoint) -> Self { +impl<'a> From<&'a OwnedMultiPoint> for MultiPoint<'a> { + fn from(value: &'a OwnedMultiPoint) -> Self { Self::new(&value.coords, &value.geom_offsets, value.geom_index) } } -impl From> for geo::MultiPoint { - fn from(value: OwnedMultiPoint<2>) -> Self { +impl From for geo::MultiPoint { + fn from(value: OwnedMultiPoint) -> Self { let geom = MultiPoint::from(&value); geom.into() } } -impl<'a, const D: usize> From> for OwnedMultiPoint { - fn from(value: MultiPoint<'a, D>) -> Self { +impl<'a> From> for OwnedMultiPoint { + fn from(value: MultiPoint<'a>) -> Self { let (coords, geom_offsets, geom_index) = value.into_owned_inner(); Self::new(coords, geom_offsets, geom_index) } } -impl From> for MultiPointArray { - fn from(value: OwnedMultiPoint) -> Self { +impl From for MultiPointArray { + fn from(value: OwnedMultiPoint) -> Self { Self::new(value.coords, value.geom_offsets, None, Default::default()) } } -impl MultiPointTrait for OwnedMultiPoint { +impl MultiPointTrait for OwnedMultiPoint { type T = f64; - type PointType<'b> = Point<'b, D> where Self: 'b; + type PointType<'b> = Point<'b> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } @@ -72,7 +71,7 @@ impl MultiPointTrait for OwnedMultiPoint { } } -impl> PartialEq for OwnedMultiPoint<2> { +impl> PartialEq for OwnedMultiPoint { fn eq(&self, other: &G) -> bool { multi_point_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/multipoint/scalar.rs b/rust/geoarrow/src/scalar/multipoint/scalar.rs index 90eb60c9..70be00d7 100644 --- a/rust/geoarrow/src/scalar/multipoint/scalar.rs +++ b/rust/geoarrow/src/scalar/multipoint/scalar.rs @@ -2,6 +2,7 @@ use crate::algorithm::native::bounding_rect::bounding_rect_multipoint; use crate::algorithm::native::eq::multi_point_eq; use crate::array::util::OffsetBufferUtils; use crate::array::{CoordBuffer, MultiPointArray}; +use crate::datatypes::Dimension; use crate::io::geo::multi_point_to_geo; use crate::scalar::Point; use crate::trait_::NativeScalar; @@ -11,7 +12,7 @@ use rstar::{RTreeObject, AABB}; /// An Arrow equivalent of a MultiPoint #[derive(Debug, Clone)] -pub struct MultiPoint<'a, const D: usize> { +pub struct MultiPoint<'a> { /// Buffer of coordinates pub(crate) coords: &'a CoordBuffer, @@ -23,7 +24,7 @@ pub struct MultiPoint<'a, const D: usize> { start_offset: usize, } -impl<'a, const D: usize> MultiPoint<'a, D> { +impl<'a> MultiPoint<'a> { pub fn new( coords: &'a CoordBuffer, geom_offsets: &'a OffsetBuffer, @@ -39,7 +40,7 @@ impl<'a, const D: usize> MultiPoint<'a, D> { } pub fn into_owned_inner(self) -> (CoordBuffer, OffsetBuffer, usize) { - let arr = MultiPointArray::::new( + let arr = MultiPointArray::new( self.coords.clone(), self.geom_offsets.clone(), None, @@ -51,7 +52,7 @@ impl<'a, const D: usize> MultiPoint<'a, D> { } } -impl<'a, const D: usize> NativeScalar for MultiPoint<'a, D> { +impl<'a> NativeScalar for MultiPoint<'a> { type ScalarGeo = geo::MultiPoint; fn to_geo(&self) -> Self::ScalarGeo { @@ -68,16 +69,14 @@ impl<'a, const D: usize> NativeScalar for MultiPoint<'a, D> { } } -impl<'a, const D: usize> MultiPointTrait for MultiPoint<'a, D> { +impl<'a> MultiPointTrait for MultiPoint<'a> { type T = f64; - type PointType<'b> = Point<'a, D> where Self: 'b; + type PointType<'b> = Point<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } @@ -91,16 +90,14 @@ impl<'a, const D: usize> MultiPointTrait for MultiPoint<'a, D> { } } -impl<'a, const D: usize> MultiPointTrait for &'a MultiPoint<'a, D> { +impl<'a> MultiPointTrait for &'a MultiPoint<'a> { type T = f64; - type PointType<'b> = Point<'a, D> where Self: 'b; + type PointType<'b> = Point<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } @@ -114,20 +111,20 @@ impl<'a, const D: usize> MultiPointTrait for &'a MultiPoint<'a, D> { } } -impl From> for geo::MultiPoint { - fn from(value: MultiPoint<'_, D>) -> Self { +impl From> for geo::MultiPoint { + fn from(value: MultiPoint<'_>) -> Self { (&value).into() } } -impl From<&MultiPoint<'_, D>> for geo::MultiPoint { - fn from(value: &MultiPoint<'_, D>) -> Self { +impl From<&MultiPoint<'_>> for geo::MultiPoint { + fn from(value: &MultiPoint<'_>) -> Self { multi_point_to_geo(value) } } -impl From> for geo::Geometry { - fn from(value: MultiPoint<'_, D>) -> Self { +impl From> for geo::Geometry { + fn from(value: MultiPoint<'_>) -> Self { geo::Geometry::MultiPoint(value.into()) } } @@ -141,7 +138,7 @@ impl RTreeObject for MultiPoint<'_, 2> { } } -impl> PartialEq for MultiPoint<'_, D> { +impl> PartialEq for MultiPoint<'_> { fn eq(&self, other: &G) -> bool { multi_point_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/multipolygon/owned.rs b/rust/geoarrow/src/scalar/multipolygon/owned.rs index 44a42594..849bcda3 100644 --- a/rust/geoarrow/src/scalar/multipolygon/owned.rs +++ b/rust/geoarrow/src/scalar/multipolygon/owned.rs @@ -1,11 +1,12 @@ use crate::algorithm::native::eq::multi_polygon_eq; use crate::array::{CoordBuffer, MultiPolygonArray}; +use crate::datatypes::Dimension; use crate::scalar::{MultiPolygon, Polygon}; use arrow_buffer::OffsetBuffer; use geo_traits::MultiPolygonTrait; #[derive(Clone, Debug)] -pub struct OwnedMultiPolygon { +pub struct OwnedMultiPolygon { coords: CoordBuffer, /// Offsets into the coordinate array where each geometry starts @@ -18,7 +19,7 @@ pub struct OwnedMultiPolygon { geom_index: usize, } -impl OwnedMultiPolygon { +impl OwnedMultiPolygon { pub fn new( coords: CoordBuffer, geom_offsets: OffsetBuffer, @@ -36,8 +37,8 @@ impl OwnedMultiPolygon { } } -impl<'a, const D: usize> From<&'a OwnedMultiPolygon> for MultiPolygon<'a, D> { - fn from(value: &'a OwnedMultiPolygon) -> Self { +impl<'a> From<&'a OwnedMultiPolygon> for MultiPolygon<'a> { + fn from(value: &'a OwnedMultiPolygon) -> Self { Self::new( &value.coords, &value.geom_offsets, @@ -48,15 +49,15 @@ impl<'a, const D: usize> From<&'a OwnedMultiPolygon> for MultiPolygon<'a, D> } } -impl From> for geo::MultiPolygon { - fn from(value: OwnedMultiPolygon<2>) -> Self { +impl From for geo::MultiPolygon { + fn from(value: OwnedMultiPolygon) -> Self { let geom = MultiPolygon::from(&value); geom.into() } } -impl<'a, const D: usize> From> for OwnedMultiPolygon { - fn from(value: MultiPolygon<'a, D>) -> Self { +impl<'a> From> for OwnedMultiPolygon { + fn from(value: MultiPolygon<'a>) -> Self { let (coords, geom_offsets, polygon_offsets, ring_offsets, geom_index) = value.into_owned_inner(); Self::new( @@ -69,8 +70,8 @@ impl<'a, const D: usize> From> for OwnedMultiPolygon { } } -impl From> for MultiPolygonArray { - fn from(value: OwnedMultiPolygon) -> Self { +impl From for MultiPolygonArray { + fn from(value: OwnedMultiPolygon) -> Self { Self::new( value.coords, value.geom_offsets, @@ -82,16 +83,14 @@ impl From> for MultiPolygonArray { } } -impl MultiPolygonTrait for OwnedMultiPolygon { +impl MultiPolygonTrait for OwnedMultiPolygon { type T = f64; - type PolygonType<'b> = Polygon<'b, D> where Self: 'b; + type PolygonType<'b> = Polygon<'b> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } @@ -104,7 +103,7 @@ impl MultiPolygonTrait for OwnedMultiPolygon { } } -impl> PartialEq for OwnedMultiPolygon<2> { +impl> PartialEq for OwnedMultiPolygon { fn eq(&self, other: &G) -> bool { multi_polygon_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/multipolygon/scalar.rs b/rust/geoarrow/src/scalar/multipolygon/scalar.rs index 7b8dd42d..6e71d4d8 100644 --- a/rust/geoarrow/src/scalar/multipolygon/scalar.rs +++ b/rust/geoarrow/src/scalar/multipolygon/scalar.rs @@ -2,6 +2,7 @@ use crate::algorithm::native::bounding_rect::bounding_rect_multipolygon; use crate::algorithm::native::eq::multi_polygon_eq; use crate::array::util::OffsetBufferUtils; use crate::array::{CoordBuffer, MultiPolygonArray}; +use crate::datatypes::Dimension; use crate::io::geo::multi_polygon_to_geo; use crate::scalar::Polygon; use crate::trait_::NativeScalar; @@ -11,7 +12,7 @@ use rstar::{RTreeObject, AABB}; /// An Arrow equivalent of a MultiPolygon #[derive(Debug, Clone)] -pub struct MultiPolygon<'a, const D: usize> { +pub struct MultiPolygon<'a> { pub(crate) coords: &'a CoordBuffer, /// Offsets into the polygon array where each geometry starts @@ -28,7 +29,7 @@ pub struct MultiPolygon<'a, const D: usize> { start_offset: usize, } -impl<'a, const D: usize> MultiPolygon<'a, D> { +impl<'a> MultiPolygon<'a> { pub fn new( coords: &'a CoordBuffer, geom_offsets: &'a OffsetBuffer, @@ -56,7 +57,7 @@ impl<'a, const D: usize> MultiPolygon<'a, D> { OffsetBuffer, usize, ) { - let arr = MultiPolygonArray::::new( + let arr = MultiPolygonArray::new( self.coords.clone(), self.geom_offsets.clone(), self.polygon_offsets.clone(), @@ -71,7 +72,7 @@ impl<'a, const D: usize> MultiPolygon<'a, D> { } } -impl<'a, const D: usize> NativeScalar for MultiPolygon<'a, D> { +impl<'a> NativeScalar for MultiPolygon<'a> { type ScalarGeo = geo::MultiPolygon; fn to_geo(&self) -> Self::ScalarGeo { @@ -88,16 +89,14 @@ impl<'a, const D: usize> NativeScalar for MultiPolygon<'a, D> { } } -impl<'a, const D: usize> MultiPolygonTrait for MultiPolygon<'a, D> { +impl<'a> MultiPolygonTrait for MultiPolygon<'a> { type T = f64; - type PolygonType<'b> = Polygon<'a, D> where Self: 'b; + type PolygonType<'b> = Polygon<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } @@ -116,16 +115,14 @@ impl<'a, const D: usize> MultiPolygonTrait for MultiPolygon<'a, D> { } } -impl<'a, const D: usize> MultiPolygonTrait for &'a MultiPolygon<'a, D> { +impl<'a> MultiPolygonTrait for &'a MultiPolygon<'a> { type T = f64; - type PolygonType<'b> = Polygon<'a, D> where Self: 'b; + type PolygonType<'b> = Polygon<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } @@ -144,25 +141,25 @@ impl<'a, const D: usize> MultiPolygonTrait for &'a MultiPolygon<'a, D> { } } -impl From> for geo::MultiPolygon { - fn from(value: MultiPolygon<'_, D>) -> Self { +impl From> for geo::MultiPolygon { + fn from(value: MultiPolygon<'_>) -> Self { (&value).into() } } -impl From<&MultiPolygon<'_, D>> for geo::MultiPolygon { - fn from(value: &MultiPolygon<'_, D>) -> Self { +impl From<&MultiPolygon<'_>> for geo::MultiPolygon { + fn from(value: &MultiPolygon<'_>) -> Self { multi_polygon_to_geo(value) } } -impl From> for geo::Geometry { - fn from(value: MultiPolygon<'_, D>) -> Self { +impl From> for geo::Geometry { + fn from(value: MultiPolygon<'_>) -> Self { geo::Geometry::MultiPolygon(value.into()) } } -impl RTreeObject for MultiPolygon<'_, 2> { +impl RTreeObject for MultiPolygon<'_> { type Envelope = AABB<[f64; 2]>; fn envelope(&self) -> Self::Envelope { @@ -171,7 +168,7 @@ impl RTreeObject for MultiPolygon<'_, 2> { } } -impl> PartialEq for MultiPolygon<'_, D> { +impl> PartialEq for MultiPolygon<'_> { fn eq(&self, other: &G) -> bool { multi_polygon_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/point/owned.rs b/rust/geoarrow/src/scalar/point/owned.rs index 9733f2b7..3d9dfe6d 100644 --- a/rust/geoarrow/src/scalar/point/owned.rs +++ b/rust/geoarrow/src/scalar/point/owned.rs @@ -5,12 +5,12 @@ use crate::scalar::{Coord, Point}; use geo_traits::PointTrait; #[derive(Clone, Debug)] -pub struct OwnedPoint { +pub struct OwnedPoint { coords: CoordBuffer, geom_index: usize, } -impl OwnedPoint { +impl OwnedPoint { pub fn new(coords: CoordBuffer, geom_index: usize) -> Self { Self { coords, geom_index } } @@ -20,26 +20,26 @@ impl OwnedPoint { } } -impl<'a, const D: usize> From<&'a OwnedPoint> for Point<'a, D> { - fn from(value: &'a OwnedPoint) -> Self { +impl<'a> From<&'a OwnedPoint> for Point<'a> { + fn from(value: &'a OwnedPoint) -> Self { Self::new(&value.coords, value.geom_index) } } -impl<'a, const D: usize> From> for OwnedPoint { - fn from(value: Point<'a, D>) -> Self { +impl<'a> From> for OwnedPoint { + fn from(value: Point<'a>) -> Self { let (coords, geom_index) = value.into_owned_inner(); Self::new(coords, geom_index) } } -impl From> for PointArray { - fn from(value: OwnedPoint) -> Self { +impl From for PointArray { + fn from(value: OwnedPoint) -> Self { Self::new(value.coords, None, Default::default()) } } -impl PointTrait for OwnedPoint { +impl PointTrait for OwnedPoint { type T = f64; type CoordType<'a> = Coord<'a>; @@ -57,19 +57,19 @@ impl PointTrait for OwnedPoint { } } -impl From> for geo::Point { - fn from(value: OwnedPoint) -> Self { +impl From for geo::Point { + fn from(value: OwnedPoint) -> Self { (&value).into() } } -impl From<&OwnedPoint> for geo::Point { - fn from(value: &OwnedPoint) -> Self { +impl From<&OwnedPoint> for geo::Point { + fn from(value: &OwnedPoint) -> Self { point_to_geo(value) } } -impl PartialEq for OwnedPoint { +impl PartialEq for OwnedPoint { fn eq(&self, other: &Self) -> bool { point_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/point/scalar.rs b/rust/geoarrow/src/scalar/point/scalar.rs index dc32d0f2..a9b5c46f 100644 --- a/rust/geoarrow/src/scalar/point/scalar.rs +++ b/rust/geoarrow/src/scalar/point/scalar.rs @@ -9,12 +9,12 @@ use rstar::{RTreeObject, AABB}; /// An Arrow equivalent of a Point #[derive(Debug, Clone)] -pub struct Point<'a, const D: usize> { +pub struct Point<'a> { coords: &'a CoordBuffer, geom_index: usize, } -impl<'a, const D: usize> Point<'a, D> { +impl<'a> Point<'a> { pub fn new(coords: &'a CoordBuffer, geom_index: usize) -> Self { Point { coords, geom_index } } @@ -29,7 +29,7 @@ impl<'a, const D: usize> Point<'a, D> { } } -impl<'a, const D: usize> NativeScalar for Point<'a, D> { +impl<'a> NativeScalar for Point<'a> { type ScalarGeo = geo::Point; fn to_geo(&self) -> Self::ScalarGeo { @@ -46,7 +46,7 @@ impl<'a, const D: usize> NativeScalar for Point<'a, D> { } } -impl<'a, const D: usize> PointTrait for Point<'a, D> { +impl<'a> PointTrait for Point<'a> { type T = f64; type CoordType<'b> = Coord<'a> where Self: 'b; @@ -64,7 +64,7 @@ impl<'a, const D: usize> PointTrait for Point<'a, D> { } } -impl<'a, const D: usize> PointTrait for &Point<'a, D> { +impl<'a> PointTrait for &Point<'a> { type T = f64; type CoordType<'b> = Coord<'a> where Self: 'b; @@ -82,25 +82,25 @@ impl<'a, const D: usize> PointTrait for &Point<'a, D> { } } -impl From> for geo::Point { - fn from(value: Point<'_, D>) -> Self { +impl From> for geo::Point { + fn from(value: Point<'_>) -> Self { (&value).into() } } -impl From<&Point<'_, D>> for geo::Point { - fn from(value: &Point<'_, D>) -> Self { +impl From<&Point<'_>> for geo::Point { + fn from(value: &Point<'_>) -> Self { point_to_geo(value) } } -impl From> for geo::Geometry { - fn from(value: Point<'_, D>) -> Self { +impl From> for geo::Geometry { + fn from(value: Point<'_>) -> Self { geo::Geometry::Point(value.into()) } } -impl RTreeObject for Point<'_, D> { +impl RTreeObject for Point<'_> { type Envelope = AABB<[f64; 2]>; fn envelope(&self) -> Self::Envelope { @@ -109,7 +109,7 @@ impl RTreeObject for Point<'_, D> { } } -impl, const D: usize> PartialEq for Point<'_, D> { +impl> PartialEq for Point<'_> { fn eq(&self, other: &G) -> bool { point_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/polygon/owned.rs b/rust/geoarrow/src/scalar/polygon/owned.rs index 9ad6a28a..d6c7d8af 100644 --- a/rust/geoarrow/src/scalar/polygon/owned.rs +++ b/rust/geoarrow/src/scalar/polygon/owned.rs @@ -1,11 +1,12 @@ use crate::algorithm::native::eq::polygon_eq; use crate::array::{CoordBuffer, PolygonArray}; +use crate::datatypes::Dimension; use crate::scalar::{LineString, Polygon}; use arrow_buffer::OffsetBuffer; use geo_traits::PolygonTrait; #[derive(Clone, Debug)] -pub struct OwnedPolygon { +pub struct OwnedPolygon { coords: CoordBuffer, /// Offsets into the coordinate array where each geometry starts @@ -16,7 +17,7 @@ pub struct OwnedPolygon { geom_index: usize, } -impl OwnedPolygon { +impl OwnedPolygon { pub fn new( coords: CoordBuffer, geom_offsets: OffsetBuffer, @@ -32,7 +33,7 @@ impl OwnedPolygon { } } -impl<'a, const D: usize> From<&'a OwnedPolygon> for Polygon<'a, D> { +impl<'a> From<&'a OwnedPolygon> for Polygon<'a> { fn from(value: &'a OwnedPolygon) -> Self { Self::new( &value.coords, @@ -50,14 +51,14 @@ impl From> for geo::Polygon { } } -impl<'a, const D: usize> From> for OwnedPolygon { - fn from(value: Polygon<'a, D>) -> Self { +impl<'a> From> for OwnedPolygon { + fn from(value: Polygon<'a>) -> Self { let (coords, geom_offsets, ring_offsets, geom_index) = value.into_owned_inner(); Self::new(coords, geom_offsets, ring_offsets, geom_index) } } -impl From> for PolygonArray { +impl From> for PolygonArray { fn from(value: OwnedPolygon) -> Self { Self::new( value.coords, @@ -69,16 +70,14 @@ impl From> for PolygonArray { } } -impl PolygonTrait for OwnedPolygon { +impl PolygonTrait for OwnedPolygon { type T = f64; type RingType<'b> = LineString<'b, D> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } diff --git a/rust/geoarrow/src/scalar/polygon/scalar.rs b/rust/geoarrow/src/scalar/polygon/scalar.rs index 21d5fa43..cbc7294d 100644 --- a/rust/geoarrow/src/scalar/polygon/scalar.rs +++ b/rust/geoarrow/src/scalar/polygon/scalar.rs @@ -2,6 +2,7 @@ use crate::algorithm::native::bounding_rect::bounding_rect_polygon; use crate::algorithm::native::eq::polygon_eq; use crate::array::util::OffsetBufferUtils; use crate::array::{CoordBuffer, PolygonArray}; +use crate::datatypes::Dimension; use crate::io::geo::polygon_to_geo; use crate::scalar::LineString; use crate::trait_::NativeScalar; @@ -11,7 +12,7 @@ use rstar::{RTreeObject, AABB}; /// An Arrow equivalent of a Polygon #[derive(Debug, Clone)] -pub struct Polygon<'a, const D: usize> { +pub struct Polygon<'a> { pub(crate) coords: &'a CoordBuffer, /// Offsets into the ring array where each geometry starts @@ -25,7 +26,7 @@ pub struct Polygon<'a, const D: usize> { start_offset: usize, } -impl<'a, const D: usize> Polygon<'a, D> { +impl<'a> Polygon<'a> { pub fn new( coords: &'a CoordBuffer, geom_offsets: &'a OffsetBuffer, @@ -43,7 +44,7 @@ impl<'a, const D: usize> Polygon<'a, D> { } pub fn into_owned_inner(self) -> (CoordBuffer, OffsetBuffer, OffsetBuffer, usize) { - let arr = PolygonArray::::new( + let arr = PolygonArray::new( self.coords.clone(), self.geom_offsets.clone(), self.ring_offsets.clone(), @@ -61,7 +62,7 @@ impl<'a, const D: usize> Polygon<'a, D> { } } -impl<'a, const D: usize> NativeScalar for Polygon<'a, D> { +impl<'a> NativeScalar for Polygon<'a> { type ScalarGeo = geo::Polygon; fn to_geo(&self) -> Self::ScalarGeo { @@ -78,16 +79,14 @@ impl<'a, const D: usize> NativeScalar for Polygon<'a, D> { } } -impl<'a, const D: usize> PolygonTrait for Polygon<'a, D> { +impl<'a> PolygonTrait for Polygon<'a> { type T = f64; - type RingType<'b> = LineString<'a, D> where Self: 'b; + type RingType<'b> = LineString<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } @@ -110,16 +109,14 @@ impl<'a, const D: usize> PolygonTrait for Polygon<'a, D> { } } -impl<'a, const D: usize> PolygonTrait for &'a Polygon<'a, D> { +impl<'a> PolygonTrait for &'a Polygon<'a> { type T = f64; - type RingType<'b> = LineString<'a, D> where Self: 'b; + type RingType<'b> = LineString<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } @@ -142,20 +139,20 @@ impl<'a, const D: usize> PolygonTrait for &'a Polygon<'a, D> { } } -impl From> for geo::Polygon { - fn from(value: Polygon<'_, D>) -> Self { +impl From> for geo::Polygon { + fn from(value: Polygon<'_>) -> Self { (&value).into() } } -impl From<&Polygon<'_, D>> for geo::Polygon { - fn from(value: &Polygon<'_, D>) -> Self { +impl From<&Polygon<'_>> for geo::Polygon { + fn from(value: &Polygon<'_>) -> Self { polygon_to_geo(value) } } -impl From> for geo::Geometry { - fn from(value: Polygon<'_, D>) -> Self { +impl From> for geo::Geometry { + fn from(value: Polygon<'_>) -> Self { geo::Geometry::Polygon(value.into()) } } @@ -169,7 +166,7 @@ impl RTreeObject for Polygon<'_, 2> { } } -impl, const D: usize> PartialEq for Polygon<'_, D> { +impl> PartialEq for Polygon<'_> { fn eq(&self, other: &G) -> bool { polygon_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/rect/owned.rs b/rust/geoarrow/src/scalar/rect/owned.rs index 018f9e62..1474db11 100644 --- a/rust/geoarrow/src/scalar/rect/owned.rs +++ b/rust/geoarrow/src/scalar/rect/owned.rs @@ -4,13 +4,13 @@ use crate::scalar::{Rect, SeparatedCoord}; use geo_traits::RectTrait; #[derive(Clone, Debug)] -pub struct OwnedRect { +pub struct OwnedRect { lower: SeparatedCoordBuffer, upper: SeparatedCoordBuffer, geom_index: usize, } -impl OwnedRect { +impl OwnedRect { pub fn new( lower: SeparatedCoordBuffer, upper: SeparatedCoordBuffer, @@ -24,35 +24,33 @@ impl OwnedRect { } } -impl<'a, const D: usize> From<&'a OwnedRect> for Rect<'a, D> { +impl<'a> From<&'a OwnedRect> for Rect<'a> { fn from(value: &'a OwnedRect) -> Self { Self::new(&value.lower, &value.upper, value.geom_index) } } -impl<'a, const D: usize> From> for OwnedRect { - fn from(value: Rect<'a, D>) -> Self { +impl<'a> From> for OwnedRect { + fn from(value: Rect<'a>) -> Self { let (lower, upper, geom_index) = value.into_owned_inner(); Self::new(lower, upper, geom_index) } } -impl From> for RectArray { +impl From> for RectArray { fn from(value: OwnedRect) -> Self { Self::new(value.lower, value.upper, None, Default::default()) } } -impl RectTrait for OwnedRect { +impl RectTrait for OwnedRect { type T = f64; type CoordType<'b> = SeparatedCoord<'b> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - // TODO: pass through field information from array - match D { - 2 => geo_traits::Dimensions::Xy, - 3 => geo_traits::Dimensions::Xyz, - _ => todo!(), + match self.coords.dim() { + Dimension::XY => geo_traits::Dimensions::Xy, + Dimension::XYZ => geo_traits::Dimensions::Xyz, } } diff --git a/rust/geoarrow/src/scalar/rect/scalar.rs b/rust/geoarrow/src/scalar/rect/scalar.rs index 77832cdd..b877d644 100644 --- a/rust/geoarrow/src/scalar/rect/scalar.rs +++ b/rust/geoarrow/src/scalar/rect/scalar.rs @@ -8,13 +8,13 @@ use crate::trait_::NativeScalar; use geo_traits::RectTrait; #[derive(Debug, Clone)] -pub struct Rect<'a, const D: usize> { +pub struct Rect<'a> { lower: &'a SeparatedCoordBuffer, upper: &'a SeparatedCoordBuffer, pub(crate) geom_index: usize, } -impl<'a, const D: usize> Rect<'a, D> { +impl<'a> Rect<'a> { pub fn new( lower: &'a SeparatedCoordBuffer, upper: &'a SeparatedCoordBuffer, @@ -32,7 +32,7 @@ impl<'a, const D: usize> Rect<'a, D> { } } -impl<'a, const D: usize> NativeScalar for Rect<'a, D> { +impl<'a> NativeScalar for Rect<'a> { type ScalarGeo = geo::Rect; fn to_geo(&self) -> Self::ScalarGeo { @@ -51,7 +51,7 @@ impl<'a, const D: usize> NativeScalar for Rect<'a, D> { } // TODO: support 3d rects -impl<'a, const D: usize> RectTrait for Rect<'a, D> { +impl<'a> RectTrait for Rect<'a> { type T = f64; type CoordType<'b> = SeparatedCoord<'a> where Self: 'b; @@ -68,25 +68,25 @@ impl<'a, const D: usize> RectTrait for Rect<'a, D> { } } -impl From> for geo::Rect { - fn from(value: Rect<'_, D>) -> Self { +impl From> for geo::Rect { + fn from(value: Rect<'_>) -> Self { (&value).into() } } -impl From<&Rect<'_, D>> for geo::Rect { - fn from(value: &Rect<'_, D>) -> Self { +impl From<&Rect<'_>> for geo::Rect { + fn from(value: &Rect<'_>) -> Self { rect_to_geo(value) } } -impl From> for geo::Geometry { - fn from(value: Rect<'_, D>) -> Self { +impl From> for geo::Geometry { + fn from(value: Rect<'_>) -> Self { geo::Geometry::Rect(value.into()) } } -impl RTreeObject for Rect<'_, D> { +impl RTreeObject for Rect<'_> { type Envelope = AABB<[f64; D]>; fn envelope(&self) -> Self::Envelope { @@ -100,7 +100,7 @@ impl RTreeObject for Rect<'_, D> { } } -impl, const D: usize> PartialEq for Rect<'_, D> { +impl> PartialEq for Rect<'_> { fn eq(&self, other: &G) -> bool { rect_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/scalar.rs b/rust/geoarrow/src/scalar/scalar.rs index 739d4d75..5487ae28 100644 --- a/rust/geoarrow/src/scalar/scalar.rs +++ b/rust/geoarrow/src/scalar/scalar.rs @@ -66,7 +66,7 @@ impl GeometryScalar { } } - pub fn as_geometry(&self) -> Option> { + pub fn as_geometry(&self) -> Option> { use NativeType::*; // Note: we use `.downcast_ref` directly here because we need to pass in the generic diff --git a/rust/geoarrow/src/trait_.rs b/rust/geoarrow/src/trait_.rs index 83c07ecc..a4168eb0 100644 --- a/rust/geoarrow/src/trait_.rs +++ b/rust/geoarrow/src/trait_.rs @@ -398,9 +398,9 @@ pub trait SerializedArray: ArrayBase { pub type SerializedArrayRef = Arc; /// Trait for accessing generic `Geometry` scalars -pub trait NativeGeometryAccessor: NativeArray { +pub trait NativeGeometryAccessor: NativeArray { /// Returns the element at index `i` as a `Geometry`, not considering validity. - fn value_as_geometry(&self, index: usize) -> Geometry<'_, D> { + fn value_as_geometry(&self, index: usize) -> Geometry<'_> { assert!(index <= self.len()); unsafe { self.value_as_geometry_unchecked(index) } } @@ -410,10 +410,10 @@ pub trait NativeGeometryAccessor: NativeArray { /// # Safety /// /// Caller is responsible for ensuring that the index is within the bounds of the array - unsafe fn value_as_geometry_unchecked(&self, index: usize) -> Geometry<'_, D>; + unsafe fn value_as_geometry_unchecked(&self, index: usize) -> Geometry<'_>; /// Returns the value at slot `i` as a `Geometry`, considering validity. - fn get_as_geometry(&self, index: usize) -> Option> { + fn get_as_geometry(&self, index: usize) -> Option> { if self.is_null(index) { return None; } @@ -426,7 +426,7 @@ pub trait NativeGeometryAccessor: NativeArray { /// # Safety /// /// Caller is responsible for ensuring that the index is within the bounds of the array - unsafe fn get_as_geometry_unchecked(&self, index: usize) -> Option> { + unsafe fn get_as_geometry_unchecked(&self, index: usize) -> Option> { if self.is_null(index) { return None; } @@ -689,7 +689,7 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// Trait for geometry array methods that return `Self`. /// /// TODO Horrible name, to be changed to a better name in the future!! -pub trait GeometryArraySelfMethods { +pub trait GeometryArraySelfMethods { /// Creates a new array with replaced coordinates. /// /// This is useful if you want to apply an operation to _every_ coordinate in unison, such as a From cb227ca5e0f544c3106c2a486c7bfa9bb1f8d6b2 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Thu, 14 Nov 2024 19:47:57 -0500 Subject: [PATCH 02/14] progress --- python/geoarrow-core/src/constructors.rs | 12 +- .../src/algorithm/native/concatenate.rs | 56 ++++---- .../geoarrow/src/algorithm/native/downcast.rs | 128 ++++++++---------- rust/geoarrow/src/array/linestring/array.rs | 25 ++-- .../src/array/multilinestring/array.rs | 34 ++--- rust/geoarrow/src/array/multipoint/array.rs | 31 +++-- rust/geoarrow/src/array/multipolygon/array.rs | 31 +++-- rust/geoarrow/src/array/point/array.rs | 33 ++--- rust/geoarrow/src/array/polygon/array.rs | 25 ++-- rust/geoarrow/src/array/rect/array.rs | 44 +++--- rust/geoarrow/src/datatypes.rs | 2 +- rust/geoarrow/src/scalar/geometry/owned.rs | 4 +- .../src/scalar/geometrycollection/owned.rs | 24 ++-- .../src/scalar/geometrycollection/scalar.rs | 12 +- rust/geoarrow/src/scalar/linestring/scalar.rs | 4 +- .../src/scalar/multilinestring/owned.rs | 6 +- .../src/scalar/multilinestring/scalar.rs | 8 +- rust/geoarrow/src/scalar/multipoint/scalar.rs | 6 +- .../src/scalar/multipolygon/scalar.rs | 4 +- rust/geoarrow/src/scalar/point/scalar.rs | 4 +- rust/geoarrow/src/scalar/polygon/owned.rs | 22 +-- rust/geoarrow/src/scalar/polygon/scalar.rs | 6 +- rust/geoarrow/src/scalar/rect/owned.rs | 19 +-- rust/geoarrow/src/scalar/scalar.rs | 89 ++++-------- rust/geoarrow/src/trait_.rs | 18 +-- 25 files changed, 295 insertions(+), 352 deletions(-) diff --git a/python/geoarrow-core/src/constructors.rs b/python/geoarrow-core/src/constructors.rs index e5e7e20e..7abe2ec3 100644 --- a/python/geoarrow-core/src/constructors.rs +++ b/python/geoarrow-core/src/constructors.rs @@ -22,7 +22,7 @@ fn create_array_metadata(crs: Option) -> Arc { pub fn points(coords: PyCoordBuffer, crs: Option) -> PyGeoArrowResult { let metadata = create_array_metadata(crs); // TODO: remove const generic - let array = PointArray::<2>::new(coords.into_inner(), None, metadata); + let array = PointArray::new(coords.into_inner(), None, metadata); Ok(PyNativeArray::new(NativeArrayDyn::new(Arc::new(array)))) } @@ -35,7 +35,7 @@ pub fn linestrings( ) -> PyGeoArrowResult { let metadata = create_array_metadata(crs); // TODO: remove const generic - let array = LineStringArray::<2>::new( + let array = LineStringArray::new( coords.into_inner(), geom_offsets.into_inner(), None, @@ -54,7 +54,7 @@ pub fn polygons( ) -> PyGeoArrowResult { let metadata = create_array_metadata(crs); // TODO: remove const generic - let array = PolygonArray::<2>::new( + let array = PolygonArray::new( coords.into_inner(), geom_offsets.into_inner(), ring_offsets.into_inner(), @@ -72,7 +72,7 @@ pub fn multipoints( crs: Option, ) -> PyGeoArrowResult { let metadata = create_array_metadata(crs); - let array = MultiPointArray::<2>::new( + let array = MultiPointArray::new( coords.into_inner(), geom_offsets.into_inner(), None, @@ -90,7 +90,7 @@ pub fn multilinestrings( crs: Option, ) -> PyGeoArrowResult { let metadata = create_array_metadata(crs); - let array = MultiLineStringArray::<2>::new( + let array = MultiLineStringArray::new( coords.into_inner(), geom_offsets.into_inner(), ring_offsets.into_inner(), @@ -110,7 +110,7 @@ pub fn multipolygons( crs: Option, ) -> PyGeoArrowResult { let metadata = create_array_metadata(crs); - let array = MultiPolygonArray::<2>::new( + let array = MultiPolygonArray::new( coords.into_inner(), geom_offsets.into_inner(), polygon_offsets.into_inner(), diff --git a/rust/geoarrow/src/algorithm/native/concatenate.rs b/rust/geoarrow/src/algorithm/native/concatenate.rs index 6b6162cd..50507875 100644 --- a/rust/geoarrow/src/algorithm/native/concatenate.rs +++ b/rust/geoarrow/src/algorithm/native/concatenate.rs @@ -9,8 +9,8 @@ pub trait Concatenate: Sized { fn concatenate(&self) -> Self::Output; } -impl Concatenate for &[PointArray<2>] { - type Output = Result>; +impl Concatenate for &[PointArray] { + type Output = Result; fn concatenate(&self) -> Self::Output { let output_capacity = self.iter().fold(0, |sum, val| sum + val.buffer_lengths()); @@ -43,50 +43,45 @@ macro_rules! impl_concatenate { } impl_concatenate!( - LineStringArray<2>, + LineStringArray, LineStringCapacity, - LineStringBuilder<2>, + LineStringBuilder, push_line_string ); +impl_concatenate!(PolygonArray, PolygonCapacity, PolygonBuilder, push_polygon); impl_concatenate!( - PolygonArray<2>, - PolygonCapacity, - PolygonBuilder<2>, - push_polygon -); -impl_concatenate!( - MultiPointArray<2>, + MultiPointArray, MultiPointCapacity, - MultiPointBuilder<2>, + MultiPointBuilder, push_multi_point ); impl_concatenate!( - MultiLineStringArray<2>, + MultiLineStringArray, MultiLineStringCapacity, - MultiLineStringBuilder<2>, + MultiLineStringBuilder, push_multi_line_string ); impl_concatenate!( - MultiPolygonArray<2>, + MultiPolygonArray, MultiPolygonCapacity, - MultiPolygonBuilder<2>, + MultiPolygonBuilder, push_multi_polygon ); impl_concatenate!( - MixedGeometryArray<2>, + MixedGeometryArray, MixedCapacity, - MixedGeometryBuilder<2>, + MixedGeometryBuilder, push_geometry ); impl_concatenate!( - GeometryCollectionArray<2>, + GeometryCollectionArray, GeometryCollectionCapacity, - GeometryCollectionBuilder<2>, + GeometryCollectionBuilder, push_geometry_collection ); -impl Concatenate for ChunkedPointArray<2> { - type Output = Result>; +impl Concatenate for ChunkedPointArray { + type Output = Result; fn concatenate(&self) -> Self::Output { self.chunks.as_slice().concatenate() @@ -105,13 +100,10 @@ macro_rules! impl_chunked_concatenate { }; } -impl_chunked_concatenate!(ChunkedLineStringArray<2>, LineStringArray<2>); -impl_chunked_concatenate!(ChunkedPolygonArray<2>, PolygonArray<2>); -impl_chunked_concatenate!(ChunkedMultiPointArray<2>, MultiPointArray<2>); -impl_chunked_concatenate!(ChunkedMultiLineStringArray<2>, MultiLineStringArray<2>); -impl_chunked_concatenate!(ChunkedMultiPolygonArray<2>, MultiPolygonArray<2>); -impl_chunked_concatenate!(ChunkedMixedGeometryArray<2>, MixedGeometryArray<2>); -impl_chunked_concatenate!( - ChunkedGeometryCollectionArray<2>, - GeometryCollectionArray<2> -); +impl_chunked_concatenate!(ChunkedLineStringArray, LineStringArray); +impl_chunked_concatenate!(ChunkedPolygonArray, PolygonArray); +impl_chunked_concatenate!(ChunkedMultiPointArray, MultiPointArray); +impl_chunked_concatenate!(ChunkedMultiLineStringArray, MultiLineStringArray); +impl_chunked_concatenate!(ChunkedMultiPolygonArray, MultiPolygonArray); +impl_chunked_concatenate!(ChunkedMixedGeometryArray, MixedGeometryArray); +impl_chunked_concatenate!(ChunkedGeometryCollectionArray, GeometryCollectionArray); diff --git a/rust/geoarrow/src/algorithm/native/downcast.rs b/rust/geoarrow/src/algorithm/native/downcast.rs index bdf306bb..9006f37e 100644 --- a/rust/geoarrow/src/algorithm/native/downcast.rs +++ b/rust/geoarrow/src/algorithm/native/downcast.rs @@ -38,7 +38,7 @@ pub trait Downcast { fn downcast(&self, small_offsets: bool) -> Self::Output; } -impl Downcast for PointArray<2> { +impl Downcast for PointArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -90,7 +90,7 @@ pub(crate) fn can_downcast_multi(buffer: &OffsetBuffer) - .all(|slice| *slice.get(1).unwrap() - *slice.first().unwrap() <= O::one()) } -impl Downcast for LineStringArray<2> { +impl Downcast for LineStringArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -111,7 +111,7 @@ impl Downcast for LineStringArray<2> { } } -impl Downcast for PolygonArray<2> { +impl Downcast for PolygonArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -126,7 +126,7 @@ impl Downcast for PolygonArray<2> { } } -impl Downcast for MultiPointArray<2> { +impl Downcast for MultiPointArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -144,7 +144,7 @@ impl Downcast for MultiPointArray<2> { fn downcast(&self, small_offsets: bool) -> Self::Output { // Note: this won't allow a downcast for empty MultiPoints if *self.geom_offsets.last() as usize == self.len() { - return Arc::new(PointArray::<2>::new( + return Arc::new(PointArray::new( self.coords.clone(), self.validity.clone(), self.metadata(), @@ -155,7 +155,7 @@ impl Downcast for MultiPointArray<2> { } } -impl Downcast for MultiLineStringArray<2> { +impl Downcast for MultiLineStringArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -173,7 +173,7 @@ impl Downcast for MultiLineStringArray<2> { fn downcast(&self, small_offsets: bool) -> Self::Output { if *self.geom_offsets.last() as usize == self.len() { - return Arc::new(LineStringArray::<2>::new( + return Arc::new(LineStringArray::new( self.coords.clone(), self.ring_offsets.clone(), self.validity.clone(), @@ -185,7 +185,7 @@ impl Downcast for MultiLineStringArray<2> { } } -impl Downcast for MultiPolygonArray<2> { +impl Downcast for MultiPolygonArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -203,7 +203,7 @@ impl Downcast for MultiPolygonArray<2> { fn downcast(&self, small_offsets: bool) -> Self::Output { if *self.geom_offsets.last() as usize == self.len() { - return Arc::new(PolygonArray::<2>::new( + return Arc::new(PolygonArray::new( self.coords.clone(), self.polygon_offsets.clone(), self.ring_offsets.clone(), @@ -216,7 +216,7 @@ impl Downcast for MultiPolygonArray<2> { } } -impl Downcast for MixedGeometryArray<2> { +impl Downcast for MixedGeometryArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -351,7 +351,7 @@ impl Downcast for MixedGeometryArray<2> { } } -impl Downcast for GeometryCollectionArray<2> { +impl Downcast for GeometryCollectionArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -368,7 +368,7 @@ impl Downcast for GeometryCollectionArray<2> { } } -impl Downcast for RectArray<2> { +impl Downcast for RectArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -387,25 +387,19 @@ impl Downcast for &dyn NativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().downcasted_data_type(small_offsets), - LineString(_, XY) => self - .as_line_string::<2>() - .downcasted_data_type(small_offsets), - Polygon(_, XY) => self.as_polygon::<2>().downcasted_data_type(small_offsets), - MultiPoint(_, XY) => self - .as_multi_point::<2>() - .downcasted_data_type(small_offsets), + Point(_, XY) => self.as_point().downcasted_data_type(small_offsets), + LineString(_, XY) => self.as_line_string().downcasted_data_type(small_offsets), + Polygon(_, XY) => self.as_polygon().downcasted_data_type(small_offsets), + MultiPoint(_, XY) => self.as_multi_point().downcasted_data_type(small_offsets), MultiLineString(_, XY) => self - .as_multi_line_string::<2>() - .downcasted_data_type(small_offsets), - MultiPolygon(_, XY) => self - .as_multi_polygon::<2>() + .as_multi_line_string() .downcasted_data_type(small_offsets), - Mixed(_, XY) => self.as_mixed::<2>().downcasted_data_type(small_offsets), + MultiPolygon(_, XY) => self.as_multi_polygon().downcasted_data_type(small_offsets), + Mixed(_, XY) => self.as_mixed().downcasted_data_type(small_offsets), GeometryCollection(_, XY) => self - .as_geometry_collection::<2>() + .as_geometry_collection() .downcasted_data_type(small_offsets), - Rect(XY) => self.as_rect::<2>().downcasted_data_type(small_offsets), + Rect(XY) => self.as_rect().downcasted_data_type(small_offsets), _ => todo!("3d support"), } } @@ -415,15 +409,15 @@ impl Downcast for &dyn NativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().downcast(small_offsets), - LineString(_, XY) => self.as_line_string::<2>().downcast(small_offsets), - Polygon(_, XY) => self.as_polygon::<2>().downcast(small_offsets), - MultiPoint(_, XY) => self.as_multi_point::<2>().downcast(small_offsets), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().downcast(small_offsets), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().downcast(small_offsets), - Mixed(_, XY) => self.as_mixed::<2>().downcast(small_offsets), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().downcast(small_offsets), - Rect(XY) => self.as_rect::<2>().downcast(small_offsets), + Point(_, XY) => self.as_point().downcast(small_offsets), + LineString(_, XY) => self.as_line_string().downcast(small_offsets), + Polygon(_, XY) => self.as_polygon().downcast(small_offsets), + MultiPoint(_, XY) => self.as_multi_point().downcast(small_offsets), + MultiLineString(_, XY) => self.as_multi_line_string().downcast(small_offsets), + MultiPolygon(_, XY) => self.as_multi_polygon().downcast(small_offsets), + Mixed(_, XY) => self.as_mixed().downcast(small_offsets), + GeometryCollection(_, XY) => self.as_geometry_collection().downcast(small_offsets), + Rect(XY) => self.as_rect().downcast(small_offsets), _ => todo!("3d support"), } } @@ -463,7 +457,7 @@ fn resolve_types(types: &HashSet) -> NativeType { } } -impl Downcast for ChunkedPointArray<2> { +impl Downcast for ChunkedPointArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -499,15 +493,15 @@ macro_rules! impl_chunked_downcast { }; } -impl_chunked_downcast!(ChunkedLineStringArray<2>); -impl_chunked_downcast!(ChunkedPolygonArray<2>); -impl_chunked_downcast!(ChunkedMultiPointArray<2>); -impl_chunked_downcast!(ChunkedMultiLineStringArray<2>); -impl_chunked_downcast!(ChunkedMultiPolygonArray<2>); -impl_chunked_downcast!(ChunkedMixedGeometryArray<2>); -impl_chunked_downcast!(ChunkedGeometryCollectionArray<2>); +impl_chunked_downcast!(ChunkedLineStringArray); +impl_chunked_downcast!(ChunkedPolygonArray); +impl_chunked_downcast!(ChunkedMultiPointArray); +impl_chunked_downcast!(ChunkedMultiLineStringArray); +impl_chunked_downcast!(ChunkedMultiPolygonArray); +impl_chunked_downcast!(ChunkedMixedGeometryArray); +impl_chunked_downcast!(ChunkedGeometryCollectionArray); -impl Downcast for ChunkedRectArray<2> { +impl Downcast for ChunkedRectArray { type Output = Arc; fn downcasted_data_type(&self, small_offsets: bool) -> NativeType { @@ -526,25 +520,19 @@ impl Downcast for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().downcasted_data_type(small_offsets), - LineString(_, XY) => self - .as_line_string::<2>() - .downcasted_data_type(small_offsets), - Polygon(_, XY) => self.as_polygon::<2>().downcasted_data_type(small_offsets), - MultiPoint(_, XY) => self - .as_multi_point::<2>() - .downcasted_data_type(small_offsets), + Point(_, XY) => self.as_point().downcasted_data_type(small_offsets), + LineString(_, XY) => self.as_line_string().downcasted_data_type(small_offsets), + Polygon(_, XY) => self.as_polygon().downcasted_data_type(small_offsets), + MultiPoint(_, XY) => self.as_multi_point().downcasted_data_type(small_offsets), MultiLineString(_, XY) => self - .as_multi_line_string::<2>() - .downcasted_data_type(small_offsets), - MultiPolygon(_, XY) => self - .as_multi_polygon::<2>() + .as_multi_line_string() .downcasted_data_type(small_offsets), - Mixed(_, XY) => self.as_mixed::<2>().downcasted_data_type(small_offsets), + MultiPolygon(_, XY) => self.as_multi_polygon().downcasted_data_type(small_offsets), + Mixed(_, XY) => self.as_mixed().downcasted_data_type(small_offsets), GeometryCollection(_, XY) => self - .as_geometry_collection::<2>() + .as_geometry_collection() .downcasted_data_type(small_offsets), - Rect(XY) => self.as_rect::<2>().downcasted_data_type(small_offsets), + Rect(XY) => self.as_rect().downcasted_data_type(small_offsets), _ => todo!("3d support"), } } @@ -554,15 +542,15 @@ impl Downcast for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().downcast(small_offsets), - LineString(_, XY) => self.as_line_string::<2>().downcast(small_offsets), - Polygon(_, XY) => self.as_polygon::<2>().downcast(small_offsets), - MultiPoint(_, XY) => self.as_multi_point::<2>().downcast(small_offsets), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().downcast(small_offsets), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().downcast(small_offsets), - Mixed(_, XY) => self.as_mixed::<2>().downcast(small_offsets), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().downcast(small_offsets), - Rect(XY) => self.as_rect::<2>().downcast(small_offsets), + Point(_, XY) => self.as_point().downcast(small_offsets), + LineString(_, XY) => self.as_line_string().downcast(small_offsets), + Polygon(_, XY) => self.as_polygon().downcast(small_offsets), + MultiPoint(_, XY) => self.as_multi_point().downcast(small_offsets), + MultiLineString(_, XY) => self.as_multi_line_string().downcast(small_offsets), + MultiPolygon(_, XY) => self.as_multi_polygon().downcast(small_offsets), + Mixed(_, XY) => self.as_mixed().downcast(small_offsets), + GeometryCollection(_, XY) => self.as_geometry_collection().downcast(small_offsets), + Rect(XY) => self.as_rect().downcast(small_offsets), _ => todo!("3d support"), } } @@ -611,7 +599,7 @@ impl DowncastTable for Table { } } -// impl Downcast for ChunkedMultiPointArray<2> { +// impl Downcast for ChunkedMultiPointArray { // type Output = Arc; // fn downcast(&self) -> Self::Output { diff --git a/rust/geoarrow/src/array/linestring/array.rs b/rust/geoarrow/src/array/linestring/array.rs index d969cd46..11a1a69b 100644 --- a/rust/geoarrow/src/array/linestring/array.rs +++ b/rust/geoarrow/src/array/linestring/array.rs @@ -10,7 +10,7 @@ use crate::array::{ CoordBuffer, CoordType, GeometryCollectionArray, MixedGeometryArray, MultiLineStringArray, MultiPointArray, WKBArray, }; -use crate::datatypes::NativeType; +use crate::datatypes::{Dimension, NativeType}; use crate::error::{GeoArrowError, Result}; use crate::scalar::{Geometry, LineString}; use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor}; @@ -346,11 +346,11 @@ impl IntoArrow for LineStringArray { } } -impl TryFrom<&GenericListArray> for LineStringArray { +impl TryFrom<(&GenericListArray, Dimension)> for LineStringArray { type Error = GeoArrowError; - fn try_from(value: &GenericListArray) -> Result { - let coords = CoordBuffer::from_arrow(value.values().as_ref(), D.try_into()?)?; + fn try_from((value, dim): (&GenericListArray, Dimension)) -> Result { + let coords = CoordBuffer::from_arrow(value.values().as_ref(), dim)?; let geom_offsets = value.offsets(); let validity = value.nulls(); @@ -363,11 +363,11 @@ impl TryFrom<&GenericListArray> for LineStringArray { } } -impl TryFrom<&GenericListArray> for LineStringArray { +impl TryFrom<(&GenericListArray, Dimension)> for LineStringArray { type Error = GeoArrowError; - fn try_from(value: &GenericListArray) -> Result { - let coords = CoordBuffer::from_arrow(value.values().as_ref(), D.try_into()?)?; + fn try_from((value, dim): (&GenericListArray, Dimension)) -> Result { + let coords = CoordBuffer::from_arrow(value.values().as_ref(), dim)?; let geom_offsets = offsets_buffer_i64_to_i32(value.offsets())?; let validity = value.nulls(); @@ -379,18 +379,18 @@ impl TryFrom<&GenericListArray> for LineStringArray { )) } } -impl TryFrom<&dyn Array> for LineStringArray { +impl TryFrom<(&dyn Array, Dimension)> for LineStringArray { type Error = GeoArrowError; - fn try_from(value: &dyn Array) -> Result { + fn try_from((value, dim): (&dyn Array, Dimension)) -> Result { match value.data_type() { DataType::List(_) => { let downcasted = value.as_list::(); - downcasted.try_into() + (downcasted, dim).try_into() } DataType::LargeList(_) => { let downcasted = value.as_list::(); - downcasted.try_into() + (downcasted, dim).try_into() } _ => Err(GeoArrowError::General(format!( "Unexpected type: {:?}", @@ -404,7 +404,8 @@ impl TryFrom<(&dyn Array, &Field)> for LineStringArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { - let mut arr: Self = arr.try_into()?; + let geom_type = NativeType::try_from(field)?; + let mut arr: Self = (arr, geom_type.dimension()).try_into()?; arr.metadata = Arc::new(ArrayMetadata::try_from(field)?); Ok(arr) } diff --git a/rust/geoarrow/src/array/multilinestring/array.rs b/rust/geoarrow/src/array/multilinestring/array.rs index ce2c54c5..2eb5064d 100644 --- a/rust/geoarrow/src/array/multilinestring/array.rs +++ b/rust/geoarrow/src/array/multilinestring/array.rs @@ -8,7 +8,7 @@ use crate::array::{ CoordBuffer, CoordType, GeometryCollectionArray, LineStringArray, MixedGeometryArray, PolygonArray, WKBArray, }; -use crate::datatypes::NativeType; +use crate::datatypes::{Dimension, NativeType}; use crate::error::{GeoArrowError, Result}; use crate::scalar::{Geometry, MultiLineString}; use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor}; @@ -386,10 +386,10 @@ impl IntoArrow for MultiLineStringArray { } } -impl TryFrom<&GenericListArray> for MultiLineStringArray { +impl TryFrom<(&GenericListArray, Dimension)> for MultiLineStringArray { type Error = GeoArrowError; - fn try_from(geom_array: &GenericListArray) -> Result { + fn try_from((geom_array, dim): (&GenericListArray, Dimension)) -> Result { let geom_offsets = geom_array.offsets(); let validity = geom_array.nulls(); @@ -397,7 +397,7 @@ impl TryFrom<&GenericListArray> for MultiLineStringArray { let rings_array = rings_dyn_array.as_list::(); let ring_offsets = rings_array.offsets(); - let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), D.try_into()?)?; + let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), dim)?; Ok(Self::new( coords, @@ -409,10 +409,10 @@ impl TryFrom<&GenericListArray> for MultiLineStringArray { } } -impl TryFrom<&GenericListArray> for MultiLineStringArray { +impl TryFrom<(&GenericListArray, Dimension)> for MultiLineStringArray { type Error = GeoArrowError; - fn try_from(geom_array: &GenericListArray) -> Result { + fn try_from((geom_array, dim): (&GenericListArray, Dimension)) -> Result { let geom_offsets = offsets_buffer_i64_to_i32(geom_array.offsets())?; let validity = geom_array.nulls(); @@ -420,7 +420,7 @@ impl TryFrom<&GenericListArray> for MultiLineStringArray { let rings_array = rings_dyn_array.as_list::(); let ring_offsets = offsets_buffer_i64_to_i32(rings_array.offsets())?; - let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), D.try_into()?)?; + let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), dim)?; Ok(Self::new( coords, @@ -432,18 +432,18 @@ impl TryFrom<&GenericListArray> for MultiLineStringArray { } } -impl TryFrom<&dyn Array> for MultiLineStringArray { +impl TryFrom<(&dyn Array, Dimension)> for MultiLineStringArray { type Error = GeoArrowError; - fn try_from(value: &dyn Array) -> Result { + fn try_from((value, dim): (&dyn Array, Dimension)) -> Result { match value.data_type() { DataType::List(_) => { let downcasted = value.as_list::(); - downcasted.try_into() + (downcasted, dim).try_into() } DataType::LargeList(_) => { let downcasted = value.as_list::(); - downcasted.try_into() + (downcasted, dim).try_into() } _ => Err(GeoArrowError::General(format!( "Unexpected type: {:?}", @@ -457,22 +457,21 @@ impl TryFrom<(&dyn Array, &Field)> for MultiLineStringArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { - let mut arr: Self = arr.try_into()?; + let geom_type = NativeType::try_from(field)?; + let mut arr: Self = (arr, geom_type.dimension()).try_into()?; arr.metadata = Arc::new(ArrayMetadata::try_from(field)?); Ok(arr) } } -impl, const D: usize> From>> - for MultiLineStringArray -{ +impl> From>> for MultiLineStringArray { fn from(other: Vec>) -> Self { let mut_arr: MultiLineStringBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From<&[G]> for MultiLineStringArray { +impl> From<&[G]> for MultiLineStringArray { fn from(other: &[G]) -> Self { let mut_arr: MultiLineStringBuilder = other.into(); mut_arr.into() @@ -493,7 +492,7 @@ impl From for PolygonArray { } } -impl TryFrom> for MultiLineStringArray { +impl TryFrom> for MultiLineStringArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { @@ -565,6 +564,7 @@ impl TryFrom for MultiLineStringArray { capacity += value.line_strings.buffer_lengths(); let mut builder = MultiLineStringBuilder::with_capacity_and_options( + value.dim(), capacity, value.coord_type(), value.metadata(), diff --git a/rust/geoarrow/src/array/multipoint/array.rs b/rust/geoarrow/src/array/multipoint/array.rs index 37c9421c..bfbd5e05 100644 --- a/rust/geoarrow/src/array/multipoint/array.rs +++ b/rust/geoarrow/src/array/multipoint/array.rs @@ -9,7 +9,7 @@ use crate::array::{ CoordBuffer, CoordType, GeometryCollectionArray, LineStringArray, MixedGeometryArray, PointArray, WKBArray, }; -use crate::datatypes::NativeType; +use crate::datatypes::{Dimension, NativeType}; use crate::error::{GeoArrowError, Result}; use crate::scalar::{Geometry, MultiPoint}; use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor}; @@ -333,11 +333,11 @@ impl IntoArrow for MultiPointArray { } } -impl TryFrom<&GenericListArray> for MultiPointArray { +impl TryFrom<(&GenericListArray, Dimension)> for MultiPointArray { type Error = GeoArrowError; - fn try_from(value: &GenericListArray) -> Result { - let coords = CoordBuffer::from_arrow(value.values().as_ref(), D.try_into()?)?; + fn try_from((value, dim): (&GenericListArray, Dimension)) -> Result { + let coords = CoordBuffer::from_arrow(value.values().as_ref(), dim)?; let geom_offsets = value.offsets(); let validity = value.nulls(); @@ -350,11 +350,11 @@ impl TryFrom<&GenericListArray> for MultiPointArray { } } -impl TryFrom<&GenericListArray> for MultiPointArray { +impl TryFrom<(&GenericListArray, Dimension)> for MultiPointArray { type Error = GeoArrowError; - fn try_from(value: &GenericListArray) -> Result { - let coords = CoordBuffer::from_arrow(value.values().as_ref(), D.try_into()?)?; + fn try_from((value, dim): (&GenericListArray, Dimension)) -> Result { + let coords = CoordBuffer::from_arrow(value.values().as_ref(), dim)?; let geom_offsets = offsets_buffer_i64_to_i32(value.offsets())?; let validity = value.nulls(); @@ -367,18 +367,18 @@ impl TryFrom<&GenericListArray> for MultiPointArray { } } -impl TryFrom<&dyn Array> for MultiPointArray { +impl TryFrom<(&dyn Array, Dimension)> for MultiPointArray { type Error = GeoArrowError; - fn try_from(value: &dyn Array) -> Result { + fn try_from((value, dim): (&dyn Array, Dimension)) -> Result { match value.data_type() { DataType::List(_) => { let downcasted = value.as_list::(); - downcasted.try_into() + (downcasted, dim).try_into() } DataType::LargeList(_) => { let downcasted = value.as_list::(); - downcasted.try_into() + (downcasted, dim).try_into() } _ => Err(GeoArrowError::General(format!( "Unexpected type: {:?}", @@ -392,27 +392,28 @@ impl TryFrom<(&dyn Array, &Field)> for MultiPointArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { - let mut arr: Self = arr.try_into()?; + let geom_type = NativeType::try_from(field)?; + let mut arr: Self = (arr, geom_type.dimension()).try_into()?; arr.metadata = Arc::new(ArrayMetadata::try_from(field)?); Ok(arr) } } -impl, const D: usize> From>> for MultiPointArray { +impl> From>> for MultiPointArray { fn from(other: Vec>) -> Self { let mut_arr: MultiPointBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From<&[G]> for MultiPointArray { +impl> From<&[G]> for MultiPointArray { fn from(other: &[G]) -> Self { let mut_arr: MultiPointBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for MultiPointArray { +impl TryFrom> for MultiPointArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { diff --git a/rust/geoarrow/src/array/multipolygon/array.rs b/rust/geoarrow/src/array/multipolygon/array.rs index 5fe8a981..2ef32b33 100644 --- a/rust/geoarrow/src/array/multipolygon/array.rs +++ b/rust/geoarrow/src/array/multipolygon/array.rs @@ -7,7 +7,7 @@ use crate::array::util::{offsets_buffer_i64_to_i32, OffsetBufferUtils}; use crate::array::{ CoordBuffer, CoordType, GeometryCollectionArray, MixedGeometryArray, PolygonArray, WKBArray, }; -use crate::datatypes::NativeType; +use crate::datatypes::{Dimension, NativeType}; use crate::error::{GeoArrowError, Result}; use crate::scalar::{Geometry, MultiPolygon}; use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor}; @@ -470,10 +470,10 @@ impl IntoArrow for MultiPolygonArray { } } -impl TryFrom<&GenericListArray> for MultiPolygonArray { +impl TryFrom<(&GenericListArray, Dimension)> for MultiPolygonArray { type Error = GeoArrowError; - fn try_from(geom_array: &GenericListArray) -> Result { + fn try_from((geom_array, dim): (&GenericListArray, Dimension)) -> Result { let geom_offsets = geom_array.offsets(); let validity = geom_array.nulls(); @@ -485,7 +485,7 @@ impl TryFrom<&GenericListArray> for MultiPolygonArray { let rings_array = rings_dyn_array.as_list::(); let ring_offsets = rings_array.offsets(); - let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), D.try_into()?)?; + let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), dim)?; Ok(Self::new( coords, @@ -498,10 +498,10 @@ impl TryFrom<&GenericListArray> for MultiPolygonArray { } } -impl TryFrom<&GenericListArray> for MultiPolygonArray { +impl TryFrom<(&GenericListArray, Dimension)> for MultiPolygonArray { type Error = GeoArrowError; - fn try_from(geom_array: &GenericListArray) -> Result { + fn try_from((geom_array, dim): (&GenericListArray, Dimension)) -> Result { let geom_offsets = offsets_buffer_i64_to_i32(geom_array.offsets())?; let validity = geom_array.nulls(); @@ -513,7 +513,7 @@ impl TryFrom<&GenericListArray> for MultiPolygonArray { let rings_array = rings_dyn_array.as_list::(); let ring_offsets = offsets_buffer_i64_to_i32(rings_array.offsets())?; - let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), D.try_into()?)?; + let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), dim)?; Ok(Self::new( coords, @@ -526,18 +526,18 @@ impl TryFrom<&GenericListArray> for MultiPolygonArray { } } -impl TryFrom<&dyn Array> for MultiPolygonArray { +impl TryFrom<(&dyn Array, Dimension)> for MultiPolygonArray { type Error = GeoArrowError; - fn try_from(value: &dyn Array) -> Result { + fn try_from((value, dim): (&dyn Array, Dimension)) -> Result { match value.data_type() { DataType::List(_) => { let downcasted = value.as_list::(); - downcasted.try_into() + (downcasted, dim).try_into() } DataType::LargeList(_) => { let downcasted = value.as_list::(); - downcasted.try_into() + (downcasted, dim).try_into() } _ => Err(GeoArrowError::General(format!( "Unexpected type: {:?}", @@ -551,27 +551,28 @@ impl TryFrom<(&dyn Array, &Field)> for MultiPolygonArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { - let mut arr: Self = arr.try_into()?; + let geom_type = NativeType::try_from(field)?; + let mut arr: Self = (arr, geom_type.dimension()).try_into()?; arr.metadata = Arc::new(ArrayMetadata::try_from(field)?); Ok(arr) } } -impl, const D: usize> From>> for MultiPolygonArray { +impl> From>> for MultiPolygonArray { fn from(other: Vec>) -> Self { let mut_arr: MultiPolygonBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From<&[G]> for MultiPolygonArray { +impl> From<&[G]> for MultiPolygonArray { fn from(other: &[G]) -> Self { let mut_arr: MultiPolygonBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for MultiPolygonArray { +impl TryFrom> for MultiPolygonArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { diff --git a/rust/geoarrow/src/array/point/array.rs b/rust/geoarrow/src/array/point/array.rs index f188b924..7d44bc68 100644 --- a/rust/geoarrow/src/array/point/array.rs +++ b/rust/geoarrow/src/array/point/array.rs @@ -7,7 +7,7 @@ use crate::array::{ CoordBuffer, CoordType, GeometryCollectionArray, InterleavedCoordBuffer, MixedGeometryArray, MultiPointArray, PointBuilder, SeparatedCoordBuffer, WKBArray, }; -use crate::datatypes::NativeType; +use crate::datatypes::{Dimension, NativeType}; use crate::error::{GeoArrowError, Result}; use crate::scalar::{Geometry, Point}; use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor}; @@ -267,7 +267,7 @@ impl IntoArrow for PointArray { match self.coords { CoordBuffer::Interleaved(c) => Arc::new(FixedSizeListArray::new( c.values_field().into(), - D as i32, + self.coords.dim().size() as i32, Arc::new(c.values_array()), validity, )), @@ -279,11 +279,11 @@ impl IntoArrow for PointArray { } } -impl TryFrom<&FixedSizeListArray> for PointArray { +impl TryFrom<(&FixedSizeListArray, Dimension)> for PointArray { type Error = GeoArrowError; - fn try_from(value: &FixedSizeListArray) -> Result { - let interleaved_coords = InterleavedCoordBuffer::from_arrow(value, D.try_into()?)?; + fn try_from((value, dim): (&FixedSizeListArray, Dimension)) -> Result { + let interleaved_coords = InterleavedCoordBuffer::from_arrow(value, dim)?; Ok(Self::new( CoordBuffer::Interleaved(interleaved_coords), @@ -293,12 +293,12 @@ impl TryFrom<&FixedSizeListArray> for PointArray { } } -impl TryFrom<&StructArray> for PointArray { +impl TryFrom<(&StructArray, Dimension)> for PointArray { type Error = GeoArrowError; - fn try_from(value: &StructArray) -> Result { + fn try_from((value, dim): (&StructArray, Dimension)) -> Result { let validity = value.nulls(); - let separated_coords = SeparatedCoordBuffer::from_arrow(value, D.try_into()?)?; + let separated_coords = SeparatedCoordBuffer::from_arrow(value, dim)?; Ok(Self::new( CoordBuffer::Separated(separated_coords), validity.cloned(), @@ -307,18 +307,18 @@ impl TryFrom<&StructArray> for PointArray { } } -impl TryFrom<&dyn Array> for PointArray { +impl TryFrom<(&dyn Array, Dimension)> for PointArray { type Error = GeoArrowError; - fn try_from(value: &dyn Array) -> Result { + fn try_from((value, dim): (&dyn Array, Dimension)) -> Result { match value.data_type() { DataType::FixedSizeList(_, _) => { let arr = value.as_any().downcast_ref::().unwrap(); - arr.try_into() + (arr, dim).try_into() } DataType::Struct(_) => { let arr = value.as_any().downcast_ref::().unwrap(); - arr.try_into() + (arr, dim).try_into() } _ => Err(GeoArrowError::General( "Invalid data type for PointArray".to_string(), @@ -331,27 +331,28 @@ impl TryFrom<(&dyn Array, &Field)> for PointArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { - let mut arr: Self = arr.try_into()?; + let geom_type = NativeType::try_from(field)?; + let mut arr: Self = (arr, geom_type.dimension()).try_into()?; arr.metadata = Arc::new(ArrayMetadata::try_from(field)?); Ok(arr) } } -impl, const D: usize> From>> for PointArray { +impl> From>> for PointArray { fn from(other: Vec>) -> Self { let mut_arr: PointBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From<&[G]> for PointArray { +impl> From<&[G]> for PointArray { fn from(other: &[G]) -> Self { let mut_arr: PointBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for PointArray { +impl TryFrom> for PointArray { type Error = GeoArrowError; fn try_from(value: WKBArray) -> Result { diff --git a/rust/geoarrow/src/array/polygon/array.rs b/rust/geoarrow/src/array/polygon/array.rs index 92150ceb..7c4facdd 100644 --- a/rust/geoarrow/src/array/polygon/array.rs +++ b/rust/geoarrow/src/array/polygon/array.rs @@ -9,7 +9,7 @@ use crate::array::{ CoordBuffer, CoordType, GeometryCollectionArray, MixedGeometryArray, MultiLineStringArray, MultiPolygonArray, RectArray, WKBArray, }; -use crate::datatypes::NativeType; +use crate::datatypes::{Dimension, NativeType}; use crate::error::{GeoArrowError, Result}; use crate::scalar::{Geometry, Polygon}; use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor}; @@ -389,10 +389,10 @@ impl IntoArrow for PolygonArray { } } -impl TryFrom<&GenericListArray> for PolygonArray { +impl TryFrom<(&GenericListArray, Dimension)> for PolygonArray { type Error = GeoArrowError; - fn try_from(geom_array: &GenericListArray) -> Result { + fn try_from((geom_array, dim): (&GenericListArray, Dimension)) -> Result { let geom_offsets = geom_array.offsets(); let validity = geom_array.nulls(); @@ -400,7 +400,7 @@ impl TryFrom<&GenericListArray> for PolygonArray { let rings_array = rings_dyn_array.as_list::(); let ring_offsets = rings_array.offsets(); - let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), D.try_into()?)?; + let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), dim)?; Ok(Self::new( coords, @@ -412,10 +412,10 @@ impl TryFrom<&GenericListArray> for PolygonArray { } } -impl TryFrom<&GenericListArray> for PolygonArray { +impl TryFrom<(&GenericListArray, Dimension)> for PolygonArray { type Error = GeoArrowError; - fn try_from(geom_array: &GenericListArray) -> Result { + fn try_from((geom_array, dim): (&GenericListArray, Dimension)) -> Result { let geom_offsets = offsets_buffer_i64_to_i32(geom_array.offsets())?; let validity = geom_array.nulls(); @@ -423,7 +423,7 @@ impl TryFrom<&GenericListArray> for PolygonArray { let rings_array = rings_dyn_array.as_list::(); let ring_offsets = offsets_buffer_i64_to_i32(rings_array.offsets())?; - let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), D.try_into()?)?; + let coords = CoordBuffer::from_arrow(rings_array.values().as_ref(), dim)?; Ok(Self::new( coords, @@ -434,18 +434,18 @@ impl TryFrom<&GenericListArray> for PolygonArray { )) } } -impl TryFrom<&dyn Array> for PolygonArray { +impl TryFrom<(&dyn Array, Dimension)> for PolygonArray { type Error = GeoArrowError; - fn try_from(value: &dyn Array) -> Result { + fn try_from((value, dim): (&dyn Array, Dimension)) -> Result { match value.data_type() { DataType::List(_) => { let downcasted = value.as_list::(); - downcasted.try_into() + (downcasted, dim).try_into() } DataType::LargeList(_) => { let downcasted = value.as_list::(); - downcasted.try_into() + (downcasted, dim).try_into() } _ => Err(GeoArrowError::General(format!( "Unexpected type: {:?}", @@ -459,7 +459,8 @@ impl TryFrom<(&dyn Array, &Field)> for PolygonArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { - let mut arr: Self = arr.try_into()?; + let geom_type = NativeType::try_from(field)?; + let mut arr: Self = (arr, geom_type.dimension()).try_into()?; arr.metadata = Arc::new(ArrayMetadata::try_from(field)?); Ok(arr) } diff --git a/rust/geoarrow/src/array/rect/array.rs b/rust/geoarrow/src/array/rect/array.rs index 844acfe5..93f2fa8a 100644 --- a/rust/geoarrow/src/array/rect/array.rs +++ b/rust/geoarrow/src/array/rect/array.rs @@ -9,7 +9,7 @@ use arrow_schema::{DataType, Field}; use crate::array::metadata::ArrayMetadata; use crate::array::rect::RectBuilder; use crate::array::{CoordBuffer, CoordType, SeparatedCoordBuffer}; -use crate::datatypes::{rect_fields, NativeType}; +use crate::datatypes::{rect_fields, Dimension, NativeType}; use crate::error::GeoArrowError; use crate::scalar::Rect; use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow}; @@ -47,7 +47,8 @@ impl RectArray { validity: Option, metadata: Arc, ) -> Self { - let data_type = NativeType::Rect(D.try_into().unwrap()); + assert_eq!(lower.dim(), upper.dim()); + let data_type = NativeType::Rect(lower.dim()); Self { data_type, lower, @@ -191,7 +192,7 @@ impl IntoArrow for RectArray { type ArrowArray = StructArray; fn into_arrow(self) -> Self::ArrowArray { - let fields = rect_fields(D.try_into().unwrap()); + let fields = rect_fields(self.data_type.dimension()); let mut arrays: Vec = vec![]; for buf in self.lower.buffers { arrays.push(Arc::new(Float64Array::new(buf, None))); @@ -205,50 +206,48 @@ impl IntoArrow for RectArray { } } -impl TryFrom<&StructArray> for RectArray { +impl TryFrom<(&StructArray, Dimension)> for RectArray { type Error = GeoArrowError; - fn try_from(value: &StructArray) -> Result { + fn try_from((value, dim): (&StructArray, Dimension)) -> Result { let validity = value.nulls(); let columns = value.columns(); - assert_eq!(columns.len(), D * 2); + assert_eq!(columns.len(), dim.size() * 2); - let lower = match D { - 2 => { + let lower = match dim { + Dimension::XY => { core::array::from_fn(|i| columns[i].as_primitive::().values().clone()) } - 3 => { + Dimension::XYZ => { core::array::from_fn(|i| columns[i].as_primitive::().values().clone()) } - _ => panic!("unexpected dim"), }; - let upper = match D { - 2 => { + let upper = match dim { + Dimension::XY => { core::array::from_fn(|i| columns[i].as_primitive::().values().clone()) } - 3 => { + Dimension::XYZ => { core::array::from_fn(|i| columns[i].as_primitive::().values().clone()) } - _ => panic!("unexpected dim"), }; Ok(Self::new( - SeparatedCoordBuffer::new(lower, D.try_into().unwrap()), - SeparatedCoordBuffer::new(upper, D.try_into().unwrap()), + SeparatedCoordBuffer::new(lower, dim), + SeparatedCoordBuffer::new(upper, dim), validity.cloned(), Default::default(), )) } } -impl TryFrom<&dyn Array> for RectArray { +impl TryFrom<(&dyn Array, Dimension)> for RectArray { type Error = GeoArrowError; - fn try_from(value: &dyn Array) -> Result { + fn try_from((value, dim): (&dyn Array, Dimension)) -> Result { match value.data_type() { DataType::Struct(_) => { let arr = value.as_any().downcast_ref::().unwrap(); - arr.try_into() + (arr, dim).try_into() } _ => Err(GeoArrowError::General( "Invalid data type for RectArray".to_string(), @@ -261,20 +260,21 @@ impl TryFrom<(&dyn Array, &Field)> for RectArray { type Error = GeoArrowError; fn try_from((arr, field): (&dyn Array, &Field)) -> Result { - let mut arr: Self = arr.try_into()?; + let geom_type = NativeType::try_from(field)?; + let mut arr: Self = (arr, geom_type.dimension()).try_into()?; arr.metadata = Arc::new(ArrayMetadata::try_from(field)?); Ok(arr) } } -impl, const D: usize> From<&[G]> for RectArray { +impl> From<&[G]> for RectArray { fn from(other: &[G]) -> Self { let mut_arr: RectBuilder = other.into(); mut_arr.into() } } -impl, const D: usize> From>> for RectArray { +impl> From>> for RectArray { fn from(other: Vec>) -> Self { let mut_arr: RectBuilder = other.into(); mut_arr.into() diff --git a/rust/geoarrow/src/datatypes.rs b/rust/geoarrow/src/datatypes.rs index 660c4b16..f9453d8e 100644 --- a/rust/geoarrow/src/datatypes.rs +++ b/rust/geoarrow/src/datatypes.rs @@ -990,7 +990,7 @@ mod test { let data_type: NativeType = field.as_ref().try_into().unwrap(); assert_eq!(ml_array.data_type(), data_type); - let mut builder = MixedGeometryBuilder::<2>::new(); + let mut builder = MixedGeometryBuilder::new(); builder.push_point(Some(&crate::test::point::p0())).unwrap(); builder.push_point(Some(&crate::test::point::p1())).unwrap(); builder.push_point(Some(&crate::test::point::p2())).unwrap(); diff --git a/rust/geoarrow/src/scalar/geometry/owned.rs b/rust/geoarrow/src/scalar/geometry/owned.rs index 4a305e80..8293c351 100644 --- a/rust/geoarrow/src/scalar/geometry/owned.rs +++ b/rust/geoarrow/src/scalar/geometry/owned.rs @@ -36,8 +36,8 @@ impl<'a> From<&'a OwnedGeometry> for Geometry<'a> { } } -impl<'a> From<&'a OwnedGeometry<2>> for geo::Geometry { - fn from(value: &'a OwnedGeometry<2>) -> Self { +impl<'a> From<&'a OwnedGeometry> for geo::Geometry { + fn from(value: &'a OwnedGeometry) -> Self { let geom = Geometry::from(value); geom.into() } diff --git a/rust/geoarrow/src/scalar/geometrycollection/owned.rs b/rust/geoarrow/src/scalar/geometrycollection/owned.rs index b534b2e1..dc747eca 100644 --- a/rust/geoarrow/src/scalar/geometrycollection/owned.rs +++ b/rust/geoarrow/src/scalar/geometrycollection/owned.rs @@ -7,7 +7,7 @@ use geo_traits::GeometryCollectionTrait; #[derive(Clone, Debug)] pub struct OwnedGeometryCollection { - array: MixedGeometryArray, + array: MixedGeometryArray, /// Offsets into the geometry array where each geometry starts geom_offsets: OffsetBuffer, @@ -15,9 +15,9 @@ pub struct OwnedGeometryCollection { geom_index: usize, } -impl OwnedGeometryCollection { +impl OwnedGeometryCollection { pub fn new( - array: MixedGeometryArray, + array: MixedGeometryArray, geom_offsets: OffsetBuffer, geom_index: usize, ) -> Self { @@ -29,33 +29,33 @@ impl OwnedGeometryCollection { } } -impl<'a> From<&'a OwnedGeometryCollection> for GeometryCollection<'a> { - fn from(value: &'a OwnedGeometryCollection) -> Self { +impl<'a> From<&'a OwnedGeometryCollection> for GeometryCollection<'a> { + fn from(value: &'a OwnedGeometryCollection) -> Self { Self::new(&value.array, &value.geom_offsets, value.geom_index) } } -impl<'a> From<&'a OwnedGeometryCollection<2>> for geo::GeometryCollection { - fn from(value: &'a OwnedGeometryCollection<2>) -> Self { +impl<'a> From<&'a OwnedGeometryCollection> for geo::GeometryCollection { + fn from(value: &'a OwnedGeometryCollection) -> Self { let geom = GeometryCollection::from(value); geom.into() } } -impl<'a> From> for OwnedGeometryCollection { +impl<'a> From> for OwnedGeometryCollection { fn from(value: GeometryCollection<'a>) -> Self { let (array, geom_offsets, geom_index) = value.into_inner(); Self::new(array.clone(), geom_offsets.clone(), geom_index) } } -impl From> for GeometryCollectionArray { - fn from(value: OwnedGeometryCollection) -> Self { +impl From for GeometryCollectionArray { + fn from(value: OwnedGeometryCollection) -> Self { Self::new(value.array, value.geom_offsets, None, Default::default()) } } -impl GeometryCollectionTrait for OwnedGeometryCollection { +impl GeometryCollectionTrait for OwnedGeometryCollection { type T = f64; type GeometryType<'b> = Geometry<'b> where Self: 'b; @@ -75,7 +75,7 @@ impl GeometryCollectionTrait for OwnedGeometryCollection { } } -impl> PartialEq for OwnedGeometryCollection<2> { +impl> PartialEq for OwnedGeometryCollection { fn eq(&self, other: &G) -> bool { geometry_collection_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/geometrycollection/scalar.rs b/rust/geoarrow/src/scalar/geometrycollection/scalar.rs index a662b93b..2a3ca9b3 100644 --- a/rust/geoarrow/src/scalar/geometrycollection/scalar.rs +++ b/rust/geoarrow/src/scalar/geometrycollection/scalar.rs @@ -13,7 +13,7 @@ use rstar::{RTreeObject, AABB}; /// An Arrow equivalent of a GeometryCollection #[derive(Debug, Clone)] pub struct GeometryCollection<'a> { - pub(crate) array: &'a MixedGeometryArray, + pub(crate) array: &'a MixedGeometryArray, /// Offsets into the geometry array where each geometry starts pub(crate) geom_offsets: &'a OffsetBuffer, @@ -25,7 +25,7 @@ pub struct GeometryCollection<'a> { impl<'a> GeometryCollection<'a> { pub fn new( - array: &'a MixedGeometryArray, + array: &'a MixedGeometryArray, geom_offsets: &'a OffsetBuffer, geom_index: usize, ) -> Self { @@ -38,7 +38,7 @@ impl<'a> GeometryCollection<'a> { } } - pub fn into_inner(&self) -> (&MixedGeometryArray, &OffsetBuffer, usize) { + pub fn into_inner(&self) -> (&MixedGeometryArray, &OffsetBuffer, usize) { (self.array, self.geom_offsets, self.geom_index) } } @@ -65,7 +65,7 @@ impl<'a> GeometryCollectionTrait for GeometryCollection<'a> { type GeometryType<'b> = Geometry<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - match self.coords.dim() { + match self.array.dim() { Dimension::XY => geo_traits::Dimensions::Xy, Dimension::XYZ => geo_traits::Dimensions::Xyz, } @@ -86,7 +86,7 @@ impl<'a> GeometryCollectionTrait for &'a GeometryCollection<'a> { type GeometryType<'b> = Geometry<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - match self.coords.dim() { + match self.array.dim() { Dimension::XY => geo_traits::Dimensions::Xy, Dimension::XYZ => geo_traits::Dimensions::Xyz, } @@ -114,7 +114,7 @@ impl From> for geo::Geometry { } } -impl RTreeObject for GeometryCollection<'_, 2> { +impl RTreeObject for GeometryCollection<'_> { type Envelope = AABB<[f64; 2]>; fn envelope(&self) -> Self::Envelope { diff --git a/rust/geoarrow/src/scalar/linestring/scalar.rs b/rust/geoarrow/src/scalar/linestring/scalar.rs index e76dfc86..2bc21196 100644 --- a/rust/geoarrow/src/scalar/linestring/scalar.rs +++ b/rust/geoarrow/src/scalar/linestring/scalar.rs @@ -145,8 +145,8 @@ mod test { /// Test Eq where the current index is true but another index is false #[test] fn test_eq_other_index_false() { - let arr1: LineStringArray<2> = vec![ls0(), ls1()].as_slice().into(); - let arr2: LineStringArray<2> = vec![ls0(), ls0()].as_slice().into(); + let arr1: LineStringArray = vec![ls0(), ls1()].as_slice().into(); + let arr2: LineStringArray = vec![ls0(), ls0()].as_slice().into(); assert_eq!(arr1.value(0), arr2.value(0)); assert_ne!(arr1.value(1), arr2.value(1)); diff --git a/rust/geoarrow/src/scalar/multilinestring/owned.rs b/rust/geoarrow/src/scalar/multilinestring/owned.rs index 4676ec3c..5d4d5bb0 100644 --- a/rust/geoarrow/src/scalar/multilinestring/owned.rs +++ b/rust/geoarrow/src/scalar/multilinestring/owned.rs @@ -44,8 +44,8 @@ impl<'a> From<&'a OwnedMultiLineString> for MultiLineString<'a> { } } -impl From> for geo::MultiLineString { - fn from(value: OwnedMultiLineString<2>) -> Self { +impl From for geo::MultiLineString { + fn from(value: OwnedMultiLineString) -> Self { let geom = MultiLineString::from(&value); geom.into() } @@ -90,7 +90,7 @@ impl MultiLineStringTrait for OwnedMultiLineString { } } -impl> PartialEq for OwnedMultiLineString<2> { +impl> PartialEq for OwnedMultiLineString { fn eq(&self, other: &G) -> bool { multi_line_string_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/multilinestring/scalar.rs b/rust/geoarrow/src/scalar/multilinestring/scalar.rs index 12e63a8c..67edeb37 100644 --- a/rust/geoarrow/src/scalar/multilinestring/scalar.rs +++ b/rust/geoarrow/src/scalar/multilinestring/scalar.rs @@ -131,7 +131,7 @@ impl From> for geo::Geometry { } } -impl RTreeObject for MultiLineString<'_, 2> { +impl RTreeObject for MultiLineString<'_> { type Envelope = AABB<[f64; 2]>; fn envelope(&self) -> Self::Envelope { @@ -140,7 +140,7 @@ impl RTreeObject for MultiLineString<'_, 2> { } } -impl> PartialEq for MultiLineString<'_, 2> { +impl> PartialEq for MultiLineString<'_> { fn eq(&self, other: &G) -> bool { multi_line_string_eq(self, other) } @@ -155,8 +155,8 @@ mod test { /// Test Eq where the current index is true but another index is false #[test] fn test_eq_other_index_false() { - let arr1: MultiLineStringArray<2> = vec![ml0(), ml1()].as_slice().into(); - let arr2: MultiLineStringArray<2> = vec![ml0(), ml0()].as_slice().into(); + let arr1: MultiLineStringArray = vec![ml0(), ml1()].as_slice().into(); + let arr2: MultiLineStringArray = vec![ml0(), ml0()].as_slice().into(); assert_eq!(arr1.value(0), arr2.value(0)); assert_ne!(arr1.value(1), arr2.value(1)); diff --git a/rust/geoarrow/src/scalar/multipoint/scalar.rs b/rust/geoarrow/src/scalar/multipoint/scalar.rs index 70be00d7..331ed044 100644 --- a/rust/geoarrow/src/scalar/multipoint/scalar.rs +++ b/rust/geoarrow/src/scalar/multipoint/scalar.rs @@ -129,7 +129,7 @@ impl From> for geo::Geometry { } } -impl RTreeObject for MultiPoint<'_, 2> { +impl RTreeObject for MultiPoint<'_> { type Envelope = AABB<[f64; 2]>; fn envelope(&self) -> Self::Envelope { @@ -153,8 +153,8 @@ mod test { /// Test Eq where the current index is true but another index is false #[test] fn test_eq_other_index_false() { - let arr1: MultiPointArray<2> = vec![mp0(), mp1()].as_slice().into(); - let arr2: MultiPointArray<2> = vec![mp0(), mp0()].as_slice().into(); + let arr1: MultiPointArray = vec![mp0(), mp1()].as_slice().into(); + let arr2: MultiPointArray = vec![mp0(), mp0()].as_slice().into(); assert_eq!(arr1.value(0), arr2.value(0)); assert_ne!(arr1.value(1), arr2.value(1)); diff --git a/rust/geoarrow/src/scalar/multipolygon/scalar.rs b/rust/geoarrow/src/scalar/multipolygon/scalar.rs index 6e71d4d8..851ab92a 100644 --- a/rust/geoarrow/src/scalar/multipolygon/scalar.rs +++ b/rust/geoarrow/src/scalar/multipolygon/scalar.rs @@ -183,8 +183,8 @@ mod test { /// Test Eq where the current index is true but another index is false #[test] fn test_eq_other_index_false() { - let arr1: MultiPolygonArray<2> = vec![mp0(), mp1()].as_slice().into(); - let arr2: MultiPolygonArray<2> = vec![mp0(), mp0()].as_slice().into(); + let arr1: MultiPolygonArray = vec![mp0(), mp1()].as_slice().into(); + let arr2: MultiPolygonArray = vec![mp0(), mp0()].as_slice().into(); assert_eq!(arr1.value(0), arr2.value(0)); assert_ne!(arr1.value(1), arr2.value(1)); diff --git a/rust/geoarrow/src/scalar/point/scalar.rs b/rust/geoarrow/src/scalar/point/scalar.rs index a9b5c46f..288e5dd9 100644 --- a/rust/geoarrow/src/scalar/point/scalar.rs +++ b/rust/geoarrow/src/scalar/point/scalar.rs @@ -126,12 +126,12 @@ mod test { let x1 = vec![0., 1., 2.]; let y1 = vec![3., 4., 5.]; let buf1 = CoordBuffer::Separated((x1, y1).try_into().unwrap()); - let arr1 = PointArray::<2>::new(buf1, None, Default::default()); + let arr1 = PointArray::new(buf1, None, Default::default()); let x2 = vec![0., 100., 2.]; let y2 = vec![3., 400., 5.]; let buf2 = CoordBuffer::Separated((x2, y2).try_into().unwrap()); - let arr2 = PointArray::<2>::new(buf2, None, Default::default()); + let arr2 = PointArray::new(buf2, None, Default::default()); assert_eq!(arr1.value(0), arr2.value(0)); } diff --git a/rust/geoarrow/src/scalar/polygon/owned.rs b/rust/geoarrow/src/scalar/polygon/owned.rs index d6c7d8af..7fbe789a 100644 --- a/rust/geoarrow/src/scalar/polygon/owned.rs +++ b/rust/geoarrow/src/scalar/polygon/owned.rs @@ -17,7 +17,7 @@ pub struct OwnedPolygon { geom_index: usize, } -impl OwnedPolygon { +impl OwnedPolygon { pub fn new( coords: CoordBuffer, geom_offsets: OffsetBuffer, @@ -33,8 +33,8 @@ impl OwnedPolygon { } } -impl<'a> From<&'a OwnedPolygon> for Polygon<'a> { - fn from(value: &'a OwnedPolygon) -> Self { +impl<'a> From<&'a OwnedPolygon> for Polygon<'a> { + fn from(value: &'a OwnedPolygon) -> Self { Self::new( &value.coords, &value.geom_offsets, @@ -44,22 +44,22 @@ impl<'a> From<&'a OwnedPolygon> for Polygon<'a> { } } -impl From> for geo::Polygon { - fn from(value: OwnedPolygon<2>) -> Self { +impl From for geo::Polygon { + fn from(value: OwnedPolygon) -> Self { let geom = Polygon::from(&value); geom.into() } } -impl<'a> From> for OwnedPolygon { +impl<'a> From> for OwnedPolygon { fn from(value: Polygon<'a>) -> Self { let (coords, geom_offsets, ring_offsets, geom_index) = value.into_owned_inner(); Self::new(coords, geom_offsets, ring_offsets, geom_index) } } -impl From> for PolygonArray { - fn from(value: OwnedPolygon) -> Self { +impl From for PolygonArray { + fn from(value: OwnedPolygon) -> Self { Self::new( value.coords, value.geom_offsets, @@ -70,9 +70,9 @@ impl From> for PolygonArray { } } -impl PolygonTrait for OwnedPolygon { +impl PolygonTrait for OwnedPolygon { type T = f64; - type RingType<'b> = LineString<'b, D> where Self: 'b; + type RingType<'b> = LineString<'b> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { match self.coords.dim() { @@ -94,7 +94,7 @@ impl PolygonTrait for OwnedPolygon { } } -impl> PartialEq for OwnedPolygon<2> { +impl> PartialEq for OwnedPolygon { fn eq(&self, other: &G) -> bool { polygon_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/polygon/scalar.rs b/rust/geoarrow/src/scalar/polygon/scalar.rs index cbc7294d..cf157d9b 100644 --- a/rust/geoarrow/src/scalar/polygon/scalar.rs +++ b/rust/geoarrow/src/scalar/polygon/scalar.rs @@ -157,7 +157,7 @@ impl From> for geo::Geometry { } } -impl RTreeObject for Polygon<'_, 2> { +impl RTreeObject for Polygon<'_> { type Envelope = AABB<[f64; 2]>; fn envelope(&self) -> Self::Envelope { @@ -181,8 +181,8 @@ mod test { /// Test Eq where the current index is true but another index is false #[test] fn test_eq_other_index_false() { - let arr1: PolygonArray<2> = vec![p0(), p1()].as_slice().into(); - let arr2: PolygonArray<2> = vec![p0(), p0()].as_slice().into(); + let arr1: PolygonArray = vec![p0(), p1()].as_slice().into(); + let arr2: PolygonArray = vec![p0(), p0()].as_slice().into(); assert_eq!(arr1.value(0), arr2.value(0)); assert_ne!(arr1.value(1), arr2.value(1)); diff --git a/rust/geoarrow/src/scalar/rect/owned.rs b/rust/geoarrow/src/scalar/rect/owned.rs index 1474db11..4d3fc1d4 100644 --- a/rust/geoarrow/src/scalar/rect/owned.rs +++ b/rust/geoarrow/src/scalar/rect/owned.rs @@ -1,5 +1,6 @@ use crate::algorithm::native::eq::rect_eq; use crate::array::{RectArray, SeparatedCoordBuffer}; +use crate::datatypes::Dimension; use crate::scalar::{Rect, SeparatedCoord}; use geo_traits::RectTrait; @@ -10,7 +11,7 @@ pub struct OwnedRect { geom_index: usize, } -impl OwnedRect { +impl OwnedRect { pub fn new( lower: SeparatedCoordBuffer, upper: SeparatedCoordBuffer, @@ -24,31 +25,31 @@ impl OwnedRect { } } -impl<'a> From<&'a OwnedRect> for Rect<'a> { - fn from(value: &'a OwnedRect) -> Self { +impl<'a> From<&'a OwnedRect> for Rect<'a> { + fn from(value: &'a OwnedRect) -> Self { Self::new(&value.lower, &value.upper, value.geom_index) } } -impl<'a> From> for OwnedRect { +impl<'a> From> for OwnedRect { fn from(value: Rect<'a>) -> Self { let (lower, upper, geom_index) = value.into_owned_inner(); Self::new(lower, upper, geom_index) } } -impl From> for RectArray { - fn from(value: OwnedRect) -> Self { +impl From for RectArray { + fn from(value: OwnedRect) -> Self { Self::new(value.lower, value.upper, None, Default::default()) } } -impl RectTrait for OwnedRect { +impl RectTrait for OwnedRect { type T = f64; type CoordType<'b> = SeparatedCoord<'b> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - match self.coords.dim() { + match self.lower.dim() { Dimension::XY => geo_traits::Dimensions::Xy, Dimension::XYZ => geo_traits::Dimensions::Xyz, } @@ -63,7 +64,7 @@ impl RectTrait for OwnedRect { } } -impl> PartialEq for OwnedRect<2> { +impl> PartialEq for OwnedRect { fn eq(&self, other: &G) -> bool { rect_eq(self, other) } diff --git a/rust/geoarrow/src/scalar/scalar.rs b/rust/geoarrow/src/scalar/scalar.rs index 5487ae28..b314383a 100644 --- a/rust/geoarrow/src/scalar/scalar.rs +++ b/rust/geoarrow/src/scalar/scalar.rs @@ -71,52 +71,43 @@ impl GeometryScalar { // Note: we use `.downcast_ref` directly here because we need to pass in the generic // TODO: may be able to change this now that we don't have + // + // TODO: as of Nov 2024 we should be able to switch back to the downcasting helpers + match self.data_type() { Point(_, _) => { - let arr = self.0.as_any().downcast_ref::>().unwrap(); + let arr = self.0.as_any().downcast_ref::().unwrap(); arr.get(0).map(Geometry::Point) } LineString(_, _) => { - let arr = self - .0 - .as_any() - .downcast_ref::>() - .unwrap(); + let arr = self.0.as_any().downcast_ref::().unwrap(); arr.get(0).map(Geometry::LineString) } Polygon(_, _) => { - let arr = self.0.as_any().downcast_ref::>().unwrap(); + let arr = self.0.as_any().downcast_ref::().unwrap(); arr.get(0).map(Geometry::Polygon) } MultiPoint(_, _) => { - let arr = self - .0 - .as_any() - .downcast_ref::>() - .unwrap(); + let arr = self.0.as_any().downcast_ref::().unwrap(); arr.get(0).map(Geometry::MultiPoint) } MultiLineString(_, _) => { let arr = self .0 .as_any() - .downcast_ref::>() + .downcast_ref::() .unwrap(); arr.get(0).map(Geometry::MultiLineString) } MultiPolygon(_, _) => { - let arr = self - .0 - .as_any() - .downcast_ref::>() - .unwrap(); + let arr = self.0.as_any().downcast_ref::().unwrap(); arr.get(0).map(Geometry::MultiPolygon) } Mixed(_, _) => { let arr = self .0 .as_any() - .downcast_ref::>() + .downcast_ref::() .unwrap(); arr.get(0) } @@ -124,12 +115,12 @@ impl GeometryScalar { let arr = self .0 .as_any() - .downcast_ref::>() + .downcast_ref::() .unwrap(); arr.get(0).map(Geometry::GeometryCollection) } Rect(_) => { - let arr = self.0.as_any().downcast_ref::>().unwrap(); + let arr = self.0.as_any().downcast_ref::().unwrap(); arr.get(0).map(Geometry::Rect) } } @@ -137,57 +128,23 @@ impl GeometryScalar { pub fn to_geo(&self) -> geo::Geometry { macro_rules! impl_to_geo { - ($cast_func:ident, $dim:expr) => {{ - self.0 - .as_ref() - .$cast_func::<$dim>() - .value(0) - .to_geo_geometry() + ($cast_func:ident) => {{ + self.0.as_ref().$cast_func().value(0).to_geo_geometry() }}; } - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => impl_to_geo!(as_point, 2), - LineString(_, XY) => impl_to_geo!(as_line_string, 2), - Polygon(_, XY) => impl_to_geo!(as_polygon, 2), - MultiPoint(_, XY) => impl_to_geo!(as_multi_point, 2), - MultiLineString(_, XY) => { - impl_to_geo!(as_multi_line_string, 2) - } - MultiPolygon(_, XY) => impl_to_geo!(as_multi_polygon, 2), - Mixed(_, XY) => impl_to_geo!(as_mixed, 2), - GeometryCollection(_, XY) => { - impl_to_geo!(as_geometry_collection, 2) - } - Rect(XY) => impl_to_geo!(as_rect, 2), - Point(_, XYZ) => impl_to_geo!(as_point, 3), - LineString(_, XYZ) => impl_to_geo!(as_line_string, 3), - Polygon(_, XYZ) => impl_to_geo!(as_polygon, 3), - MultiPoint(_, XYZ) => impl_to_geo!(as_multi_point, 3), - MultiLineString(_, XYZ) => { - impl_to_geo!(as_multi_line_string, 3) - } - MultiPolygon(_, XYZ) => impl_to_geo!(as_multi_polygon, 3), - Mixed(_, XYZ) => impl_to_geo!(as_mixed, 3), - GeometryCollection(_, XYZ) => { - impl_to_geo!(as_geometry_collection, 3) - } - Rect(XYZ) => impl_to_geo!(as_rect, 3), - // WKB => { - // let arr = self.0.as_ref(); - // let wkb_arr = arr.as_wkb().value(0); - // let wkb_object = wkb_arr.to_wkb_object(); - // geometry_to_geo(&wkb_object) - // } - // LargeWKB => { - // let arr = self.0.as_ref(); - // let wkb_arr = arr.as_large_wkb().value(0); - // let wkb_object = wkb_arr.to_wkb_object(); - // geometry_to_geo(&wkb_object) - // } + Point(_, _) => impl_to_geo!(as_point), + LineString(_, _) => impl_to_geo!(as_line_string), + Polygon(_, _) => impl_to_geo!(as_polygon), + MultiPoint(_, _) => impl_to_geo!(as_multi_point), + MultiLineString(_, _) => impl_to_geo!(as_multi_line_string), + MultiPolygon(_, _) => impl_to_geo!(as_multi_polygon), + Mixed(_, _) => impl_to_geo!(as_mixed), + GeometryCollection(_, _) => impl_to_geo!(as_geometry_collection), + Rect(_) => impl_to_geo!(as_rect), } } diff --git a/rust/geoarrow/src/trait_.rs b/rust/geoarrow/src/trait_.rs index a4168eb0..5b86ccf9 100644 --- a/rust/geoarrow/src/trait_.rs +++ b/rust/geoarrow/src/trait_.rs @@ -814,7 +814,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// ``` /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; /// - /// let mut builder = PointBuilder::<2>::new(); + /// let mut builder = PointBuilder::new(Dimension::XY); /// assert_eq!(builder.len(), 0); /// builder.push_point(Some(&geo::point!(x: 1., y: 2.))); /// assert_eq!(builder.len(), 1); @@ -828,7 +828,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// ``` /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; /// - /// let mut builder = PointBuilder::<2>::new(); + /// let mut builder = PointBuilder::new(Dimension::XY); /// assert!(builder.is_empty()); /// builder.push_point(Some(&geo::point!(x: 1., y: 2.))); /// assert!(!builder.is_empty()); @@ -844,7 +844,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// ``` /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; /// - /// let builder = PointBuilder::<2>::new(); + /// let builder = PointBuilder::new(Dimension::XY); /// assert!(builder.nulls().is_empty()); /// ``` fn nulls(&self) -> &NullBufferBuilder; @@ -855,7 +855,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; - /// let builder = PointBuilder::<2>::new(); + /// let builder = PointBuilder::new(Dimension::XY); /// ``` fn new() -> Self; @@ -915,7 +915,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// array::{PointBuilder, metadata::{ArrayMetadata, Edges}}, /// trait_::GeometryArrayBuilder, /// }; - /// let mut builder = PointBuilder::<2>::new(); + /// let mut builder = PointBuilder::new(Dimension::XY); /// let metadata = ArrayMetadata { /// crs: None, /// edges: Some(Edges::Spherical), @@ -931,7 +931,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// ``` /// use geoarrow::{array::PointBuilder, trait_::{GeometryArrayBuilder, NativeArray, ArrayBase}}; /// - /// let mut builder = PointBuilder::<2>::new(); + /// let mut builder = PointBuilder::new(Dimension::XY); /// builder.push_point(Some(&geo::point!(x: 1., y: 2.))); /// let array = builder.finish(); /// assert_eq!(array.len(), 1); @@ -944,7 +944,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::{PointBuilder, CoordType}, trait_::GeometryArrayBuilder}; - /// let builder = PointBuilder::<2>::new(); + /// let builder = PointBuilder::new(Dimension::XY); /// assert_eq!(builder.coord_type(), CoordType::Interleaved); /// ``` fn coord_type(&self) -> CoordType; @@ -955,7 +955,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::{PointBuilder, CoordType}, trait_::GeometryArrayBuilder}; - /// let builder = PointBuilder::<2>::new(); + /// let builder = PointBuilder::new(Dimension::XY); /// let metadata = builder.metadata(); /// ``` fn metadata(&self) -> Arc; @@ -980,7 +980,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; - /// let builder = PointBuilder::<2>::new(); + /// let builder = PointBuilder::new(Dimension::XY); /// let array_ref = builder.into_array_ref(); /// ``` fn into_array_ref(self) -> Arc; From b5614108bbc2410e979ef464dd3e40ad29efe958 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Thu, 14 Nov 2024 20:20:39 -0500 Subject: [PATCH 03/14] Progress --- .../src/algorithm/geo/euclidean_distance.rs | 76 +++--- rust/geoarrow/src/algorithm/geo/within.rs | 74 +++--- rust/geoarrow/src/algorithm/native/explode.rs | 40 +-- rust/geoarrow/src/algorithm/native/type_id.rs | 14 +- rust/geoarrow/src/array/dynamic.rs | 50 +--- rust/geoarrow/src/array/linestring/array.rs | 9 +- rust/geoarrow/src/array/linestring/builder.rs | 84 +++--- .../src/array/multilinestring/array.rs | 8 +- .../src/array/multilinestring/builder.rs | 49 ++-- rust/geoarrow/src/chunked_array/dynamic.rs | 71 ++--- rust/geoarrow/src/chunked_array/mod.rs | 42 ++- rust/geoarrow/src/indexed/array.rs | 20 +- rust/geoarrow/src/indexed/chunked.rs | 23 +- rust/geoarrow/src/io/display/array.rs | 36 +-- .../src/io/geos/array/geometrycollection.rs | 6 +- rust/geoarrow/src/io/geos/array/linestring.rs | 6 +- rust/geoarrow/src/io/geos/array/mixed.rs | 6 +- .../src/io/geos/array/multilinestring.rs | 4 +- rust/geoarrow/src/io/geos/array/multipoint.rs | 4 +- .../src/io/geos/array/multipolygon.rs | 4 +- rust/geoarrow/src/io/geos/array/point.rs | 4 +- rust/geoarrow/src/io/geos/array/polygon.rs | 4 +- rust/geoarrow/src/io/postgis/reader.rs | 2 +- rust/geoarrow/src/io/wkb/api.rs | 246 +++++------------- rust/geoarrow/src/io/wkb/writer/geometry.rs | 12 +- .../src/io/wkb/writer/geometrycollection.rs | 8 +- rust/geoarrow/src/io/wkb/writer/linestring.rs | 12 +- .../src/io/wkb/writer/multilinestring.rs | 8 +- rust/geoarrow/src/io/wkb/writer/multipoint.rs | 8 +- .../src/io/wkb/writer/multipolygon.rs | 8 +- rust/geoarrow/src/io/wkb/writer/point.rs | 20 +- rust/geoarrow/src/io/wkb/writer/polygon.rs | 8 +- rust/geoarrow/src/io/wkt/reader/mod.rs | 2 +- .../src/scalar/geometrycollection/owned.rs | 2 +- rust/geoarrow/src/test/geoarrow_data/mod.rs | 41 ++- rust/geoarrow/src/test/linestring.rs | 18 +- rust/geoarrow/src/test/multilinestring.rs | 14 +- rust/geoarrow/src/test/multipoint.rs | 7 +- rust/geoarrow/src/test/multipolygon.rs | 2 +- rust/geoarrow/src/test/point.rs | 7 +- rust/geoarrow/src/test/polygon.rs | 7 +- rust/geoarrow/src/trait_.rs | 8 +- 42 files changed, 481 insertions(+), 593 deletions(-) diff --git a/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs b/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs index 81910129..054c48a6 100644 --- a/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs +++ b/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs @@ -57,7 +57,7 @@ pub trait EuclideanDistance { /// /// let distance = point.euclidean_distance(&polygon); /// - /// assert_relative_eq!(distance, 2.1213203435596424); + /// assert_relative_eq!(distance.1213203435596424); /// ``` /// /// `Point` to `LineString`: @@ -186,9 +186,9 @@ iter_geo_impl!(MultiPolygonArray, PointArray); // └─────────────────────────────────┘ // Note: this implementation is outside the macro because it is not generic over O -impl<'a> EuclideanDistance> for PointArray { +impl<'a> EuclideanDistance> for PointArray { /// Minimum distance between two Points - fn euclidean_distance(&self, other: &Point<'a, 2>) -> Float64Array { + fn euclidean_distance(&self, other: &Point<'a>) -> Float64Array { let mut output_array = Float64Builder::with_capacity(self.len()); self.iter_geo().for_each(|maybe_point| { @@ -220,48 +220,48 @@ macro_rules! iter_geo_impl_scalar { } // Implementations on PointArray -iter_geo_impl_scalar!(PointArray, LineString<'a, 2>); -iter_geo_impl_scalar!(PointArray, Polygon<'a, 2>); -iter_geo_impl_scalar!(PointArray, MultiPoint<'a, 2>); -iter_geo_impl_scalar!(PointArray, MultiLineString<'a, 2>); -iter_geo_impl_scalar!(PointArray, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(PointArray, LineString<'a>); +iter_geo_impl_scalar!(PointArray, Polygon<'a>); +iter_geo_impl_scalar!(PointArray, MultiPoint<'a>); +iter_geo_impl_scalar!(PointArray, MultiLineString<'a>); +iter_geo_impl_scalar!(PointArray, MultiPolygon<'a>); // Implementations on LineStringArray -iter_geo_impl_scalar!(LineStringArray, Point<'a, 2>); -iter_geo_impl_scalar!(LineStringArray, LineString<'a, 2>); -iter_geo_impl_scalar!(LineStringArray, Polygon<'a, 2>); -// iter_geo_impl_scalar!(LineStringArray, MultiPoint<'a, 2>); -// iter_geo_impl_scalar!(LineStringArray, MultiLineString<'a, 2>); -// iter_geo_impl_scalar!(LineStringArray, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(LineStringArray, Point<'a>); +iter_geo_impl_scalar!(LineStringArray, LineString<'a>); +iter_geo_impl_scalar!(LineStringArray, Polygon<'a>); +// iter_geo_impl_scalar!(LineStringArray, MultiPoint<'a>); +// iter_geo_impl_scalar!(LineStringArray, MultiLineString<'a>); +// iter_geo_impl_scalar!(LineStringArray, MultiPolygon<'a>); // Implementations on PolygonArray -iter_geo_impl_scalar!(PolygonArray, Point<'a, 2>); -iter_geo_impl_scalar!(PolygonArray, LineString<'a, 2>); -iter_geo_impl_scalar!(PolygonArray, Polygon<'a, 2>); -// iter_geo_impl_scalar!(PolygonArray, MultiPoint<'a, 2>); -// iter_geo_impl_scalar!(PolygonArray, MultiLineString<'a, 2>); -// iter_geo_impl_scalar!(PolygonArray, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(PolygonArray, Point<'a>); +iter_geo_impl_scalar!(PolygonArray, LineString<'a>); +iter_geo_impl_scalar!(PolygonArray, Polygon<'a>); +// iter_geo_impl_scalar!(PolygonArray, MultiPoint<'a>); +// iter_geo_impl_scalar!(PolygonArray, MultiLineString<'a>); +// iter_geo_impl_scalar!(PolygonArray, MultiPolygon<'a>); // Implementations on MultiPointArray -iter_geo_impl_scalar!(MultiPointArray, Point<'a, 2>); -// iter_geo_impl_scalar!(MultiPointArray, LineString<'a, 2>); -// iter_geo_impl_scalar!(MultiPointArray, Polygon<'a, 2>); -// iter_geo_impl_scalar!(MultiPointArray, MultiPoint<'a, 2>); -// iter_geo_impl_scalar!(MultiPointArray, MultiLineString<'a, 2>); -// iter_geo_impl_scalar!(MultiPointArray, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(MultiPointArray, Point<'a>); +// iter_geo_impl_scalar!(MultiPointArray, LineString<'a>); +// iter_geo_impl_scalar!(MultiPointArray, Polygon<'a>); +// iter_geo_impl_scalar!(MultiPointArray, MultiPoint<'a>); +// iter_geo_impl_scalar!(MultiPointArray, MultiLineString<'a>); +// iter_geo_impl_scalar!(MultiPointArray, MultiPolygon<'a>); // Implementations on MultiLineStringArray -iter_geo_impl_scalar!(MultiLineStringArray, Point<'a, 2>); -// iter_geo_impl_scalar!(MultiLineStringArray, LineString<'a, 2>); -// iter_geo_impl_scalar!(MultiLineStringArray, Polygon<'a, 2>); -// iter_geo_impl_scalar!(MultiLineStringArray, MultiPoint<'a, 2>); -// iter_geo_impl_scalar!(MultiLineStringArray, MultiLineString<'a, 2>); -// iter_geo_impl_scalar!(MultiLineStringArray, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(MultiLineStringArray, Point<'a>); +// iter_geo_impl_scalar!(MultiLineStringArray, LineString<'a>); +// iter_geo_impl_scalar!(MultiLineStringArray, Polygon<'a>); +// iter_geo_impl_scalar!(MultiLineStringArray, MultiPoint<'a>); +// iter_geo_impl_scalar!(MultiLineStringArray, MultiLineString<'a>); +// iter_geo_impl_scalar!(MultiLineStringArray, MultiPolygon<'a>); // Implementations on MultiPolygonArray -iter_geo_impl_scalar!(MultiPolygonArray, Point<'a, 2>); -// iter_geo_impl_scalar!(MultiPolygonArray, LineString<'a, 2>); -// iter_geo_impl_scalar!(MultiPolygonArray, Polygon<'a, 2>); -// iter_geo_impl_scalar!(MultiPolygonArray, MultiPoint<'a, 2>); -// iter_geo_impl_scalar!(MultiPolygonArray, MultiLineString<'a, 2>); -// iter_geo_impl_scalar!(MultiPolygonArray, MultiPolygon<'a, 2>); +iter_geo_impl_scalar!(MultiPolygonArray, Point<'a>); +// iter_geo_impl_scalar!(MultiPolygonArray, LineString<'a>); +// iter_geo_impl_scalar!(MultiPolygonArray, Polygon<'a>); +// iter_geo_impl_scalar!(MultiPolygonArray, MultiPoint<'a>); +// iter_geo_impl_scalar!(MultiPolygonArray, MultiLineString<'a>); +// iter_geo_impl_scalar!(MultiPolygonArray, MultiPolygon<'a>); diff --git a/rust/geoarrow/src/algorithm/geo/within.rs b/rust/geoarrow/src/algorithm/geo/within.rs index d7be79af..20eeea51 100644 --- a/rust/geoarrow/src/algorithm/geo/within.rs +++ b/rust/geoarrow/src/algorithm/geo/within.rs @@ -142,8 +142,8 @@ iter_geo_impl!(MultiPolygonArray, MultiPolygonArray); // └──────────────────────────────────────────┘ // Note: this implementation is outside the macro because it is not generic over O -impl<'a> Within> for PointArray { - fn is_within(&self, rhs: &Point<'a, 2>) -> BooleanArray { +impl<'a> Within> for PointArray { + fn is_within(&self, rhs: &Point<'a>) -> BooleanArray { let mut output_array = BooleanBuilder::with_capacity(self.len()); self.iter_geo().for_each(|maybe_point| { @@ -175,51 +175,51 @@ macro_rules! iter_geo_impl_geoarrow_scalar { } // Implementations on PointArray -iter_geo_impl_geoarrow_scalar!(PointArray, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PointArray, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PointArray, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PointArray, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PointArray, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PointArray, LineString<'a>); +iter_geo_impl_geoarrow_scalar!(PointArray, Polygon<'a>); +iter_geo_impl_geoarrow_scalar!(PointArray, MultiPoint<'a>); +iter_geo_impl_geoarrow_scalar!(PointArray, MultiLineString<'a>); +iter_geo_impl_geoarrow_scalar!(PointArray, MultiPolygon<'a>); // Implementations on LineStringArray -iter_geo_impl_geoarrow_scalar!(LineStringArray, Point<'a, 2>); -iter_geo_impl_geoarrow_scalar!(LineStringArray, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(LineStringArray, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, Point<'a>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, LineString<'a>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, Polygon<'a>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiPoint<'a>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiLineString<'a>); +iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiPolygon<'a>); // Implementations on PolygonArray -iter_geo_impl_geoarrow_scalar!(PolygonArray, Point<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PolygonArray, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PolygonArray, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, Point<'a>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, LineString<'a>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, Polygon<'a>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiPoint<'a>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiLineString<'a>); +iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiPolygon<'a>); // Implementations on MultiPointArray -iter_geo_impl_geoarrow_scalar!(MultiPointArray, Point<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPointArray, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPointArray, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, Point<'a>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, LineString<'a>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, Polygon<'a>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiPoint<'a>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiLineString<'a>); +iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiPolygon<'a>); // Implementations on MultiLineStringArray -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, Point<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, Point<'a>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, LineString<'a>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, Polygon<'a>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiPoint<'a>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiLineString<'a>); +iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiPolygon<'a>); // Implementations on MultiPolygonArray -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, Point<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, LineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, Polygon<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiPoint<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiLineString<'a, 2>); -iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiPolygon<'a, 2>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, Point<'a>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, LineString<'a>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, Polygon<'a>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiPoint<'a>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiLineString<'a>); +iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiPolygon<'a>); // ┌─────────────────────────────────────┐ // │ Implementations for RHS geo scalars │ diff --git a/rust/geoarrow/src/algorithm/native/explode.rs b/rust/geoarrow/src/algorithm/native/explode.rs index 36fc2536..11952486 100644 --- a/rust/geoarrow/src/algorithm/native/explode.rs +++ b/rust/geoarrow/src/algorithm/native/explode.rs @@ -22,7 +22,7 @@ pub trait Explode { fn explode(&self) -> Self::Output; } -impl Explode for PointArray<2> { +impl Explode for PointArray { type Output = (Self, Option); fn explode(&self) -> Self::Output { @@ -30,7 +30,7 @@ impl Explode for PointArray<2> { } } -impl Explode for LineStringArray<2> { +impl Explode for LineStringArray { type Output = (Self, Option); fn explode(&self) -> Self::Output { @@ -38,7 +38,7 @@ impl Explode for LineStringArray<2> { } } -impl Explode for PolygonArray<2> { +impl Explode for PolygonArray { type Output = (Self, Option); fn explode(&self) -> Self::Output { @@ -67,8 +67,8 @@ fn explode_offsets(offsets: &OffsetBuffer) -> Int32Array { Int32Array::new(take_indices.into(), None) } -impl Explode for MultiPointArray<2> { - type Output = (PointArray<2>, Option); +impl Explode for MultiPointArray { + type Output = (PointArray, Option); fn explode(&self) -> Self::Output { assert_eq!( @@ -83,8 +83,8 @@ impl Explode for MultiPointArray<2> { } } -impl Explode for MultiLineStringArray<2> { - type Output = (LineStringArray<2>, Option); +impl Explode for MultiLineStringArray { + type Output = (LineStringArray, Option); fn explode(&self) -> Self::Output { assert_eq!( @@ -104,8 +104,8 @@ impl Explode for MultiLineStringArray<2> { } } -impl Explode for MultiPolygonArray<2> { - type Output = (PolygonArray<2>, Option); +impl Explode for MultiPolygonArray { + type Output = (PolygonArray, Option); fn explode(&self) -> Self::Output { assert_eq!( @@ -147,8 +147,8 @@ impl Explode for &dyn NativeArray { MultiPoint(_, XY) => call_explode!(as_multi_point), MultiLineString(_, XY) => call_explode!(as_multi_line_string), MultiPolygon(_, XY) => call_explode!(as_multi_polygon), - // Mixed(_, XY) => self.as_mixed::<2>().explode(), - // GeometryCollection(_, XY) => self.as_geometry_collection::<2>().explode(), + // Mixed(_, XY) => self.as_mixed::().explode(), + // GeometryCollection(_, XY) => self.as_geometry_collection::().explode(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -192,15 +192,15 @@ impl Explode for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().explode(), - LineString(_, XY) => self.as_line_string::<2>().explode(), - Polygon(_, XY) => self.as_polygon::<2>().explode(), - MultiPoint(_, XY) => self.as_multi_point::<2>().explode(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().explode(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().explode(), - Mixed(_, XY) => self.as_mixed::<2>().explode(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().explode(), - Rect(XY) => self.as_rect::<2>().explode(), + Point(_, XY) => self.as_point::().explode(), + LineString(_, XY) => self.as_line_string::().explode(), + Polygon(_, XY) => self.as_polygon::().explode(), + MultiPoint(_, XY) => self.as_multi_point::().explode(), + MultiLineString(_, XY) => self.as_multi_line_string::().explode(), + MultiPolygon(_, XY) => self.as_multi_polygon::().explode(), + Mixed(_, XY) => self.as_mixed::().explode(), + GeometryCollection(_, XY) => self.as_geometry_collection::().explode(), + Rect(XY) => self.as_rect::().explode(), _ => todo!(), } } diff --git a/rust/geoarrow/src/algorithm/native/type_id.rs b/rust/geoarrow/src/algorithm/native/type_id.rs index 2cfaf689..b9866afb 100644 --- a/rust/geoarrow/src/algorithm/native/type_id.rs +++ b/rust/geoarrow/src/algorithm/native/type_id.rs @@ -37,7 +37,7 @@ pub trait TypeIds { fn get_unique_type_ids(&self) -> HashSet; } -impl TypeIds for PointArray<2> { +impl TypeIds for PointArray { fn get_type_ids(&self) -> Int16Array { let values = vec![0i16; self.len()]; Int16Array::new(values.into(), self.nulls().cloned()) @@ -67,13 +67,13 @@ macro_rules! constant_impl { }; } -constant_impl!(LineStringArray<2>, 1); -constant_impl!(PolygonArray<2>, 3); -constant_impl!(MultiPointArray<2>, 4); -constant_impl!(MultiLineStringArray<2>, 5); -constant_impl!(MultiPolygonArray<2>, 6); +constant_impl!(LineStringArray, 1); +constant_impl!(PolygonArray, 3); +constant_impl!(MultiPointArray, 4); +constant_impl!(MultiLineStringArray, 5); +constant_impl!(MultiPolygonArray, 6); -impl TypeIds for MixedGeometryArray<2> { +impl TypeIds for MixedGeometryArray { fn get_type_ids(&self) -> Int16Array { use crate::scalar::Geometry::*; diff --git a/rust/geoarrow/src/array/dynamic.rs b/rust/geoarrow/src/array/dynamic.rs index 3afe16d6..90784fce 100644 --- a/rust/geoarrow/src/array/dynamic.rs +++ b/rust/geoarrow/src/array/dynamic.rs @@ -11,7 +11,7 @@ use crate::array::metadata::ArrayMetadata; use crate::array::wkt::WKTArray; use crate::array::CoordType; use crate::array::*; -use crate::datatypes::{Dimension, NativeType, SerializedType}; +use crate::datatypes::{NativeType, SerializedType}; use crate::error::Result; use crate::trait_::{NativeArrayRef, SerializedArray, SerializedArrayRef}; use crate::{ArrayBase, NativeArray}; @@ -29,45 +29,19 @@ impl NativeArrayDyn { pub fn from_arrow_array(array: &dyn Array, field: &Field) -> Result { let data_type = NativeType::try_from(field)?; - use Dimension::*; use NativeType::*; let geo_arr: Arc = match data_type { - Point(_, dim) => match dim { - XY => Arc::new(PointArray::try_from((array, field))?), - XYZ => Arc::new(PointArray::<3>::try_from((array, field))?), - }, - LineString(_, dim) => match dim { - XY => Arc::new(LineStringArray::try_from((array, field))?), - XYZ => Arc::new(LineStringArray::<3>::try_from((array, field))?), - }, - Polygon(_, dim) => match dim { - XY => Arc::new(PolygonArray::try_from((array, field))?), - XYZ => Arc::new(PolygonArray::<3>::try_from((array, field))?), - }, - MultiPoint(_, dim) => match dim { - XY => Arc::new(MultiPointArray::try_from((array, field))?), - XYZ => Arc::new(MultiPointArray::<3>::try_from((array, field))?), - }, - MultiLineString(_, dim) => match dim { - XY => Arc::new(MultiLineStringArray::try_from((array, field))?), - XYZ => Arc::new(MultiLineStringArray::<3>::try_from((array, field))?), - }, - MultiPolygon(_, dim) => match dim { - XY => Arc::new(MultiPolygonArray::try_from((array, field))?), - XYZ => Arc::new(MultiPolygonArray::<3>::try_from((array, field))?), - }, - Mixed(_, dim) => match dim { - XY => Arc::new(MixedGeometryArray::try_from((array, field))?), - XYZ => Arc::new(MixedGeometryArray::<3>::try_from((array, field))?), - }, - GeometryCollection(_, dim) => match dim { - XY => Arc::new(GeometryCollectionArray::try_from((array, field))?), - XYZ => Arc::new(GeometryCollectionArray::<3>::try_from((array, field))?), - }, - Rect(dim) => match dim { - XY => Arc::new(RectArray::try_from((array, field))?), - XYZ => Arc::new(RectArray::<3>::try_from((array, field))?), - }, + Point(_, _) => Arc::new(PointArray::try_from((array, field))?), + LineString(_, _) => Arc::new(LineStringArray::try_from((array, field))?), + Polygon(_, _) => Arc::new(PolygonArray::try_from((array, field))?), + MultiPoint(_, _) => Arc::new(MultiPointArray::try_from((array, field))?), + MultiLineString(_, _) => Arc::new(MultiLineStringArray::try_from((array, field))?), + MultiPolygon(_, _) => Arc::new(MultiPolygonArray::try_from((array, field))?), + Mixed(_, _) => Arc::new(MixedGeometryArray::try_from((array, field))?), + GeometryCollection(_, _) => { + Arc::new(GeometryCollectionArray::try_from((array, field))?) + } + Rect(_) => Arc::new(RectArray::try_from((array, field))?), }; Ok(Self(geo_arr)) diff --git a/rust/geoarrow/src/array/linestring/array.rs b/rust/geoarrow/src/array/linestring/array.rs index 11a1a69b..eb4c6e17 100644 --- a/rust/geoarrow/src/array/linestring/array.rs +++ b/rust/geoarrow/src/array/linestring/array.rs @@ -411,15 +411,15 @@ impl TryFrom<(&dyn Array, &Field)> for LineStringArray { } } -impl> From>> for LineStringArray { - fn from(other: Vec>) -> Self { +impl> From<(Vec>, Dimension)> for LineStringArray { + fn from(other: (Vec>, Dimension)) -> Self { let mut_arr: LineStringBuilder = other.into(); mut_arr.into() } } -impl> From<&[G]> for LineStringArray { - fn from(other: &[G]) -> Self { +impl> From<(&[G], Dimension)> for LineStringArray { + fn from(other: (&[G], Dimension)) -> Self { let mut_arr: LineStringBuilder = other.into(); mut_arr.into() } @@ -515,6 +515,7 @@ impl TryFrom for LineStringArray { capacity.geom_capacity += buffer_lengths.ring_capacity; let mut builder = LineStringBuilder::with_capacity_and_options( + value.dim(), capacity, value.coord_type(), value.metadata(), diff --git a/rust/geoarrow/src/array/linestring/builder.rs b/rust/geoarrow/src/array/linestring/builder.rs index 05b8c941..d925f025 100644 --- a/rust/geoarrow/src/array/linestring/builder.rs +++ b/rust/geoarrow/src/array/linestring/builder.rs @@ -6,6 +6,7 @@ use crate::array::{ CoordBufferBuilder, CoordType, InterleavedCoordBufferBuilder, LineStringArray, MultiPointBuilder, SeparatedCoordBufferBuilder, WKBArray, }; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::scalar::WKB; use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow}; @@ -33,37 +34,36 @@ pub struct LineStringBuilder { impl LineStringBuilder { /// Creates a new empty [`LineStringBuilder`]. - pub fn new() -> Self { - Self::new_with_options(Default::default(), Default::default()) + pub fn new(dim: Dimension) -> Self { + Self::new_with_options(dim, Default::default(), Default::default()) } - pub fn new_with_options(coord_type: CoordType, metadata: Arc) -> Self { - Self::with_capacity_and_options(Default::default(), coord_type, metadata) + pub fn new_with_options( + dim: Dimension, + coord_type: CoordType, + metadata: Arc, + ) -> Self { + Self::with_capacity_and_options(dim, Default::default(), coord_type, metadata) } /// Creates a new [`LineStringBuilder`] with a capacity. - pub fn with_capacity(capacity: LineStringCapacity) -> Self { - Self::with_capacity_and_options(capacity, Default::default(), Default::default()) + pub fn with_capacity(dim: Dimension, capacity: LineStringCapacity) -> Self { + Self::with_capacity_and_options(dim, capacity, Default::default(), Default::default()) } pub fn with_capacity_and_options( + dim: Dimension, capacity: LineStringCapacity, coord_type: CoordType, metadata: Arc, ) -> Self { let coords = match coord_type { - CoordType::Interleaved => { - CoordBufferBuilder::Interleaved(InterleavedCoordBufferBuilder::with_capacity( - capacity.coord_capacity(), - D.try_into().unwrap(), - )) - } - CoordType::Separated => { - CoordBufferBuilder::Separated(SeparatedCoordBufferBuilder::with_capacity( - capacity.coord_capacity(), - D.try_into().unwrap(), - )) - } + CoordType::Interleaved => CoordBufferBuilder::Interleaved( + InterleavedCoordBufferBuilder::with_capacity(capacity.coord_capacity(), dim), + ), + CoordType::Separated => CoordBufferBuilder::Separated( + SeparatedCoordBufferBuilder::with_capacity(capacity.coord_capacity(), dim), + ), }; Self { coords, @@ -161,17 +161,24 @@ impl LineStringBuilder { pub fn with_capacity_from_iter<'a>( geoms: impl Iterator>, + dim: Dimension, ) -> Self { - Self::with_capacity_and_options_from_iter(geoms, Default::default(), Default::default()) + Self::with_capacity_and_options_from_iter( + geoms, + dim, + Default::default(), + Default::default(), + ) } pub fn with_capacity_and_options_from_iter<'a>( geoms: impl Iterator>, + dim: Dimension, coord_type: CoordType, metadata: Arc, ) -> Self { let counter = LineStringCapacity::from_line_strings(geoms); - Self::with_capacity_and_options(counter, coord_type, metadata) + Self::with_capacity_and_options(dim, counter, coord_type, metadata) } pub fn reserve_from_iter<'a>( @@ -192,11 +199,13 @@ impl LineStringBuilder { pub fn from_line_strings( geoms: &[impl LineStringTrait], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(Some), + dim, coord_type.unwrap_or_default(), metadata, ); @@ -206,11 +215,13 @@ impl LineStringBuilder { pub fn from_nullable_line_strings( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(|x| x.as_ref()), + dim, coord_type.unwrap_or_default(), metadata, ); @@ -290,18 +301,24 @@ impl LineStringBuilder { } pub fn from_nullable_geometries( + dim: Dimension, geoms: &[Option>], coord_type: Option, metadata: Arc, ) -> Result { let capacity = LineStringCapacity::from_geometries(geoms.iter().map(|x| x.as_ref()))?; - let mut array = - Self::with_capacity_and_options(capacity, coord_type.unwrap_or_default(), metadata); + let mut array = Self::with_capacity_and_options( + dim, + capacity, + coord_type.unwrap_or_default(), + metadata, + ); array.extend_from_geometry_iter(geoms.iter().map(|x| x.as_ref()))?; Ok(array) } pub(crate) fn from_wkb( + dim: Dimension, wkb_objects: &[Option>], coord_type: Option, metadata: Arc, @@ -310,22 +327,23 @@ impl LineStringBuilder { .iter() .map(|maybe_wkb| maybe_wkb.as_ref().map(|wkb| wkb.parse()).transpose()) .collect::>>()?; - Self::from_nullable_geometries(&wkb_objects2, coord_type, metadata) + Self::from_nullable_geometries(dim, &wkb_objects2, coord_type, metadata) } } impl GeometryArrayBuilder for LineStringBuilder { - fn new() -> Self { - Self::new() + fn new(dim: Dimension) -> Self { + Self::new(dim) } fn with_geom_capacity_and_options( + dim: Dimension, geom_capacity: usize, coord_type: CoordType, metadata: Arc, ) -> Self { let capacity = LineStringCapacity::new(0, geom_capacity); - Self::with_capacity_and_options(capacity, coord_type, metadata) + Self::with_capacity_and_options(dim, capacity, coord_type, metadata) } fn push_geometry(&mut self, value: Option<&impl GeometryTrait>) -> Result<()> { @@ -372,7 +390,7 @@ impl IntoArrow for LineStringBuilder { impl Default for LineStringBuilder { fn default() -> Self { - Self::new() + LineStringBuilder::new(Dimension::XY) } } @@ -394,15 +412,15 @@ impl From for GenericListArray { } } -impl> From<&[G]> for LineStringBuilder { - fn from(geoms: &[G]) -> Self { - Self::from_line_strings(geoms, Default::default(), Default::default()) +impl> From<(&[G], Dimension)> for LineStringBuilder { + fn from((geoms, dim): (&[G], Dimension)) -> Self { + Self::from_line_strings(geoms, dim, Default::default(), Default::default()) } } -impl> From>> for LineStringBuilder { - fn from(geoms: Vec>) -> Self { - Self::from_nullable_line_strings(&geoms, Default::default(), Default::default()) +impl> From<(Vec>, Dimension)> for LineStringBuilder { + fn from((geoms, dim): (Vec>, Dimension)) -> Self { + Self::from_nullable_line_strings(&geoms, dim, Default::default(), Default::default()) } } diff --git a/rust/geoarrow/src/array/multilinestring/array.rs b/rust/geoarrow/src/array/multilinestring/array.rs index 2eb5064d..6a32eb6f 100644 --- a/rust/geoarrow/src/array/multilinestring/array.rs +++ b/rust/geoarrow/src/array/multilinestring/array.rs @@ -464,15 +464,15 @@ impl TryFrom<(&dyn Array, &Field)> for MultiLineStringArray { } } -impl> From>> for MultiLineStringArray { - fn from(other: Vec>) -> Self { +impl> From<(Vec>, Dimension)> for MultiLineStringArray { + fn from(other: (Vec>, Dimension)) -> Self { let mut_arr: MultiLineStringBuilder = other.into(); mut_arr.into() } } -impl> From<&[G]> for MultiLineStringArray { - fn from(other: &[G]) -> Self { +impl> From<(&[G], Dimension)> for MultiLineStringArray { + fn from(other: (&[G], Dimension)) -> Self { let mut_arr: MultiLineStringBuilder = other.into(); mut_arr.into() } diff --git a/rust/geoarrow/src/array/multilinestring/builder.rs b/rust/geoarrow/src/array/multilinestring/builder.rs index 64d05367..023b6388 100644 --- a/rust/geoarrow/src/array/multilinestring/builder.rs +++ b/rust/geoarrow/src/array/multilinestring/builder.rs @@ -59,7 +59,7 @@ impl MultiLineStringBuilder { /// Creates a new [`MultiLineStringBuilder`] with a capacity. pub fn with_capacity(dim: Dimension, capacity: MultiLineStringCapacity) -> Self { - Self::with_capacity_and_options(capacity, Default::default(), Default::default()) + Self::with_capacity_and_options(dim, capacity, Default::default(), Default::default()) } pub fn with_capacity_and_options( @@ -193,17 +193,24 @@ impl MultiLineStringBuilder { pub fn with_capacity_from_iter<'a>( geoms: impl Iterator>, + dim: Dimension, ) -> Self { - Self::with_capacity_and_options_from_iter(geoms, Default::default(), Default::default()) + Self::with_capacity_and_options_from_iter( + geoms, + dim, + Default::default(), + Default::default(), + ) } pub fn with_capacity_and_options_from_iter<'a>( geoms: impl Iterator>, + dim: Dimension, coord_type: CoordType, metadata: Arc, ) -> Self { let counter = MultiLineStringCapacity::from_multi_line_strings(geoms); - Self::with_capacity_and_options(counter, coord_type, metadata) + Self::with_capacity_and_options(dim, counter, coord_type, metadata) } pub fn reserve_from_iter<'a>( @@ -349,11 +356,13 @@ impl MultiLineStringBuilder { pub fn from_multi_line_strings( geoms: &[impl MultiLineStringTrait], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(Some), + dim, coord_type.unwrap_or_default(), metadata, ); @@ -363,11 +372,13 @@ impl MultiLineStringBuilder { pub fn from_nullable_multi_line_strings( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(|x| x.as_ref()), + dim, coord_type.unwrap_or_default(), metadata, ); @@ -377,12 +388,17 @@ impl MultiLineStringBuilder { pub fn from_nullable_geometries( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { let capacity = MultiLineStringCapacity::from_geometries(geoms.iter().map(|x| x.as_ref()))?; - let mut array = - Self::with_capacity_and_options(capacity, coord_type.unwrap_or_default(), metadata); + let mut array = Self::with_capacity_and_options( + dim, + capacity, + coord_type.unwrap_or_default(), + metadata, + ); array.extend_from_geometry_iter(geoms.iter().map(|x| x.as_ref()))?; Ok(array) } @@ -401,17 +417,18 @@ impl MultiLineStringBuilder { } impl GeometryArrayBuilder for MultiLineStringBuilder { - fn new() -> Self { - Self::new() + fn new(dim: Dimension) -> Self { + Self::new(dim) } fn with_geom_capacity_and_options( + dim: Dimension, geom_capacity: usize, coord_type: CoordType, metadata: Arc, ) -> Self { let capacity = MultiLineStringCapacity::new(0, 0, geom_capacity); - Self::with_capacity_and_options(capacity, coord_type, metadata) + Self::with_capacity_and_options(dim, capacity, coord_type, metadata) } fn push_geometry(&mut self, value: Option<&impl GeometryTrait>) -> Result<()> { @@ -458,7 +475,7 @@ impl IntoArrow for MultiLineStringBuilder { impl Default for MultiLineStringBuilder { fn default() -> Self { - Self::new() + Self::new(Dimension::XY) } } @@ -479,15 +496,17 @@ impl From for MultiLineStringArray { } } -impl> From<&[G]> for MultiLineStringBuilder { - fn from(geoms: &[G]) -> Self { - Self::from_multi_line_strings(geoms, Default::default(), Default::default()) +impl> From<(&[G], Dimension)> for MultiLineStringBuilder { + fn from((geoms, dim): (&[G], Dimension)) -> Self { + Self::from_multi_line_strings(geoms, dim, Default::default(), Default::default()) } } -impl> From>> for MultiLineStringBuilder { - fn from(geoms: Vec>) -> Self { - Self::from_nullable_multi_line_strings(&geoms, Default::default(), Default::default()) +impl> From<(Vec>, Dimension)> + for MultiLineStringBuilder +{ + fn from((geoms, dim): (Vec>, Dimension)) -> Self { + Self::from_nullable_multi_line_strings(&geoms, dim, Default::default(), Default::default()) } } diff --git a/rust/geoarrow/src/chunked_array/dynamic.rs b/rust/geoarrow/src/chunked_array/dynamic.rs index b2f24db0..bff97c9d 100644 --- a/rust/geoarrow/src/chunked_array/dynamic.rs +++ b/rust/geoarrow/src/chunked_array/dynamic.rs @@ -6,7 +6,7 @@ use arrow_schema::Field; use crate::array::*; use crate::chunked_array::{ChunkedGeometryArray, ChunkedNativeArray}; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::error::{GeoArrowError, Result}; /// A wrapper around a ChunkedNativeArray of unknown type @@ -30,7 +30,7 @@ impl ChunkedNativeArrayDyn { /// use geoarrow::chunked_array::ChunkedNativeArrayDyn; /// use std::sync::Arc; /// - /// let array: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); + /// let array: PointArray = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); /// let field = array.extension_field(); /// let array = array.into_array_ref(); /// let chunks = vec![array.as_ref()]; @@ -57,29 +57,17 @@ impl ChunkedNativeArrayDyn { let typ = NativeType::try_from(field)?; let ca: Arc = match typ { - Point(_, Dimension::XY) => impl_downcast!(PointArray<2>), - LineString(_, Dimension::XY) => impl_downcast!(LineStringArray<2>), - Polygon(_, Dimension::XY) => impl_downcast!(PolygonArray<2>), - MultiPoint(_, Dimension::XY) => impl_downcast!(MultiPointArray<2>), - MultiLineString(_, Dimension::XY) => impl_downcast!(MultiLineStringArray<2>), - MultiPolygon(_, Dimension::XY) => impl_downcast!(MultiPolygonArray<2>), - Mixed(_, Dimension::XY) => impl_downcast!(MixedGeometryArray<2>), - GeometryCollection(_, Dimension::XY) => { - impl_downcast!(GeometryCollectionArray<2>) + Point(_, _) => impl_downcast!(PointArray), + LineString(_, _) => impl_downcast!(LineStringArray), + Polygon(_, _) => impl_downcast!(PolygonArray), + MultiPoint(_, _) => impl_downcast!(MultiPointArray), + MultiLineString(_, _) => impl_downcast!(MultiLineStringArray), + MultiPolygon(_, _) => impl_downcast!(MultiPolygonArray), + Mixed(_, _) => impl_downcast!(MixedGeometryArray), + GeometryCollection(_, _) => { + impl_downcast!(GeometryCollectionArray) } - Rect(Dimension::XY) => impl_downcast!(RectArray<2>), - - Point(_, Dimension::XYZ) => impl_downcast!(PointArray<3>), - LineString(_, Dimension::XYZ) => impl_downcast!(LineStringArray<3>), - Polygon(_, Dimension::XYZ) => impl_downcast!(PolygonArray<3>), - MultiPoint(_, Dimension::XYZ) => impl_downcast!(MultiPointArray<3>), - MultiLineString(_, Dimension::XYZ) => impl_downcast!(MultiLineStringArray<3>), - MultiPolygon(_, Dimension::XYZ) => impl_downcast!(MultiPolygonArray<3>), - Mixed(_, Dimension::XYZ) => impl_downcast!(MixedGeometryArray<3>), - GeometryCollection(_, Dimension::XYZ) => { - impl_downcast!(GeometryCollectionArray<3>) - } - Rect(Dimension::XYZ) => impl_downcast!(RectArray<3>), + Rect(_) => impl_downcast!(RectArray), }; Ok(Self(ca)) } @@ -92,8 +80,8 @@ impl ChunkedNativeArrayDyn { /// use geoarrow::{NativeArray, array::PointArray}; /// use geoarrow::chunked_array::ChunkedNativeArrayDyn; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); + /// let array_1: PointArray = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); /// let chunks = vec![array_0.as_ref(), array_1.as_ref()]; /// let chunked_array = ChunkedNativeArrayDyn::from_geoarrow_chunks(chunks.as_slice()).unwrap(); /// ``` @@ -111,11 +99,11 @@ impl ChunkedNativeArrayDyn { if data_types.len() == 1 { macro_rules! impl_downcast { - ($cast_func:ident, $dim:expr) => { + ($cast_func:ident) => { Arc::new(ChunkedGeometryArray::new( chunks .iter() - .map(|chunk| chunk.as_ref().$cast_func::<$dim>().clone()) + .map(|chunk| chunk.as_ref().$cast_func().clone()) .collect(), )) }; @@ -123,24 +111,15 @@ impl ChunkedNativeArrayDyn { use NativeType::*; let result: Arc = match data_types.drain().next().unwrap() { - Point(_, Dimension::XY) => impl_downcast!(as_point, 2), - LineString(_, Dimension::XY) => impl_downcast!(as_line_string, 2), - Polygon(_, Dimension::XY) => impl_downcast!(as_polygon, 2), - MultiPoint(_, Dimension::XY) => impl_downcast!(as_multi_point, 2), - MultiLineString(_, Dimension::XY) => impl_downcast!(as_multi_line_string, 2), - MultiPolygon(_, Dimension::XY) => impl_downcast!(as_multi_polygon, 2), - Mixed(_, Dimension::XY) => impl_downcast!(as_mixed, 2), - GeometryCollection(_, Dimension::XY) => impl_downcast!(as_geometry_collection, 2), - Point(_, Dimension::XYZ) => impl_downcast!(as_point, 3), - LineString(_, Dimension::XYZ) => impl_downcast!(as_line_string, 3), - Polygon(_, Dimension::XYZ) => impl_downcast!(as_polygon, 3), - MultiPoint(_, Dimension::XYZ) => impl_downcast!(as_multi_point, 3), - MultiLineString(_, Dimension::XYZ) => impl_downcast!(as_multi_line_string, 3), - MultiPolygon(_, Dimension::XYZ) => impl_downcast!(as_multi_polygon, 3), - Mixed(_, Dimension::XYZ) => impl_downcast!(as_mixed, 3), - GeometryCollection(_, Dimension::XYZ) => impl_downcast!(as_geometry_collection, 3), - Rect(Dimension::XY) => impl_downcast!(as_rect, 2), - Rect(Dimension::XYZ) => impl_downcast!(as_rect, 3), + Point(_, _) => impl_downcast!(as_point), + LineString(_, _) => impl_downcast!(as_line_string), + Polygon(_, _) => impl_downcast!(as_polygon), + MultiPoint(_, _) => impl_downcast!(as_multi_point), + MultiLineString(_, _) => impl_downcast!(as_multi_line_string), + MultiPolygon(_, _) => impl_downcast!(as_multi_polygon), + Mixed(_, _) => impl_downcast!(as_mixed), + GeometryCollection(_, _) => impl_downcast!(as_geometry_collection), + Rect(_) => impl_downcast!(as_rect), }; Ok(Self(result)) } else { diff --git a/rust/geoarrow/src/chunked_array/mod.rs b/rust/geoarrow/src/chunked_array/mod.rs index 087f6dee..ec8c0b54 100644 --- a/rust/geoarrow/src/chunked_array/mod.rs +++ b/rust/geoarrow/src/chunked_array/mod.rs @@ -568,25 +568,23 @@ impl TryFrom> for ChunkedGeometryArray { } /// A chunked point array. -pub type ChunkedPointArray = ChunkedGeometryArray>; +pub type ChunkedPointArray = ChunkedGeometryArray; /// A chunked line string array. -pub type ChunkedLineStringArray = ChunkedGeometryArray>; +pub type ChunkedLineStringArray = ChunkedGeometryArray; /// A chunked polygon array. -pub type ChunkedPolygonArray = ChunkedGeometryArray>; +pub type ChunkedPolygonArray = ChunkedGeometryArray; /// A chunked multi-point array. -pub type ChunkedMultiPointArray = ChunkedGeometryArray>; +pub type ChunkedMultiPointArray = ChunkedGeometryArray; /// A chunked mutli-line string array. -pub type ChunkedMultiLineStringArray = - ChunkedGeometryArray>; +pub type ChunkedMultiLineStringArray = ChunkedGeometryArray; /// A chunked multi-polygon array. -pub type ChunkedMultiPolygonArray = ChunkedGeometryArray>; +pub type ChunkedMultiPolygonArray = ChunkedGeometryArray; /// A chunked mixed geometry array. -pub type ChunkedMixedGeometryArray = ChunkedGeometryArray>; +pub type ChunkedMixedGeometryArray = ChunkedGeometryArray; /// A chunked geometry collection array. -pub type ChunkedGeometryCollectionArray = - ChunkedGeometryArray>; +pub type ChunkedGeometryCollectionArray = ChunkedGeometryArray; /// A chunked rect array. -pub type ChunkedRectArray = ChunkedGeometryArray>; +pub type ChunkedRectArray = ChunkedGeometryArray; /// A chunked unknown geometry array. #[allow(dead_code)] pub type ChunkedUnknownGeometryArray = ChunkedGeometryArray>; @@ -797,7 +795,7 @@ pub trait ChunkedNativeArray: ChunkedArrayBase { } } -impl ChunkedArrayBase for ChunkedPointArray { +impl ChunkedArrayBase for ChunkedPointArray { fn as_any(&self) -> &dyn Any { self } @@ -823,7 +821,7 @@ impl ChunkedArrayBase for ChunkedPointArray { } } -impl ChunkedNativeArray for ChunkedPointArray { +impl ChunkedNativeArray for ChunkedPointArray { fn data_type(&self) -> NativeType { self.chunks.first().unwrap().data_type() } @@ -930,15 +928,15 @@ macro_rules! impl_trait { }; } -impl_trait!(ChunkedLineStringArray); -impl_trait!(ChunkedPolygonArray); -impl_trait!(ChunkedMultiPointArray); -impl_trait!(ChunkedMultiLineStringArray); -impl_trait!(ChunkedMultiPolygonArray); -impl_trait!(ChunkedMixedGeometryArray); -impl_trait!(ChunkedGeometryCollectionArray); +impl_trait!(ChunkedLineStringArray); +impl_trait!(ChunkedPolygonArray); +impl_trait!(ChunkedMultiPointArray); +impl_trait!(ChunkedMultiLineStringArray); +impl_trait!(ChunkedMultiPolygonArray); +impl_trait!(ChunkedMixedGeometryArray); +impl_trait!(ChunkedGeometryCollectionArray); -impl ChunkedArrayBase for ChunkedRectArray { +impl ChunkedArrayBase for ChunkedRectArray { fn as_any(&self) -> &dyn Any { self } @@ -965,7 +963,7 @@ impl ChunkedArrayBase for ChunkedRectArray { } } -impl ChunkedNativeArray for ChunkedRectArray { +impl ChunkedNativeArray for ChunkedRectArray { fn data_type(&self) -> NativeType { self.chunks.first().unwrap().data_type() } diff --git a/rust/geoarrow/src/indexed/array.rs b/rust/geoarrow/src/indexed/array.rs index 72976db8..aac1f8b1 100644 --- a/rust/geoarrow/src/indexed/array.rs +++ b/rust/geoarrow/src/indexed/array.rs @@ -125,20 +125,18 @@ impl<'a, G: NativeArray + ArrayAccessor<'a>> IndexedGeometryArray { } } -pub type IndexedPointArray = IndexedGeometryArray>; -pub type IndexedLineStringArray = IndexedGeometryArray>; -pub type IndexedPolygonArray = IndexedGeometryArray>; -pub type IndexedMultiPointArray = IndexedGeometryArray>; -pub type IndexedMultiLineStringArray = - IndexedGeometryArray>; -pub type IndexedMultiPolygonArray = IndexedGeometryArray>; -pub type IndexedMixedGeometryArray = IndexedGeometryArray>; -pub type IndexedGeometryCollectionArray = - IndexedGeometryArray>; +pub type IndexedPointArray = IndexedGeometryArray; +pub type IndexedLineStringArray = IndexedGeometryArray; +pub type IndexedPolygonArray = IndexedGeometryArray; +pub type IndexedMultiPointArray = IndexedGeometryArray; +pub type IndexedMultiLineStringArray = IndexedGeometryArray; +pub type IndexedMultiPolygonArray = IndexedGeometryArray; +pub type IndexedMixedGeometryArray = IndexedGeometryArray; +pub type IndexedGeometryCollectionArray = IndexedGeometryArray; #[allow(dead_code)] pub type IndexedWKBArray = IndexedGeometryArray>; #[allow(dead_code)] -pub type IndexedRectArray = IndexedGeometryArray>; +pub type IndexedRectArray = IndexedGeometryArray; #[allow(dead_code)] pub type IndexedUnknownGeometryArray = IndexedGeometryArray>; diff --git a/rust/geoarrow/src/indexed/chunked.rs b/rust/geoarrow/src/indexed/chunked.rs index 7fe2d44e..d4c4ff47 100644 --- a/rust/geoarrow/src/indexed/chunked.rs +++ b/rust/geoarrow/src/indexed/chunked.rs @@ -42,24 +42,19 @@ impl IndexedChunkedGeometryArray { } } -pub type IndexedChunkedPointArray = IndexedChunkedGeometryArray>; -pub type IndexedChunkedLineStringArray = - IndexedChunkedGeometryArray>; -pub type IndexedChunkedPolygonArray = IndexedChunkedGeometryArray>; -pub type IndexedChunkedMultiPointArray = - IndexedChunkedGeometryArray>; -pub type IndexedChunkedMultiLineStringArray = - IndexedChunkedGeometryArray>; -pub type IndexedChunkedMultiPolygonArray = - IndexedChunkedGeometryArray>; -pub type IndexedChunkedMixedGeometryArray = - IndexedChunkedGeometryArray>; +pub type IndexedChunkedPointArray = IndexedChunkedGeometryArray; +pub type IndexedChunkedLineStringArray = IndexedChunkedGeometryArray; +pub type IndexedChunkedPolygonArray = IndexedChunkedGeometryArray; +pub type IndexedChunkedMultiPointArray = IndexedChunkedGeometryArray; +pub type IndexedChunkedMultiLineStringArray = IndexedChunkedGeometryArray; +pub type IndexedChunkedMultiPolygonArray = IndexedChunkedGeometryArray; +pub type IndexedChunkedMixedGeometryArray = IndexedChunkedGeometryArray; pub type IndexedChunkedGeometryCollectionArray = - IndexedChunkedGeometryArray>; + IndexedChunkedGeometryArray; #[allow(dead_code)] pub type IndexedChunkedWKBArray = IndexedChunkedGeometryArray>; #[allow(dead_code)] -pub type IndexedChunkedRectArray = IndexedChunkedGeometryArray>; +pub type IndexedChunkedRectArray = IndexedChunkedGeometryArray; #[allow(dead_code)] pub type IndexedChunkedUnknownGeometryArray = IndexedChunkedGeometryArray>; diff --git a/rust/geoarrow/src/io/display/array.rs b/rust/geoarrow/src/io/display/array.rs index b5ba9f06..b1440773 100644 --- a/rust/geoarrow/src/io/display/array.rs +++ b/rust/geoarrow/src/io/display/array.rs @@ -78,8 +78,8 @@ macro_rules! impl_fmt_non_generic { }; } -impl_fmt_non_generic!(PointArray<2>, "PointArray"); -impl_fmt_non_generic!(RectArray<2>, "RectArray"); +impl_fmt_non_generic!(PointArray, "PointArray"); +impl_fmt_non_generic!(RectArray, "RectArray"); macro_rules! impl_fmt_generic { ($struct_name:ty, $str_literal:tt) => { @@ -122,22 +122,22 @@ macro_rules! impl_fmt_generic { }; } -impl_fmt_generic!(LineStringArray<2>, "LineStringArray"); -impl_fmt_generic!(PolygonArray<2>, "PolygonArray"); -impl_fmt_generic!(MultiPointArray<2>, "MultiPointArray"); -impl_fmt_generic!(MultiLineStringArray<2>, "MultiLineStringArray"); -impl_fmt_generic!(MultiPolygonArray<2>, "MultiPolygonArray"); -impl_fmt_generic!(MixedGeometryArray<2>, "MixedGeometryArray"); -impl_fmt_generic!(GeometryCollectionArray<2>, "GeometryCollectionArray"); +impl_fmt_generic!(LineStringArray, "LineStringArray"); +impl_fmt_generic!(PolygonArray, "PolygonArray"); +impl_fmt_generic!(MultiPointArray, "MultiPointArray"); +impl_fmt_generic!(MultiLineStringArray, "MultiLineStringArray"); +impl_fmt_generic!(MultiPolygonArray, "MultiPolygonArray"); +impl_fmt_generic!(MixedGeometryArray, "MixedGeometryArray"); +impl_fmt_generic!(GeometryCollectionArray, "GeometryCollectionArray"); // impl_fmt_generic!(WKBArray, "WKBArray"); -impl fmt::Display for PointArray<2> { +impl fmt::Display for PointArray { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.write(f, 0) } } -impl fmt::Display for RectArray<2> { +impl fmt::Display for RectArray { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { self.write(f, 0) } @@ -153,13 +153,13 @@ macro_rules! impl_fmt { }; } -impl_fmt!(LineStringArray<2>, "LineStringArray"); -impl_fmt!(PolygonArray<2>, "PolygonArray"); -impl_fmt!(MultiPointArray<2>, "MultiPointArray"); -impl_fmt!(MultiLineStringArray<2>, "MultiLineStringArray"); -impl_fmt!(MultiPolygonArray<2>, "MultiPolygonArray"); -impl_fmt!(MixedGeometryArray<2>, "MixedGeometryArray"); -impl_fmt!(GeometryCollectionArray<2>, "GeometryCollectionArray"); +impl_fmt!(LineStringArray, "LineStringArray"); +impl_fmt!(PolygonArray, "PolygonArray"); +impl_fmt!(MultiPointArray, "MultiPointArray"); +impl_fmt!(MultiLineStringArray, "MultiLineStringArray"); +impl_fmt!(MultiPolygonArray, "MultiPolygonArray"); +impl_fmt!(MixedGeometryArray, "MixedGeometryArray"); +impl_fmt!(GeometryCollectionArray, "GeometryCollectionArray"); // impl_fmt!(WKBArray, "WKBArray"); #[cfg(test)] diff --git a/rust/geoarrow/src/io/geos/array/geometrycollection.rs b/rust/geoarrow/src/io/geos/array/geometrycollection.rs index d88d1201..3a912d35 100644 --- a/rust/geoarrow/src/io/geos/array/geometrycollection.rs +++ b/rust/geoarrow/src/io/geos/array/geometrycollection.rs @@ -2,7 +2,7 @@ use crate::array::{GeometryCollectionArray, GeometryCollectionBuilder}; use crate::error::GeoArrowError; use crate::io::geos::scalar::GEOSGeometryCollection; -impl TryFrom> for GeometryCollectionBuilder { +impl TryFrom> for GeometryCollectionBuilder { type Error = GeoArrowError; fn try_from(value: Vec) -> std::result::Result { @@ -14,11 +14,11 @@ impl TryFrom> for GeometryCollectionBuilder { } } -impl TryFrom> for GeometryCollectionArray { +impl TryFrom> for GeometryCollectionArray { type Error = GeoArrowError; fn try_from(value: Vec) -> std::result::Result { - let mutable_arr: GeometryCollectionBuilder = value.try_into()?; + let mutable_arr: GeometryCollectionBuilder = value.try_into()?; Ok(mutable_arr.into()) } } diff --git a/rust/geoarrow/src/io/geos/array/linestring.rs b/rust/geoarrow/src/io/geos/array/linestring.rs index 95909857..a0402be7 100644 --- a/rust/geoarrow/src/io/geos/array/linestring.rs +++ b/rust/geoarrow/src/io/geos/array/linestring.rs @@ -2,7 +2,7 @@ use crate::array::{LineStringArray, LineStringBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSLineString; -impl LineStringBuilder { +impl LineStringBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value @@ -13,7 +13,7 @@ impl LineStringBuilder { } } -impl LineStringArray { +impl LineStringArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = LineStringBuilder::from_geos(value)?; Ok(mutable_arr.into()) @@ -34,7 +34,7 @@ mod test { .iter() .map(|opt_x| opt_x.map(|x| x.to_geos().unwrap())) .collect(); - let round_trip = LineStringArray::<2>::from_geos(geos_geoms).unwrap(); + let round_trip = LineStringArray::from_geos(geos_geoms).unwrap(); assert_eq!(arr, round_trip); } } diff --git a/rust/geoarrow/src/io/geos/array/mixed.rs b/rust/geoarrow/src/io/geos/array/mixed.rs index 0afcfceb..492178b0 100644 --- a/rust/geoarrow/src/io/geos/array/mixed.rs +++ b/rust/geoarrow/src/io/geos/array/mixed.rs @@ -2,7 +2,7 @@ use crate::array::{MixedGeometryArray, MixedGeometryBuilder}; use crate::error::GeoArrowError; use crate::io::geos::scalar::GEOSGeometry; -impl TryFrom> for MixedGeometryBuilder { +impl TryFrom> for MixedGeometryBuilder { type Error = GeoArrowError; fn try_from(value: Vec) -> std::result::Result { @@ -11,11 +11,11 @@ impl TryFrom> for MixedGeometryBuilder { } } -impl TryFrom> for MixedGeometryArray { +impl TryFrom> for MixedGeometryArray { type Error = GeoArrowError; fn try_from(value: Vec) -> std::result::Result { - let mutable_arr: MixedGeometryBuilder = value.try_into()?; + let mutable_arr: MixedGeometryBuilder = value.try_into()?; Ok(mutable_arr.into()) } } diff --git a/rust/geoarrow/src/io/geos/array/multilinestring.rs b/rust/geoarrow/src/io/geos/array/multilinestring.rs index 42807e37..0dda7b1c 100644 --- a/rust/geoarrow/src/io/geos/array/multilinestring.rs +++ b/rust/geoarrow/src/io/geos/array/multilinestring.rs @@ -2,7 +2,7 @@ use crate::array::{MultiLineStringArray, MultiLineStringBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSMultiLineString; -impl MultiLineStringBuilder { +impl MultiLineStringBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value @@ -13,7 +13,7 @@ impl MultiLineStringBuilder { } } -impl MultiLineStringArray { +impl MultiLineStringArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = MultiLineStringBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/geos/array/multipoint.rs b/rust/geoarrow/src/io/geos/array/multipoint.rs index ae55055a..387e7756 100644 --- a/rust/geoarrow/src/io/geos/array/multipoint.rs +++ b/rust/geoarrow/src/io/geos/array/multipoint.rs @@ -2,7 +2,7 @@ use crate::array::{MultiPointArray, MultiPointBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSMultiPoint; -impl MultiPointBuilder { +impl MultiPointBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value @@ -13,7 +13,7 @@ impl MultiPointBuilder { } } -impl MultiPointArray { +impl MultiPointArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = MultiPointBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/geos/array/multipolygon.rs b/rust/geoarrow/src/io/geos/array/multipolygon.rs index ff2988d7..40ed7de3 100644 --- a/rust/geoarrow/src/io/geos/array/multipolygon.rs +++ b/rust/geoarrow/src/io/geos/array/multipolygon.rs @@ -2,7 +2,7 @@ use crate::array::{MultiPolygonArray, MultiPolygonBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSMultiPolygon; -impl MultiPolygonBuilder { +impl MultiPolygonBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value @@ -13,7 +13,7 @@ impl MultiPolygonBuilder { } } -impl MultiPolygonArray { +impl MultiPolygonArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = MultiPolygonBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/geos/array/point.rs b/rust/geoarrow/src/io/geos/array/point.rs index d0f1bf5d..f387b17d 100644 --- a/rust/geoarrow/src/io/geos/array/point.rs +++ b/rust/geoarrow/src/io/geos/array/point.rs @@ -2,7 +2,7 @@ use crate::array::{PointArray, PointBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSPoint; -impl PointBuilder { +impl PointBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_linestring_objects: Vec> = value @@ -13,7 +13,7 @@ impl PointBuilder { } } -impl PointArray { +impl PointArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = PointBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/geos/array/polygon.rs b/rust/geoarrow/src/io/geos/array/polygon.rs index 54bec8b6..aef53b04 100644 --- a/rust/geoarrow/src/io/geos/array/polygon.rs +++ b/rust/geoarrow/src/io/geos/array/polygon.rs @@ -2,7 +2,7 @@ use crate::array::{PolygonArray, PolygonBuilder}; use crate::error::Result; use crate::io::geos::scalar::GEOSPolygon; -impl PolygonBuilder { +impl PolygonBuilder { pub fn from_geos(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value @@ -14,7 +14,7 @@ impl PolygonBuilder { } } -impl PolygonArray { +impl PolygonArray { pub fn from_geos(value: Vec>) -> Result { let mutable_arr = PolygonBuilder::from_geos(value)?; Ok(mutable_arr.into()) diff --git a/rust/geoarrow/src/io/postgis/reader.rs b/rust/geoarrow/src/io/postgis/reader.rs index 4e98ca22..53945b49 100644 --- a/rust/geoarrow/src/io/postgis/reader.rs +++ b/rust/geoarrow/src/io/postgis/reader.rs @@ -172,7 +172,7 @@ pub async fn read_postgis<'c, E: Executor<'c, Database = Postgres>>( ) -> Result> { let query = sqlx::query::(sql); let mut result_stream = query.fetch(executor); - let mut table_builder: Option>> = None; + let mut table_builder: Option> = None; // TODO: try out chunking with `result_stream.try_chunks` let mut row_idx = 0; diff --git a/rust/geoarrow/src/io/wkb/api.rs b/rust/geoarrow/src/io/wkb/api.rs index 4a3ee9c9..21c30783 100644 --- a/rust/geoarrow/src/io/wkb/api.rs +++ b/rust/geoarrow/src/io/wkb/api.rs @@ -22,7 +22,7 @@ pub trait FromWKB: Sized { fn from_wkb(arr: &Self::Input, coord_type: CoordType) -> Result; } -impl FromWKB for PointArray<2> { +impl FromWKB for PointArray { type Input = WKBArray; fn from_wkb(arr: &WKBArray, coord_type: CoordType) -> Result { @@ -49,33 +49,29 @@ macro_rules! impl_from_wkb { }; } -impl_from_wkb!(LineStringArray<2>, LineStringBuilder<2>); -impl_from_wkb!(PolygonArray<2>, PolygonBuilder<2>); -impl_from_wkb!(MultiPointArray<2>, MultiPointBuilder<2>); -impl_from_wkb!(MultiLineStringArray<2>, MultiLineStringBuilder<2>); -impl_from_wkb!(MultiPolygonArray<2>, MultiPolygonBuilder<2>); +impl_from_wkb!(LineStringArray, LineStringBuilder); +impl_from_wkb!(PolygonArray, PolygonBuilder); +impl_from_wkb!(MultiPointArray, MultiPointBuilder); +impl_from_wkb!(MultiLineStringArray, MultiLineStringBuilder); +impl_from_wkb!(MultiPolygonArray, MultiPolygonBuilder); -impl FromWKB for MixedGeometryArray<2> { +impl FromWKB for MixedGeometryArray { type Input = WKBArray; fn from_wkb(arr: &WKBArray, coord_type: CoordType) -> Result { let wkb_objects: Vec>> = arr.iter().collect(); - let builder = MixedGeometryBuilder::<2>::from_wkb( - &wkb_objects, - Some(coord_type), - arr.metadata(), - true, - )?; + let builder = + MixedGeometryBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata(), true)?; Ok(builder.finish()) } } -impl FromWKB for GeometryCollectionArray<2> { +impl FromWKB for GeometryCollectionArray { type Input = WKBArray; fn from_wkb(arr: &WKBArray, coord_type: CoordType) -> Result { let wkb_objects: Vec>> = arr.iter().collect(); - let builder = GeometryCollectionBuilder::<2>::from_wkb( + let builder = GeometryCollectionBuilder::from_wkb( &wkb_objects, Some(coord_type), arr.metadata(), @@ -90,7 +86,7 @@ impl FromWKB for Arc { fn from_wkb(arr: &WKBArray, coord_type: CoordType) -> Result { let wkb_objects: Vec>> = arr.iter().collect(); - let builder = GeometryCollectionBuilder::<2>::from_wkb( + let builder = GeometryCollectionBuilder::from_wkb( &wkb_objects, Some(coord_type), arr.metadata(), @@ -100,7 +96,7 @@ impl FromWKB for Arc { } } -impl FromWKB for ChunkedPointArray<2> { +impl FromWKB for ChunkedPointArray { type Input = ChunkedWKBArray; fn from_wkb(arr: &Self::Input, coord_type: CoordType) -> Result { @@ -125,13 +121,13 @@ macro_rules! impl_chunked { }; } -impl_chunked!(ChunkedLineStringArray<2>); -impl_chunked!(ChunkedPolygonArray<2>); -impl_chunked!(ChunkedMultiPointArray<2>); -impl_chunked!(ChunkedMultiLineStringArray<2>); -impl_chunked!(ChunkedMultiPolygonArray<2>); -impl_chunked!(ChunkedMixedGeometryArray<2>); -impl_chunked!(ChunkedGeometryCollectionArray<2>); +impl_chunked!(ChunkedLineStringArray); +impl_chunked!(ChunkedPolygonArray); +impl_chunked!(ChunkedMultiPointArray); +impl_chunked!(ChunkedMultiLineStringArray); +impl_chunked!(ChunkedMultiPolygonArray); +impl_chunked!(ChunkedMixedGeometryArray); +impl_chunked!(ChunkedGeometryCollectionArray); impl FromWKB for Arc { type Input = ChunkedWKBArray; @@ -140,7 +136,7 @@ impl FromWKB for Arc { arr: &ChunkedWKBArray, coord_type: CoordType, ) -> Result { - let geom_arr = ChunkedGeometryCollectionArray::<2>::from_wkb(arr, coord_type)?; + let geom_arr = ChunkedGeometryCollectionArray::from_wkb(arr, coord_type)?; Ok(geom_arr.downcast(true)) } } @@ -154,95 +150,44 @@ pub fn from_wkb( prefer_multi: bool, ) -> Result> { use NativeType::*; + let target_dim = target_geo_data_type.dimension(); let wkb_objects: Vec>> = arr.iter().collect(); match target_geo_data_type { - Point(coord_type, Dimension::XY) => { - let builder = - PointBuilder::<2>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; - Ok(Arc::new(builder.finish())) - } - LineString(coord_type, Dimension::XY) => { - let builder = - LineStringBuilder::<2>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; - Ok(Arc::new(builder.finish())) - } - Polygon(coord_type, Dimension::XY) => { - let builder = - PolygonBuilder::<2>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; - Ok(Arc::new(builder.finish())) - } - MultiPoint(coord_type, Dimension::XY) => { - let builder = - MultiPointBuilder::<2>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; - Ok(Arc::new(builder.finish())) - } - MultiLineString(coord_type, Dimension::XY) => { - let builder = MultiLineStringBuilder::<2>::from_wkb( - &wkb_objects, - Some(coord_type), - arr.metadata(), - )?; - Ok(Arc::new(builder.finish())) - } - MultiPolygon(coord_type, Dimension::XY) => { - let builder = - MultiPolygonBuilder::<2>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; - Ok(Arc::new(builder.finish())) - } - Mixed(coord_type, Dimension::XY) => { - let builder = MixedGeometryBuilder::<2>::from_wkb( - &wkb_objects, - Some(coord_type), - arr.metadata(), - prefer_multi, - )?; + Point(coord_type, _) => { + let builder = PointBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; Ok(Arc::new(builder.finish())) } - GeometryCollection(coord_type, Dimension::XY) => { - let builder = GeometryCollectionBuilder::<2>::from_wkb( + LineString(coord_type, _) => { + let builder = LineStringBuilder::from_wkb( + target_dim, &wkb_objects, Some(coord_type), arr.metadata(), - prefer_multi, )?; Ok(Arc::new(builder.finish())) } - Point(coord_type, Dimension::XYZ) => { - let builder = - PointBuilder::<3>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + Polygon(coord_type, _) => { + let builder = PolygonBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; Ok(Arc::new(builder.finish())) } - LineString(coord_type, Dimension::XYZ) => { + MultiPoint(coord_type, _) => { let builder = - LineStringBuilder::<3>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + MultiPointBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; Ok(Arc::new(builder.finish())) } - Polygon(coord_type, Dimension::XYZ) => { + MultiLineString(coord_type, _) => { let builder = - PolygonBuilder::<3>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + MultiLineStringBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; Ok(Arc::new(builder.finish())) } - MultiPoint(coord_type, Dimension::XYZ) => { + MultiPolygon(coord_type, _) => { let builder = - MultiPointBuilder::<3>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + MultiPolygonBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; Ok(Arc::new(builder.finish())) } - MultiLineString(coord_type, Dimension::XYZ) => { - let builder = MultiLineStringBuilder::<3>::from_wkb( - &wkb_objects, - Some(coord_type), - arr.metadata(), - )?; - Ok(Arc::new(builder.finish())) - } - MultiPolygon(coord_type, Dimension::XYZ) => { - let builder = - MultiPolygonBuilder::<3>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; - Ok(Arc::new(builder.finish())) - } - Mixed(coord_type, Dimension::XYZ) => { - let builder = MixedGeometryBuilder::<3>::from_wkb( + Mixed(coord_type, _) => { + let builder = MixedGeometryBuilder::from_wkb( &wkb_objects, Some(coord_type), arr.metadata(), @@ -250,8 +195,8 @@ pub fn from_wkb( )?; Ok(Arc::new(builder.finish())) } - GeometryCollection(coord_type, Dimension::XYZ) => { - let builder = GeometryCollectionBuilder::<3>::from_wkb( + GeometryCollection(coord_type, _) => { + let builder = GeometryCollectionBuilder::from_wkb( &wkb_objects, Some(coord_type), arr.metadata(), @@ -281,27 +226,18 @@ impl ToWKB for &dyn NativeArray { type Output = WKBArray; fn to_wkb(&self) -> Self::Output { - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().into(), - LineString(_, XY) => self.as_line_string::<2>().into(), - Polygon(_, XY) => self.as_polygon::<2>().into(), - MultiPoint(_, XY) => self.as_multi_point::<2>().into(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().into(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().into(), - Mixed(_, XY) => self.as_mixed::<2>().into(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().into(), - - Point(_, XYZ) => self.as_point::<3>().into(), - LineString(_, XYZ) => self.as_line_string::<3>().into(), - Polygon(_, XYZ) => self.as_polygon::<3>().into(), - MultiPoint(_, XYZ) => self.as_multi_point::<3>().into(), - MultiLineString(_, XYZ) => self.as_multi_line_string::<3>().into(), - MultiPolygon(_, XYZ) => self.as_multi_polygon::<3>().into(), - Mixed(_, XYZ) => self.as_mixed::<3>().into(), - GeometryCollection(_, XYZ) => self.as_geometry_collection::<3>().into(), + Point(_, _) => self.as_point().into(), + LineString(_, _) => self.as_line_string().into(), + Polygon(_, _) => self.as_polygon().into(), + MultiPoint(_, _) => self.as_multi_point().into(), + MultiLineString(_, _) => self.as_multi_line_string().into(), + MultiPolygon(_, _) => self.as_multi_polygon().into(), + Mixed(_, _) => self.as_mixed().into(), + GeometryCollection(_, _) => self.as_geometry_collection().into(), + Rect(_) => todo!(), } } @@ -314,54 +250,24 @@ impl ToWKB for &dyn ChunkedNativeArray { use NativeType::*; match self.data_type() { - Point(_, Dimension::XY) => { - ChunkedGeometryArray::new(self.as_point::<2>().map(|chunk| chunk.into())) - } - LineString(_, Dimension::XY) => { - ChunkedGeometryArray::new(self.as_line_string::<2>().map(|chunk| chunk.into())) - } - Polygon(_, Dimension::XY) => { - ChunkedGeometryArray::new(self.as_polygon::<2>().map(|chunk| chunk.into())) - } - MultiPoint(_, Dimension::XY) => { - ChunkedGeometryArray::new(self.as_multi_point::<2>().map(|chunk| chunk.into())) - } - MultiLineString(_, Dimension::XY) => ChunkedGeometryArray::new( - self.as_multi_line_string::<2>().map(|chunk| chunk.into()), - ), - MultiPolygon(_, Dimension::XY) => { - ChunkedGeometryArray::new(self.as_multi_polygon::<2>().map(|chunk| chunk.into())) - } - Mixed(_, Dimension::XY) => { - ChunkedGeometryArray::new(self.as_mixed::<2>().map(|chunk| chunk.into())) - } - GeometryCollection(_, Dimension::XY) => ChunkedGeometryArray::new( - self.as_geometry_collection::<2>().map(|chunk| chunk.into()), - ), - Point(_, Dimension::XYZ) => { - ChunkedGeometryArray::new(self.as_point::<3>().map(|chunk| chunk.into())) - } - LineString(_, Dimension::XYZ) => { - ChunkedGeometryArray::new(self.as_line_string::<3>().map(|chunk| chunk.into())) + Point(_, _) => ChunkedGeometryArray::new(self.as_point().map(|chunk| chunk.into())), + LineString(_, _) => { + ChunkedGeometryArray::new(self.as_line_string().map(|chunk| chunk.into())) } - Polygon(_, Dimension::XYZ) => { - ChunkedGeometryArray::new(self.as_polygon::<3>().map(|chunk| chunk.into())) + Polygon(_, _) => ChunkedGeometryArray::new(self.as_polygon().map(|chunk| chunk.into())), + MultiPoint(_, _) => { + ChunkedGeometryArray::new(self.as_multi_point().map(|chunk| chunk.into())) } - MultiPoint(_, Dimension::XYZ) => { - ChunkedGeometryArray::new(self.as_multi_point::<3>().map(|chunk| chunk.into())) + MultiLineString(_, _) => { + ChunkedGeometryArray::new(self.as_multi_line_string().map(|chunk| chunk.into())) } - MultiLineString(_, Dimension::XYZ) => ChunkedGeometryArray::new( - self.as_multi_line_string::<3>().map(|chunk| chunk.into()), - ), - MultiPolygon(_, Dimension::XYZ) => { - ChunkedGeometryArray::new(self.as_multi_polygon::<3>().map(|chunk| chunk.into())) + MultiPolygon(_, _) => { + ChunkedGeometryArray::new(self.as_multi_polygon().map(|chunk| chunk.into())) } - Mixed(_, Dimension::XYZ) => { - ChunkedGeometryArray::new(self.as_mixed::<3>().map(|chunk| chunk.into())) + Mixed(_, _) => ChunkedGeometryArray::new(self.as_mixed().map(|chunk| chunk.into())), + GeometryCollection(_, _) => { + ChunkedGeometryArray::new(self.as_geometry_collection().map(|chunk| chunk.into())) } - GeometryCollection(_, Dimension::XYZ) => ChunkedGeometryArray::new( - self.as_geometry_collection::<3>().map(|chunk| chunk.into()), - ), Rect(_) => todo!(), } } @@ -372,22 +278,14 @@ pub fn to_wkb(arr: &dyn NativeArray) -> WKBArray { use NativeType::*; match arr.data_type() { - Point(_, Dimension::XY) => arr.as_point::<2>().into(), - LineString(_, Dimension::XY) => arr.as_line_string::<2>().into(), - Polygon(_, Dimension::XY) => arr.as_polygon::<2>().into(), - MultiPoint(_, Dimension::XY) => arr.as_multi_point::<2>().into(), - MultiLineString(_, Dimension::XY) => arr.as_multi_line_string::<2>().into(), - MultiPolygon(_, Dimension::XY) => arr.as_multi_polygon::<2>().into(), - Mixed(_, Dimension::XY) => arr.as_mixed::<2>().into(), - GeometryCollection(_, Dimension::XY) => arr.as_geometry_collection::<2>().into(), - Point(_, Dimension::XYZ) => arr.as_point::<3>().into(), - LineString(_, Dimension::XYZ) => arr.as_line_string::<3>().into(), - Polygon(_, Dimension::XYZ) => arr.as_polygon::<3>().into(), - MultiPoint(_, Dimension::XYZ) => arr.as_multi_point::<3>().into(), - MultiLineString(_, Dimension::XYZ) => arr.as_multi_line_string::<3>().into(), - MultiPolygon(_, Dimension::XYZ) => arr.as_multi_polygon::<3>().into(), - Mixed(_, Dimension::XYZ) => arr.as_mixed::<3>().into(), - GeometryCollection(_, Dimension::XYZ) => arr.as_geometry_collection::<3>().into(), + Point(_, _) => arr.as_point().into(), + LineString(_, _) => arr.as_line_string().into(), + Polygon(_, _) => arr.as_polygon().into(), + MultiPoint(_, _) => arr.as_multi_point().into(), + MultiLineString(_, _) => arr.as_multi_line_string().into(), + MultiPolygon(_, _) => arr.as_multi_polygon().into(), + Mixed(_, _) => arr.as_mixed().into(), + GeometryCollection(_, _) => arr.as_geometry_collection().into(), Rect(_) => todo!(), } } @@ -408,7 +306,7 @@ mod test { ) .unwrap(); let rt_point_arr = roundtrip.as_ref(); - let rt_point_arr_ref = rt_point_arr.as_point::<2>(); + let rt_point_arr_ref = rt_point_arr.as_point(); assert_eq!(&arr, rt_point_arr_ref); } @@ -423,10 +321,10 @@ mod test { ) .unwrap(); let rt_ref = roundtrip.as_ref(); - let rt_mixed_arr = rt_ref.as_mixed::<2>(); + let rt_mixed_arr = rt_ref.as_mixed(); let downcasted = rt_mixed_arr.downcast(true); let downcasted_ref = downcasted.as_ref(); - let rt_point_arr = downcasted_ref.as_point::<2>(); + let rt_point_arr = downcasted_ref.as_point(); assert_eq!(&arr, rt_point_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/geometry.rs b/rust/geoarrow/src/io/wkb/writer/geometry.rs index 5b3591fa..e790531c 100644 --- a/rust/geoarrow/src/io/wkb/writer/geometry.rs +++ b/rust/geoarrow/src/io/wkb/writer/geometry.rs @@ -9,8 +9,8 @@ use crate::trait_::ArrayAccessor; use crate::ArrayBase; use std::io::Cursor; -impl From<&MixedGeometryArray> for WKBArray { - fn from(value: &MixedGeometryArray) -> Self { +impl From<&MixedGeometryArray> for WKBArray { + fn from(value: &MixedGeometryArray) -> Self { let mut offsets: OffsetsBuilder = OffsetsBuilder::with_capacity(value.len()); // First pass: calculate binary array offsets @@ -50,7 +50,7 @@ mod test { #[test] fn round_trip() { - let orig_arr: MixedGeometryArray<2> = vec![ + let orig_arr: MixedGeometryArray = vec![ Some(geo::Geometry::MultiLineString(ml0())), Some(geo::Geometry::MultiLineString(ml1())), Some(geo::Geometry::Point(p0())), @@ -59,7 +59,7 @@ mod test { .try_into() .unwrap(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: MixedGeometryArray<2> = wkb_arr.try_into().unwrap(); + let new_arr: MixedGeometryArray = wkb_arr.try_into().unwrap(); assert_eq!(orig_arr, new_arr); } @@ -67,7 +67,7 @@ mod test { #[ignore = "None not allowed in geometry array."] #[test] fn round_trip_null() { - let orig_arr: MixedGeometryArray<2> = vec![ + let orig_arr: MixedGeometryArray = vec![ Some(geo::Geometry::MultiLineString(ml0())), Some(geo::Geometry::MultiLineString(ml1())), Some(geo::Geometry::Point(p0())), @@ -77,7 +77,7 @@ mod test { .try_into() .unwrap(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: MixedGeometryArray<2> = wkb_arr.try_into().unwrap(); + let new_arr: MixedGeometryArray = wkb_arr.try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/geometrycollection.rs b/rust/geoarrow/src/io/wkb/writer/geometrycollection.rs index 749e821d..603f450e 100644 --- a/rust/geoarrow/src/io/wkb/writer/geometrycollection.rs +++ b/rust/geoarrow/src/io/wkb/writer/geometrycollection.rs @@ -8,8 +8,8 @@ use std::io::Cursor; use wkb::writer::{geometry_collection_wkb_size, write_geometry_collection}; use wkb::Endianness; -impl From<&GeometryCollectionArray> for WKBArray { - fn from(value: &GeometryCollectionArray) -> Self { +impl From<&GeometryCollectionArray> for WKBArray { + fn from(value: &GeometryCollectionArray) -> Self { let mut offsets: OffsetsBuilder = OffsetsBuilder::with_capacity(value.len()); // First pass: calculate binary array offsets @@ -61,9 +61,9 @@ mod test { geo::Geometry::MultiPolygon(multipolygon::mp1()), ]); - let orig_arr: GeometryCollectionArray<2> = vec![Some(gc0), Some(gc1), None].into(); + let orig_arr: GeometryCollectionArray = vec![Some(gc0), Some(gc1), None].into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: GeometryCollectionArray<2> = wkb_arr.try_into().unwrap(); + let new_arr: GeometryCollectionArray = wkb_arr.try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/linestring.rs b/rust/geoarrow/src/io/wkb/writer/linestring.rs index eebb3a73..e9b6c515 100644 --- a/rust/geoarrow/src/io/wkb/writer/linestring.rs +++ b/rust/geoarrow/src/io/wkb/writer/linestring.rs @@ -8,8 +8,8 @@ use std::io::Cursor; use wkb::writer::{line_string_wkb_size, write_line_string}; use wkb::Endianness; -impl From<&LineStringArray> for WKBArray { - fn from(value: &LineStringArray) -> Self { +impl From<&LineStringArray> for WKBArray { + fn from(value: &LineStringArray) -> Self { let mut offsets: OffsetsBuilder = OffsetsBuilder::with_capacity(value.len()); // First pass: calculate binary array offsets @@ -48,9 +48,9 @@ mod test { #[test] fn round_trip() { - let orig_arr: LineStringArray<2> = vec![Some(ls0()), Some(ls1()), None].into(); + let orig_arr: LineStringArray = vec![Some(ls0()), Some(ls1()), None].into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: LineStringArray<2> = wkb_arr.try_into().unwrap(); + let new_arr: LineStringArray = wkb_arr.try_into().unwrap(); assert_eq!(orig_arr, new_arr); } @@ -58,9 +58,9 @@ mod test { // TODO: parsing WKBArray into LineStringArray not yet implemented #[test] fn round_trip_to_i64() { - let orig_arr: LineStringArray<2> = vec![Some(ls0()), Some(ls1()), None].into(); + let orig_arr: LineStringArray = vec![Some(ls0()), Some(ls1()), None].into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: LineStringArray<2> = wkb_arr.try_into().unwrap(); + let new_arr: LineStringArray = wkb_arr.try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/multilinestring.rs b/rust/geoarrow/src/io/wkb/writer/multilinestring.rs index bcb64253..e51db496 100644 --- a/rust/geoarrow/src/io/wkb/writer/multilinestring.rs +++ b/rust/geoarrow/src/io/wkb/writer/multilinestring.rs @@ -8,8 +8,8 @@ use std::io::Cursor; use wkb::writer::{multi_line_string_wkb_size, write_multi_line_string}; use wkb::Endianness; -impl From<&MultiLineStringArray> for WKBArray { - fn from(value: &MultiLineStringArray) -> Self { +impl From<&MultiLineStringArray> for WKBArray { + fn from(value: &MultiLineStringArray) -> Self { let mut offsets: OffsetsBuilder = OffsetsBuilder::with_capacity(value.len()); // First pass: calculate binary array offsets @@ -50,9 +50,9 @@ mod test { #[test] fn round_trip() { - let orig_arr: MultiLineStringArray<2> = vec![Some(ml0()), Some(ml1()), None].into(); + let orig_arr: MultiLineStringArray = vec![Some(ml0()), Some(ml1()), None].into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: MultiLineStringArray<2> = wkb_arr.try_into().unwrap(); + let new_arr: MultiLineStringArray = wkb_arr.try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/multipoint.rs b/rust/geoarrow/src/io/wkb/writer/multipoint.rs index 7f4f0f39..58abbff8 100644 --- a/rust/geoarrow/src/io/wkb/writer/multipoint.rs +++ b/rust/geoarrow/src/io/wkb/writer/multipoint.rs @@ -8,8 +8,8 @@ use std::io::Cursor; use wkb::writer::{multi_point_wkb_size, write_multi_point}; use wkb::Endianness; -impl From<&MultiPointArray> for WKBArray { - fn from(value: &MultiPointArray) -> Self { +impl From<&MultiPointArray> for WKBArray { + fn from(value: &MultiPointArray) -> Self { let mut offsets: OffsetsBuilder = OffsetsBuilder::with_capacity(value.len()); // First pass: calculate binary array offsets @@ -48,9 +48,9 @@ mod test { #[test] fn round_trip() { - let orig_arr: MultiPointArray<2> = vec![Some(mp0()), Some(mp1()), None].into(); + let orig_arr: MultiPointArray = vec![Some(mp0()), Some(mp1()), None].into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: MultiPointArray<2> = wkb_arr.try_into().unwrap(); + let new_arr: MultiPointArray = wkb_arr.try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/multipolygon.rs b/rust/geoarrow/src/io/wkb/writer/multipolygon.rs index b7969f42..12223d20 100644 --- a/rust/geoarrow/src/io/wkb/writer/multipolygon.rs +++ b/rust/geoarrow/src/io/wkb/writer/multipolygon.rs @@ -8,8 +8,8 @@ use std::io::Cursor; use wkb::writer::{multi_polygon_wkb_size, write_multi_polygon}; use wkb::Endianness; -impl From<&MultiPolygonArray> for WKBArray { - fn from(value: &MultiPolygonArray) -> Self { +impl From<&MultiPolygonArray> for WKBArray { + fn from(value: &MultiPolygonArray) -> Self { let mut offsets: OffsetsBuilder = OffsetsBuilder::with_capacity(value.len()); // First pass: calculate binary array offsets @@ -50,9 +50,9 @@ mod test { #[test] fn round_trip() { - let orig_arr: MultiPolygonArray<2> = vec![Some(mp0()), Some(mp1()), None].into(); + let orig_arr: MultiPolygonArray = vec![Some(mp0()), Some(mp1()), None].into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: MultiPolygonArray<2> = wkb_arr.try_into().unwrap(); + let new_arr: MultiPolygonArray = wkb_arr.try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/point.rs b/rust/geoarrow/src/io/wkb/writer/point.rs index 7bc1c312..e3bcabe1 100644 --- a/rust/geoarrow/src/io/wkb/writer/point.rs +++ b/rust/geoarrow/src/io/wkb/writer/point.rs @@ -8,15 +8,17 @@ use std::io::Cursor; use wkb::writer::{point_wkb_size, write_point}; use wkb::Endianness; -impl From<&PointArray> for WKBArray { - fn from(value: &PointArray) -> Self { +impl From<&PointArray> for WKBArray { + fn from(value: &PointArray) -> Self { + let dim = value.coords.dim(); + let non_null_count = value .nulls() .map_or(value.len(), |validity| value.len() - validity.null_count()); let validity = value.nulls().cloned(); // only allocate space for a WKBPoint for non-null items - let values_len = non_null_count * point_wkb_size(geo_traits::Dimensions::Unknown(D)); + let values_len = non_null_count * point_wkb_size(dim.into()); let mut offsets: OffsetsBuilder = OffsetsBuilder::with_capacity(value.len()); let values = { @@ -26,9 +28,7 @@ impl From<&PointArray> for WKBArray { for maybe_geom in value.iter() { if let Some(geom) = maybe_geom { write_point(&mut writer, &geom, Endianness::LittleEndian).unwrap(); - offsets - .try_push_usize(point_wkb_size(geo_traits::Dimensions::Unknown(D))) - .unwrap(); + offsets.try_push_usize(point_wkb_size(dim.into())).unwrap(); } else { offsets.extend_constant(1); } @@ -51,18 +51,18 @@ mod test { #[test] fn round_trip() { // TODO: test with nulls - let orig_arr: PointArray<2> = vec![Some(p0()), Some(p1()), Some(p2())].into(); + let orig_arr: PointArray = vec![Some(p0()), Some(p1()), Some(p2())].into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: PointArray<2> = wkb_arr.try_into().unwrap(); + let new_arr: PointArray = wkb_arr.try_into().unwrap(); assert_eq!(orig_arr, new_arr); } #[test] fn round_trip_with_null() { - let orig_arr: PointArray<2> = vec![Some(p0()), None, Some(p1()), None, Some(p2())].into(); + let orig_arr: PointArray = vec![Some(p0()), None, Some(p1()), None, Some(p2())].into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: PointArray<2> = wkb_arr.try_into().unwrap(); + let new_arr: PointArray = wkb_arr.try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/polygon.rs b/rust/geoarrow/src/io/wkb/writer/polygon.rs index ae4d6a56..10a44b0e 100644 --- a/rust/geoarrow/src/io/wkb/writer/polygon.rs +++ b/rust/geoarrow/src/io/wkb/writer/polygon.rs @@ -8,8 +8,8 @@ use std::io::Cursor; use wkb::writer::{polygon_wkb_size, write_polygon}; use wkb::Endianness; -impl From<&PolygonArray> for WKBArray { - fn from(value: &PolygonArray) -> Self { +impl From<&PolygonArray> for WKBArray { + fn from(value: &PolygonArray) -> Self { let mut offsets: OffsetsBuilder = OffsetsBuilder::with_capacity(value.len()); // First pass: calculate binary array offsets @@ -50,9 +50,9 @@ mod test { #[test] fn round_trip() { - let orig_arr: PolygonArray<2> = vec![Some(p0()), Some(p1()), None].into(); + let orig_arr: PolygonArray = vec![Some(p0()), Some(p1()), None].into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: PolygonArray<2> = wkb_arr.clone().try_into().unwrap(); + let new_arr: PolygonArray = wkb_arr.clone().try_into().unwrap(); let wkb0 = geo::Geometry::Polygon(p0()) .to_wkb(CoordDimensions::xy()) diff --git a/rust/geoarrow/src/io/wkt/reader/mod.rs b/rust/geoarrow/src/io/wkt/reader/mod.rs index e0437efc..aea8dcaa 100644 --- a/rust/geoarrow/src/io/wkt/reader/mod.rs +++ b/rust/geoarrow/src/io/wkt/reader/mod.rs @@ -21,7 +21,7 @@ impl ParseWKT for GenericStringArray { fn parse_wkt(&self, coord_type: CoordType, metadata: Arc) -> Self::Output { // TODO: switch this prefer_multi to true when we use downcasting here. - let mut builder = MixedGeometryBuilder::<2>::new_with_options(coord_type, metadata, false); + let mut builder = MixedGeometryBuilder::new_with_options(coord_type, metadata, false); for i in 0..self.len() { if self.is_valid(i) { let w = wkt::Wkt::::from_str(self.value(i)).unwrap(); diff --git a/rust/geoarrow/src/scalar/geometrycollection/owned.rs b/rust/geoarrow/src/scalar/geometrycollection/owned.rs index dc747eca..09408e8a 100644 --- a/rust/geoarrow/src/scalar/geometrycollection/owned.rs +++ b/rust/geoarrow/src/scalar/geometrycollection/owned.rs @@ -60,7 +60,7 @@ impl GeometryCollectionTrait for OwnedGeometryCollection { type GeometryType<'b> = Geometry<'b> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - match self.coords.dim() { + match self.array.dim() { Dimension::XY => geo_traits::Dimensions::Xy, Dimension::XYZ => geo_traits::Dimensions::Xyz, } diff --git a/rust/geoarrow/src/test/geoarrow_data/mod.rs b/rust/geoarrow/src/test/geoarrow_data/mod.rs index 68b8b273..b73cac74 100644 --- a/rust/geoarrow/src/test/geoarrow_data/mod.rs +++ b/rust/geoarrow/src/test/geoarrow_data/mod.rs @@ -1,6 +1,7 @@ pub mod util; use crate::array::*; +use crate::datatypes::Dimension; use crate::test::geoarrow_data::util::read_geometry_column; macro_rules! geoarrow_data_impl { @@ -11,65 +12,55 @@ macro_rules! geoarrow_data_impl { $file_part ); let geometry_dyn_column = read_geometry_column(&path); - geometry_dyn_column.as_ref().try_into().unwrap() + (geometry_dyn_column.as_ref(), Dimension::XY) + .try_into() + .unwrap() } }; } // Point -geoarrow_data_impl!( - example_point_interleaved, - "point-interleaved", - PointArray<2> -); -geoarrow_data_impl!(example_point_separated, "point", PointArray<2>); +geoarrow_data_impl!(example_point_interleaved, "point-interleaved", PointArray); +geoarrow_data_impl!(example_point_separated, "point", PointArray); geoarrow_data_impl!(example_point_wkb, "point-wkb", WKBArray); // LineString geoarrow_data_impl!( example_linestring_interleaved, "linestring-interleaved", - LineStringArray<2> -); -geoarrow_data_impl!( - example_linestring_separated, - "linestring", - LineStringArray<2> + LineStringArray ); +geoarrow_data_impl!(example_linestring_separated, "linestring", LineStringArray); geoarrow_data_impl!(example_linestring_wkb, "linestring-wkb", WKBArray); // Polygon geoarrow_data_impl!( example_polygon_interleaved, "polygon-interleaved", - PolygonArray<2> + PolygonArray ); -geoarrow_data_impl!(example_polygon_separated, "polygon", PolygonArray<2>); +geoarrow_data_impl!(example_polygon_separated, "polygon", PolygonArray); geoarrow_data_impl!(example_polygon_wkb, "polygon-wkb", WKBArray); // MultiPoint geoarrow_data_impl!( example_multipoint_interleaved, "multipoint-interleaved", - MultiPointArray<2> -); -geoarrow_data_impl!( - example_multipoint_separated, - "multipoint", - MultiPointArray<2> + MultiPointArray ); +geoarrow_data_impl!(example_multipoint_separated, "multipoint", MultiPointArray); geoarrow_data_impl!(example_multipoint_wkb, "multipoint-wkb", WKBArray); // MultiLineString geoarrow_data_impl!( example_multilinestring_interleaved, "multilinestring-interleaved", - MultiLineStringArray<2> + MultiLineStringArray ); geoarrow_data_impl!( example_multilinestring_separated, "multilinestring", - MultiLineStringArray<2> + MultiLineStringArray ); geoarrow_data_impl!( example_multilinestring_wkb, @@ -81,11 +72,11 @@ geoarrow_data_impl!( geoarrow_data_impl!( example_multipolygon_interleaved, "multipolygon-interleaved", - MultiPolygonArray<2> + MultiPolygonArray ); geoarrow_data_impl!( example_multipolygon_separated, "multipolygon", - MultiPolygonArray<2> + MultiPolygonArray ); geoarrow_data_impl!(example_multipolygon_wkb, "multipolygon-wkb", WKBArray); diff --git a/rust/geoarrow/src/test/linestring.rs b/rust/geoarrow/src/test/linestring.rs index 18021f49..d277d658 100644 --- a/rust/geoarrow/src/test/linestring.rs +++ b/rust/geoarrow/src/test/linestring.rs @@ -1,6 +1,7 @@ use geo::{line_string, LineString}; -use crate::array::LineStringArray; +use crate::array::{LineStringArray, LineStringBuilder}; +use crate::datatypes::Dimension; pub(crate) fn ls0() -> LineString { line_string![ @@ -17,10 +18,13 @@ pub(crate) fn ls1() -> LineString { } #[allow(dead_code)] -pub(crate) fn ls_array() -> LineStringArray<2> { - vec![ls0(), ls1()].as_slice().into() -} - -pub(crate) fn large_ls_array() -> LineStringArray<2> { - vec![ls0(), ls1()].as_slice().into() +pub(crate) fn ls_array() -> LineStringArray { + let geoms = vec![ls0(), ls1()]; + LineStringBuilder::from_line_strings( + &geoms, + Dimension::XY, + Default::default(), + Default::default(), + ) + .finish() } diff --git a/rust/geoarrow/src/test/multilinestring.rs b/rust/geoarrow/src/test/multilinestring.rs index 88f813a5..af0b8478 100644 --- a/rust/geoarrow/src/test/multilinestring.rs +++ b/rust/geoarrow/src/test/multilinestring.rs @@ -1,6 +1,7 @@ use geo::{line_string, MultiLineString}; -use crate::array::MultiLineStringArray; +use crate::array::{MultiLineStringArray, MultiLineStringBuilder}; +use crate::datatypes::Dimension; pub(crate) fn ml0() -> MultiLineString { MultiLineString::new(vec![line_string![ @@ -28,6 +29,13 @@ pub(crate) fn ml1() -> MultiLineString { ]) } -pub(crate) fn ml_array() -> MultiLineStringArray<2> { - vec![ml0(), ml1()].as_slice().into() +pub(crate) fn ml_array() -> MultiLineStringArray { + let geoms = vec![ml0(), ml1()]; + MultiLineStringBuilder::from_multi_line_strings( + &geoms, + Dimension::XY, + Default::default(), + Default::default(), + ) + .finish() } diff --git a/rust/geoarrow/src/test/multipoint.rs b/rust/geoarrow/src/test/multipoint.rs index ce544477..45e44747 100644 --- a/rust/geoarrow/src/test/multipoint.rs +++ b/rust/geoarrow/src/test/multipoint.rs @@ -1,6 +1,6 @@ use geo::{point, MultiPoint}; -use crate::array::MultiPointArray; +use crate::array::{MultiPointArray, MultiPointBuilder}; pub(crate) fn mp0() -> MultiPoint { MultiPoint::new(vec![ @@ -24,6 +24,7 @@ pub(crate) fn mp1() -> MultiPoint { ]) } -pub(crate) fn mp_array() -> MultiPointArray<2> { - vec![mp0(), mp1()].as_slice().into() +pub(crate) fn mp_array() -> MultiPointArray { + let geoms = vec![mp0(), mp1()]; + MultiPointBuilder::from_multi_points(&geoms, Default::default(), Default::default()).finish() } diff --git a/rust/geoarrow/src/test/multipolygon.rs b/rust/geoarrow/src/test/multipolygon.rs index b4d6a9d2..04c7c113 100644 --- a/rust/geoarrow/src/test/multipolygon.rs +++ b/rust/geoarrow/src/test/multipolygon.rs @@ -46,6 +46,6 @@ pub(crate) fn mp1() -> MultiPolygon { ]) } -pub(crate) fn mp_array() -> MultiPolygonArray<2> { +pub(crate) fn mp_array() -> MultiPolygonArray { vec![mp0(), mp1()].as_slice().into() } diff --git a/rust/geoarrow/src/test/point.rs b/rust/geoarrow/src/test/point.rs index 39e58e3e..e6070ca1 100644 --- a/rust/geoarrow/src/test/point.rs +++ b/rust/geoarrow/src/test/point.rs @@ -29,8 +29,9 @@ pub(crate) fn p2() -> Point { ) } -pub(crate) fn point_array() -> PointArray<2> { - vec![p0(), p1(), p2()].as_slice().into() +pub(crate) fn point_array() -> PointArray { + let geoms = vec![p0(), p1(), p2()]; + PointBuilder::from_points(geoms.iter(), Default::default(), Default::default()).finish() } struct CoordZ { @@ -64,7 +65,7 @@ impl CoordTrait for CoordZ { } } -pub(crate) fn point_z_array() -> PointArray<3> { +pub(crate) fn point_z_array() -> PointArray { let mut builder = PointBuilder::with_capacity(3); let coords = vec![ CoordZ { diff --git a/rust/geoarrow/src/test/polygon.rs b/rust/geoarrow/src/test/polygon.rs index 2b7f22cf..95c23865 100644 --- a/rust/geoarrow/src/test/polygon.rs +++ b/rust/geoarrow/src/test/polygon.rs @@ -1,4 +1,4 @@ -use crate::array::PolygonArray; +use crate::array::{PolygonArray, PolygonBuilder}; use geo::{polygon, Polygon}; pub(crate) fn p0() -> Polygon { @@ -29,6 +29,7 @@ pub(crate) fn p1() -> Polygon { ) } -pub(crate) fn p_array() -> PolygonArray<2> { - vec![p0(), p1()].as_slice().into() +pub(crate) fn p_array() -> PolygonArray { + let geoms = vec![p0(), p1()]; + PolygonBuilder::from_polygons(&geoms, Default::default(), Default::default()).finish() } diff --git a/rust/geoarrow/src/trait_.rs b/rust/geoarrow/src/trait_.rs index 5b86ccf9..469209f1 100644 --- a/rust/geoarrow/src/trait_.rs +++ b/rust/geoarrow/src/trait_.rs @@ -2,7 +2,7 @@ use crate::array::metadata::ArrayMetadata; use crate::array::{CoordBuffer, CoordType}; -use crate::datatypes::{NativeType, SerializedType}; +use crate::datatypes::{Dimension, NativeType, SerializedType}; use crate::error::Result; use crate::scalar::Geometry; use arrow_array::{Array, ArrayRef}; @@ -857,7 +857,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; /// let builder = PointBuilder::new(Dimension::XY); /// ``` - fn new() -> Self; + fn new(dim: Dimension) -> Self; /// Creates a new builder with capacity and other options. /// @@ -879,6 +879,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// ); /// ``` fn with_geom_capacity_and_options( + dim: Dimension, geom_capacity: usize, coord_type: CoordType, metadata: Arc, @@ -895,8 +896,9 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// }; /// let builder = PointBuilder::<2>::with_geom_capacity(2); /// ``` - fn with_geom_capacity(geom_capacity: usize) -> Self { + fn with_geom_capacity(dim: Dimension, geom_capacity: usize) -> Self { GeometryArrayBuilder::with_geom_capacity_and_options( + dim, geom_capacity, Default::default(), Default::default(), From 7d148a2af40546188350b18db02fd68f9a70c0cc Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 21:08:37 -0500 Subject: [PATCH 04/14] array mod compiles --- .../src/array/geometrycollection/array.rs | 16 +- .../src/array/geometrycollection/builder.rs | 61 +++-- rust/geoarrow/src/array/linestring/array.rs | 18 +- rust/geoarrow/src/array/linestring/builder.rs | 12 +- rust/geoarrow/src/array/mixed/array.rs | 230 +++++++++--------- rust/geoarrow/src/array/mixed/builder.rs | 60 +++-- .../src/array/multilinestring/array.rs | 17 +- .../src/array/multilinestring/builder.rs | 9 +- rust/geoarrow/src/array/multipoint/array.rs | 25 +- rust/geoarrow/src/array/multipoint/builder.rs | 90 ++++--- rust/geoarrow/src/array/multipolygon/array.rs | 25 +- .../src/array/multipolygon/builder.rs | 90 ++++--- rust/geoarrow/src/array/point/array.rs | 34 +-- rust/geoarrow/src/array/point/builder.rs | 78 ++++-- rust/geoarrow/src/array/polygon/array.rs | 31 ++- rust/geoarrow/src/array/polygon/builder.rs | 90 ++++--- rust/geoarrow/src/array/rect/array.rs | 8 +- rust/geoarrow/src/array/rect/builder.rs | 43 ++-- rust/geoarrow/src/test/point.rs | 9 +- rust/geoarrow/src/trait_.rs | 4 + 20 files changed, 562 insertions(+), 388 deletions(-) diff --git a/rust/geoarrow/src/array/geometrycollection/array.rs b/rust/geoarrow/src/array/geometrycollection/array.rs index 062a0af9..6af2ef6e 100644 --- a/rust/geoarrow/src/array/geometrycollection/array.rs +++ b/rust/geoarrow/src/array/geometrycollection/array.rs @@ -13,7 +13,7 @@ use crate::array::{ CoordBuffer, CoordType, LineStringArray, MixedGeometryArray, MultiLineStringArray, MultiPointArray, MultiPolygonArray, PointArray, PolygonArray, WKBArray, }; -use crate::datatypes::NativeType; +use crate::datatypes::{Dimension, NativeType}; use crate::error::{GeoArrowError, Result}; use crate::scalar::{Geometry, GeometryCollection}; use crate::trait_::{ArrayAccessor, GeometryArraySelfMethods, IntoArrow, NativeGeometryAccessor}; @@ -326,24 +326,26 @@ impl TryFrom<(&dyn Array, &Field)> for GeometryCollectionArray { } } -impl> From<&[G]> for GeometryCollectionArray { - fn from(other: &[G]) -> Self { +impl> From<(&[G], Dimension)> for GeometryCollectionArray { + fn from(other: (&[G], Dimension)) -> Self { let mut_arr: GeometryCollectionBuilder = other.into(); mut_arr.into() } } -impl> From>> for GeometryCollectionArray { - fn from(other: Vec>) -> Self { +impl> From<(Vec>, Dimension)> + for GeometryCollectionArray +{ + fn from(other: (Vec>, Dimension)) -> Self { let mut_arr: GeometryCollectionBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for GeometryCollectionArray { +impl TryFrom<(WKBArray, Dimension)> for GeometryCollectionArray { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from(value: (WKBArray, Dimension)) -> Result { let mut_arr: GeometryCollectionBuilder = value.try_into()?; Ok(mut_arr.into()) } diff --git a/rust/geoarrow/src/array/geometrycollection/builder.rs b/rust/geoarrow/src/array/geometrycollection/builder.rs index d4305c9a..39626a77 100644 --- a/rust/geoarrow/src/array/geometrycollection/builder.rs +++ b/rust/geoarrow/src/array/geometrycollection/builder.rs @@ -8,6 +8,7 @@ use crate::array::metadata::ArrayMetadata; use crate::array::mixed::builder::DEFAULT_PREFER_MULTI; use crate::array::offset_builder::OffsetsBuilder; use crate::array::{CoordType, GeometryCollectionArray, MixedGeometryBuilder, WKBArray}; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::scalar::WKB; use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow}; @@ -33,20 +34,27 @@ pub struct GeometryCollectionBuilder { impl<'a> GeometryCollectionBuilder { /// Creates a new empty [`GeometryCollectionBuilder`]. - pub fn new() -> Self { - Self::new_with_options(Default::default(), Default::default(), DEFAULT_PREFER_MULTI) + pub fn new(dim: Dimension) -> Self { + Self::new_with_options( + dim, + Default::default(), + Default::default(), + DEFAULT_PREFER_MULTI, + ) } pub fn new_with_options( + dim: Dimension, coord_type: CoordType, metadata: Arc, prefer_multi: bool, ) -> Self { - Self::with_capacity_and_options(Default::default(), coord_type, metadata, prefer_multi) + Self::with_capacity_and_options(dim, Default::default(), coord_type, metadata, prefer_multi) } - pub fn with_capacity(capacity: GeometryCollectionCapacity) -> Self { + pub fn with_capacity(dim: Dimension, capacity: GeometryCollectionCapacity) -> Self { Self::with_capacity_and_options( + dim, capacity, Default::default(), Default::default(), @@ -55,6 +63,7 @@ impl<'a> GeometryCollectionBuilder { } pub fn with_capacity_and_options( + dim: Dimension, capacity: GeometryCollectionCapacity, coord_type: CoordType, metadata: Arc, @@ -63,6 +72,7 @@ impl<'a> GeometryCollectionBuilder { // Should we be storing array metadata on child arrays? Self { geoms: MixedGeometryBuilder::with_capacity_and_options( + dim, capacity.mixed_capacity, coord_type, metadata.clone(), @@ -112,9 +122,11 @@ impl<'a> GeometryCollectionBuilder { pub fn with_capacity_from_iter( geoms: impl Iterator>, + dim: Dimension, ) -> Result { Self::with_capacity_and_options_from_iter( geoms, + dim, Default::default(), Default::default(), DEFAULT_PREFER_MULTI, @@ -123,12 +135,14 @@ impl<'a> GeometryCollectionBuilder { pub fn with_capacity_and_options_from_iter( geoms: impl Iterator>, + dim: Dimension, coord_type: CoordType, metadata: Arc, prefer_multi: bool, ) -> Result { let counter = GeometryCollectionCapacity::from_geometry_collections(geoms)?; Ok(Self::with_capacity_and_options( + dim, counter, coord_type, metadata, @@ -287,12 +301,14 @@ impl<'a> GeometryCollectionBuilder { pub fn from_geometry_collections( geoms: &[impl GeometryCollectionTrait], + dim: Dimension, coord_type: Option, metadata: Arc, prefer_multi: bool, ) -> Result { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(Some), + dim, coord_type.unwrap_or_default(), metadata, prefer_multi, @@ -303,12 +319,14 @@ impl<'a> GeometryCollectionBuilder { pub fn from_nullable_geometry_collections( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, prefer_multi: bool, ) -> Result { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(|x| x.as_ref()), + dim, coord_type.unwrap_or_default(), metadata, prefer_multi, @@ -319,12 +337,14 @@ impl<'a> GeometryCollectionBuilder { pub fn from_geometries( geoms: &[impl GeometryTrait], + dim: Dimension, coord_type: Option, metadata: Arc, prefer_multi: bool, ) -> Result { let capacity = GeometryCollectionCapacity::from_geometries(geoms.iter().map(Some))?; let mut array = Self::with_capacity_and_options( + dim, capacity, coord_type.unwrap_or_default(), metadata, @@ -338,6 +358,7 @@ impl<'a> GeometryCollectionBuilder { pub fn from_nullable_geometries( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, prefer_multi: bool, @@ -345,6 +366,7 @@ impl<'a> GeometryCollectionBuilder { let capacity = GeometryCollectionCapacity::from_geometries(geoms.iter().map(|x| x.as_ref()))?; let mut array = Self::with_capacity_and_options( + dim, capacity, coord_type.unwrap_or_default(), metadata, @@ -358,6 +380,7 @@ impl<'a> GeometryCollectionBuilder { pub(crate) fn from_wkb( wkb_objects: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, prefer_multi: bool, @@ -366,22 +389,23 @@ impl<'a> GeometryCollectionBuilder { .iter() .map(|maybe_wkb| maybe_wkb.as_ref().map(|wkb| wkb.parse()).transpose()) .collect::>>()?; - Self::from_nullable_geometries(&wkb_objects2, coord_type, metadata, prefer_multi) + Self::from_nullable_geometries(&wkb_objects2, dim, coord_type, metadata, prefer_multi) } } impl GeometryArrayBuilder for GeometryCollectionBuilder { - fn new() -> Self { - Self::new() + fn new(dim: Dimension) -> Self { + Self::new(dim) } fn with_geom_capacity_and_options( + dim: Dimension, geom_capacity: usize, coord_type: CoordType, metadata: Arc, ) -> Self { let capacity = GeometryCollectionCapacity::new(Default::default(), geom_capacity); - Self::with_capacity_and_options(capacity, coord_type, metadata, DEFAULT_PREFER_MULTI) + Self::with_capacity_and_options(dim, capacity, coord_type, metadata, DEFAULT_PREFER_MULTI) } fn push_geometry(&mut self, value: Option<&impl GeometryTrait>) -> Result<()> { @@ -428,7 +452,7 @@ impl IntoArrow for GeometryCollectionBuilder { impl Default for GeometryCollectionBuilder { fn default() -> Self { - Self::new() + Self::new(Dimension::XY) } } @@ -450,17 +474,20 @@ impl From for GenericListArray { } } -impl> From<&[G]> for GeometryCollectionBuilder { - fn from(geoms: &[G]) -> Self { - Self::from_geometry_collections(geoms, Default::default(), Default::default(), true) +impl> From<(&[G], Dimension)> for GeometryCollectionBuilder { + fn from((geoms, dim): (&[G], Dimension)) -> Self { + Self::from_geometry_collections(geoms, dim, Default::default(), Default::default(), true) .unwrap() } } -impl> From>> for GeometryCollectionBuilder { - fn from(geoms: Vec>) -> Self { +impl> From<(Vec>, Dimension)> + for GeometryCollectionBuilder +{ + fn from((geoms, dim): (Vec>, Dimension)) -> Self { Self::from_nullable_geometry_collections( &geoms, + dim, Default::default(), Default::default(), true, @@ -469,12 +496,12 @@ impl> From>> for GeometryColle } } -impl TryFrom> for GeometryCollectionBuilder { +impl TryFrom<(WKBArray, Dimension)> for GeometryCollectionBuilder { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from((value, dim): (WKBArray, Dimension)) -> Result { let metadata = value.metadata.clone(); let wkb_objects: Vec>> = value.iter().collect(); - Self::from_wkb(&wkb_objects, Default::default(), metadata, true) + Self::from_wkb(&wkb_objects, dim, Default::default(), metadata, true) } } diff --git a/rust/geoarrow/src/array/linestring/array.rs b/rust/geoarrow/src/array/linestring/array.rs index eb4c6e17..9e32753d 100644 --- a/rust/geoarrow/src/array/linestring/array.rs +++ b/rust/geoarrow/src/array/linestring/array.rs @@ -438,10 +438,10 @@ impl From for MultiPointArray { } } -impl TryFrom> for LineStringArray { +impl TryFrom<(WKBArray, Dimension)> for LineStringArray { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from(value: (WKBArray, Dimension)) -> Result { let mut_arr: LineStringBuilder = value.try_into()?; Ok(mut_arr.into()) } @@ -546,14 +546,14 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: LineStringArray = vec![ls0(), ls1()].as_slice().into(); + let arr: LineStringArray = (vec![ls0(), ls1()].as_slice(), Dimension::XY).into(); assert_eq!(arr.value_as_geo(0), ls0()); assert_eq!(arr.value_as_geo(1), ls1()); } #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: LineStringArray = vec![Some(ls0()), Some(ls1()), None].into(); + let arr: LineStringArray = (vec![Some(ls0()), Some(ls1()), None], Dimension::XY).into(); assert_eq!(arr.get_as_geo(0), Some(ls0())); assert_eq!(arr.get_as_geo(1), Some(ls1())); assert_eq!(arr.get_as_geo(2), None); @@ -561,7 +561,7 @@ mod test { // #[test] // fn rstar_integration() { - // let arr: LineStringArray = vec![ls0(), ls1()].as_slice().into(); + // let arr: LineStringArray = (vec![ls0(), ls1()].as_slice(), Dimension::XY).into(); // let tree = arr.rstar_tree(); // let search_box = AABB::from_corners([3.5, 5.5], [4.5, 6.5]); @@ -577,7 +577,7 @@ mod test { #[test] fn slice() { - let arr: LineStringArray = vec![ls0(), ls1()].as_slice().into(); + let arr: LineStringArray = (vec![ls0(), ls1()].as_slice(), Dimension::XY).into(); let sliced = arr.slice(1, 1); assert_eq!(sliced.len(), 1); assert_eq!(sliced.get_as_geo(0), Some(ls1())); @@ -585,7 +585,7 @@ mod test { #[test] fn owned_slice() { - let arr: LineStringArray = vec![ls0(), ls1()].as_slice().into(); + let arr: LineStringArray = (vec![ls0(), ls1()].as_slice(), Dimension::XY).into(); let sliced = arr.owned_slice(1, 1); // assert!( @@ -602,7 +602,7 @@ mod test { let linestring_arr = example_linestring_interleaved(); let wkb_arr = example_linestring_wkb(); - let parsed_linestring_arr: LineStringArray = wkb_arr.try_into().unwrap(); + let parsed_linestring_arr: LineStringArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(linestring_arr, parsed_linestring_arr); } @@ -612,7 +612,7 @@ mod test { let linestring_arr = example_linestring_separated().into_coord_type(CoordType::Interleaved); let wkb_arr = example_linestring_wkb(); - let parsed_linestring_arr: LineStringArray = wkb_arr.try_into().unwrap(); + let parsed_linestring_arr: LineStringArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(linestring_arr, parsed_linestring_arr); } diff --git a/rust/geoarrow/src/array/linestring/builder.rs b/rust/geoarrow/src/array/linestring/builder.rs index d925f025..0e74577a 100644 --- a/rust/geoarrow/src/array/linestring/builder.rs +++ b/rust/geoarrow/src/array/linestring/builder.rs @@ -301,8 +301,8 @@ impl LineStringBuilder { } pub fn from_nullable_geometries( - dim: Dimension, geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { @@ -318,8 +318,8 @@ impl LineStringBuilder { } pub(crate) fn from_wkb( - dim: Dimension, wkb_objects: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { @@ -327,7 +327,7 @@ impl LineStringBuilder { .iter() .map(|maybe_wkb| maybe_wkb.as_ref().map(|wkb| wkb.parse()).transpose()) .collect::>>()?; - Self::from_nullable_geometries(dim, &wkb_objects2, coord_type, metadata) + Self::from_nullable_geometries(&wkb_objects2, dim, coord_type, metadata) } } @@ -424,13 +424,13 @@ impl> From<(Vec>, Dimension)> for LineStri } } -impl TryFrom> for LineStringBuilder { +impl TryFrom<(WKBArray, Dimension)> for LineStringBuilder { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from((value, dim): (WKBArray, Dimension)) -> Result { let metadata = value.metadata.clone(); let wkb_objects: Vec>> = value.iter().collect(); - Self::from_wkb(&wkb_objects, Default::default(), metadata) + Self::from_wkb(&wkb_objects, dim, Default::default(), metadata) } } diff --git a/rust/geoarrow/src/array/mixed/array.rs b/rust/geoarrow/src/array/mixed/array.rs index 560a4ab2..db39061c 100644 --- a/rust/geoarrow/src/array/mixed/array.rs +++ b/rust/geoarrow/src/array/mixed/array.rs @@ -167,7 +167,19 @@ impl MixedGeometryArray { assert_eq!(coord_types.len(), 1); let coord_type = coord_types.into_iter().next().unwrap(); - let data_type = NativeType::Mixed(coord_type, D.try_into().unwrap()); + + let mut dimensions = HashSet::new(); + dimensions.insert(points.dimension()); + dimensions.insert(line_strings.dimension()); + dimensions.insert(polygons.dimension()); + dimensions.insert(multi_points.dimension()); + dimensions.insert(multi_line_strings.dimension()); + dimensions.insert(multi_polygons.dimension()); + assert_eq!(dimensions.len(), 1); + + let dim = dimensions.into_iter().next().unwrap(); + + let data_type = NativeType::Mixed(coord_type, dim); Self { data_type, @@ -552,12 +564,12 @@ impl TryFrom<&UnionArray> for MixedGeometryArray { type Error = GeoArrowError; fn try_from(value: &UnionArray) -> std::result::Result { - let mut points: Option = None; - let mut line_strings: Option = None; - let mut polygons: Option = None; - let mut multi_points: Option = None; - let mut multi_line_strings: Option = None; - let mut multi_polygons: Option = None; + let mut points: Vec = vec![]; + let mut line_strings: Vec = vec![]; + let mut polygons: Vec = vec![]; + let mut multi_points: Vec = vec![]; + let mut multi_line_strings: Vec = vec![]; + let mut multi_polygons: Vec = vec![]; match value.data_type() { DataType::Union(fields, mode) => { if !matches!(mode, UnionMode::Dense) { @@ -565,71 +577,64 @@ impl TryFrom<&UnionArray> for MixedGeometryArray { } for (type_id, _field) in fields.iter() { - match D { - 2 => match type_id { - 1 => { - points = Some(value.child(type_id).as_ref().try_into().unwrap()); - } - 2 => { - line_strings = - Some(value.child(type_id).as_ref().try_into().unwrap()); - } - 3 => { - polygons = Some(value.child(type_id).as_ref().try_into().unwrap()); - } - 4 => { - multi_points = - Some(value.child(type_id).as_ref().try_into().unwrap()); - } - 5 => { - multi_line_strings = - Some(value.child(type_id).as_ref().try_into().unwrap()); - } - 6 => { - multi_polygons = - Some(value.child(type_id).as_ref().try_into().unwrap()); - } - _ => { - return Err(GeoArrowError::General(format!( - "Unexpected type_id {} for dimension {}", - type_id, D - ))) - } - }, - 3 => match type_id { - 11 => { - points = Some(value.child(type_id).as_ref().try_into().unwrap()); - } - 12 => { - line_strings = - Some(value.child(type_id).as_ref().try_into().unwrap()); - } - 13 => { - polygons = Some(value.child(type_id).as_ref().try_into().unwrap()); - } - 14 => { - multi_points = - Some(value.child(type_id).as_ref().try_into().unwrap()); - } - 15 => { - multi_line_strings = - Some(value.child(type_id).as_ref().try_into().unwrap()); - } - 16 => { - multi_polygons = - Some(value.child(type_id).as_ref().try_into().unwrap()); - } - _ => { - return Err(GeoArrowError::General(format!( - "Unexpected type_id {} for dimension {}", - type_id, D - ))) - } - }, + let dimension = if type_id < 10 { + Dimension::XY + } else if type_id < 20 { + Dimension::XYZ + } else { + return Err(GeoArrowError::General(format!( + "Unsupported type_id: {}", + type_id + ))); + }; + + match type_id { + 1 | 11 => { + points.push( + (value.child(type_id).as_ref(), dimension) + .try_into() + .unwrap(), + ); + } + 2 | 12 => { + line_strings.push( + (value.child(type_id).as_ref(), dimension) + .try_into() + .unwrap(), + ); + } + 3 | 13 => { + polygons.push( + (value.child(type_id).as_ref(), dimension) + .try_into() + .unwrap(), + ); + } + 4 | 14 => { + multi_points.push( + (value.child(type_id).as_ref(), dimension) + .try_into() + .unwrap(), + ); + } + 5 | 15 => { + multi_line_strings.push( + (value.child(type_id).as_ref(), dimension) + .try_into() + .unwrap(), + ); + } + 6 | 16 => { + multi_polygons.push( + (value.child(type_id).as_ref(), dimension) + .try_into() + .unwrap(), + ); + } _ => { return Err(GeoArrowError::General(format!( - "Unexpected type_id {} for dimension {}", - type_id, D + "Unexpected type_id {}", + type_id ))) } } @@ -642,15 +647,24 @@ impl TryFrom<&UnionArray> for MixedGeometryArray { // This is after checking for dense union let offsets = value.offsets().unwrap().clone(); + // TODO: make nicer errors. We don't currently allow a mixed geometry array with multiple + // dimensions of underlying geometries. + assert!(points.len() <= 1); + assert!(line_strings.len() <= 1); + assert!(polygons.len() <= 1); + assert!(multi_points.len() <= 1); + assert!(multi_line_strings.len() <= 1); + assert!(multi_polygons.len() <= 1); + Ok(Self::new( type_ids, offsets, - points.unwrap_or_default(), - line_strings.unwrap_or_default(), - polygons.unwrap_or_default(), - multi_points.unwrap_or_default(), - multi_line_strings.unwrap_or_default(), - multi_polygons.unwrap_or_default(), + points.get(0).cloned().unwrap_or_default(), + line_strings.get(0).cloned().unwrap_or_default(), + polygons.get(0).cloned().unwrap_or_default(), + multi_points.get(0).cloned().unwrap_or_default(), + multi_line_strings.get(0).cloned().unwrap_or_default(), + multi_polygons.get(0).cloned().unwrap_or_default(), Default::default(), )) } @@ -683,28 +697,28 @@ impl TryFrom<(&dyn Array, &Field)> for MixedGeometryArray { } } -impl> TryFrom<&[G]> for MixedGeometryArray { +impl> TryFrom<(&[G], Dimension)> for MixedGeometryArray { type Error = GeoArrowError; - fn try_from(geoms: &[G]) -> Result { + fn try_from(geoms: (&[G], Dimension)) -> Result { let mut_arr: MixedGeometryBuilder = geoms.try_into()?; Ok(mut_arr.into()) } } -impl> TryFrom>> for MixedGeometryArray { +impl> TryFrom<(Vec>, Dimension)> for MixedGeometryArray { type Error = GeoArrowError; - fn try_from(geoms: Vec>) -> Result { + fn try_from(geoms: (Vec>, Dimension)) -> Result { let mut_arr: MixedGeometryBuilder = geoms.try_into()?; Ok(mut_arr.into()) } } -impl TryFrom> for MixedGeometryArray { +impl TryFrom<(WKBArray, Dimension)> for MixedGeometryArray { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from(value: (WKBArray, Dimension)) -> Result { let mut_arr: MixedGeometryBuilder = value.try_into()?; Ok(mut_arr.into()) } @@ -712,10 +726,9 @@ impl TryFrom> for MixedGeometryArray { impl From for MixedGeometryArray { fn from(value: PointArray) -> Self { - let type_ids = match D { - 2 => vec![1; value.len()], - 3 => vec![11; value.len()], - _ => panic!(), + let type_ids = match value.dimension() { + Dimension::XY => vec![1; value.len()], + Dimension::XYZ => vec![11; value.len()], }; let metadata = value.metadata.clone(); Self::new( @@ -734,10 +747,9 @@ impl From for MixedGeometryArray { impl From for MixedGeometryArray { fn from(value: LineStringArray) -> Self { - let type_ids = match D { - 2 => vec![2; value.len()], - 3 => vec![12; value.len()], - _ => panic!(), + let type_ids = match value.dimension() { + Dimension::XY => vec![2; value.len()], + Dimension::XYZ => vec![12; value.len()], }; let metadata = value.metadata.clone(); Self::new( @@ -756,10 +768,9 @@ impl From for MixedGeometryArray { impl From for MixedGeometryArray { fn from(value: PolygonArray) -> Self { - let type_ids = match D { - 2 => vec![3; value.len()], - 3 => vec![13; value.len()], - _ => panic!(), + let type_ids = match value.dimension() { + Dimension::XY => vec![3; value.len()], + Dimension::XYZ => vec![13; value.len()], }; let metadata = value.metadata.clone(); Self::new( @@ -778,10 +789,9 @@ impl From for MixedGeometryArray { impl From for MixedGeometryArray { fn from(value: MultiPointArray) -> Self { - let type_ids = match D { - 2 => vec![4; value.len()], - 3 => vec![14; value.len()], - _ => panic!(), + let type_ids = match value.dimension() { + Dimension::XY => vec![4; value.len()], + Dimension::XYZ => vec![14; value.len()], }; let metadata = value.metadata.clone(); Self::new( @@ -800,10 +810,9 @@ impl From for MixedGeometryArray { impl From for MixedGeometryArray { fn from(value: MultiLineStringArray) -> Self { - let type_ids = match D { - 2 => vec![5; value.len()], - 3 => vec![15; value.len()], - _ => panic!(), + let type_ids = match value.dimension() { + Dimension::XY => vec![5; value.len()], + Dimension::XYZ => vec![15; value.len()], }; let metadata = value.metadata.clone(); Self::new( @@ -822,10 +831,9 @@ impl From for MixedGeometryArray { impl From for MixedGeometryArray { fn from(value: MultiPolygonArray) -> Self { - let type_ids = match D { - 2 => vec![6; value.len()], - 3 => vec![16; value.len()], - _ => panic!(), + let type_ids = match value.dimension() { + Dimension::XY => vec![6; value.len()], + Dimension::XYZ => vec![16; value.len()], }; let metadata = value.metadata.clone(); Self::new( @@ -880,7 +888,7 @@ mod test { geo::Geometry::Point(point::p1()), geo::Geometry::Point(point::p2()), ]; - let arr: MixedGeometryArray = geoms.as_slice().try_into().unwrap(); + let arr: MixedGeometryArray = (geoms.as_slice(), Dimension::XY).try_into().unwrap(); assert_eq!( arr.value_as_geo(0), @@ -906,7 +914,7 @@ mod test { geo::Geometry::MultiLineString(multilinestring::ml0()), geo::Geometry::MultiPolygon(multipolygon::mp0()), ]; - let arr: MixedGeometryArray = geoms.as_slice().try_into().unwrap(); + let arr: MixedGeometryArray = (geoms.as_slice(), Dimension::XY).try_into().unwrap(); assert_eq!( arr.value_as_geo(0), @@ -935,7 +943,7 @@ mod test { geo::Geometry::MultiLineString(multilinestring::ml0()), geo::Geometry::MultiPolygon(multipolygon::mp0()), ]; - let arr: MixedGeometryArray = geoms.as_slice().try_into().unwrap(); + let arr: MixedGeometryArray = (geoms.as_slice(), Dimension::XY).try_into().unwrap(); // Round trip to/from arrow-rs let arrow_array = arr.into_arrow(); @@ -965,7 +973,7 @@ mod test { geo::Geometry::MultiLineString(multilinestring::ml0()), geo::Geometry::MultiPolygon(multipolygon::mp0()), ]; - let arr: MixedGeometryArray = geoms.as_slice().try_into().unwrap(); + let arr: MixedGeometryArray = (geoms.as_slice(), Dimension::XY).try_into().unwrap(); // Round trip to/from arrow-rs let arrow_array = arr.into_arrow(); @@ -982,7 +990,7 @@ mod test { geo::Geometry::MultiPoint(multipoint::mp0()), geo::Geometry::MultiPolygon(multipolygon::mp0()), ]; - let arr: MixedGeometryArray = geoms.as_slice().try_into().unwrap(); + let arr: MixedGeometryArray = (geoms.as_slice(), Dimension::XY).try_into().unwrap(); // Round trip to/from arrow-rs let arrow_array = arr.into_arrow(); diff --git a/rust/geoarrow/src/array/mixed/builder.rs b/rust/geoarrow/src/array/mixed/builder.rs index 3bc4d3f8..10f4cccc 100644 --- a/rust/geoarrow/src/array/mixed/builder.rs +++ b/rust/geoarrow/src/array/mixed/builder.rs @@ -7,6 +7,7 @@ use crate::array::{ CoordType, LineStringBuilder, MixedGeometryArray, MultiLineStringBuilder, MultiPointBuilder, MultiPolygonBuilder, PointBuilder, PolygonBuilder, WKBArray, }; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::scalar::WKB; use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow}; @@ -56,21 +57,28 @@ pub struct MixedGeometryBuilder { impl<'a> MixedGeometryBuilder { /// Creates a new empty [`MixedGeometryBuilder`]. - pub fn new() -> Self { - Self::new_with_options(Default::default(), Default::default(), DEFAULT_PREFER_MULTI) + pub fn new(dim: Dimension) -> Self { + Self::new_with_options( + dim, + Default::default(), + Default::default(), + DEFAULT_PREFER_MULTI, + ) } pub fn new_with_options( + dim: Dimension, coord_type: CoordType, metadata: Arc, prefer_multi: bool, ) -> Self { - Self::with_capacity_and_options(Default::default(), coord_type, metadata, prefer_multi) + Self::with_capacity_and_options(dim, Default::default(), coord_type, metadata, prefer_multi) } /// Creates a new [`MixedGeometryBuilder`] with given capacity and no validity. - pub fn with_capacity(capacity: MixedCapacity) -> Self { + pub fn with_capacity(dim: Dimension, capacity: MixedCapacity) -> Self { Self::with_capacity_and_options( + dim, capacity, Default::default(), Default::default(), @@ -79,6 +87,7 @@ impl<'a> MixedGeometryBuilder { } pub fn with_capacity_and_options( + dim: Dimension, capacity: MixedCapacity, coord_type: CoordType, metadata: Arc, @@ -89,31 +98,37 @@ impl<'a> MixedGeometryBuilder { metadata, types: vec![], points: PointBuilder::with_capacity_and_options( + dim, capacity.point, coord_type, Default::default(), ), line_strings: LineStringBuilder::with_capacity_and_options( + dim, capacity.line_string, coord_type, Default::default(), ), polygons: PolygonBuilder::with_capacity_and_options( + dim, capacity.polygon, coord_type, Default::default(), ), multi_points: MultiPointBuilder::with_capacity_and_options( + dim, capacity.multi_point, coord_type, Default::default(), ), multi_line_strings: MultiLineStringBuilder::with_capacity_and_options( + dim, capacity.multi_line_string, coord_type, Default::default(), ), multi_polygons: MultiPolygonBuilder::with_capacity_and_options( + dim, capacity.multi_polygon, coord_type, Default::default(), @@ -183,9 +198,11 @@ impl<'a> MixedGeometryBuilder { pub fn with_capacity_from_iter( geoms: impl Iterator>, + dim: Dimension, ) -> Result { Self::with_capacity_and_options_from_iter( geoms, + dim, Default::default(), Default::default(), DEFAULT_PREFER_MULTI, @@ -194,12 +211,14 @@ impl<'a> MixedGeometryBuilder { pub fn with_capacity_and_options_from_iter( geoms: impl Iterator>, + dim: Dimension, coord_type: CoordType, metadata: Arc, prefer_multi: bool, ) -> Result { let counter = MixedCapacity::from_geometries(geoms)?; Ok(Self::with_capacity_and_options( + dim, counter, coord_type, metadata, @@ -419,12 +438,14 @@ impl<'a> MixedGeometryBuilder { /// Create this builder from a slice of Geometries. pub fn from_geometries( geoms: &[impl GeometryTrait], + dim: Dimension, coord_type: Option, metadata: Arc, prefer_multi: bool, ) -> Result { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(Some), + dim, coord_type.unwrap_or_default(), metadata, prefer_multi, @@ -436,12 +457,14 @@ impl<'a> MixedGeometryBuilder { /// Create this builder from a slice of nullable Geometries. pub fn from_nullable_geometries( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, prefer_multi: bool, ) -> Result { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(|x| x.as_ref()), + dim, coord_type.unwrap_or_default(), metadata, prefer_multi, @@ -452,6 +475,7 @@ impl<'a> MixedGeometryBuilder { pub(crate) fn from_wkb( wkb_objects: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, prefer_multi: bool, @@ -460,13 +484,13 @@ impl<'a> MixedGeometryBuilder { .iter() .map(|maybe_wkb| maybe_wkb.as_ref().map(|wkb| wkb.parse()).transpose()) .collect::>>()?; - Self::from_nullable_geometries(&wkb_objects2, coord_type, metadata, prefer_multi) + Self::from_nullable_geometries(&wkb_objects2, dim, coord_type, metadata, prefer_multi) } } impl Default for MixedGeometryBuilder { fn default() -> Self { - Self::new() + Self::new(Dimension::XY) } } @@ -494,26 +518,26 @@ impl From for MixedGeometryArray { } } -impl> TryFrom<&[G]> for MixedGeometryBuilder { +impl> TryFrom<(&[G], Dimension)> for MixedGeometryBuilder { type Error = GeoArrowError; - fn try_from(geoms: &[G]) -> Result { - Self::from_geometries(geoms, Default::default(), Default::default(), true) + fn try_from((geoms, dim): (&[G], Dimension)) -> Result { + Self::from_geometries(geoms, dim, Default::default(), Default::default(), true) } } -impl> TryFrom>> for MixedGeometryBuilder { +impl> TryFrom<(Vec>, Dimension)> for MixedGeometryBuilder { type Error = GeoArrowError; - fn try_from(geoms: Vec>) -> Result { - Self::from_nullable_geometries(&geoms, Default::default(), Default::default(), true) + fn try_from((geoms, dim): (Vec>, Dimension)) -> Result { + Self::from_nullable_geometries(&geoms, dim, Default::default(), Default::default(), true) } } -impl TryFrom> for MixedGeometryBuilder { +impl TryFrom<(WKBArray, Dimension)> for MixedGeometryBuilder { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> std::result::Result { + fn try_from((value, dim): (WKBArray, Dimension)) -> std::result::Result { assert_eq!( value.nulls().map_or(0, |validity| validity.null_count()), 0, @@ -522,7 +546,7 @@ impl TryFrom> for MixedGeometryBuilder { let metadata = value.metadata.clone(); let wkb_objects: Vec>> = value.iter().collect(); - Self::from_wkb(&wkb_objects, Default::default(), metadata, true) + Self::from_wkb(&wkb_objects, dim, Default::default(), metadata, true) } } @@ -536,8 +560,8 @@ impl GeometryArrayBuilder for MixedGeometryBuilder { todo!() } - fn new() -> Self { - Self::new() + fn new(dim: Dimension) -> Self { + Self::new(dim) } fn into_array_ref(self) -> Arc { @@ -545,12 +569,14 @@ impl GeometryArrayBuilder for MixedGeometryBuilder { } fn with_geom_capacity_and_options( + dim: Dimension, _geom_capacity: usize, coord_type: CoordType, metadata: Arc, ) -> Self { // We don't know where to allocate the capacity Self::with_capacity_and_options( + dim, Default::default(), coord_type, metadata, diff --git a/rust/geoarrow/src/array/multilinestring/array.rs b/rust/geoarrow/src/array/multilinestring/array.rs index 6a32eb6f..36f8c61a 100644 --- a/rust/geoarrow/src/array/multilinestring/array.rs +++ b/rust/geoarrow/src/array/multilinestring/array.rs @@ -492,10 +492,10 @@ impl From for PolygonArray { } } -impl TryFrom> for MultiLineStringArray { +impl TryFrom<(WKBArray, Dimension)> for MultiLineStringArray { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from(value: (WKBArray, Dimension)) -> Result { let mut_arr: MultiLineStringBuilder = value.try_into()?; Ok(mut_arr.into()) } @@ -596,14 +596,15 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: MultiLineStringArray = vec![ml0(), ml1()].as_slice().into(); + let arr: MultiLineStringArray = (vec![ml0(), ml1()].as_slice(), Dimension::XY).into(); assert_eq!(arr.value_as_geo(0), ml0()); assert_eq!(arr.value_as_geo(1), ml1()); } #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: MultiLineStringArray = vec![Some(ml0()), Some(ml1()), None].into(); + let arr: MultiLineStringArray = + (vec![Some(ml0()), Some(ml1()), None], Dimension::XY).into(); assert_eq!(arr.get_as_geo(0), Some(ml0())); assert_eq!(arr.get_as_geo(1), Some(ml1())); assert_eq!(arr.get_as_geo(2), None); @@ -611,7 +612,7 @@ mod test { #[test] fn slice() { - let arr: MultiLineStringArray = vec![ml0(), ml1()].as_slice().into(); + let arr: MultiLineStringArray = (vec![ml0(), ml1()].as_slice(), Dimension::XY).into(); let sliced = arr.slice(1, 1); assert_eq!(sliced.len(), 1); assert_eq!(sliced.get_as_geo(0), Some(ml1())); @@ -619,7 +620,7 @@ mod test { #[test] fn owned_slice() { - let arr: MultiLineStringArray = vec![ml0(), ml1()].as_slice().into(); + let arr: MultiLineStringArray = (vec![ml0(), ml1()].as_slice(), Dimension::XY).into(); let sliced = arr.owned_slice(1, 1); // assert!( @@ -640,7 +641,7 @@ mod test { let geom_arr = example_multilinestring_interleaved(); let wkb_arr = example_multilinestring_wkb(); - let parsed_geom_arr: MultiLineStringArray = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiLineStringArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } @@ -650,7 +651,7 @@ mod test { let geom_arr = example_multilinestring_separated().into_coord_type(CoordType::Interleaved); let wkb_arr = example_multilinestring_wkb(); - let parsed_geom_arr: MultiLineStringArray = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiLineStringArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } diff --git a/rust/geoarrow/src/array/multilinestring/builder.rs b/rust/geoarrow/src/array/multilinestring/builder.rs index 023b6388..00586043 100644 --- a/rust/geoarrow/src/array/multilinestring/builder.rs +++ b/rust/geoarrow/src/array/multilinestring/builder.rs @@ -405,6 +405,7 @@ impl MultiLineStringBuilder { pub(crate) fn from_wkb( wkb_objects: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { @@ -412,7 +413,7 @@ impl MultiLineStringBuilder { .iter() .map(|maybe_wkb| maybe_wkb.as_ref().map(|wkb| wkb.parse()).transpose()) .collect::>>()?; - Self::from_nullable_geometries(&wkb_objects2, coord_type, metadata) + Self::from_nullable_geometries(&wkb_objects2, dim, coord_type, metadata) } } @@ -510,13 +511,13 @@ impl> From<(Vec>, Dimension)> } } -impl TryFrom> for MultiLineStringBuilder { +impl TryFrom<(WKBArray, Dimension)> for MultiLineStringBuilder { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from((value, dim): (WKBArray, Dimension)) -> Result { let metadata = value.metadata.clone(); let wkb_objects: Vec>> = value.iter().collect(); - Self::from_wkb(&wkb_objects, Default::default(), metadata) + Self::from_wkb(&wkb_objects, dim, Default::default(), metadata) } } diff --git a/rust/geoarrow/src/array/multipoint/array.rs b/rust/geoarrow/src/array/multipoint/array.rs index bfbd5e05..e7ce0016 100644 --- a/rust/geoarrow/src/array/multipoint/array.rs +++ b/rust/geoarrow/src/array/multipoint/array.rs @@ -399,24 +399,24 @@ impl TryFrom<(&dyn Array, &Field)> for MultiPointArray { } } -impl> From>> for MultiPointArray { - fn from(other: Vec>) -> Self { +impl> From<(Vec>, Dimension)> for MultiPointArray { + fn from(other: (Vec>, Dimension)) -> Self { let mut_arr: MultiPointBuilder = other.into(); mut_arr.into() } } -impl> From<&[G]> for MultiPointArray { - fn from(other: &[G]) -> Self { +impl> From<(&[G], Dimension)> for MultiPointArray { + fn from(other: (&[G], Dimension)) -> Self { let mut_arr: MultiPointBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for MultiPointArray { +impl TryFrom<(WKBArray, Dimension)> for MultiPointArray { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from(value: (WKBArray, Dimension)) -> Result { let mut_arr: MultiPointBuilder = value.try_into()?; Ok(mut_arr.into()) } @@ -495,6 +495,7 @@ impl TryFrom for MultiPointArray { capacity.geom_capacity += value.points.buffer_lengths(); let mut builder = MultiPointBuilder::with_capacity_and_options( + value.dimension(), capacity, value.coord_type(), value.metadata(), @@ -524,14 +525,14 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: MultiPointArray = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPointArray = (vec![mp0(), mp1()].as_slice(), Dimension::XY).into(); assert_eq!(arr.value_as_geo(0), mp0()); assert_eq!(arr.value_as_geo(1), mp1()); } #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: MultiPointArray = vec![Some(mp0()), Some(mp1()), None].into(); + let arr: MultiPointArray = (vec![Some(mp0()), Some(mp1()), None], Dimension::XY).into(); assert_eq!(arr.get_as_geo(0), Some(mp0())); assert_eq!(arr.get_as_geo(1), Some(mp1())); assert_eq!(arr.get_as_geo(2), None); @@ -539,7 +540,7 @@ mod test { #[test] fn slice() { - let arr: MultiPointArray = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPointArray = (vec![mp0(), mp1()].as_slice(), Dimension::XY).into(); let sliced = arr.slice(1, 1); assert_eq!(sliced.len(), 1); assert_eq!(sliced.get_as_geo(0), Some(mp1())); @@ -547,7 +548,7 @@ mod test { #[test] fn owned_slice() { - let arr: MultiPointArray = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPointArray = (vec![mp0(), mp1()].as_slice(), Dimension::XY).into(); let sliced = arr.owned_slice(1, 1); // assert!( @@ -564,7 +565,7 @@ mod test { let geom_arr = example_multipoint_interleaved(); let wkb_arr = example_multipoint_wkb(); - let parsed_geom_arr: MultiPointArray = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiPointArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } @@ -575,7 +576,7 @@ mod test { let geom_arr = example_multipoint_separated().into_coord_type(CoordType::Interleaved); let wkb_arr = example_multipoint_wkb(); - let parsed_geom_arr: MultiPointArray = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiPointArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } diff --git a/rust/geoarrow/src/array/multipoint/builder.rs b/rust/geoarrow/src/array/multipoint/builder.rs index aa0b533e..f698b0d0 100644 --- a/rust/geoarrow/src/array/multipoint/builder.rs +++ b/rust/geoarrow/src/array/multipoint/builder.rs @@ -8,6 +8,7 @@ use crate::array::{ CoordBufferBuilder, CoordType, InterleavedCoordBufferBuilder, LineStringBuilder, MultiPointArray, SeparatedCoordBufferBuilder, WKBArray, }; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::scalar::WKB; use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow}; @@ -32,38 +33,37 @@ pub struct MultiPointBuilder { impl MultiPointBuilder { /// Creates a new empty [`MultiPointBuilder`]. - pub fn new() -> Self { - Self::new_with_options(Default::default(), Default::default()) + pub fn new(dim: Dimension) -> Self { + Self::new_with_options(dim, Default::default(), Default::default()) } /// Creates a new [`MultiPointBuilder`] with a specified [`CoordType`] - pub fn new_with_options(coord_type: CoordType, metadata: Arc) -> Self { - Self::with_capacity_and_options(Default::default(), coord_type, metadata) + pub fn new_with_options( + dim: Dimension, + coord_type: CoordType, + metadata: Arc, + ) -> Self { + Self::with_capacity_and_options(dim, Default::default(), coord_type, metadata) } /// Creates a new [`MultiPointBuilder`] with a capacity. - pub fn with_capacity(capacity: MultiPointCapacity) -> Self { - Self::with_capacity_and_options(capacity, Default::default(), Default::default()) + pub fn with_capacity(dim: Dimension, capacity: MultiPointCapacity) -> Self { + Self::with_capacity_and_options(dim, capacity, Default::default(), Default::default()) } // with capacity and options enables us to write with_capacity based on this method pub fn with_capacity_and_options( + dim: Dimension, capacity: MultiPointCapacity, coord_type: CoordType, metadata: Arc, ) -> Self { let coords = match coord_type { - CoordType::Interleaved => { - CoordBufferBuilder::Interleaved(InterleavedCoordBufferBuilder::with_capacity( - capacity.coord_capacity, - D.try_into().unwrap(), - )) - } - CoordType::Separated => { - CoordBufferBuilder::Separated(SeparatedCoordBufferBuilder::with_capacity( - capacity.coord_capacity, - D.try_into().unwrap(), - )) - } + CoordType::Interleaved => CoordBufferBuilder::Interleaved( + InterleavedCoordBufferBuilder::with_capacity(capacity.coord_capacity, dim), + ), + CoordType::Separated => CoordBufferBuilder::Separated( + SeparatedCoordBufferBuilder::with_capacity(capacity.coord_capacity, dim), + ), }; Self { coords, @@ -146,17 +146,24 @@ impl MultiPointBuilder { pub fn with_capacity_from_iter<'a>( geoms: impl Iterator>, + dim: Dimension, ) -> Self { - Self::with_capacity_and_options_from_iter(geoms, Default::default(), Default::default()) + Self::with_capacity_and_options_from_iter( + geoms, + dim, + Default::default(), + Default::default(), + ) } pub fn with_capacity_and_options_from_iter<'a>( geoms: impl Iterator>, + dim: Dimension, coord_type: CoordType, metadata: Arc, ) -> Self { let counter = MultiPointCapacity::from_multi_points(geoms); - Self::with_capacity_and_options(counter, coord_type, metadata) + Self::with_capacity_and_options(dim, counter, coord_type, metadata) } pub fn reserve_from_iter<'a>( @@ -290,11 +297,13 @@ impl MultiPointBuilder { pub fn from_multi_points( geoms: &[impl MultiPointTrait], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(Some), + dim, coord_type.unwrap_or_default(), metadata, ); @@ -304,11 +313,13 @@ impl MultiPointBuilder { pub fn from_nullable_multi_points( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(|x| x.as_ref()), + dim, coord_type.unwrap_or_default(), metadata, ); @@ -318,17 +329,23 @@ impl MultiPointBuilder { pub fn from_nullable_geometries( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { let capacity = MultiPointCapacity::from_geometries(geoms.iter().map(|x| x.as_ref()))?; - let mut array = - Self::with_capacity_and_options(capacity, coord_type.unwrap_or_default(), metadata); + let mut array = Self::with_capacity_and_options( + dim, + capacity, + coord_type.unwrap_or_default(), + metadata, + ); array.extend_from_geometry_iter(geoms.iter().map(|x| x.as_ref()))?; Ok(array) } pub(crate) fn from_wkb( wkb_objects: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { @@ -336,28 +353,29 @@ impl MultiPointBuilder { .iter() .map(|maybe_wkb| maybe_wkb.as_ref().map(|wkb| wkb.parse()).transpose()) .collect::>>()?; - Self::from_nullable_geometries(&wkb_objects2, coord_type, metadata) + Self::from_nullable_geometries(&wkb_objects2, dim, coord_type, metadata) } } impl Default for MultiPointBuilder { fn default() -> Self { - Self::new() + Self::new(Dimension::XY) } } impl GeometryArrayBuilder for MultiPointBuilder { - fn new() -> Self { - Self::new() + fn new(dim: Dimension) -> Self { + Self::new(dim) } fn with_geom_capacity_and_options( + dim: Dimension, geom_capacity: usize, coord_type: CoordType, metadata: Arc, ) -> Self { let capacity = MultiPointCapacity::new(0, geom_capacity); - Self::with_capacity_and_options(capacity, coord_type, metadata) + Self::with_capacity_and_options(dim, capacity, coord_type, metadata) } fn push_geometry(&mut self, value: Option<&impl GeometryTrait>) -> Result<()> { @@ -425,25 +443,25 @@ impl From for GenericListArray { } } -impl, const D: usize> From<&[G]> for MultiPointBuilder { - fn from(geoms: &[G]) -> Self { - Self::from_multi_points(geoms, Default::default(), Default::default()) +impl> From<(&[G], Dimension)> for MultiPointBuilder { + fn from((geoms, dim): (&[G], Dimension)) -> Self { + Self::from_multi_points(geoms, dim, Default::default(), Default::default()) } } -impl, const D: usize> From>> for MultiPointBuilder { - fn from(geoms: Vec>) -> Self { - Self::from_nullable_multi_points(&geoms, Default::default(), Default::default()) +impl> From<(Vec>, Dimension)> for MultiPointBuilder { + fn from((geoms, dim): (Vec>, Dimension)) -> Self { + Self::from_nullable_multi_points(&geoms, dim, Default::default(), Default::default()) } } -impl TryFrom> for MultiPointBuilder { +impl TryFrom<(WKBArray, Dimension)> for MultiPointBuilder { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from((value, dim): (WKBArray, Dimension)) -> Result { let metadata = value.metadata.clone(); let wkb_objects: Vec>> = value.iter().collect(); - Self::from_wkb(&wkb_objects, Default::default(), metadata) + Self::from_wkb(&wkb_objects, dim, Default::default(), metadata) } } diff --git a/rust/geoarrow/src/array/multipolygon/array.rs b/rust/geoarrow/src/array/multipolygon/array.rs index 2ef32b33..212632f4 100644 --- a/rust/geoarrow/src/array/multipolygon/array.rs +++ b/rust/geoarrow/src/array/multipolygon/array.rs @@ -558,24 +558,24 @@ impl TryFrom<(&dyn Array, &Field)> for MultiPolygonArray { } } -impl> From>> for MultiPolygonArray { - fn from(other: Vec>) -> Self { +impl> From<(Vec>, Dimension)> for MultiPolygonArray { + fn from(other: (Vec>, Dimension)) -> Self { let mut_arr: MultiPolygonBuilder = other.into(); mut_arr.into() } } -impl> From<&[G]> for MultiPolygonArray { - fn from(other: &[G]) -> Self { +impl> From<(&[G], Dimension)> for MultiPolygonArray { + fn from(other: (&[G], Dimension)) -> Self { let mut_arr: MultiPolygonBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for MultiPolygonArray { +impl TryFrom<(WKBArray, Dimension)> for MultiPolygonArray { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from(value: (WKBArray, Dimension)) -> Result { let mut_arr: MultiPolygonBuilder = value.try_into()?; Ok(mut_arr.into()) } @@ -656,6 +656,7 @@ impl TryFrom for MultiPolygonArray { capacity += value.polygons.buffer_lengths(); let mut builder = MultiPolygonBuilder::with_capacity_and_options( + value.dimension(), capacity, value.coord_type(), value.metadata(), @@ -685,14 +686,14 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: MultiPolygonArray = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPolygonArray = (vec![mp0(), mp1()].as_slice(), Dimension::XY).into(); assert_eq!(arr.value_as_geo(0), mp0()); assert_eq!(arr.value_as_geo(1), mp1()); } #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: MultiPolygonArray = vec![Some(mp0()), Some(mp1()), None].into(); + let arr: MultiPolygonArray = (vec![Some(mp0()), Some(mp1()), None], Dimension::XY).into(); assert_eq!(arr.get_as_geo(0), Some(mp0())); assert_eq!(arr.get_as_geo(1), Some(mp1())); assert_eq!(arr.get_as_geo(2), None); @@ -700,7 +701,7 @@ mod test { #[test] fn slice() { - let arr: MultiPolygonArray = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPolygonArray = (vec![mp0(), mp1()].as_slice(), Dimension::XY).into(); let sliced = arr.slice(1, 1); assert_eq!(sliced.len(), 1); assert_eq!(sliced.get_as_geo(0), Some(mp1())); @@ -708,7 +709,7 @@ mod test { #[test] fn owned_slice() { - let arr: MultiPolygonArray = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPolygonArray = (vec![mp0(), mp1()].as_slice(), Dimension::XY).into(); let sliced = arr.owned_slice(1, 1); // assert!( @@ -729,7 +730,7 @@ mod test { let geom_arr = example_multipolygon_interleaved(); let wkb_arr = example_multipolygon_wkb(); - let parsed_geom_arr: MultiPolygonArray = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiPolygonArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } @@ -740,7 +741,7 @@ mod test { let geom_arr = example_multipolygon_separated().into_coord_type(CoordType::Interleaved); let wkb_arr = example_multipolygon_wkb(); - let parsed_geom_arr: MultiPolygonArray = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: MultiPolygonArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } diff --git a/rust/geoarrow/src/array/multipolygon/builder.rs b/rust/geoarrow/src/array/multipolygon/builder.rs index 0acf5338..9abafb6c 100644 --- a/rust/geoarrow/src/array/multipolygon/builder.rs +++ b/rust/geoarrow/src/array/multipolygon/builder.rs @@ -8,6 +8,7 @@ use crate::array::{ CoordBufferBuilder, CoordType, InterleavedCoordBufferBuilder, MultiPolygonArray, SeparatedCoordBufferBuilder, WKBArray, }; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::scalar::WKB; use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow}; @@ -49,37 +50,36 @@ pub struct MultiPolygonBuilder { impl MultiPolygonBuilder { /// Creates a new empty [`MultiPolygonBuilder`]. - pub fn new() -> Self { - Self::new_with_options(Default::default(), Default::default()) + pub fn new(dim: Dimension) -> Self { + Self::new_with_options(dim, Default::default(), Default::default()) } - pub fn new_with_options(coord_type: CoordType, metadata: Arc) -> Self { - Self::with_capacity_and_options(Default::default(), coord_type, metadata) + pub fn new_with_options( + dim: Dimension, + coord_type: CoordType, + metadata: Arc, + ) -> Self { + Self::with_capacity_and_options(dim, Default::default(), coord_type, metadata) } /// Creates a new [`MultiPolygonBuilder`] with a capacity. - pub fn with_capacity(capacity: MultiPolygonCapacity) -> Self { - Self::with_capacity_and_options(capacity, Default::default(), Default::default()) + pub fn with_capacity(dim: Dimension, capacity: MultiPolygonCapacity) -> Self { + Self::with_capacity_and_options(dim, capacity, Default::default(), Default::default()) } pub fn with_capacity_and_options( + dim: Dimension, capacity: MultiPolygonCapacity, coord_type: CoordType, metadata: Arc, ) -> Self { let coords = match coord_type { - CoordType::Interleaved => { - CoordBufferBuilder::Interleaved(InterleavedCoordBufferBuilder::with_capacity( - capacity.coord_capacity, - D.try_into().unwrap(), - )) - } - CoordType::Separated => { - CoordBufferBuilder::Separated(SeparatedCoordBufferBuilder::with_capacity( - capacity.coord_capacity, - D.try_into().unwrap(), - )) - } + CoordType::Interleaved => CoordBufferBuilder::Interleaved( + InterleavedCoordBufferBuilder::with_capacity(capacity.coord_capacity, dim), + ), + CoordType::Separated => CoordBufferBuilder::Separated( + SeparatedCoordBufferBuilder::with_capacity(capacity.coord_capacity, dim), + ), }; Self { @@ -183,17 +183,24 @@ impl MultiPolygonBuilder { pub fn with_capacity_from_iter<'a>( geoms: impl Iterator>, + dim: Dimension, ) -> Self { - Self::with_capacity_and_options_from_iter(geoms, Default::default(), Default::default()) + Self::with_capacity_and_options_from_iter( + geoms, + dim, + Default::default(), + Default::default(), + ) } pub fn with_capacity_and_options_from_iter<'a>( geoms: impl Iterator>, + dim: Dimension, coord_type: CoordType, metadata: Arc, ) -> Self { let capacity = MultiPolygonCapacity::from_multi_polygons(geoms); - Self::with_capacity_and_options(capacity, coord_type, metadata) + Self::with_capacity_and_options(dim, capacity, coord_type, metadata) } pub fn reserve_from_iter<'a>( @@ -409,11 +416,13 @@ impl MultiPolygonBuilder { pub fn from_multi_polygons( geoms: &[impl MultiPolygonTrait], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(Some), + dim, coord_type.unwrap_or_default(), metadata, ); @@ -423,11 +432,13 @@ impl MultiPolygonBuilder { pub fn from_nullable_multi_polygons( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(|x| x.as_ref()), + dim, coord_type.unwrap_or_default(), metadata, ); @@ -437,18 +448,24 @@ impl MultiPolygonBuilder { pub fn from_nullable_geometries( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { let capacity = MultiPolygonCapacity::from_geometries(geoms.iter().map(|x| x.as_ref()))?; - let mut array = - Self::with_capacity_and_options(capacity, coord_type.unwrap_or_default(), metadata); + let mut array = Self::with_capacity_and_options( + dim, + capacity, + coord_type.unwrap_or_default(), + metadata, + ); array.extend_from_geometry_iter(geoms.iter().map(|x| x.as_ref()))?; Ok(array) } pub(crate) fn from_wkb( wkb_objects: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { @@ -456,22 +473,23 @@ impl MultiPolygonBuilder { .iter() .map(|maybe_wkb| maybe_wkb.as_ref().map(|wkb| wkb.parse()).transpose()) .collect::>>()?; - Self::from_nullable_geometries(&wkb_objects2, coord_type, metadata) + Self::from_nullable_geometries(&wkb_objects2, dim, coord_type, metadata) } } impl Default for MultiPolygonBuilder { fn default() -> Self { - Self::new() + Self::new(Dimension::XY) } } impl GeometryArrayBuilder for MultiPolygonBuilder { - fn new() -> Self { - Self::new() + fn new(dim: Dimension) -> Self { + Self::new(dim) } fn with_geom_capacity_and_options( + dim: Dimension, geom_capacity: usize, coord_type: CoordType, metadata: Arc, @@ -482,7 +500,7 @@ impl GeometryArrayBuilder for MultiPolygonBuilder { Default::default(), geom_capacity, ); - Self::with_capacity_and_options(capacity, coord_type, metadata) + Self::with_capacity_and_options(dim, capacity, coord_type, metadata) } fn push_geometry(&mut self, value: Option<&impl GeometryTrait>) -> Result<()> { @@ -546,24 +564,24 @@ impl From for MultiPolygonArray { } } -impl, const D: usize> From<&[G]> for MultiPolygonBuilder { - fn from(geoms: &[G]) -> Self { - Self::from_multi_polygons(geoms, Default::default(), Default::default()) +impl> From<(&[G], Dimension)> for MultiPolygonBuilder { + fn from((geoms, dim): (&[G], Dimension)) -> Self { + Self::from_multi_polygons(geoms, dim, Default::default(), Default::default()) } } -impl, const D: usize> From>> for MultiPolygonBuilder { - fn from(geoms: Vec>) -> Self { - Self::from_nullable_multi_polygons(&geoms, Default::default(), Default::default()) +impl> From<(Vec>, Dimension)> for MultiPolygonBuilder { + fn from((geoms, dim): (Vec>, Dimension)) -> Self { + Self::from_nullable_multi_polygons(&geoms, dim, Default::default(), Default::default()) } } -impl TryFrom> for MultiPolygonBuilder { +impl TryFrom<(WKBArray, Dimension)> for MultiPolygonBuilder { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from((value, dim): (WKBArray, Dimension)) -> Result { let metadata = value.metadata.clone(); let wkb_objects: Vec>> = value.iter().collect(); - Self::from_wkb(&wkb_objects, Default::default(), metadata) + Self::from_wkb(&wkb_objects, dim, Default::default(), metadata) } } diff --git a/rust/geoarrow/src/array/point/array.rs b/rust/geoarrow/src/array/point/array.rs index 7d44bc68..a802b741 100644 --- a/rust/geoarrow/src/array/point/array.rs +++ b/rust/geoarrow/src/array/point/array.rs @@ -99,7 +99,7 @@ impl PointArray { /// The number of bytes occupied by this array. pub fn num_bytes(&self) -> usize { let validity_len = self.nulls().map(|v| v.buffer().len()).unwrap_or(0); - validity_len + self.buffer_lengths() * D * 8 + validity_len + self.buffer_lengths() * self.dimension().size() * 8 } /// Slices this [`PointArray`] in place. @@ -264,10 +264,11 @@ impl IntoArrow for PointArray { fn into_arrow(self) -> Self::ArrowArray { let validity = self.validity; + let dim = self.coords.dim(); match self.coords { CoordBuffer::Interleaved(c) => Arc::new(FixedSizeListArray::new( c.values_field().into(), - self.coords.dim().size() as i32, + dim.size() as i32, Arc::new(c.values_array()), validity, )), @@ -338,24 +339,24 @@ impl TryFrom<(&dyn Array, &Field)> for PointArray { } } -impl> From>> for PointArray { - fn from(other: Vec>) -> Self { +impl> From<(Vec>, Dimension)> for PointArray { + fn from(other: (Vec>, Dimension)) -> Self { let mut_arr: PointBuilder = other.into(); mut_arr.into() } } -impl> From<&[G]> for PointArray { - fn from(other: &[G]) -> Self { +impl> From<(&[G], Dimension)> for PointArray { + fn from(other: (&[G], Dimension)) -> Self { let mut_arr: PointBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for PointArray { +impl TryFrom<(WKBArray, Dimension)> for PointArray { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from(value: (WKBArray, Dimension)) -> Result { let mut_arr: PointBuilder = value.try_into()?; Ok(mut_arr.into()) } @@ -436,6 +437,7 @@ impl TryFrom for PointArray { } let mut builder = PointBuilder::with_capacity_and_options( + value.dimension(), value.len(), value.coord_type(), value.metadata(), @@ -467,7 +469,7 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: PointArray = vec![p0(), p1(), p2()].as_slice().into(); + let arr: PointArray = (vec![p0(), p1(), p2()].as_slice(), Dimension::XY).into(); assert_eq!(arr.value_as_geo(0), p0()); assert_eq!(arr.value_as_geo(1), p1()); assert_eq!(arr.value_as_geo(2), p2()); @@ -475,7 +477,11 @@ mod test { #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: PointArray = vec![Some(p0()), Some(p1()), Some(p2()), None].into(); + let arr: PointArray = ( + vec![Some(p0()), Some(p1()), Some(p2()), None], + Dimension::XY, + ) + .into(); assert_eq!(arr.get_as_geo(0), Some(p0())); assert_eq!(arr.get_as_geo(1), Some(p1())); assert_eq!(arr.get_as_geo(2), Some(p2())); @@ -485,7 +491,7 @@ mod test { #[test] fn slice() { let points: Vec = vec![p0(), p1(), p2()]; - let point_array: PointArray = points.as_slice().into(); + let point_array: PointArray = (points.as_slice(), Dimension::XY).into(); let sliced = point_array.slice(1, 1); assert_eq!(sliced.len(), 1); assert_eq!(sliced.get_as_geo(0), Some(p1())); @@ -494,7 +500,7 @@ mod test { #[test] fn owned_slice() { let points: Vec = vec![p0(), p1(), p2()]; - let point_array: PointArray = points.as_slice().into(); + let point_array: PointArray = (points.as_slice(), Dimension::XY).into(); let sliced = point_array.owned_slice(1, 1); assert_eq!(point_array.len(), 3); @@ -508,7 +514,7 @@ mod test { let geom_arr = example_point_interleaved(); let wkb_arr = example_point_wkb(); - let parsed_geom_arr: PointArray = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: PointArray = (wkb_arr, Dimension::XY).try_into().unwrap(); // Comparisons on the point array directly currently fail because of NaN values in // coordinate 1. @@ -521,7 +527,7 @@ mod test { let geom_arr = example_point_separated(); let wkb_arr = example_point_wkb(); - let parsed_geom_arr: PointArray = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: PointArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } diff --git a/rust/geoarrow/src/array/point/builder.rs b/rust/geoarrow/src/array/point/builder.rs index 3bff24fe..cdf8330e 100644 --- a/rust/geoarrow/src/array/point/builder.rs +++ b/rust/geoarrow/src/array/point/builder.rs @@ -7,6 +7,7 @@ use crate::array::{ CoordBufferBuilder, CoordType, InterleavedCoordBufferBuilder, PointArray, SeparatedCoordBufferBuilder, WKBArray, }; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::scalar::WKB; use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow}; @@ -26,31 +27,36 @@ pub struct PointBuilder { impl PointBuilder { /// Creates a new empty [`PointBuilder`]. - pub fn new() -> Self { - Self::new_with_options(Default::default(), Default::default()) + pub fn new(dim: Dimension) -> Self { + Self::new_with_options(dim, Default::default(), Default::default()) } - pub fn new_with_options(coord_type: CoordType, metadata: Arc) -> Self { - Self::with_capacity_and_options(0, coord_type, metadata) + pub fn new_with_options( + dim: Dimension, + coord_type: CoordType, + metadata: Arc, + ) -> Self { + Self::with_capacity_and_options(dim, 0, coord_type, metadata) } /// Creates a new [`PointBuilder`] with a capacity. - pub fn with_capacity(capacity: usize) -> Self { - Self::with_capacity_and_options(capacity, Default::default(), Default::default()) + pub fn with_capacity(dim: Dimension, capacity: usize) -> Self { + Self::with_capacity_and_options(dim, capacity, Default::default(), Default::default()) } /// Creates a new [`PointBuilder`] with a capacity. pub fn with_capacity_and_options( + dim: Dimension, capacity: usize, coord_type: CoordType, metadata: Arc, ) -> Self { let coords = match coord_type { CoordType::Interleaved => CoordBufferBuilder::Interleaved( - InterleavedCoordBufferBuilder::with_capacity(capacity, D.try_into().unwrap()), + InterleavedCoordBufferBuilder::with_capacity(capacity, dim), ), CoordType::Separated => CoordBufferBuilder::Separated( - SeparatedCoordBufferBuilder::with_capacity(capacity, D.try_into().unwrap()), + SeparatedCoordBufferBuilder::with_capacity(capacity, dim), ), }; Self { @@ -223,11 +229,16 @@ impl PointBuilder { pub fn from_points<'a>( geoms: impl ExactSizeIterator + 'a)>, + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { - let mut mutable_array = - Self::with_capacity_and_options(geoms.len(), coord_type.unwrap_or_default(), metadata); + let mut mutable_array = Self::with_capacity_and_options( + dim, + geoms.len(), + coord_type.unwrap_or_default(), + metadata, + ); geoms .into_iter() .for_each(|maybe_point| mutable_array.push_point(Some(maybe_point))); @@ -236,11 +247,16 @@ impl PointBuilder { pub fn from_nullable_points<'a>( geoms: impl ExactSizeIterator + 'a)>>, + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { - let mut mutable_array = - Self::with_capacity_and_options(geoms.len(), coord_type.unwrap_or_default(), metadata); + let mut mutable_array = Self::with_capacity_and_options( + dim, + geoms.len(), + coord_type.unwrap_or_default(), + metadata, + ); geoms .into_iter() .for_each(|maybe_point| mutable_array.push_point(maybe_point)); @@ -249,18 +265,24 @@ impl PointBuilder { pub fn from_nullable_geometries( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { let capacity = geoms.len(); - let mut array = - Self::with_capacity_and_options(capacity, coord_type.unwrap_or_default(), metadata); + let mut array = Self::with_capacity_and_options( + dim, + capacity, + coord_type.unwrap_or_default(), + metadata, + ); array.extend_from_geometry_iter(geoms.iter().map(|x| x.as_ref()))?; Ok(array) } pub(crate) fn from_wkb( wkb_objects: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { @@ -268,21 +290,22 @@ impl PointBuilder { .iter() .map(|maybe_wkb| maybe_wkb.as_ref().map(|wkb| wkb.parse()).transpose()) .collect::>>()?; - Self::from_nullable_geometries(&wkb_objects2, coord_type, metadata) + Self::from_nullable_geometries(&wkb_objects2, dim, coord_type, metadata) } } impl GeometryArrayBuilder for PointBuilder { - fn new() -> Self { - Self::new() + fn new(dim: Dimension) -> Self { + Self::new(dim) } fn with_geom_capacity_and_options( + dim: Dimension, geom_capacity: usize, coord_type: CoordType, metadata: Arc, ) -> Self { - Self::with_capacity_and_options(geom_capacity, coord_type, metadata) + Self::with_capacity_and_options(dim, geom_capacity, coord_type, metadata) } fn set_metadata(&mut self, metadata: Arc) { @@ -320,7 +343,7 @@ impl GeometryArrayBuilder for PointBuilder { impl Default for PointBuilder { fn default() -> Self { - Self::new() + Self::new(Dimension::XY) } } @@ -346,28 +369,29 @@ impl From for Arc { } } -impl> From<&[G]> for PointBuilder { - fn from(value: &[G]) -> Self { - PointBuilder::from_points(value.iter(), Default::default(), Default::default()) +impl> From<(&[G], Dimension)> for PointBuilder { + fn from((value, dim): (&[G], Dimension)) -> Self { + PointBuilder::from_points(value.iter(), dim, Default::default(), Default::default()) } } -impl> From>> for PointBuilder { - fn from(geoms: Vec>) -> Self { +impl> From<(Vec>, Dimension)> for PointBuilder { + fn from((geoms, dim): (Vec>, Dimension)) -> Self { PointBuilder::from_nullable_points( geoms.iter().map(|x| x.as_ref()), + dim, Default::default(), Default::default(), ) } } -impl TryFrom> for PointBuilder { +impl TryFrom<(WKBArray, Dimension)> for PointBuilder { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from((value, dim): (WKBArray, Dimension)) -> Result { let metadata = value.metadata.clone(); let wkb_objects: Vec>> = value.iter().collect(); - Self::from_wkb(&wkb_objects, Default::default(), metadata) + Self::from_wkb(&wkb_objects, dim, Default::default(), metadata) } } diff --git a/rust/geoarrow/src/array/polygon/array.rs b/rust/geoarrow/src/array/polygon/array.rs index 7c4facdd..679745a3 100644 --- a/rust/geoarrow/src/array/polygon/array.rs +++ b/rust/geoarrow/src/array/polygon/array.rs @@ -466,24 +466,24 @@ impl TryFrom<(&dyn Array, &Field)> for PolygonArray { } } -impl> From>> for PolygonArray { - fn from(other: Vec>) -> Self { +impl> From<(Vec>, Dimension)> for PolygonArray { + fn from(other: (Vec>, Dimension)) -> Self { let mut_arr: PolygonBuilder = other.into(); mut_arr.into() } } -impl> From<&[G]> for PolygonArray { - fn from(other: &[G]) -> Self { +impl> From<(&[G], Dimension)> for PolygonArray { + fn from(other: (&[G], Dimension)) -> Self { let mut_arr: PolygonBuilder = other.into(); mut_arr.into() } } -impl TryFrom> for PolygonArray { +impl TryFrom<(WKBArray, Dimension)> for PolygonArray { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from(value: (WKBArray, Dimension)) -> Result { let mut_arr: PolygonBuilder = value.try_into()?; Ok(mut_arr.into()) } @@ -505,6 +505,8 @@ impl From for MultiLineStringArray { impl From for PolygonArray { fn from(value: RectArray) -> Self { + let dim = value.dimension(); + // The number of output geoms is the same as the input let geom_capacity = value.len(); @@ -516,7 +518,7 @@ impl From for PolygonArray { let coord_capacity = (value.len() - value.null_count()) * 5; let capacity = PolygonCapacity::new(coord_capacity, ring_capacity, geom_capacity); - let mut output_array = PolygonBuilder::with_capacity(capacity); + let mut output_array = PolygonBuilder::with_capacity(dim, capacity); value.iter_geo().for_each(|maybe_g| { output_array @@ -579,6 +581,8 @@ impl TryFrom for PolygonArray { type Error = GeoArrowError; fn try_from(value: MixedGeometryArray) -> Result { + let dim = value.dim(); + if value.has_points() || value.has_line_strings() || value.has_multi_points() @@ -602,6 +606,7 @@ impl TryFrom for PolygonArray { capacity.geom_capacity += buffer_lengths.polygon_capacity; let mut builder = PolygonBuilder::with_capacity_and_options( + dim, capacity, value.coord_type(), value.metadata(), @@ -632,14 +637,14 @@ mod test { #[test] fn geo_roundtrip_accurate() { - let arr: PolygonArray = vec![p0(), p1()].as_slice().into(); + let arr: PolygonArray = (vec![p0(), p1()].as_slice(), Dimension::XY).into(); assert_eq!(arr.value_as_geo(0), p0()); assert_eq!(arr.value_as_geo(1), p1()); } #[test] fn geo_roundtrip_accurate_option_vec() { - let arr: PolygonArray = vec![Some(p0()), Some(p1()), None].into(); + let arr: PolygonArray = (vec![Some(p0()), Some(p1()), None], Dimension::XY).into(); assert_eq!(arr.get_as_geo(0), Some(p0())); assert_eq!(arr.get_as_geo(1), Some(p1())); assert_eq!(arr.get_as_geo(2), None); @@ -647,7 +652,7 @@ mod test { #[test] fn slice() { - let arr: PolygonArray = vec![p0(), p1()].as_slice().into(); + let arr: PolygonArray = (vec![p0(), p1()].as_slice(), Dimension::XY).into(); let sliced = arr.slice(1, 1); assert_eq!(sliced.len(), 1); @@ -659,7 +664,7 @@ mod test { #[test] fn owned_slice() { - let arr: PolygonArray = vec![p0(), p1()].as_slice().into(); + let arr: PolygonArray = (vec![p0(), p1()].as_slice(), Dimension::XY).into(); let sliced = arr.owned_slice(1, 1); // assert!( @@ -680,7 +685,7 @@ mod test { let geom_arr = example_polygon_interleaved(); let wkb_arr = example_polygon_wkb(); - let parsed_geom_arr: PolygonArray = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: PolygonArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } @@ -691,7 +696,7 @@ mod test { let geom_arr = example_polygon_separated().into_coord_type(CoordType::Interleaved); let wkb_arr = example_polygon_wkb(); - let parsed_geom_arr: PolygonArray = wkb_arr.try_into().unwrap(); + let parsed_geom_arr: PolygonArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(geom_arr, parsed_geom_arr); } diff --git a/rust/geoarrow/src/array/polygon/builder.rs b/rust/geoarrow/src/array/polygon/builder.rs index f250bffc..38e21e48 100644 --- a/rust/geoarrow/src/array/polygon/builder.rs +++ b/rust/geoarrow/src/array/polygon/builder.rs @@ -8,6 +8,7 @@ use crate::array::{ CoordBufferBuilder, CoordType, InterleavedCoordBufferBuilder, MultiLineStringBuilder, PolygonArray, SeparatedCoordBufferBuilder, WKBArray, }; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::scalar::WKB; use crate::trait_::{ArrayAccessor, GeometryArrayBuilder, IntoArrow}; @@ -46,37 +47,36 @@ pub struct PolygonBuilder { impl PolygonBuilder { /// Creates a new empty [`PolygonBuilder`]. - pub fn new() -> Self { - Self::new_with_options(Default::default(), Default::default()) + pub fn new(dim: Dimension) -> Self { + Self::new_with_options(dim, Default::default(), Default::default()) } - pub fn new_with_options(coord_type: CoordType, metadata: Arc) -> Self { - Self::with_capacity_and_options(Default::default(), coord_type, metadata) + pub fn new_with_options( + dim: Dimension, + coord_type: CoordType, + metadata: Arc, + ) -> Self { + Self::with_capacity_and_options(dim, Default::default(), coord_type, metadata) } /// Creates a new [`PolygonBuilder`] with given capacity and no validity. - pub fn with_capacity(capacity: PolygonCapacity) -> Self { - Self::with_capacity_and_options(capacity, Default::default(), Default::default()) + pub fn with_capacity(dim: Dimension, capacity: PolygonCapacity) -> Self { + Self::with_capacity_and_options(dim, capacity, Default::default(), Default::default()) } pub fn with_capacity_and_options( + dim: Dimension, capacity: PolygonCapacity, coord_type: CoordType, metadata: Arc, ) -> Self { let coords = match coord_type { - CoordType::Interleaved => { - CoordBufferBuilder::Interleaved(InterleavedCoordBufferBuilder::with_capacity( - capacity.coord_capacity, - D.try_into().unwrap(), - )) - } - CoordType::Separated => { - CoordBufferBuilder::Separated(SeparatedCoordBufferBuilder::with_capacity( - capacity.coord_capacity, - D.try_into().unwrap(), - )) - } + CoordType::Interleaved => CoordBufferBuilder::Interleaved( + InterleavedCoordBufferBuilder::with_capacity(capacity.coord_capacity, dim), + ), + CoordType::Separated => CoordBufferBuilder::Separated( + SeparatedCoordBufferBuilder::with_capacity(capacity.coord_capacity, dim), + ), }; Self { coords, @@ -210,17 +210,24 @@ impl PolygonBuilder { pub fn with_capacity_from_iter<'a>( geoms: impl Iterator>, + dim: Dimension, ) -> Self { - Self::with_capacity_and_options_from_iter(geoms, Default::default(), Default::default()) + Self::with_capacity_and_options_from_iter( + geoms, + dim, + Default::default(), + Default::default(), + ) } pub fn with_capacity_and_options_from_iter<'a>( geoms: impl Iterator>, + dim: Dimension, coord_type: CoordType, metadata: Arc, ) -> Self { let counter = PolygonCapacity::from_polygons(geoms); - Self::with_capacity_and_options(counter, coord_type, metadata) + Self::with_capacity_and_options(dim, counter, coord_type, metadata) } /// Add a new Polygon to the end of this array. @@ -375,11 +382,13 @@ impl PolygonBuilder { pub fn from_polygons( geoms: &[impl PolygonTrait], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(Some), + dim, coord_type.unwrap_or_default(), metadata, ); @@ -389,11 +398,13 @@ impl PolygonBuilder { pub fn from_nullable_polygons( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Self { let mut array = Self::with_capacity_and_options_from_iter( geoms.iter().map(|x| x.as_ref()), + dim, coord_type.unwrap_or_default(), metadata, ); @@ -403,18 +414,24 @@ impl PolygonBuilder { pub fn from_nullable_geometries( geoms: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { let capacity = PolygonCapacity::from_geometries(geoms.iter().map(|x| x.as_ref()))?; - let mut array = - Self::with_capacity_and_options(capacity, coord_type.unwrap_or_default(), metadata); + let mut array = Self::with_capacity_and_options( + dim, + capacity, + coord_type.unwrap_or_default(), + metadata, + ); array.extend_from_geometry_iter(geoms.iter().map(|x| x.as_ref()))?; Ok(array) } pub(crate) fn from_wkb( wkb_objects: &[Option>], + dim: Dimension, coord_type: Option, metadata: Arc, ) -> Result { @@ -422,28 +439,29 @@ impl PolygonBuilder { .iter() .map(|maybe_wkb| maybe_wkb.as_ref().map(|wkb| wkb.parse()).transpose()) .collect::>>()?; - Self::from_nullable_geometries(&wkb_objects2, coord_type, metadata) + Self::from_nullable_geometries(&wkb_objects2, dim, coord_type, metadata) } } impl Default for PolygonBuilder { fn default() -> Self { - Self::new() + Self::new(Dimension::XY) } } impl GeometryArrayBuilder for PolygonBuilder { - fn new() -> Self { - Self::new() + fn new(dim: Dimension) -> Self { + Self::new(dim) } fn with_geom_capacity_and_options( + dim: Dimension, geom_capacity: usize, coord_type: CoordType, metadata: Arc, ) -> Self { let capacity = PolygonCapacity::new(0, 0, geom_capacity); - Self::with_capacity_and_options(capacity, coord_type, metadata) + Self::with_capacity_and_options(dim, capacity, coord_type, metadata) } fn push_geometry(&mut self, value: Option<&impl GeometryTrait>) -> Result<()> { @@ -505,25 +523,25 @@ impl From for PolygonArray { } } -impl, const D: usize> From<&[G]> for PolygonBuilder { - fn from(geoms: &[G]) -> Self { - Self::from_polygons(geoms, Default::default(), Default::default()) +impl> From<(&[G], Dimension)> for PolygonBuilder { + fn from((geoms, dim): (&[G], Dimension)) -> Self { + Self::from_polygons(geoms, dim, Default::default(), Default::default()) } } -impl, const D: usize> From>> for PolygonBuilder { - fn from(geoms: Vec>) -> Self { - Self::from_nullable_polygons(&geoms, Default::default(), Default::default()) +impl> From<(Vec>, Dimension)> for PolygonBuilder { + fn from((geoms, dim): (Vec>, Dimension)) -> Self { + Self::from_nullable_polygons(&geoms, dim, Default::default(), Default::default()) } } -impl TryFrom> for PolygonBuilder { +impl TryFrom<(WKBArray, Dimension)> for PolygonBuilder { type Error = GeoArrowError; - fn try_from(value: WKBArray) -> Result { + fn try_from((value, dim): (WKBArray, Dimension)) -> Result { let metadata = value.metadata.clone(); let wkb_objects: Vec>> = value.iter().collect(); - Self::from_wkb(&wkb_objects, Default::default(), metadata) + Self::from_wkb(&wkb_objects, dim, Default::default(), metadata) } } diff --git a/rust/geoarrow/src/array/rect/array.rs b/rust/geoarrow/src/array/rect/array.rs index 93f2fa8a..532484d6 100644 --- a/rust/geoarrow/src/array/rect/array.rs +++ b/rust/geoarrow/src/array/rect/array.rs @@ -267,15 +267,15 @@ impl TryFrom<(&dyn Array, &Field)> for RectArray { } } -impl> From<&[G]> for RectArray { - fn from(other: &[G]) -> Self { +impl> From<(&[G], Dimension)> for RectArray { + fn from(other: (&[G], Dimension)) -> Self { let mut_arr: RectBuilder = other.into(); mut_arr.into() } } -impl> From>> for RectArray { - fn from(other: Vec>) -> Self { +impl> From<(Vec>, Dimension)> for RectArray { + fn from(other: (Vec>, Dimension)) -> Self { let mut_arr: RectBuilder = other.into(); mut_arr.into() } diff --git a/rust/geoarrow/src/array/rect/builder.rs b/rust/geoarrow/src/array/rect/builder.rs index 8abb52da..4136021d 100644 --- a/rust/geoarrow/src/array/rect/builder.rs +++ b/rust/geoarrow/src/array/rect/builder.rs @@ -1,5 +1,6 @@ use crate::array::metadata::ArrayMetadata; use crate::array::{RectArray, SeparatedCoordBufferBuilder}; +use crate::datatypes::Dimension; use crate::error::GeoArrowError; use crate::scalar::Rect; use crate::trait_::IntoArrow; @@ -21,24 +22,28 @@ pub struct RectBuilder { impl RectBuilder { /// Creates a new empty [`RectBuilder`]. - pub fn new() -> Self { - Self::new_with_options(Default::default()) + pub fn new(dim: Dimension) -> Self { + Self::new_with_options(dim, Default::default()) } - pub fn new_with_options(metadata: Arc) -> Self { - Self::with_capacity_and_options(0, metadata) + pub fn new_with_options(dim: Dimension, metadata: Arc) -> Self { + Self::with_capacity_and_options(dim, 0, metadata) } /// Creates a new [`RectBuilder`] with a capacity. - pub fn with_capacity(capacity: usize) -> Self { - Self::with_capacity_and_options(capacity, Default::default()) + pub fn with_capacity(dim: Dimension, capacity: usize) -> Self { + Self::with_capacity_and_options(dim, capacity, Default::default()) } /// Creates a new [`RectBuilder`] with a capacity. - pub fn with_capacity_and_options(capacity: usize, metadata: Arc) -> Self { + pub fn with_capacity_and_options( + dim: Dimension, + capacity: usize, + metadata: Arc, + ) -> Self { Self { - lower: SeparatedCoordBufferBuilder::with_capacity(capacity, D.try_into().unwrap()), - upper: SeparatedCoordBufferBuilder::with_capacity(capacity, D.try_into().unwrap()), + lower: SeparatedCoordBufferBuilder::with_capacity(capacity, dim), + upper: SeparatedCoordBufferBuilder::with_capacity(capacity, dim), validity: NullBufferBuilder::new(capacity), metadata, } @@ -147,9 +152,10 @@ impl RectBuilder { /// Create this builder from a iterator of Rects. pub fn from_rects<'a>( geoms: impl ExactSizeIterator + 'a)>, + dim: Dimension, metadata: Arc, ) -> Self { - let mut mutable_array = Self::with_capacity_and_options(geoms.len(), metadata); + let mut mutable_array = Self::with_capacity_and_options(dim, geoms.len(), metadata); geoms .into_iter() .for_each(|rect| mutable_array.push_rect(Some(rect))); @@ -159,9 +165,10 @@ impl RectBuilder { /// Create this builder from a iterator of nullable Rects. pub fn from_nullable_rects<'a>( geoms: impl ExactSizeIterator + 'a)>>, + dim: Dimension, metadata: Arc, ) -> Self { - let mut mutable_array = Self::with_capacity_and_options(geoms.len(), metadata); + let mut mutable_array = Self::with_capacity_and_options(dim, geoms.len(), metadata); geoms .into_iter() .for_each(|maybe_rect| mutable_array.push_rect(maybe_rect)); @@ -171,7 +178,7 @@ impl RectBuilder { impl Default for RectBuilder { fn default() -> Self { - Self::new() + Self::new(Dimension::XY) } } @@ -195,14 +202,14 @@ impl From for RectArray { } } -impl, const D: usize> From<&[G]> for RectBuilder { - fn from(geoms: &[G]) -> Self { - RectBuilder::from_rects(geoms.iter(), Default::default()) +impl> From<(&[G], Dimension)> for RectBuilder { + fn from((geoms, dim): (&[G], Dimension)) -> Self { + RectBuilder::from_rects(geoms.iter(), dim, Default::default()) } } -impl, const D: usize> From>> for RectBuilder { - fn from(geoms: Vec>) -> Self { - RectBuilder::from_nullable_rects(geoms.iter().map(|x| x.as_ref()), Default::default()) +impl> From<(Vec>, Dimension)> for RectBuilder { + fn from((geoms, dim): (Vec>, Dimension)) -> Self { + RectBuilder::from_nullable_rects(geoms.iter().map(|x| x.as_ref()), dim, Default::default()) } } diff --git a/rust/geoarrow/src/test/point.rs b/rust/geoarrow/src/test/point.rs index e6070ca1..fb219a4f 100644 --- a/rust/geoarrow/src/test/point.rs +++ b/rust/geoarrow/src/test/point.rs @@ -6,6 +6,7 @@ use arrow_schema::{DataType, Field, Schema}; use geo::{point, Point}; use crate::array::{PointArray, PointBuilder}; +use crate::datatypes::Dimension; use crate::table::Table; use crate::test::properties; use crate::ArrayBase; @@ -31,7 +32,13 @@ pub(crate) fn p2() -> Point { pub(crate) fn point_array() -> PointArray { let geoms = vec![p0(), p1(), p2()]; - PointBuilder::from_points(geoms.iter(), Default::default(), Default::default()).finish() + PointBuilder::from_points( + geoms.iter(), + Dimension::XY, + Default::default(), + Default::default(), + ) + .finish() } struct CoordZ { diff --git a/rust/geoarrow/src/trait_.rs b/rust/geoarrow/src/trait_.rs index 469209f1..dc95d8a4 100644 --- a/rust/geoarrow/src/trait_.rs +++ b/rust/geoarrow/src/trait_.rs @@ -265,6 +265,10 @@ pub trait NativeArray: ArrayBase { /// ``` fn coord_type(&self) -> CoordType; + fn dimension(&self) -> Dimension { + self.data_type().dimension() + } + /// Converts this array to the same type of array but with the provided [CoordType]. /// /// # Examples From 2eb22b64d61aa42bc4a474d528667bf9333cd4ca Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 21:38:01 -0500 Subject: [PATCH 05/14] progress --- rust/geoarrow/src/algorithm/geo/affine_ops.rs | 45 ++----- .../src/algorithm/geo/bounding_rect.rs | 4 +- rust/geoarrow/src/algorithm/geo/center.rs | 2 +- rust/geoarrow/src/algorithm/geo/centroid.rs | 2 +- .../src/algorithm/geo/chaikin_smoothing.rs | 24 ++-- .../geoarrow/src/algorithm/geo/convex_hull.rs | 7 +- rust/geoarrow/src/algorithm/geo/densify.rs | 10 +- .../src/algorithm/geo/euclidean_length.rs | 2 +- .../src/algorithm/geo/geodesic_length.rs | 2 +- .../src/algorithm/geo/haversine_length.rs | 2 +- .../algorithm/geo/line_interpolate_point.rs | 4 +- .../src/algorithm/geo/minimum_rotated_rect.rs | 2 +- .../algorithm/geo/remove_repeated_points.rs | 9 +- rust/geoarrow/src/algorithm/geo/scale.rs | 16 +-- rust/geoarrow/src/algorithm/geo/simplify.rs | 6 +- .../geoarrow/src/algorithm/geo/simplify_vw.rs | 10 +- .../src/algorithm/geo/simplify_vw_preserve.rs | 20 +-- rust/geoarrow/src/algorithm/geo/skew.rs | 16 +-- rust/geoarrow/src/algorithm/geo/translate.rs | 11 +- .../src/algorithm/geo/vincenty_length.rs | 2 +- rust/geoarrow/src/algorithm/geos/buffer.rs | 9 +- rust/geoarrow/src/algorithm/geos/util.rs | 4 +- rust/geoarrow/src/algorithm/native/cast.rs | 120 ++++-------------- rust/geoarrow/src/algorithm/native/explode.rs | 20 ++- .../src/algorithm/native/map_coords.rs | 12 +- rust/geoarrow/src/algorithm/native/take.rs | 6 + .../src/algorithm/native/total_bounds.rs | 59 +++------ rust/geoarrow/src/algorithm/native/unary.rs | 25 +++- rust/geoarrow/src/algorithm/polylabel.rs | 2 +- rust/geoarrow/src/algorithm/proj.rs | 11 +- rust/geoarrow/src/io/geozero/array/dynamic.rs | 43 ++----- .../io/geozero/array/geometrycollection.rs | 2 +- .../src/io/geozero/array/linestring.rs | 23 ++-- rust/geoarrow/src/io/geozero/array/mixed.rs | 60 ++++++--- .../src/io/geozero/array/multilinestring.rs | 35 +++-- .../src/io/geozero/array/multipoint.rs | 23 ++-- .../src/io/geozero/array/multipolygon.rs | 29 +++-- rust/geoarrow/src/io/geozero/array/point.rs | 24 ++-- rust/geoarrow/src/io/geozero/array/polygon.rs | 23 ++-- .../src/io/geozero/scalar/geometry.rs | 7 +- .../src/io/geozero/scalar/geometry_array.rs | 42 +++--- .../src/io/geozero/table/builder/table.rs | 18 ++- .../src/io/geozero/table/data_source.rs | 66 +++------- rust/geoarrow/src/io/shapefile/reader.rs | 13 +- 44 files changed, 384 insertions(+), 488 deletions(-) diff --git a/rust/geoarrow/src/algorithm/geo/affine_ops.rs b/rust/geoarrow/src/algorithm/geo/affine_ops.rs index 12808eed..45c23134 100644 --- a/rust/geoarrow/src/algorithm/geo/affine_ops.rs +++ b/rust/geoarrow/src/algorithm/geo/affine_ops.rs @@ -58,7 +58,7 @@ impl AffineOps<&AffineTransform> for PointArray { type Output = Self; fn affine_transform(&self, transform: &AffineTransform) -> Self::Output { - let mut output_array = PointBuilder::with_capacity(self.buffer_lengths()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo().for_each(|maybe_g| { output_array.push_point( @@ -79,7 +79,8 @@ macro_rules! iter_geo_impl { type Output = Self; fn affine_transform(&self, transform: &AffineTransform) -> Self::Output { - let mut output_array = <$builder_type>::with_capacity(self.buffer_lengths()); + let mut output_array = + <$builder_type>::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo().for_each(|maybe_g| { output_array @@ -105,16 +106,8 @@ iter_geo_impl!( MultiLineStringBuilder, push_multi_line_string ); -iter_geo_impl!( - MultiPolygonArray, - MultiPolygonBuilder, - push_multi_polygon -); -iter_geo_impl!( - MixedGeometryArray, - MixedGeometryBuilder, - push_geometry -); +iter_geo_impl!(MultiPolygonArray, MultiPolygonBuilder, push_multi_polygon); +iter_geo_impl!(MixedGeometryArray, MixedGeometryBuilder, push_geometry); iter_geo_impl!( GeometryCollectionArray, GeometryCollectionBuilder, @@ -218,7 +211,7 @@ impl AffineOps<&[AffineTransform]> for PointArray { type Output = Self; fn affine_transform(&self, transform: &[AffineTransform]) -> Self::Output { - let mut output_array = PointBuilder::with_capacity(self.buffer_lengths()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo() .zip(transform.iter()) @@ -241,7 +234,8 @@ macro_rules! iter_geo_impl2 { type Output = Self; fn affine_transform(&self, transform: &[AffineTransform]) -> Self::Output { - let mut output_array = <$builder_type>::with_capacity(self.buffer_lengths()); + let mut output_array = + <$builder_type>::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo() .zip(transform.iter()) @@ -269,16 +263,8 @@ iter_geo_impl2!( MultiLineStringBuilder, push_multi_line_string ); -iter_geo_impl2!( - MultiPolygonArray, - MultiPolygonBuilder, - push_multi_polygon -); -iter_geo_impl2!( - MixedGeometryArray, - MixedGeometryBuilder, - push_geometry -); +iter_geo_impl2!(MultiPolygonArray, MultiPolygonBuilder, push_multi_polygon); +iter_geo_impl2!(MixedGeometryArray, MixedGeometryBuilder, push_geometry); iter_geo_impl2!( GeometryCollectionArray, GeometryCollectionBuilder, @@ -300,14 +286,11 @@ impl AffineOps<&[AffineTransform]> for &dyn NativeArray { MultiLineString(_, XY) => { Arc::new(self.as_multi_line_string().affine_transform(transform)) } - MultiPolygon(_, XY) => { - Arc::new(self.as_multi_polygon().affine_transform(transform)) - } + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().affine_transform(transform)), Mixed(_, XY) => Arc::new(self.as_mixed().affine_transform(transform)), - GeometryCollection(_, XY) => Arc::new( - self.as_geometry_collection() - .affine_transform(transform), - ), + GeometryCollection(_, XY) => { + Arc::new(self.as_geometry_collection().affine_transform(transform)) + } _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) diff --git a/rust/geoarrow/src/algorithm/geo/bounding_rect.rs b/rust/geoarrow/src/algorithm/geo/bounding_rect.rs index c5c09787..509b5b68 100644 --- a/rust/geoarrow/src/algorithm/geo/bounding_rect.rs +++ b/rust/geoarrow/src/algorithm/geo/bounding_rect.rs @@ -44,7 +44,7 @@ impl BoundingRect for PointArray { .map(|maybe_g| maybe_g.map(|geom| geom.bounding_rect())) .collect(); - output_geoms.into() + (output_geoms, Dimension::XY).into() } } @@ -60,7 +60,7 @@ macro_rules! iter_geo_impl { .map(|maybe_g| maybe_g.and_then(|geom| geom.bounding_rect())) .collect(); - output_geoms.into() + (output_geoms, Dimension::XY).into() } } }; diff --git a/rust/geoarrow/src/algorithm/geo/center.rs b/rust/geoarrow/src/algorithm/geo/center.rs index 5aa7f10e..a2fffd53 100644 --- a/rust/geoarrow/src/algorithm/geo/center.rs +++ b/rust/geoarrow/src/algorithm/geo/center.rs @@ -30,7 +30,7 @@ macro_rules! iter_geo_impl { type Output = PointArray; fn center(&self) -> Self::Output { - let mut output_array = PointBuilder::with_capacity(self.len()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.len()); self.iter_geo().for_each(|maybe_g| { output_array.push_coord( maybe_g diff --git a/rust/geoarrow/src/algorithm/geo/centroid.rs b/rust/geoarrow/src/algorithm/geo/centroid.rs index 52d0dcc5..1e8f8224 100644 --- a/rust/geoarrow/src/algorithm/geo/centroid.rs +++ b/rust/geoarrow/src/algorithm/geo/centroid.rs @@ -79,7 +79,7 @@ macro_rules! iter_geo_impl { type Output = PointArray; fn centroid(&self) -> Self::Output { - let mut output_array = PointBuilder::with_capacity(self.len()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.len()); self.iter_geo().for_each(|maybe_g| { output_array.push_point(maybe_g.and_then(|g| g.centroid()).as_ref()) }); diff --git a/rust/geoarrow/src/algorithm/geo/chaikin_smoothing.rs b/rust/geoarrow/src/algorithm/geo/chaikin_smoothing.rs index 0fc85e48..2a97a629 100644 --- a/rust/geoarrow/src/algorithm/geo/chaikin_smoothing.rs +++ b/rust/geoarrow/src/algorithm/geo/chaikin_smoothing.rs @@ -40,7 +40,7 @@ macro_rules! iter_geo_impl { }) .collect(); - output_geoms.into() + (output_geoms, Dimension::XY).into() } } }; @@ -59,14 +59,11 @@ impl ChaikinSmoothing for &dyn NativeArray { use NativeType::*; let result: Arc = match self.data_type() { - LineString(_, XY) => { - Arc::new(self.as_line_string().chaikin_smoothing(n_iterations)) - } + LineString(_, XY) => Arc::new(self.as_line_string().chaikin_smoothing(n_iterations)), Polygon(_, XY) => Arc::new(self.as_polygon().chaikin_smoothing(n_iterations)), - MultiLineString(_, XY) => Arc::new( - self.as_multi_line_string() - .chaikin_smoothing(n_iterations), - ), + MultiLineString(_, XY) => { + Arc::new(self.as_multi_line_string().chaikin_smoothing(n_iterations)) + } MultiPolygon(_, XY) => { Arc::new(self.as_multi_polygon().chaikin_smoothing(n_iterations)) } @@ -103,14 +100,11 @@ impl ChaikinSmoothing for &dyn ChunkedNativeArray { use NativeType::*; let result: Arc = match self.data_type() { - LineString(_, XY) => { - Arc::new(self.as_line_string().chaikin_smoothing(n_iterations)) - } + LineString(_, XY) => Arc::new(self.as_line_string().chaikin_smoothing(n_iterations)), Polygon(_, XY) => Arc::new(self.as_polygon().chaikin_smoothing(n_iterations)), - MultiLineString(_, XY) => Arc::new( - self.as_multi_line_string() - .chaikin_smoothing(n_iterations), - ), + MultiLineString(_, XY) => { + Arc::new(self.as_multi_line_string().chaikin_smoothing(n_iterations)) + } MultiPolygon(_, XY) => { Arc::new(self.as_multi_polygon().chaikin_smoothing(n_iterations)) } diff --git a/rust/geoarrow/src/algorithm/geo/convex_hull.rs b/rust/geoarrow/src/algorithm/geo/convex_hull.rs index 9def42e0..6185d72b 100644 --- a/rust/geoarrow/src/algorithm/geo/convex_hull.rs +++ b/rust/geoarrow/src/algorithm/geo/convex_hull.rs @@ -61,7 +61,7 @@ macro_rules! iter_geo_impl { .map(|maybe_g| maybe_g.map(|geom| geom.convex_hull())) .collect(); - output_geoms.into() + (output_geoms, Dimension::XY).into() } } }; @@ -136,6 +136,7 @@ mod tests { use super::ConvexHull; use crate::array::polygon::PolygonArray; use crate::array::{LineStringArray, MultiPointArray}; + use crate::datatypes::Dimension; use crate::trait_::ArrayAccessor; use geo::{line_string, polygon, MultiPoint, Point}; @@ -154,7 +155,7 @@ mod tests { Point::new(0.0, 10.0), ] .into(); - let input_array: MultiPointArray = vec![input_geom].as_slice().into(); + let input_array: MultiPointArray = (vec![input_geom].as_slice(), Dimension::XY).into(); let result_array: PolygonArray = input_array.convex_hull(); let expected = polygon![ @@ -182,7 +183,7 @@ mod tests { (x: 0.0, y: 10.0), ]; - let input_array: LineStringArray = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = (vec![input_geom].as_slice(), Dimension::XY).into(); let result_array: PolygonArray = input_array.convex_hull(); let expected = polygon![ diff --git a/rust/geoarrow/src/algorithm/geo/densify.rs b/rust/geoarrow/src/algorithm/geo/densify.rs index 91d7eade..e95aa190 100644 --- a/rust/geoarrow/src/algorithm/geo/densify.rs +++ b/rust/geoarrow/src/algorithm/geo/densify.rs @@ -42,7 +42,7 @@ macro_rules! iter_geo_impl { .map(|maybe_g| maybe_g.map(|geom| geom.densify(max_distance))) .collect(); - output_geoms.into() + (output_geoms, Dimension::XY).into() } } }; @@ -63,9 +63,7 @@ impl Densify for &dyn NativeArray { let result: Arc = match self.data_type() { LineString(_, XY) => Arc::new(self.as_line_string().densify(max_distance)), Polygon(_, XY) => Arc::new(self.as_polygon().densify(max_distance)), - MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string().densify(max_distance)) - } + MultiLineString(_, XY) => Arc::new(self.as_multi_line_string().densify(max_distance)), MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().densify(max_distance)), _ => return Err(GeoArrowError::IncorrectType("".into())), }; @@ -102,9 +100,7 @@ impl Densify for &dyn ChunkedNativeArray { let result: Arc = match self.data_type() { LineString(_, XY) => Arc::new(self.as_line_string().densify(max_distance)), Polygon(_, XY) => Arc::new(self.as_polygon().densify(max_distance)), - MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string().densify(max_distance)) - } + MultiLineString(_, XY) => Arc::new(self.as_multi_line_string().densify(max_distance)), MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().densify(max_distance)), _ => return Err(GeoArrowError::IncorrectType("".into())), }; diff --git a/rust/geoarrow/src/algorithm/geo/euclidean_length.rs b/rust/geoarrow/src/algorithm/geo/euclidean_length.rs index 2c3c13eb..744a12bb 100644 --- a/rust/geoarrow/src/algorithm/geo/euclidean_length.rs +++ b/rust/geoarrow/src/algorithm/geo/euclidean_length.rs @@ -166,7 +166,7 @@ mod tests { (x: 10., y: 1.), (x: 11., y: 1.) ]; - let input_array: LineStringArray = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = (vec![input_geom].as_slice(), Dimension::XY).into(); let result_array = input_array.euclidean_length(); let expected = 10.0_f64; diff --git a/rust/geoarrow/src/algorithm/geo/geodesic_length.rs b/rust/geoarrow/src/algorithm/geo/geodesic_length.rs index 50811f8f..873fe83a 100644 --- a/rust/geoarrow/src/algorithm/geo/geodesic_length.rs +++ b/rust/geoarrow/src/algorithm/geo/geodesic_length.rs @@ -174,7 +174,7 @@ mod tests { // Osaka (x: 135.5244559, y: 34.687455), ]; - let input_array: LineStringArray = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = (vec![input_geom].as_slice(), Dimension::XY).into(); let result_array = input_array.geodesic_length(); // Meters diff --git a/rust/geoarrow/src/algorithm/geo/haversine_length.rs b/rust/geoarrow/src/algorithm/geo/haversine_length.rs index 4db3232b..7bdd0ead 100644 --- a/rust/geoarrow/src/algorithm/geo/haversine_length.rs +++ b/rust/geoarrow/src/algorithm/geo/haversine_length.rs @@ -166,7 +166,7 @@ mod tests { // London (x: -0.1278, y: 51.5074), ]; - let input_array: LineStringArray = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = (vec![input_geom].as_slice(), Dimension::XY).into(); let result_array = input_array.haversine_length(); // Meters diff --git a/rust/geoarrow/src/algorithm/geo/line_interpolate_point.rs b/rust/geoarrow/src/algorithm/geo/line_interpolate_point.rs index 18dd289d..201d4600 100644 --- a/rust/geoarrow/src/algorithm/geo/line_interpolate_point.rs +++ b/rust/geoarrow/src/algorithm/geo/line_interpolate_point.rs @@ -47,7 +47,7 @@ impl LineInterpolatePoint<&Float64Array> for LineStringArray { type Output = PointArray; fn line_interpolate_point(&self, p: &Float64Array) -> Self::Output { - let mut output_array = PointBuilder::with_capacity(self.len()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.len()); self.iter_geo() .zip(p) @@ -108,7 +108,7 @@ impl LineInterpolatePoint for LineStringArray { type Output = PointArray; fn line_interpolate_point(&self, p: f64) -> Self::Output { - let mut output_array = PointBuilder::with_capacity(self.len()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.len()); self.iter_geo().for_each(|maybe_line_string| { if let Some(line_string) = maybe_line_string { diff --git a/rust/geoarrow/src/algorithm/geo/minimum_rotated_rect.rs b/rust/geoarrow/src/algorithm/geo/minimum_rotated_rect.rs index bc941aff..3249e7ee 100644 --- a/rust/geoarrow/src/algorithm/geo/minimum_rotated_rect.rs +++ b/rust/geoarrow/src/algorithm/geo/minimum_rotated_rect.rs @@ -55,7 +55,7 @@ macro_rules! iter_geo_impl { let capacity = PolygonCapacity::new(coord_capacity, ring_capacity, geom_capacity); - let mut output_array = PolygonBuilder::with_capacity(capacity); + let mut output_array = PolygonBuilder::with_capacity(Dimension::XY, capacity); self.iter_geo().for_each(|maybe_g| { output_array diff --git a/rust/geoarrow/src/algorithm/geo/remove_repeated_points.rs b/rust/geoarrow/src/algorithm/geo/remove_repeated_points.rs index 847618bc..43c7d722 100644 --- a/rust/geoarrow/src/algorithm/geo/remove_repeated_points.rs +++ b/rust/geoarrow/src/algorithm/geo/remove_repeated_points.rs @@ -41,7 +41,8 @@ macro_rules! iter_geo_impl { type Output = Self; fn remove_repeated_points(&self) -> Self::Output { - let mut output_array = <$builder_type>::with_capacity(self.buffer_lengths()); + let mut output_array = + <$builder_type>::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo().for_each(|maybe_g| { output_array @@ -63,11 +64,7 @@ iter_geo_impl!( MultiLineStringBuilder, push_multi_line_string ); -iter_geo_impl!( - MultiPolygonArray, - MultiPolygonBuilder, - push_multi_polygon -); +iter_geo_impl!(MultiPolygonArray, MultiPolygonBuilder, push_multi_polygon); // iter_geo_impl!(MixedGeometryArray, MixedGeometryBuilder, push_geometry); // iter_geo_impl!(GeometryCollectionArray, geo::GeometryCollection); diff --git a/rust/geoarrow/src/algorithm/geo/scale.rs b/rust/geoarrow/src/algorithm/geo/scale.rs index 25e7d615..22730533 100644 --- a/rust/geoarrow/src/algorithm/geo/scale.rs +++ b/rust/geoarrow/src/algorithm/geo/scale.rs @@ -108,7 +108,7 @@ impl Scale for PointArray { x_factor: &BroadcastablePrimitive, y_factor: &BroadcastablePrimitive, ) -> Self { - let mut output_array = PointBuilder::with_capacity(self.buffer_lengths()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo() .zip(x_factor) @@ -130,7 +130,7 @@ impl Scale for PointArray { y_factor: &BroadcastablePrimitive, origin: geo::Point, ) -> Self { - let mut output_array = PointBuilder::with_capacity(self.buffer_lengths()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo() .zip(x_factor) @@ -160,7 +160,8 @@ macro_rules! iter_geo_impl { x_factor: &BroadcastablePrimitive, y_factor: &BroadcastablePrimitive, ) -> Self { - let mut output_array = <$builder_type>::with_capacity(self.buffer_lengths()); + let mut output_array = + <$builder_type>::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo().zip(x_factor).zip(y_factor).for_each( |((maybe_g, x_factor), y_factor)| { @@ -183,7 +184,8 @@ macro_rules! iter_geo_impl { y_factor: &BroadcastablePrimitive, origin: geo::Point, ) -> Self { - let mut output_array = <$builder_type>::with_capacity(self.buffer_lengths()); + let mut output_array = + <$builder_type>::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo().zip(x_factor).zip(y_factor).for_each( |((maybe_g, x_factor), y_factor)| { @@ -217,11 +219,7 @@ iter_geo_impl!( MultiLineStringBuilder, push_multi_line_string ); -iter_geo_impl!( - MultiPolygonArray, - MultiPolygonBuilder, - push_multi_polygon -); +iter_geo_impl!(MultiPolygonArray, MultiPolygonBuilder, push_multi_polygon); impl Scale for &dyn NativeArray { type Output = Result>; diff --git a/rust/geoarrow/src/algorithm/geo/simplify.rs b/rust/geoarrow/src/algorithm/geo/simplify.rs index d96328da..7c363705 100644 --- a/rust/geoarrow/src/algorithm/geo/simplify.rs +++ b/rust/geoarrow/src/algorithm/geo/simplify.rs @@ -82,7 +82,7 @@ macro_rules! iter_geo_impl { .map(|maybe_g| maybe_g.map(|geom| geom.simplify(epsilon))) .collect(); - output_geoms.into() + (output_geoms, Dimension::XY).into() } } }; @@ -186,7 +186,7 @@ mod tests { (x: 17.3, y: 3.2 ), (x: 27.8, y: 0.1 ), ]; - let input_array: LineStringArray = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = (vec![input_geom].as_slice(), Dimension::XY).into(); let result_array = input_array.simplify(&1.0); let expected = line_string![ @@ -209,7 +209,7 @@ mod tests { (x: 10., y: 0.), (x: 0., y: 0.), ]; - let input_array: PolygonArray = vec![input_geom].as_slice().into(); + let input_array: PolygonArray = (vec![input_geom].as_slice(), Dimension::XY).into(); let result_array = input_array.simplify(&2.0); let expected = polygon![ diff --git a/rust/geoarrow/src/algorithm/geo/simplify_vw.rs b/rust/geoarrow/src/algorithm/geo/simplify_vw.rs index f94defa8..d3a256fc 100644 --- a/rust/geoarrow/src/algorithm/geo/simplify_vw.rs +++ b/rust/geoarrow/src/algorithm/geo/simplify_vw.rs @@ -80,7 +80,7 @@ macro_rules! iter_geo_impl { .map(|maybe_g| maybe_g.map(|geom| geom.simplify_vw(epsilon))) .collect(); - output_geoms.into() + (output_geoms, Dimension::XY).into() } } }; @@ -105,9 +105,7 @@ impl SimplifyVw for &dyn NativeArray { LineString(_, XY) => Arc::new(self.as_line_string().simplify_vw(epsilon)), Polygon(_, XY) => Arc::new(self.as_polygon().simplify_vw(epsilon)), MultiPoint(_, XY) => Arc::new(self.as_multi_point().simplify_vw(epsilon)), - MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string().simplify_vw(epsilon)) - } + MultiLineString(_, XY) => Arc::new(self.as_multi_line_string().simplify_vw(epsilon)), MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().simplify_vw(epsilon)), // Mixed(_, XY) => self.as_mixed().simplify_vw(epsilon), // GeometryCollection(_, XY) => self.as_geometry_collection().simplify_vw(), @@ -160,9 +158,7 @@ impl SimplifyVw for &dyn ChunkedNativeArray { LineString(_, XY) => Arc::new(self.as_line_string().simplify_vw(epsilon)), Polygon(_, XY) => Arc::new(self.as_polygon().simplify_vw(epsilon)), MultiPoint(_, XY) => Arc::new(self.as_multi_point().simplify_vw(epsilon)), - MultiLineString(_, XY) => { - Arc::new(self.as_multi_line_string().simplify_vw(epsilon)) - } + MultiLineString(_, XY) => Arc::new(self.as_multi_line_string().simplify_vw(epsilon)), MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().simplify_vw(epsilon)), // Mixed(_, XY) => self.as_mixed().simplify_vw(epsilon), // GeometryCollection(_, XY) => self.as_geometry_collection().simplify_vw(), diff --git a/rust/geoarrow/src/algorithm/geo/simplify_vw_preserve.rs b/rust/geoarrow/src/algorithm/geo/simplify_vw_preserve.rs index c79e775f..257ebee8 100644 --- a/rust/geoarrow/src/algorithm/geo/simplify_vw_preserve.rs +++ b/rust/geoarrow/src/algorithm/geo/simplify_vw_preserve.rs @@ -74,7 +74,7 @@ macro_rules! iter_geo_impl { .map(|maybe_g| maybe_g.map(|geom| geom.simplify_vw_preserve(epsilon))) .collect(); - output_geoms.into() + (output_geoms, Dimension::XY).into() } } }; @@ -99,13 +99,10 @@ impl SimplifyVwPreserve for &dyn NativeArray { LineString(_, XY) => Arc::new(self.as_line_string().simplify_vw_preserve(epsilon)), Polygon(_, XY) => Arc::new(self.as_polygon().simplify_vw_preserve(epsilon)), MultiPoint(_, XY) => Arc::new(self.as_multi_point().simplify_vw_preserve(epsilon)), - MultiLineString(_, XY) => Arc::new( - self.as_multi_line_string() - .simplify_vw_preserve(epsilon), - ), - MultiPolygon(_, XY) => { - Arc::new(self.as_multi_polygon().simplify_vw_preserve(epsilon)) + MultiLineString(_, XY) => { + Arc::new(self.as_multi_line_string().simplify_vw_preserve(epsilon)) } + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().simplify_vw_preserve(epsilon)), // Mixed(_, XY) => self.as_mixed().simplify_vw_preserve(epsilon), // GeometryCollection(_, XY) => self.as_geometry_collection().simplify_vw_preserve(), _ => return Err(GeoArrowError::IncorrectType("".into())), @@ -157,13 +154,10 @@ impl SimplifyVwPreserve for &dyn ChunkedNativeArray { LineString(_, XY) => Arc::new(self.as_line_string().simplify_vw_preserve(epsilon)), Polygon(_, XY) => Arc::new(self.as_polygon().simplify_vw_preserve(epsilon)), MultiPoint(_, XY) => Arc::new(self.as_multi_point().simplify_vw_preserve(epsilon)), - MultiLineString(_, XY) => Arc::new( - self.as_multi_line_string() - .simplify_vw_preserve(epsilon), - ), - MultiPolygon(_, XY) => { - Arc::new(self.as_multi_polygon().simplify_vw_preserve(epsilon)) + MultiLineString(_, XY) => { + Arc::new(self.as_multi_line_string().simplify_vw_preserve(epsilon)) } + MultiPolygon(_, XY) => Arc::new(self.as_multi_polygon().simplify_vw_preserve(epsilon)), // Mixed(_, XY) => self.as_mixed().simplify_vw_preserve(epsilon), // GeometryCollection(_, XY) => self.as_geometry_collection().simplify_vw_preserve(), _ => return Err(GeoArrowError::IncorrectType("".into())), diff --git a/rust/geoarrow/src/algorithm/geo/skew.rs b/rust/geoarrow/src/algorithm/geo/skew.rs index 1de7d3d8..7ac84aca 100644 --- a/rust/geoarrow/src/algorithm/geo/skew.rs +++ b/rust/geoarrow/src/algorithm/geo/skew.rs @@ -134,7 +134,7 @@ impl Skew for PointArray { x_factor: &BroadcastablePrimitive, y_factor: &BroadcastablePrimitive, ) -> Self { - let mut output_array = PointBuilder::with_capacity(self.buffer_lengths()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo() .zip(x_factor) @@ -156,7 +156,7 @@ impl Skew for PointArray { y_factor: &BroadcastablePrimitive, origin: geo::Point, ) -> Self { - let mut output_array = PointBuilder::with_capacity(self.buffer_lengths()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo() .zip(x_factor) @@ -186,7 +186,8 @@ macro_rules! iter_geo_impl { x_factor: &BroadcastablePrimitive, y_factor: &BroadcastablePrimitive, ) -> Self { - let mut output_array = <$builder_type>::with_capacity(self.buffer_lengths()); + let mut output_array = + <$builder_type>::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo().zip(x_factor).zip(y_factor).for_each( |((maybe_g, x_factor), y_factor)| { @@ -209,7 +210,8 @@ macro_rules! iter_geo_impl { y_factor: &BroadcastablePrimitive, origin: geo::Point, ) -> Self { - let mut output_array = <$builder_type>::with_capacity(self.buffer_lengths()); + let mut output_array = + <$builder_type>::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo().zip(x_factor).zip(y_factor).for_each( |((maybe_g, x_factor), y_factor)| { @@ -243,11 +245,7 @@ iter_geo_impl!( MultiLineStringBuilder, push_multi_line_string ); -iter_geo_impl!( - MultiPolygonArray, - MultiPolygonBuilder, - push_multi_polygon -); +iter_geo_impl!(MultiPolygonArray, MultiPolygonBuilder, push_multi_polygon); impl Skew for &dyn NativeArray { type Output = Result>; diff --git a/rust/geoarrow/src/algorithm/geo/translate.rs b/rust/geoarrow/src/algorithm/geo/translate.rs index 7d15ab71..a5431400 100644 --- a/rust/geoarrow/src/algorithm/geo/translate.rs +++ b/rust/geoarrow/src/algorithm/geo/translate.rs @@ -60,7 +60,7 @@ impl Translate for PointArray { x_offset: &BroadcastablePrimitive, y_offset: &BroadcastablePrimitive, ) -> Self { - let mut output_array = PointBuilder::with_capacity(self.buffer_lengths()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo() .zip(x_offset) @@ -88,7 +88,8 @@ macro_rules! iter_geo_impl { x_offset: &BroadcastablePrimitive, y_offset: &BroadcastablePrimitive, ) -> Self { - let mut output_array = <$builder_type>::with_capacity(self.buffer_lengths()); + let mut output_array = + <$builder_type>::with_capacity(Dimension::XY, self.buffer_lengths()); self.iter_geo().zip(x_offset).zip(y_offset).for_each( |((maybe_g, x_offset), y_offset)| { @@ -118,11 +119,7 @@ iter_geo_impl!( MultiLineStringBuilder, push_multi_line_string ); -iter_geo_impl!( - MultiPolygonArray, - MultiPolygonBuilder, - push_multi_polygon -); +iter_geo_impl!(MultiPolygonArray, MultiPolygonBuilder, push_multi_polygon); impl Translate for &dyn NativeArray { type Output = Result>; diff --git a/rust/geoarrow/src/algorithm/geo/vincenty_length.rs b/rust/geoarrow/src/algorithm/geo/vincenty_length.rs index eb2f11ef..2ef83d52 100644 --- a/rust/geoarrow/src/algorithm/geo/vincenty_length.rs +++ b/rust/geoarrow/src/algorithm/geo/vincenty_length.rs @@ -164,7 +164,7 @@ mod tests { // London (x: -0.1278, y: 51.5074), ]; - let input_array: LineStringArray = vec![input_geom].as_slice().into(); + let input_array: LineStringArray = (vec![input_geom].as_slice(), Dimension::XY).into(); let result_array = input_array.vincenty_length().unwrap(); // Meters diff --git a/rust/geoarrow/src/algorithm/geos/buffer.rs b/rust/geoarrow/src/algorithm/geos/buffer.rs index 32829a9c..1b64241a 100644 --- a/rust/geoarrow/src/algorithm/geos/buffer.rs +++ b/rust/geoarrow/src/algorithm/geos/buffer.rs @@ -1,6 +1,7 @@ use crate::algorithm::geos::util::try_unary_polygon; use crate::array::{PointArray, PolygonArray}; use crate::error::Result; +use crate::NativeArray; use geos::{BufferParams, Geom}; pub trait Buffer { @@ -15,11 +16,15 @@ impl Buffer for PointArray { type Output = Result; fn buffer(&self, width: f64, quadsegs: i32) -> Self::Output { - try_unary_polygon(self, |g| g.buffer(width, quadsegs)) + try_unary_polygon(self, |g| g.buffer(width, quadsegs), self.dimension()) } fn buffer_with_params(&self, width: f64, buffer_params: &BufferParams) -> Self::Output { - try_unary_polygon(self, |g| g.buffer_with_params(width, buffer_params)) + try_unary_polygon( + self, + |g| g.buffer_with_params(width, buffer_params), + self.dimension(), + ) } } diff --git a/rust/geoarrow/src/algorithm/geos/util.rs b/rust/geoarrow/src/algorithm/geos/util.rs index 3c56d11a..84e12d9e 100644 --- a/rust/geoarrow/src/algorithm/geos/util.rs +++ b/rust/geoarrow/src/algorithm/geos/util.rs @@ -2,6 +2,7 @@ use arrow_array::{ArrowPrimitiveType, PrimitiveArray}; use arrow_buffer::BufferBuilder; use crate::array::PolygonArray; +use crate::datatypes::Dimension; use crate::error::GeoArrowError; use crate::io::geos::scalar::GEOSPolygon; use crate::trait_::NativeGEOSGeometryAccessor; @@ -42,6 +43,7 @@ where pub(super) fn try_unary_polygon<'a, F>( array: &'a dyn NativeGEOSGeometryAccessor<'a>, op: F, + output_dim: Dimension, ) -> std::result::Result where F: Fn(geos::Geometry) -> std::result::Result, @@ -65,5 +67,5 @@ where None => (0..len).try_for_each(f)?, } - Ok(PolygonArray::from(buffer)) + Ok(PolygonArray::from((buffer, output_dim))) } diff --git a/rust/geoarrow/src/algorithm/native/cast.rs b/rust/geoarrow/src/algorithm/native/cast.rs index e005c692..0599b673 100644 --- a/rust/geoarrow/src/algorithm/native/cast.rs +++ b/rust/geoarrow/src/algorithm/native/cast.rs @@ -228,26 +228,17 @@ impl Cast for &dyn NativeArray { // return Ok(Arc::new(self.to_owned())); // } - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_ref().as_point().cast(to_type), - LineString(_, XY) => self.as_ref().as_line_string().cast(to_type), - Polygon(_, XY) => self.as_ref().as_polygon().cast(to_type), - MultiPoint(_, XY) => self.as_ref().as_multi_point().cast(to_type), - MultiLineString(_, XY) => self.as_ref().as_multi_line_string().cast(to_type), - MultiPolygon(_, XY) => self.as_ref().as_multi_polygon().cast(to_type), - Mixed(_, XY) => self.as_ref().as_mixed().cast(to_type), - GeometryCollection(_, XY) => self.as_ref().as_geometry_collection().cast(to_type), - Point(_, XYZ) => self.as_ref().as_point().cast(to_type), - LineString(_, XYZ) => self.as_ref().as_line_string().cast(to_type), - Polygon(_, XYZ) => self.as_ref().as_polygon().cast(to_type), - MultiPoint(_, XYZ) => self.as_ref().as_multi_point().cast(to_type), - MultiLineString(_, XYZ) => self.as_ref().as_multi_line_string().cast(to_type), - MultiPolygon(_, XYZ) => self.as_ref().as_multi_polygon().cast(to_type), - Mixed(_, XYZ) => self.as_ref().as_mixed().cast(to_type), - GeometryCollection(_, XYZ) => self.as_ref().as_geometry_collection().cast(to_type), + Point(_, _) => self.as_ref().as_point().cast(to_type), + LineString(_, _) => self.as_ref().as_line_string().cast(to_type), + Polygon(_, _) => self.as_ref().as_polygon().cast(to_type), + MultiPoint(_, _) => self.as_ref().as_multi_point().cast(to_type), + MultiLineString(_, _) => self.as_ref().as_multi_line_string().cast(to_type), + MultiPolygon(_, _) => self.as_ref().as_multi_polygon().cast(to_type), + Mixed(_, _) => self.as_ref().as_mixed().cast(to_type), + GeometryCollection(_, _) => self.as_ref().as_geometry_collection().cast(to_type), _ => todo!(), } } @@ -270,45 +261,20 @@ macro_rules! impl_chunked_cast_non_generic { .collect::>>()?, )) }; - ($method:ident, $dim:expr) => { - Arc::new(ChunkedGeometryArray::new( - self.geometry_chunks() - .iter() - .map(|chunk| { - Ok(chunk - .as_ref() - .cast(to_type)? - .as_ref() - .$method::<$dim>() - .clone()) - }) - .collect::>>()?, - )) - }; } - use Dimension::*; use NativeType::*; let result: Arc = match to_type { - Point(_, XY) => impl_cast!(as_point, 2), - LineString(_, XY) => impl_cast!(as_line_string, 2), - Polygon(_, XY) => impl_cast!(as_polygon, 2), - MultiPoint(_, XY) => impl_cast!(as_multi_point, 2), - MultiLineString(_, XY) => impl_cast!(as_multi_line_string, 2), - MultiPolygon(_, XY) => impl_cast!(as_multi_polygon, 2), - Mixed(_, XY) => impl_cast!(as_mixed, 2), - GeometryCollection(_, XY) => impl_cast!(as_geometry_collection, 2), - Point(_, XYZ) => impl_cast!(as_point, 3), - LineString(_, XYZ) => impl_cast!(as_line_string, 3), - Polygon(_, XYZ) => impl_cast!(as_polygon, 3), - MultiPoint(_, XYZ) => impl_cast!(as_multi_point, 3), - MultiLineString(_, XYZ) => impl_cast!(as_multi_line_string, 3), - MultiPolygon(_, XYZ) => impl_cast!(as_multi_polygon, 3), - Mixed(_, XYZ) => impl_cast!(as_mixed, 3), - GeometryCollection(_, XYZ) => impl_cast!(as_geometry_collection, 3), - Rect(XY) => impl_cast!(as_rect, 2), - Rect(XYZ) => impl_cast!(as_rect, 3), + Point(_, _) => impl_cast!(as_point), + LineString(_, _) => impl_cast!(as_line_string), + Polygon(_, _) => impl_cast!(as_polygon), + MultiPoint(_, _) => impl_cast!(as_multi_point), + MultiLineString(_, _) => impl_cast!(as_multi_line_string), + MultiPolygon(_, _) => impl_cast!(as_multi_polygon), + Mixed(_, _) => impl_cast!(as_mixed), + GeometryCollection(_, _) => impl_cast!(as_geometry_collection), + Rect(_) => impl_cast!(as_rect), }; Ok(result) } @@ -333,45 +299,20 @@ macro_rules! impl_chunked_cast_generic { .collect::>>()?, )) }; - ($method:ident, $dim:expr) => { - Arc::new(ChunkedGeometryArray::new( - self.geometry_chunks() - .iter() - .map(|chunk| { - Ok(chunk - .as_ref() - .cast(to_type)? - .as_ref() - .$method::<$dim>() - .clone()) - }) - .collect::>>()?, - )) - }; } - use Dimension::*; use NativeType::*; let result: Arc = match to_type { - Point(_, XY) => impl_cast!(as_point, 2), - LineString(_, XY) => impl_cast!(as_line_string, 2), - Polygon(_, XY) => impl_cast!(as_polygon, 2), - MultiPoint(_, XY) => impl_cast!(as_multi_point, 2), - MultiLineString(_, XY) => impl_cast!(as_multi_line_string, 2), - MultiPolygon(_, XY) => impl_cast!(as_multi_polygon, 2), - Mixed(_, XY) => impl_cast!(as_mixed, 2), - GeometryCollection(_, XY) => impl_cast!(as_geometry_collection, 2), - Point(_, XYZ) => impl_cast!(as_point, 3), - LineString(_, XYZ) => impl_cast!(as_line_string, 3), - Polygon(_, XYZ) => impl_cast!(as_polygon, 3), - MultiPoint(_, XYZ) => impl_cast!(as_multi_point, 3), - MultiLineString(_, XYZ) => impl_cast!(as_multi_line_string, 3), - MultiPolygon(_, XYZ) => impl_cast!(as_multi_polygon, 3), - Mixed(_, XYZ) => impl_cast!(as_mixed, 3), - GeometryCollection(_, XYZ) => impl_cast!(as_geometry_collection, 3), - Rect(XY) => impl_cast!(as_rect, 2), - Rect(XYZ) => impl_cast!(as_rect, 3), + Point(_, _) => impl_cast!(as_point), + LineString(_, _) => impl_cast!(as_line_string), + Polygon(_, _) => impl_cast!(as_polygon), + MultiPoint(_, _) => impl_cast!(as_multi_point), + MultiLineString(_, _) => impl_cast!(as_multi_line_string), + MultiPolygon(_, _) => impl_cast!(as_multi_polygon), + Mixed(_, _) => impl_cast!(as_mixed), + GeometryCollection(_, _) => impl_cast!(as_geometry_collection), + Rect(_) => impl_cast!(as_rect), }; Ok(result) } @@ -389,12 +330,3 @@ impl_chunked_cast_generic!(ChunkedMultiLineStringArray); impl_chunked_cast_generic!(ChunkedMultiPolygonArray); impl_chunked_cast_generic!(ChunkedMixedGeometryArray); impl_chunked_cast_generic!(ChunkedGeometryCollectionArray); -impl_chunked_cast_non_generic!(ChunkedPointArray); -impl_chunked_cast_non_generic!(ChunkedRectArray); -impl_chunked_cast_generic!(ChunkedLineStringArray); -impl_chunked_cast_generic!(ChunkedPolygonArray); -impl_chunked_cast_generic!(ChunkedMultiPointArray); -impl_chunked_cast_generic!(ChunkedMultiLineStringArray); -impl_chunked_cast_generic!(ChunkedMultiPolygonArray); -impl_chunked_cast_generic!(ChunkedMixedGeometryArray); -impl_chunked_cast_generic!(ChunkedGeometryCollectionArray); diff --git a/rust/geoarrow/src/algorithm/native/explode.rs b/rust/geoarrow/src/algorithm/native/explode.rs index 11952486..ae0e0ee6 100644 --- a/rust/geoarrow/src/algorithm/native/explode.rs +++ b/rust/geoarrow/src/algorithm/native/explode.rs @@ -188,20 +188,18 @@ impl Explode for &dyn ChunkedNativeArray { )>; fn explode(&self) -> Self::Output { - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::().explode(), - LineString(_, XY) => self.as_line_string::().explode(), - Polygon(_, XY) => self.as_polygon::().explode(), - MultiPoint(_, XY) => self.as_multi_point::().explode(), - MultiLineString(_, XY) => self.as_multi_line_string::().explode(), - MultiPolygon(_, XY) => self.as_multi_polygon::().explode(), - Mixed(_, XY) => self.as_mixed::().explode(), - GeometryCollection(_, XY) => self.as_geometry_collection::().explode(), - Rect(XY) => self.as_rect::().explode(), - _ => todo!(), + Point(_, _) => self.as_point().explode(), + LineString(_, _) => self.as_line_string().explode(), + Polygon(_, _) => self.as_polygon().explode(), + MultiPoint(_, _) => self.as_multi_point().explode(), + MultiLineString(_, _) => self.as_multi_line_string().explode(), + MultiPolygon(_, _) => self.as_multi_polygon().explode(), + Mixed(_, _) => self.as_mixed().explode(), + GeometryCollection(_, _) => self.as_geometry_collection().explode(), + Rect(_) => self.as_rect().explode(), } } } diff --git a/rust/geoarrow/src/algorithm/native/map_coords.rs b/rust/geoarrow/src/algorithm/native/map_coords.rs index ff7299f6..2cca36c7 100644 --- a/rust/geoarrow/src/algorithm/native/map_coords.rs +++ b/rust/geoarrow/src/algorithm/native/map_coords.rs @@ -13,6 +13,7 @@ use geo_traits::{ MultiLineStringTrait, MultiPointTrait, MultiPolygonTrait, PolygonTrait, RectTrait, }; +/// Note: this will currently always create a _two-dimensional_ output array because it returns a [`geo::Coord`]. pub trait MapCoords { type Output; @@ -221,6 +222,7 @@ impl MapCoords for PointArray { GeoArrowError: From, { let mut builder = PointBuilder::with_capacity_and_options( + Dimension::XY, self.buffer_lengths(), self.coord_type(), self.metadata(), @@ -246,6 +248,7 @@ impl MapCoords for LineStringArray { GeoArrowError: From, { let mut builder = LineStringBuilder::with_capacity_and_options( + Dimension::XY, self.buffer_lengths(), self.coord_type(), self.metadata(), @@ -271,6 +274,7 @@ impl MapCoords for PolygonArray { GeoArrowError: From, { let mut builder = PolygonBuilder::with_capacity_and_options( + Dimension::XY, self.buffer_lengths(), self.coord_type(), self.metadata(), @@ -296,6 +300,7 @@ impl MapCoords for MultiPointArray { GeoArrowError: From, { let mut builder = MultiPointBuilder::with_capacity_and_options( + Dimension::XY, self.buffer_lengths(), self.coord_type(), self.metadata(), @@ -321,6 +326,7 @@ impl MapCoords for MultiLineStringArray { GeoArrowError: From, { let mut builder = MultiLineStringBuilder::with_capacity_and_options( + Dimension::XY, self.buffer_lengths(), self.coord_type(), self.metadata(), @@ -346,6 +352,7 @@ impl MapCoords for MultiPolygonArray { GeoArrowError: From, { let mut builder = MultiPolygonBuilder::with_capacity_and_options( + Dimension::XY, self.buffer_lengths(), self.coord_type(), self.metadata(), @@ -371,6 +378,7 @@ impl MapCoords for MixedGeometryArray { GeoArrowError: From, { let mut builder = MixedGeometryBuilder::with_capacity_and_options( + Dimension::XY, self.buffer_lengths(), self.coord_type(), self.metadata(), @@ -397,6 +405,7 @@ impl MapCoords for GeometryCollectionArray { GeoArrowError: From, { let mut builder = GeometryCollectionBuilder::with_capacity_and_options( + Dimension::XY, self.buffer_lengths(), self.coord_type(), self.metadata(), @@ -422,7 +431,8 @@ impl MapCoords for RectArray { F: Fn(&crate::scalar::Coord) -> std::result::Result + Sync, GeoArrowError: From, { - let mut builder = RectBuilder::with_capacity_and_options(self.len(), self.metadata()); + let mut builder = + RectBuilder::with_capacity_and_options(Dimension::XY, self.len(), self.metadata()); for maybe_geom in self.iter() { if let Some(geom) = maybe_geom { let result = geom.try_map_coords(&map_op)?; diff --git a/rust/geoarrow/src/algorithm/native/take.rs b/rust/geoarrow/src/algorithm/native/take.rs index ed6384fe..5e279619 100644 --- a/rust/geoarrow/src/algorithm/native/take.rs +++ b/rust/geoarrow/src/algorithm/native/take.rs @@ -25,6 +25,7 @@ impl Take for PointArray { fn take(&self, indices: &UInt32Array) -> Self::Output { let mut builder = PointBuilder::with_capacity_and_options( + self.dimension(), indices.len(), self.coord_type(), self.metadata(), @@ -42,6 +43,7 @@ impl Take for PointArray { fn take_range(&self, range: &Range) -> Self::Output { let mut builder = PointBuilder::with_capacity_and_options( + self.dimension(), range.end - range.start, self.coord_type(), self.metadata(), @@ -68,6 +70,7 @@ macro_rules! take_impl { } let mut builder = <$builder_type>::with_capacity_and_options( + self.dimension(), capacity, self.coord_type(), self.metadata(), @@ -92,6 +95,7 @@ macro_rules! take_impl { } let mut builder = <$builder_type>::with_capacity_and_options( + self.dimension(), capacity, self.coord_type(), self.metadata(), @@ -156,6 +160,7 @@ macro_rules! take_impl_fallible { } let mut builder = <$builder_type>::with_capacity_and_options( + self.dimension(), capacity, self.coord_type(), self.metadata(), @@ -181,6 +186,7 @@ macro_rules! take_impl_fallible { } let mut builder = <$builder_type>::with_capacity_and_options( + self.dimension(), capacity, self.coord_type(), self.metadata(), diff --git a/rust/geoarrow/src/algorithm/native/total_bounds.rs b/rust/geoarrow/src/algorithm/native/total_bounds.rs index bad85a0f..4e335524 100644 --- a/rust/geoarrow/src/algorithm/native/total_bounds.rs +++ b/rust/geoarrow/src/algorithm/native/total_bounds.rs @@ -1,7 +1,7 @@ use crate::algorithm::native::bounding_rect::BoundingRect; use crate::array::*; use crate::chunked_array::*; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::trait_::ArrayAccessor; use crate::NativeArray; @@ -64,28 +64,18 @@ impl_array!(GeometryCollectionArray, add_geometry_collection); impl TotalBounds for &dyn NativeArray { fn total_bounds(&self) -> BoundingRect { - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().total_bounds(), - LineString(_, XY) => self.as_line_string::<2>().total_bounds(), - Polygon(_, XY) => self.as_polygon::<2>().total_bounds(), - MultiPoint(_, XY) => self.as_multi_point::<2>().total_bounds(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().total_bounds(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().total_bounds(), - Mixed(_, XY) => self.as_mixed::<2>().total_bounds(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().total_bounds(), - Rect(XY) => self.as_rect::<2>().total_bounds(), - Point(_, XYZ) => self.as_point::<3>().total_bounds(), - LineString(_, XYZ) => self.as_line_string::<3>().total_bounds(), - Polygon(_, XYZ) => self.as_polygon::<3>().total_bounds(), - MultiPoint(_, XYZ) => self.as_multi_point::<3>().total_bounds(), - MultiLineString(_, XYZ) => self.as_multi_line_string::<3>().total_bounds(), - MultiPolygon(_, XYZ) => self.as_multi_polygon::<3>().total_bounds(), - Mixed(_, XYZ) => self.as_mixed::<3>().total_bounds(), - GeometryCollection(_, XYZ) => self.as_geometry_collection::<3>().total_bounds(), - Rect(XYZ) => self.as_rect::<3>().total_bounds(), + Point(_, _) => self.as_point().total_bounds(), + LineString(_, _) => self.as_line_string().total_bounds(), + Polygon(_, _) => self.as_polygon().total_bounds(), + MultiPoint(_, _) => self.as_multi_point().total_bounds(), + MultiLineString(_, _) => self.as_multi_line_string().total_bounds(), + MultiPolygon(_, _) => self.as_multi_polygon().total_bounds(), + Mixed(_, _) => self.as_mixed().total_bounds(), + GeometryCollection(_, _) => self.as_geometry_collection().total_bounds(), + Rect(_) => self.as_rect().total_bounds(), // WKB => self.as_wkb().total_bounds(), // LargeWKB => self.as_large_wkb().total_bounds(), } @@ -103,29 +93,18 @@ impl TotalBounds for ChunkedGeometryArray { impl TotalBounds for &dyn ChunkedNativeArray { fn total_bounds(&self) -> BoundingRect { - use Dimension::*; use NativeType::*; match self.data_type() { - Point(_, XY) => self.as_point::<2>().total_bounds(), - LineString(_, XY) => self.as_line_string::<2>().total_bounds(), - Polygon(_, XY) => self.as_polygon::<2>().total_bounds(), - MultiPoint(_, XY) => self.as_multi_point::<2>().total_bounds(), - MultiLineString(_, XY) => self.as_multi_line_string::<2>().total_bounds(), - MultiPolygon(_, XY) => self.as_multi_polygon::<2>().total_bounds(), - Mixed(_, XY) => self.as_mixed::<2>().total_bounds(), - GeometryCollection(_, XY) => self.as_geometry_collection::<2>().total_bounds(), - Rect(XY) => self.as_rect::<2>().total_bounds(), - - Point(_, XYZ) => self.as_point::<3>().total_bounds(), - LineString(_, XYZ) => self.as_line_string::<3>().total_bounds(), - Polygon(_, XYZ) => self.as_polygon::<3>().total_bounds(), - MultiPoint(_, XYZ) => self.as_multi_point::<3>().total_bounds(), - MultiLineString(_, XYZ) => self.as_multi_line_string::<3>().total_bounds(), - MultiPolygon(_, XYZ) => self.as_multi_polygon::<3>().total_bounds(), - Mixed(_, XYZ) => self.as_mixed::<3>().total_bounds(), - GeometryCollection(_, XYZ) => self.as_geometry_collection::<3>().total_bounds(), - Rect(XYZ) => self.as_rect::<3>().total_bounds(), + Point(_, _) => self.as_point().total_bounds(), + LineString(_, _) => self.as_line_string().total_bounds(), + Polygon(_, _) => self.as_polygon().total_bounds(), + MultiPoint(_, _) => self.as_multi_point().total_bounds(), + MultiLineString(_, _) => self.as_multi_line_string().total_bounds(), + MultiPolygon(_, _) => self.as_multi_polygon().total_bounds(), + Mixed(_, _) => self.as_mixed().total_bounds(), + GeometryCollection(_, _) => self.as_geometry_collection().total_bounds(), + Rect(_) => self.as_rect().total_bounds(), } } } diff --git a/rust/geoarrow/src/algorithm/native/unary.rs b/rust/geoarrow/src/algorithm/native/unary.rs index 11ea9e39..6d1eda9e 100644 --- a/rust/geoarrow/src/algorithm/native/unary.rs +++ b/rust/geoarrow/src/algorithm/native/unary.rs @@ -3,6 +3,7 @@ use arrow_array::{BooleanArray, OffsetSizeTrait, PrimitiveArray}; use arrow_buffer::{BooleanBufferBuilder, BufferBuilder}; use crate::array::*; +use crate::datatypes::Dimension; use crate::trait_::ArrayAccessor; use geo_traits::*; @@ -99,27 +100,39 @@ impl<'a, O: OffsetSizeTrait> Unary<'a> for WKBArray {} #[allow(dead_code)] pub trait UnaryPoint<'a>: ArrayAccessor<'a> + NativeArray { - fn unary_point(&'a self, op: F) -> PointArray + fn unary_point(&'a self, op: F, output_dim: Dimension) -> PointArray where G: PointTrait + 'a, F: Fn(Self::Item) -> &'a G, { let nulls = self.nulls().cloned(); let result_geom_iter = self.iter_values().map(op); - let builder = - PointBuilder::from_points(result_geom_iter, Some(self.coord_type()), self.metadata()); + let builder = PointBuilder::from_points( + result_geom_iter, + output_dim, + Some(self.coord_type()), + self.metadata(), + ); let mut result = builder.finish(); result.validity = nulls; result } - fn try_unary_point(&'a self, op: F) -> std::result::Result + fn try_unary_point( + &'a self, + op: F, + output_dim: Dimension, + ) -> std::result::Result where G: PointTrait + 'a, F: Fn(Self::Item) -> std::result::Result, { - let mut builder = - PointBuilder::with_capacity_and_options(self.len(), self.coord_type(), self.metadata()); + let mut builder = PointBuilder::with_capacity_and_options( + output_dim, + self.len(), + self.coord_type(), + self.metadata(), + ); for maybe_geom in self.iter() { if let Some(geom) = maybe_geom { diff --git a/rust/geoarrow/src/algorithm/polylabel.rs b/rust/geoarrow/src/algorithm/polylabel.rs index b3ff8de2..88846c87 100644 --- a/rust/geoarrow/src/algorithm/polylabel.rs +++ b/rust/geoarrow/src/algorithm/polylabel.rs @@ -29,7 +29,7 @@ impl Polylabel for PolygonArray { type Output = Result; fn polylabel(&self, tolerance: f64) -> Self::Output { - Ok(self.try_unary_point(|geom| polylabel(&geom.to_geo(), &tolerance))?) + Ok(self.try_unary_point(|geom| polylabel(&geom.to_geo(), &tolerance), Dimension::XY)?) } } diff --git a/rust/geoarrow/src/algorithm/proj.rs b/rust/geoarrow/src/algorithm/proj.rs index d9b65f6e..4cfb43a2 100644 --- a/rust/geoarrow/src/algorithm/proj.rs +++ b/rust/geoarrow/src/algorithm/proj.rs @@ -1,11 +1,14 @@ //! Bindings to the [`proj`] crate for coordinate reprojection. use crate::array::*; +use crate::datatypes::Dimension; use crate::error::Result; use crate::trait_::ArrayAccessor; use proj::{Proj, Transform}; /// Reproject an array using PROJ +/// +/// Note: this will currently return a two-dimensional array pub trait Reproject { fn reproject(&self, proj: &Proj) -> Result where @@ -14,7 +17,7 @@ pub trait Reproject { impl Reproject for PointArray { fn reproject(&self, proj: &Proj) -> Result { - let mut output_array = PointBuilder::with_capacity(self.len()); + let mut output_array = PointBuilder::with_capacity(Dimension::XY, self.len()); for maybe_geom in self.iter_geo() { if let Some(mut geom) = maybe_geom { @@ -33,7 +36,8 @@ macro_rules! iter_geo_impl { ($type:ty, $builder_type:ty, $push_func:ident) => { impl Reproject for $type { fn reproject(&self, proj: &Proj) -> Result { - let mut output_array = <$builder_type>::with_capacity(self.buffer_lengths()); + let mut output_array = + <$builder_type>::with_capacity(Dimension::XY, self.buffer_lengths()); for maybe_geom in self.iter_geo() { if let Some(mut geom) = maybe_geom { @@ -70,7 +74,8 @@ mod test { #[test] fn point_round_trip() { - let point_array: PointArray = vec![Some(p0()), Some(p1()), Some(p2())].into(); + let point_array: PointArray = + (vec![Some(p0()), Some(p1()), Some(p2())], Dimension::XY).into(); let proj = Proj::new_known_crs("EPSG:4326", "EPSG:3857", None).unwrap(); // You can verify this with PROJ on the command line: diff --git a/rust/geoarrow/src/io/geozero/array/dynamic.rs b/rust/geoarrow/src/io/geozero/array/dynamic.rs index afdd5cc4..28d3c025 100644 --- a/rust/geoarrow/src/io/geozero/array/dynamic.rs +++ b/rust/geoarrow/src/io/geozero/array/dynamic.rs @@ -2,7 +2,7 @@ use geozero::{GeomProcessor, GeozeroGeometry}; use crate::array::dynamic::NativeArrayDyn; use crate::array::AsNativeArray; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; impl GeozeroGeometry for NativeArrayDyn { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> @@ -10,47 +10,30 @@ impl GeozeroGeometry for NativeArrayDyn { Self: Sized, { macro_rules! impl_process { - ($cast_func:ident, $dim:expr) => {{ - let arr = self.inner().as_ref(); - arr.$cast_func::<$dim>().process_geom(processor) - }}; ($cast_func:ident) => {{ let arr = self.inner().as_ref(); arr.$cast_func().process_geom(processor) }}; } - use Dimension::*; use NativeType::*; match self.inner().data_type() { - Point(_, XY) => impl_process!(as_point, 2), - LineString(_, XY) => impl_process!(as_line_string, 2), - Polygon(_, XY) => impl_process!(as_polygon, 2), - MultiPoint(_, XY) => impl_process!(as_multi_point, 2), - MultiLineString(_, XY) => { - impl_process!(as_multi_line_string, 2) - } - MultiPolygon(_, XY) => impl_process!(as_multi_polygon, 2), - Mixed(_, XY) => impl_process!(as_mixed, 2), - GeometryCollection(_, XY) => { - impl_process!(as_geometry_collection, 2) - } - Point(_, XYZ) => impl_process!(as_point, 3), - LineString(_, XYZ) => impl_process!(as_line_string, 3), - Polygon(_, XYZ) => impl_process!(as_polygon, 3), - MultiPoint(_, XYZ) => impl_process!(as_multi_point, 3), - MultiLineString(_, XYZ) => { - impl_process!(as_multi_line_string, 3) + Point(_, _) => impl_process!(as_point), + LineString(_, _) => impl_process!(as_line_string), + Polygon(_, _) => impl_process!(as_polygon), + MultiPoint(_, _) => impl_process!(as_multi_point), + MultiLineString(_, _) => { + impl_process!(as_multi_line_string) } - MultiPolygon(_, XYZ) => impl_process!(as_multi_polygon, 3), - Mixed(_, XYZ) => impl_process!(as_mixed, 3), - GeometryCollection(_, XYZ) => { - impl_process!(as_geometry_collection, 3) + MultiPolygon(_, _) => impl_process!(as_multi_polygon), + Mixed(_, _) => impl_process!(as_mixed), + GeometryCollection(_, _) => { + impl_process!(as_geometry_collection) } _ => todo!(), // WKB => impl_process!(as_wkb), - // Rect(XY) => impl_process!(as_rect, 2) + // Rect(_) => impl_process!(as_rect) // Rect(XYZ) => impl_process!(as_rect, 3) } } @@ -71,7 +54,7 @@ mod test { fn test() { let arr = point::point_array(); let geom_arr = NativeArrayDyn::new(Arc::new(arr)); - let test = geom_arr.as_any().downcast_ref::>().unwrap(); + let test = geom_arr.as_any().downcast_ref::().unwrap(); dbg!(geom_arr.to_geo().unwrap()); dbg!(test); } diff --git a/rust/geoarrow/src/io/geozero/array/geometrycollection.rs b/rust/geoarrow/src/io/geozero/array/geometrycollection.rs index 44d000af..e0b1960c 100644 --- a/rust/geoarrow/src/io/geozero/array/geometrycollection.rs +++ b/rust/geoarrow/src/io/geozero/array/geometrycollection.rs @@ -4,7 +4,7 @@ use crate::trait_::ArrayAccessor; use crate::ArrayBase; use geozero::{GeomProcessor, GeozeroGeometry}; -impl GeozeroGeometry for GeometryCollectionArray { +impl GeozeroGeometry for GeometryCollectionArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, diff --git a/rust/geoarrow/src/io/geozero/array/linestring.rs b/rust/geoarrow/src/io/geozero/array/linestring.rs index c41ab84f..10b890d6 100644 --- a/rust/geoarrow/src/io/geozero/array/linestring.rs +++ b/rust/geoarrow/src/io/geozero/array/linestring.rs @@ -2,11 +2,12 @@ use geozero::{GeomProcessor, GeozeroGeometry}; use crate::array::linestring::LineStringCapacity; use crate::array::{LineStringArray, LineStringBuilder}; +use crate::datatypes::Dimension; use crate::io::geozero::scalar::process_line_string; use crate::trait_::ArrayAccessor; use crate::ArrayBase; -impl GeozeroGeometry for LineStringArray { +impl GeozeroGeometry for LineStringArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -26,26 +27,26 @@ impl GeozeroGeometry for LineStringArray { /// GeoZero trait to convert to GeoArrow LineStringArray. pub trait ToLineStringArray { /// Convert to GeoArrow LineStringArray - fn to_line_string_array(&self) -> geozero::error::Result>; + fn to_line_string_array(&self, dim: Dimension) -> geozero::error::Result; /// Convert to a GeoArrow LineStringBuilder - fn to_line_string_builder(&self) -> geozero::error::Result>; + fn to_line_string_builder(&self, dim: Dimension) -> geozero::error::Result; } -impl ToLineStringArray for T { - fn to_line_string_array(&self) -> geozero::error::Result> { - Ok(self.to_line_string_builder()?.into()) +impl ToLineStringArray for T { + fn to_line_string_array(&self, dim: Dimension) -> geozero::error::Result { + Ok(self.to_line_string_builder(dim)?.into()) } - fn to_line_string_builder(&self) -> geozero::error::Result> { - let mut mutable_array = LineStringBuilder::new(); + fn to_line_string_builder(&self, dim: Dimension) -> geozero::error::Result { + let mut mutable_array = LineStringBuilder::new(dim); self.process_geom(&mut mutable_array)?; Ok(mutable_array) } } #[allow(unused_variables)] -impl GeomProcessor for LineStringBuilder { +impl GeomProcessor for LineStringBuilder { fn geometrycollection_begin(&mut self, size: usize, idx: usize) -> geozero::error::Result<()> { let capacity = LineStringCapacity::new(0, size); self.reserve(capacity); @@ -93,7 +94,7 @@ mod test { #[test] fn geozero_process_geom() -> geozero::error::Result<()> { - let arr: LineStringArray<2> = vec![ls0(), ls1()].as_slice().into(); + let arr: LineStringArray = (vec![ls0(), ls1()].as_slice(), Dimension::XY).into(); let wkt = arr.to_wkt()?; let expected = "GEOMETRYCOLLECTION(LINESTRING(0 1,1 2),LINESTRING(3 4,5 6))"; assert_eq!(wkt, expected); @@ -108,7 +109,7 @@ mod test { .map(Geometry::LineString) .collect(), ); - let multi_point_array: LineStringArray<2> = geo.to_line_string_array().unwrap(); + let multi_point_array = geo.to_line_string_array(Dimension::XY).unwrap(); assert_eq!(multi_point_array.value_as_geo(0), ls0()); assert_eq!(multi_point_array.value_as_geo(1), ls1()); Ok(()) diff --git a/rust/geoarrow/src/io/geozero/array/mixed.rs b/rust/geoarrow/src/io/geozero/array/mixed.rs index b301d8b1..91cdd1c9 100644 --- a/rust/geoarrow/src/io/geozero/array/mixed.rs +++ b/rust/geoarrow/src/io/geozero/array/mixed.rs @@ -3,13 +3,14 @@ use std::sync::Arc; use crate::array::metadata::ArrayMetadata; use crate::array::mixed::array::GeometryType; use crate::array::{CoordType, MixedGeometryArray, MixedGeometryBuilder}; +use crate::datatypes::Dimension; use crate::io::geozero::scalar::process_geometry; use crate::trait_::{ArrayAccessor, GeometryArrayBuilder}; use crate::ArrayBase; use crate::NativeArray; use geozero::{GeomProcessor, GeozeroGeometry}; -impl GeozeroGeometry for MixedGeometryArray { +impl GeozeroGeometry for MixedGeometryArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -30,19 +31,29 @@ impl GeozeroGeometry for MixedGeometryArray { /// GeoZero trait to convert to GeoArrow MixedArray. pub trait ToMixedArray { /// Convert to GeoArrow MixedArray - fn to_mixed_geometry_array(&self) -> geozero::error::Result>; + fn to_mixed_geometry_array(&self, dim: Dimension) + -> geozero::error::Result; /// Convert to a GeoArrow MixedArrayBuilder - fn to_mixed_geometry_builder(&self) -> geozero::error::Result>; + fn to_mixed_geometry_builder( + &self, + dim: Dimension, + ) -> geozero::error::Result; } -impl ToMixedArray for T { - fn to_mixed_geometry_array(&self) -> geozero::error::Result> { - Ok(self.to_mixed_geometry_builder()?.into()) +impl ToMixedArray for T { + fn to_mixed_geometry_array( + &self, + dim: Dimension, + ) -> geozero::error::Result { + Ok(self.to_mixed_geometry_builder(dim)?.into()) } - fn to_mixed_geometry_builder(&self) -> geozero::error::Result> { - let mut stream_builder = MixedGeometryStreamBuilder::new(); + fn to_mixed_geometry_builder( + &self, + dim: Dimension, + ) -> geozero::error::Result { + let mut stream_builder = MixedGeometryStreamBuilder::new(dim); self.process_geom(&mut stream_builder)?; Ok(stream_builder.builder) } @@ -56,7 +67,7 @@ impl ToMixedArray for T { /// Converting an [`MixedGeometryStreamBuilder`] into a [`MixedGeometryArray`] is `O(1)`. #[derive(Debug)] pub struct MixedGeometryStreamBuilder { - builder: MixedGeometryBuilder, + builder: MixedGeometryBuilder, // Note: we don't know if, when `linestring_end` is called, that means a ring of a polygon has // finished or if a tagged line string has finished. This means we can't have an "unknown" enum // type, because we'll never be able to set it to unknown after a line string is done, meaning @@ -64,18 +75,24 @@ pub struct MixedGeometryStreamBuilder { current_geom_type: GeometryType, } -impl MixedGeometryStreamBuilder { - pub fn new() -> Self { - Self::new_with_options(Default::default(), Default::default(), true) +impl MixedGeometryStreamBuilder { + pub fn new(dim: Dimension) -> Self { + Self::new_with_options(dim, Default::default(), Default::default(), true) } pub fn new_with_options( + dim: Dimension, coord_type: CoordType, metadata: Arc, prefer_multi: bool, ) -> Self { Self { - builder: MixedGeometryBuilder::new_with_options(coord_type, metadata, prefer_multi), + builder: MixedGeometryBuilder::new_with_options( + dim, + coord_type, + metadata, + prefer_multi, + ), current_geom_type: GeometryType::Point, } } @@ -84,19 +101,19 @@ impl MixedGeometryStreamBuilder { self.builder.push_null() } - pub fn finish(self) -> MixedGeometryArray { + pub fn finish(self) -> MixedGeometryArray { self.builder.finish() } } -impl Default for MixedGeometryStreamBuilder { +impl Default for MixedGeometryStreamBuilder { fn default() -> Self { - Self::new() + Self::new(Dimension::XY) } } #[allow(unused_variables)] -impl GeomProcessor for MixedGeometryStreamBuilder { +impl GeomProcessor for MixedGeometryStreamBuilder { fn xy(&mut self, x: f64, y: f64, idx: usize) -> geozero::error::Result<()> { match self.current_geom_type { GeometryType::Point => { @@ -258,7 +275,7 @@ impl GeomProcessor for MixedGeometryStreamBuilder { } } -impl GeometryArrayBuilder for MixedGeometryStreamBuilder { +impl GeometryArrayBuilder for MixedGeometryStreamBuilder { fn len(&self) -> usize { self.builder.len() } @@ -275,8 +292,8 @@ impl GeometryArrayBuilder for MixedGeometryStreamBuilder { todo!() } - fn new() -> Self { - Self::with_geom_capacity_and_options(0, Default::default(), Default::default()) + fn new(dim: Dimension) -> Self { + Self::with_geom_capacity_and_options(dim, 0, Default::default(), Default::default()) } fn into_array_ref(self) -> Arc { @@ -284,11 +301,12 @@ impl GeometryArrayBuilder for MixedGeometryStreamBuilder { } fn with_geom_capacity_and_options( + dim: Dimension, _geom_capacity: usize, coord_type: CoordType, metadata: Arc, ) -> Self { - Self::new_with_options(coord_type, metadata, true) + Self::new_with_options(dim, coord_type, metadata, true) } fn set_metadata(&mut self, metadata: Arc) { diff --git a/rust/geoarrow/src/io/geozero/array/multilinestring.rs b/rust/geoarrow/src/io/geozero/array/multilinestring.rs index fdf4cec9..e94159c5 100644 --- a/rust/geoarrow/src/io/geozero/array/multilinestring.rs +++ b/rust/geoarrow/src/io/geozero/array/multilinestring.rs @@ -2,11 +2,12 @@ use geozero::{GeomProcessor, GeozeroGeometry}; use crate::array::multilinestring::MultiLineStringCapacity; use crate::array::{MultiLineStringArray, MultiLineStringBuilder}; +use crate::datatypes::Dimension; use crate::io::geozero::scalar::process_multi_line_string; use crate::trait_::ArrayAccessor; use crate::ArrayBase; -impl GeozeroGeometry for MultiLineStringArray { +impl GeozeroGeometry for MultiLineStringArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -26,26 +27,38 @@ impl GeozeroGeometry for MultiLineStringArray { /// GeoZero trait to convert to GeoArrow MultiLineStringArray. pub trait ToMultiLineStringArray { /// Convert to GeoArrow MultiLineStringArray - fn to_line_string_array(&self) -> geozero::error::Result>; + fn to_multi_line_string_array( + &self, + dim: Dimension, + ) -> geozero::error::Result; /// Convert to a GeoArrow MultiLineStringBuilder - fn to_line_string_builder(&self) -> geozero::error::Result>; + fn to_multi_line_string_builder( + &self, + dim: Dimension, + ) -> geozero::error::Result; } -impl ToMultiLineStringArray for T { - fn to_line_string_array(&self) -> geozero::error::Result> { - Ok(self.to_line_string_builder()?.into()) +impl ToMultiLineStringArray for T { + fn to_multi_line_string_array( + &self, + dim: Dimension, + ) -> geozero::error::Result { + Ok(self.to_multi_line_string_builder(dim)?.into()) } - fn to_line_string_builder(&self) -> geozero::error::Result> { - let mut mutable_array = MultiLineStringBuilder::new(); + fn to_multi_line_string_builder( + &self, + dim: Dimension, + ) -> geozero::error::Result { + let mut mutable_array = MultiLineStringBuilder::new(dim); self.process_geom(&mut mutable_array)?; Ok(mutable_array) } } #[allow(unused_variables)] -impl GeomProcessor for MultiLineStringBuilder { +impl GeomProcessor for MultiLineStringBuilder { fn geometrycollection_begin(&mut self, size: usize, idx: usize) -> geozero::error::Result<()> { // reserve `size` geometries let capacity = MultiLineStringCapacity::new(0, 0, size); @@ -121,7 +134,7 @@ mod test { #[test] fn geozero_process_geom() -> geozero::error::Result<()> { - let arr: MultiLineStringArray<2> = vec![ml0(), ml1()].as_slice().into(); + let arr: MultiLineStringArray = (vec![ml0(), ml1()].as_slice(), Dimension::XY).into(); let wkt = arr.to_wkt()?; let expected = "GEOMETRYCOLLECTION(MULTILINESTRING((-111 45,-111 41,-104 41,-104 45)),MULTILINESTRING((-111 45,-111 41,-104 41,-104 45),(-110 44,-110 42,-105 42,-105 44)))"; assert_eq!(wkt, expected); @@ -136,7 +149,7 @@ mod test { .map(Geometry::MultiLineString) .collect(), ); - let multi_point_array: MultiLineStringArray<2> = geo.to_line_string_array().unwrap(); + let multi_point_array = geo.to_multi_line_string_array(Dimension::XY).unwrap(); assert_eq!(multi_point_array.value_as_geo(0), ml0()); assert_eq!(multi_point_array.value_as_geo(1), ml1()); Ok(()) diff --git a/rust/geoarrow/src/io/geozero/array/multipoint.rs b/rust/geoarrow/src/io/geozero/array/multipoint.rs index 4fa32f77..7db87d92 100644 --- a/rust/geoarrow/src/io/geozero/array/multipoint.rs +++ b/rust/geoarrow/src/io/geozero/array/multipoint.rs @@ -1,11 +1,12 @@ use crate::array::multipoint::MultiPointCapacity; use crate::array::{MultiPointArray, MultiPointBuilder}; +use crate::datatypes::Dimension; use crate::io::geozero::scalar::process_multi_point; use crate::trait_::ArrayAccessor; use crate::ArrayBase; use geozero::{GeomProcessor, GeozeroGeometry}; -impl GeozeroGeometry for MultiPointArray { +impl GeozeroGeometry for MultiPointArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -25,26 +26,26 @@ impl GeozeroGeometry for MultiPointArray { /// GeoZero trait to convert to GeoArrow MultiPointArray. pub trait ToMultiPointArray { /// Convert to GeoArrow MultiPointArray - fn to_multi_point_array(&self) -> geozero::error::Result>; + fn to_multi_point_array(&self, dim: Dimension) -> geozero::error::Result; /// Convert to a GeoArrow MultiPointBuilder - fn to_multi_point_builder(&self) -> geozero::error::Result>; + fn to_multi_point_builder(&self, dim: Dimension) -> geozero::error::Result; } -impl ToMultiPointArray for T { - fn to_multi_point_array(&self) -> geozero::error::Result> { - Ok(self.to_multi_point_builder()?.into()) +impl ToMultiPointArray for T { + fn to_multi_point_array(&self, dim: Dimension) -> geozero::error::Result { + Ok(self.to_multi_point_builder(dim)?.into()) } - fn to_multi_point_builder(&self) -> geozero::error::Result> { - let mut mutable_array = MultiPointBuilder::new(); + fn to_multi_point_builder(&self, dim: Dimension) -> geozero::error::Result { + let mut mutable_array = MultiPointBuilder::new(dim); self.process_geom(&mut mutable_array)?; Ok(mutable_array) } } #[allow(unused_variables)] -impl GeomProcessor for MultiPointBuilder { +impl GeomProcessor for MultiPointBuilder { fn geometrycollection_begin(&mut self, size: usize, idx: usize) -> geozero::error::Result<()> { let capacity = MultiPointCapacity::new(0, size); self.reserve(capacity); @@ -93,7 +94,7 @@ mod test { #[test] fn geozero_process_geom() -> Result<()> { - let arr: MultiPointArray<2> = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPointArray = (vec![mp0(), mp1()].as_slice(), Dimension::XY).into(); let wkt = arr.to_wkt()?; let expected = "GEOMETRYCOLLECTION(MULTIPOINT(0 1,1 2),MULTIPOINT(3 4,5 6))"; assert_eq!(wkt, expected); @@ -108,7 +109,7 @@ mod test { .map(Geometry::MultiPoint) .collect(), ); - let multi_point_array: MultiPointArray<2> = geo.to_multi_point_array().unwrap(); + let multi_point_array = geo.to_multi_point_array(Dimension::XY).unwrap(); assert_eq!(multi_point_array.value_as_geo(0), mp0()); assert_eq!(multi_point_array.value_as_geo(1), mp1()); Ok(()) diff --git a/rust/geoarrow/src/io/geozero/array/multipolygon.rs b/rust/geoarrow/src/io/geozero/array/multipolygon.rs index c1ca3a2b..846031b4 100644 --- a/rust/geoarrow/src/io/geozero/array/multipolygon.rs +++ b/rust/geoarrow/src/io/geozero/array/multipolygon.rs @@ -2,11 +2,12 @@ use geozero::{GeomProcessor, GeozeroGeometry}; use crate::array::multipolygon::MultiPolygonCapacity; use crate::array::{MultiPolygonArray, MultiPolygonBuilder}; +use crate::datatypes::Dimension; use crate::io::geozero::scalar::process_multi_polygon; use crate::trait_::ArrayAccessor; use crate::ArrayBase; -impl GeozeroGeometry for MultiPolygonArray { +impl GeozeroGeometry for MultiPolygonArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -26,26 +27,32 @@ impl GeozeroGeometry for MultiPolygonArray { /// GeoZero trait to convert to GeoArrow MultiPolygonArray. pub trait ToMultiPolygonArray { /// Convert to GeoArrow MultiPolygonArray - fn to_line_string_array(&self) -> geozero::error::Result>; + fn to_multi_polygon_array(&self, dim: Dimension) -> geozero::error::Result; /// Convert to a GeoArrow MultiPolygonBuilder - fn to_line_string_builder(&self) -> geozero::error::Result>; + fn to_multi_polygon_builder( + &self, + dim: Dimension, + ) -> geozero::error::Result; } -impl ToMultiPolygonArray for T { - fn to_line_string_array(&self) -> geozero::error::Result> { - Ok(self.to_line_string_builder()?.into()) +impl ToMultiPolygonArray for T { + fn to_multi_polygon_array(&self, dim: Dimension) -> geozero::error::Result { + Ok(self.to_multi_polygon_builder(dim)?.into()) } - fn to_line_string_builder(&self) -> geozero::error::Result> { - let mut mutable_array = MultiPolygonBuilder::new(); + fn to_multi_polygon_builder( + &self, + dim: Dimension, + ) -> geozero::error::Result { + let mut mutable_array = MultiPolygonBuilder::new(dim); self.process_geom(&mut mutable_array)?; Ok(mutable_array) } } #[allow(unused_variables)] -impl GeomProcessor for MultiPolygonBuilder { +impl GeomProcessor for MultiPolygonBuilder { fn geometrycollection_begin(&mut self, size: usize, idx: usize) -> geozero::error::Result<()> { // reserve `size` geometries let capacity = MultiPolygonCapacity::new(0, 0, 0, size); @@ -138,7 +145,7 @@ mod test { #[test] fn geozero_process_geom() -> geozero::error::Result<()> { - let arr: MultiPolygonArray<2> = vec![mp0(), mp1()].as_slice().into(); + let arr: MultiPolygonArray = (vec![mp0(), mp1()].as_slice(), Dimension::XY).into(); let wkt = arr.to_wkt()?; let expected = "GEOMETRYCOLLECTION(MULTIPOLYGON(((-111 45,-111 41,-104 41,-104 45,-111 45)),((-111 45,-111 41,-104 41,-104 45,-111 45),(-110 44,-110 42,-105 42,-105 44,-110 44))),MULTIPOLYGON(((-111 45,-111 41,-104 41,-104 45,-111 45)),((-110 44,-110 42,-105 42,-105 44,-110 44))))"; assert_eq!(wkt, expected); @@ -153,7 +160,7 @@ mod test { .map(Geometry::MultiPolygon) .collect(), ); - let multi_point_array: MultiPolygonArray<2> = geo.to_line_string_array().unwrap(); + let multi_point_array = geo.to_multi_polygon_array(Dimension::XY).unwrap(); assert_eq!(multi_point_array.value_as_geo(0), mp0()); assert_eq!(multi_point_array.value_as_geo(1), mp1()); Ok(()) diff --git a/rust/geoarrow/src/io/geozero/array/point.rs b/rust/geoarrow/src/io/geozero/array/point.rs index 937c5cba..4df4c7f2 100644 --- a/rust/geoarrow/src/io/geozero/array/point.rs +++ b/rust/geoarrow/src/io/geozero/array/point.rs @@ -1,10 +1,11 @@ use crate::array::{PointArray, PointBuilder}; +use crate::datatypes::Dimension; use crate::io::geozero::scalar::process_point; use crate::trait_::ArrayAccessor; use crate::ArrayBase; use geozero::{GeomProcessor, GeozeroGeometry}; -impl GeozeroGeometry for PointArray { +impl GeozeroGeometry for PointArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -24,26 +25,26 @@ impl GeozeroGeometry for PointArray { /// GeoZero trait to convert to GeoArrow PointArray. pub trait ToPointArray { /// Convert to GeoArrow PointArray - fn to_point_array(&self) -> geozero::error::Result>; + fn to_point_array(&self, dim: Dimension) -> geozero::error::Result; /// Convert to a GeoArrow PointBuilder - fn to_point_builder(&self) -> geozero::error::Result>; + fn to_point_builder(&self, dim: Dimension) -> geozero::error::Result; } -impl ToPointArray for T { - fn to_point_array(&self) -> geozero::error::Result> { - Ok(self.to_point_builder()?.into()) +impl ToPointArray for T { + fn to_point_array(&self, dim: Dimension) -> geozero::error::Result { + Ok(self.to_point_builder(dim)?.into()) } - fn to_point_builder(&self) -> geozero::error::Result> { - let mut mutable_point_array = PointBuilder::new(); + fn to_point_builder(&self, dim: Dimension) -> geozero::error::Result { + let mut mutable_point_array = PointBuilder::new(dim); self.process_geom(&mut mutable_point_array)?; Ok(mutable_point_array) } } #[allow(unused_variables)] -impl GeomProcessor for PointBuilder { +impl GeomProcessor for PointBuilder { fn empty_point(&mut self, idx: usize) -> geozero::error::Result<()> { self.push_empty(); Ok(()) @@ -162,7 +163,6 @@ impl GeomProcessor for PointBuilder { #[cfg(test)] mod test { use super::*; - use crate::array::PointArray; use crate::trait_::ArrayAccessor; use geo::{line_string, point, Geometry, GeometryCollection, LineString, Point}; @@ -201,7 +201,7 @@ mod test { ] .into(), ); - let point_array: PointArray<2> = geo.to_point_array().unwrap(); + let point_array = geo.to_point_array(Dimension::XY).unwrap(); assert_eq!(point_array.value_as_geo(0), p0()); assert_eq!(point_array.value_as_geo(1), p1()); assert_eq!(point_array.value_as_geo(2), p2()); @@ -213,7 +213,7 @@ mod test { Geometry::Point(p0()), Geometry::LineString(ls0()), ])); - let err = ToPointArray::<2>::to_point_array(&geo).unwrap_err(); + let err = ToPointArray::to_point_array(&geo, Dimension::XY).unwrap_err(); assert!(matches!(err, geozero::error::GeozeroError::Geometry(..))); } } diff --git a/rust/geoarrow/src/io/geozero/array/polygon.rs b/rust/geoarrow/src/io/geozero/array/polygon.rs index a8cbf35a..3455fde1 100644 --- a/rust/geoarrow/src/io/geozero/array/polygon.rs +++ b/rust/geoarrow/src/io/geozero/array/polygon.rs @@ -1,11 +1,12 @@ use crate::array::polygon::PolygonCapacity; use crate::array::{PolygonArray, PolygonBuilder}; +use crate::datatypes::Dimension; use crate::io::geozero::scalar::process_polygon; use crate::trait_::ArrayAccessor; use crate::ArrayBase; use geozero::{GeomProcessor, GeozeroGeometry}; -impl GeozeroGeometry for PolygonArray { +impl GeozeroGeometry for PolygonArray { fn process_geom(&self, processor: &mut P) -> geozero::error::Result<()> where Self: Sized, @@ -25,26 +26,26 @@ impl GeozeroGeometry for PolygonArray { /// GeoZero trait to convert to GeoArrow PolygonArray. pub trait ToPolygonArray { /// Convert to GeoArrow PolygonArray - fn to_line_string_array(&self) -> geozero::error::Result>; + fn to_line_string_array(&self, dim: Dimension) -> geozero::error::Result; /// Convert to a GeoArrow PolygonBuilder - fn to_line_string_builder(&self) -> geozero::error::Result>; + fn to_line_string_builder(&self, dim: Dimension) -> geozero::error::Result; } -impl ToPolygonArray for T { - fn to_line_string_array(&self) -> geozero::error::Result> { - Ok(self.to_line_string_builder()?.into()) +impl ToPolygonArray for T { + fn to_line_string_array(&self, dim: Dimension) -> geozero::error::Result { + Ok(self.to_line_string_builder(dim)?.into()) } - fn to_line_string_builder(&self) -> geozero::error::Result> { - let mut mutable_array = PolygonBuilder::new(); + fn to_line_string_builder(&self, dim: Dimension) -> geozero::error::Result { + let mut mutable_array = PolygonBuilder::new(dim); self.process_geom(&mut mutable_array)?; Ok(mutable_array) } } #[allow(unused_variables)] -impl GeomProcessor for PolygonBuilder { +impl GeomProcessor for PolygonBuilder { fn geometrycollection_begin(&mut self, size: usize, idx: usize) -> geozero::error::Result<()> { // reserve `size` geometries let capacity = PolygonCapacity::new(0, 0, size); @@ -112,7 +113,7 @@ mod test { #[test] fn geozero_process_geom() -> geozero::error::Result<()> { - let arr: PolygonArray<2> = vec![p0(), p1()].as_slice().into(); + let arr: PolygonArray = (vec![p0(), p1()].as_slice(), Dimension::XY).into(); let wkt = arr.to_wkt()?; let expected = "GEOMETRYCOLLECTION(POLYGON((-111 45,-111 41,-104 41,-104 45,-111 45)),POLYGON((-111 45,-111 41,-104 41,-104 45,-111 45),(-110 44,-110 42,-105 42,-105 44,-110 44)))"; assert_eq!(wkt, expected); @@ -127,7 +128,7 @@ mod test { .map(Geometry::Polygon) .collect(), ); - let multi_point_array: PolygonArray<2> = geo.to_line_string_array().unwrap(); + let multi_point_array = geo.to_line_string_array(Dimension::XY).unwrap(); assert_eq!(multi_point_array.value_as_geo(0), p0()); assert_eq!(multi_point_array.value_as_geo(1), p1()); Ok(()) diff --git a/rust/geoarrow/src/io/geozero/scalar/geometry.rs b/rust/geoarrow/src/io/geozero/scalar/geometry.rs index 63ada79d..60e9b3ed 100644 --- a/rust/geoarrow/src/io/geozero/scalar/geometry.rs +++ b/rust/geoarrow/src/io/geozero/scalar/geometry.rs @@ -1,3 +1,4 @@ +use crate::datatypes::Dimension; use crate::io::geozero::scalar::geometry_collection::process_geometry_collection; use crate::io::geozero::scalar::linestring::process_line_string; use crate::io::geozero::scalar::multilinestring::process_multi_line_string; @@ -45,12 +46,12 @@ impl GeozeroGeometry for Geometry<'_> { } pub trait ToGeometry { - fn to_geometry(&self) -> geozero::error::Result>; + fn to_geometry(&self, dim: Dimension) -> geozero::error::Result; } impl ToGeometry for T { - fn to_geometry(&self) -> geozero::error::Result> { - let arr = self.to_mixed_geometry_array()?; + fn to_geometry(&self, dim: Dimension) -> geozero::error::Result { + let arr = self.to_mixed_geometry_array(dim)?; assert_eq!(arr.len(), 1); Ok(OwnedGeometry::from(arr.value(0))) } diff --git a/rust/geoarrow/src/io/geozero/scalar/geometry_array.rs b/rust/geoarrow/src/io/geozero/scalar/geometry_array.rs index 8fb7fb75..ed6023c9 100644 --- a/rust/geoarrow/src/io/geozero/scalar/geometry_array.rs +++ b/rust/geoarrow/src/io/geozero/scalar/geometry_array.rs @@ -1,5 +1,5 @@ use crate::array::AsNativeArray; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::io::geozero::scalar::geometry_collection::process_geometry_collection; use crate::io::geozero::scalar::linestring::process_line_string; use crate::io::geozero::scalar::multilinestring::process_multi_line_string; @@ -18,16 +18,16 @@ pub fn process_geometry_scalar_array( processor: &mut P, ) -> geozero::error::Result<()> { macro_rules! impl_process { - ($process_func:ident, $cast_func:ident, $dim:expr) => { + ($process_func:ident, $cast_func:ident) => { $process_func( - &geom.inner().as_ref().$cast_func::<$dim>().value(0), + &geom.inner().as_ref().$cast_func().value(0), geom_idx, processor, ) }; - ($process_func:ident, true, $cast_func:ident, $dim:expr) => { + ($process_func:ident, true, $cast_func:ident) => { $process_func( - &geom.inner().as_ref().$cast_func::<$dim>().value(0), + &geom.inner().as_ref().$cast_func().value(0), true, geom_idx, processor, @@ -35,32 +35,20 @@ pub fn process_geometry_scalar_array( }; } - use Dimension::*; use NativeType::*; match geom.data_type() { - Point(_, XY) => impl_process!(process_point, as_point, 2), - LineString(_, XY) => impl_process!(process_line_string, as_line_string, 2), - Polygon(_, XY) => impl_process!(process_polygon, true, as_polygon, 2), - MultiPoint(_, XY) => impl_process!(process_multi_point, as_multi_point, 2), - MultiLineString(_, XY) => impl_process!(process_multi_line_string, as_multi_line_string, 2), - MultiPolygon(_, XY) => impl_process!(process_multi_polygon, as_multi_polygon, 2), - Mixed(_, XY) => impl_process!(process_geometry, as_mixed, 2), - GeometryCollection(_, XY) => { - impl_process!(process_geometry_collection, as_geometry_collection, 2) - } - Point(_, XYZ) => impl_process!(process_point, as_point, 3), - LineString(_, XYZ) => impl_process!(process_line_string, as_line_string, 3), - Polygon(_, XYZ) => impl_process!(process_polygon, true, as_polygon, 3), - MultiPoint(_, XYZ) => impl_process!(process_multi_point, as_multi_point, 3), - MultiLineString(_, XYZ) => { - impl_process!(process_multi_line_string, as_multi_line_string, 3) - } - MultiPolygon(_, XYZ) => impl_process!(process_multi_polygon, as_multi_polygon, 3), - Mixed(_, XYZ) => impl_process!(process_geometry, as_mixed, 3), - GeometryCollection(_, XYZ) => { - impl_process!(process_geometry_collection, as_geometry_collection, 3) + Point(_, _) => impl_process!(process_point, as_point), + LineString(_, _) => impl_process!(process_line_string, as_line_string), + Polygon(_, _) => impl_process!(process_polygon, true, as_polygon), + MultiPoint(_, _) => impl_process!(process_multi_point, as_multi_point), + MultiLineString(_, _) => impl_process!(process_multi_line_string, as_multi_line_string), + MultiPolygon(_, _) => impl_process!(process_multi_polygon, as_multi_polygon), + Mixed(_, _) => impl_process!(process_geometry, as_mixed), + GeometryCollection(_, _) => { + impl_process!(process_geometry_collection, as_geometry_collection) } + // WKB => { // let arr = &geom.inner().as_ref(); // let wkb_arr = arr.as_wkb().value(0); diff --git a/rust/geoarrow/src/io/geozero/table/builder/table.rs b/rust/geoarrow/src/io/geozero/table/builder/table.rs index de48b863..dd6ad69d 100644 --- a/rust/geoarrow/src/io/geozero/table/builder/table.rs +++ b/rust/geoarrow/src/io/geozero/table/builder/table.rs @@ -8,6 +8,7 @@ use geozero::{FeatureProcessor, GeomProcessor, PropertyProcessor}; use crate::array::metadata::ArrayMetadata; use crate::array::CoordType; use crate::chunked_array::ChunkedNativeArrayDyn; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::io::geozero::table::builder::properties::PropertiesBatchBuilder; use crate::table::Table; @@ -97,14 +98,16 @@ pub struct GeoTableBuilder { /// Builder for the geometries of the current batch geom_builder: G, + + dim: Dimension, } impl GeoTableBuilder { - pub fn new() -> Self { - Self::new_with_options(Default::default()) + pub fn new(dim: Dimension) -> Self { + Self::new_with_options(dim, Default::default()) } - pub fn new_with_options(options: GeoTableBuilderOptions) -> Self { + pub fn new_with_options(dim: Dimension, options: GeoTableBuilderOptions) -> Self { let (current_batch_size, num_batches) = if let Some(total_num_rows) = options.num_rows { ( Some(total_num_rows.min(options.batch_size)), @@ -133,12 +136,13 @@ impl GeoTableBuilder { let geom_builder = if let Some(current_batch_size) = current_batch_size { G::with_geom_capacity_and_options( + dim, current_batch_size, options.coord_type, options.metadata, ) } else { - G::with_geom_capacity_and_options(0, options.coord_type, options.metadata) + G::with_geom_capacity_and_options(dim, 0, options.coord_type, options.metadata) }; Self { @@ -149,6 +153,7 @@ impl GeoTableBuilder { prop_builder, geom_arrays, geom_builder, + dim, } } @@ -176,11 +181,12 @@ impl GeoTableBuilder { let batch_size = self.batch_size.min(rows_left); let prop_builder = PropertiesBatchBuilder::from_schema_with_capacity(&next_schema, batch_size); - let geom_builder = G::with_geom_capacity_and_options(batch_size, coord_type, metadata); + let geom_builder = + G::with_geom_capacity_and_options(self.dim, batch_size, coord_type, metadata); (prop_builder, geom_builder) } else { let prop_builder = PropertiesBatchBuilder::from_schema(&next_schema); - let geom_builder = G::with_geom_capacity_and_options(0, coord_type, metadata); + let geom_builder = G::with_geom_capacity_and_options(self.dim, 0, coord_type, metadata); (prop_builder, geom_builder) }; diff --git a/rust/geoarrow/src/io/geozero/table/data_source.rs b/rust/geoarrow/src/io/geozero/table/data_source.rs index 1373e38e..b526e6fa 100644 --- a/rust/geoarrow/src/io/geozero/table/data_source.rs +++ b/rust/geoarrow/src/io/geozero/table/data_source.rs @@ -4,7 +4,7 @@ use std::str::FromStr; use std::sync::Arc; use crate::array::{from_arrow_array, AsNativeArray}; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::io::geozero::scalar::{ process_geometry, process_geometry_collection, process_line_string, process_multi_line_string, process_multi_point, process_multi_polygon, process_point, process_polygon, @@ -369,68 +369,36 @@ fn process_geometry_n( let i = within_batch_row_idx; use NativeType::*; match arr.data_type() { - Point(_, Dimension::XY) => { - let geom = arr.as_point::<2>().value(i); + Point(_, _) => { + let geom = arr.as_point().value(i); process_point(&geom, 0, processor)?; } - LineString(_, Dimension::XY) => { - let geom = arr.as_line_string::<2>().value(i); + LineString(_, _) => { + let geom = arr.as_line_string().value(i); process_line_string(&geom, 0, processor)?; } - Polygon(_, Dimension::XY) => { - let geom = arr.as_polygon::<2>().value(i); + Polygon(_, _) => { + let geom = arr.as_polygon().value(i); process_polygon(&geom, true, 0, processor)?; } - MultiPoint(_, Dimension::XY) => { - let geom = arr.as_multi_point::<2>().value(i); + MultiPoint(_, _) => { + let geom = arr.as_multi_point().value(i); process_multi_point(&geom, 0, processor)?; } - MultiLineString(_, Dimension::XY) => { - let geom = arr.as_multi_line_string::<2>().value(i); + MultiLineString(_, _) => { + let geom = arr.as_multi_line_string().value(i); process_multi_line_string(&geom, 0, processor)?; } - MultiPolygon(_, Dimension::XY) => { - let geom = arr.as_multi_polygon::<2>().value(i); + MultiPolygon(_, _) => { + let geom = arr.as_multi_polygon().value(i); process_multi_polygon(&geom, 0, processor)?; } - Mixed(_, Dimension::XY) => { - let geom = arr.as_mixed::<2>().value(i); + Mixed(_, _) => { + let geom = arr.as_mixed().value(i); process_geometry(&geom, 0, processor)?; } - GeometryCollection(_, Dimension::XY) => { - let geom = arr.as_geometry_collection::<2>().value(i); - process_geometry_collection(&geom, 0, processor)?; - } - Point(_, Dimension::XYZ) => { - let geom = arr.as_point::<3>().value(i); - process_point(&geom, 0, processor)?; - } - LineString(_, Dimension::XYZ) => { - let geom = arr.as_line_string::<3>().value(i); - process_line_string(&geom, 0, processor)?; - } - Polygon(_, Dimension::XYZ) => { - let geom = arr.as_polygon::<3>().value(i); - process_polygon(&geom, true, 0, processor)?; - } - MultiPoint(_, Dimension::XYZ) => { - let geom = arr.as_multi_point::<3>().value(i); - process_multi_point(&geom, 0, processor)?; - } - MultiLineString(_, Dimension::XYZ) => { - let geom = arr.as_multi_line_string::<3>().value(i); - process_multi_line_string(&geom, 0, processor)?; - } - MultiPolygon(_, Dimension::XYZ) => { - let geom = arr.as_multi_polygon::<3>().value(i); - process_multi_polygon(&geom, 0, processor)?; - } - Mixed(_, Dimension::XYZ) => { - let geom = arr.as_mixed::<3>().value(i); - process_geometry(&geom, 0, processor)?; - } - GeometryCollection(_, Dimension::XYZ) => { - let geom = arr.as_geometry_collection::<3>().value(i); + GeometryCollection(_, _) => { + let geom = arr.as_geometry_collection().value(i); process_geometry_collection(&geom, 0, processor)?; } // WKB => { diff --git a/rust/geoarrow/src/io/shapefile/reader.rs b/rust/geoarrow/src/io/shapefile/reader.rs index 5f38e4fb..acceddd8 100644 --- a/rust/geoarrow/src/io/shapefile/reader.rs +++ b/rust/geoarrow/src/io/shapefile/reader.rs @@ -7,6 +7,7 @@ use geozero::FeatureProcessor; use shapefile::{Reader, ShapeReader, ShapeType}; use crate::array::{MultiLineStringBuilder, MultiPointBuilder, MultiPolygonBuilder, PointBuilder}; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::io::geozero::table::builder::anyvalue::AnyBuilder; use crate::io::geozero::table::builder::properties::PropertiesBatchBuilder; @@ -52,7 +53,8 @@ pub fn read_shapefile(shp_reader: T, dbf_reader: T) -> Result { - let mut builder = GeoTableBuilder::>::new_with_options(options); + let mut builder = + GeoTableBuilder::::new_with_options(Dimension::XY, options); for geom_and_record in reader.iter_shapes_and_records_as::() @@ -75,7 +77,8 @@ pub fn read_shapefile(shp_reader: T, dbf_reader: T) -> Result { - let mut builder = GeoTableBuilder::>::new_with_options(options); + let mut builder = + GeoTableBuilder::::new_with_options(Dimension::XYZ, options); for geom_and_record in reader.iter_shapes_and_records_as::() @@ -98,7 +101,8 @@ pub fn read_shapefile(shp_reader: T, dbf_reader: T) -> Result { - let mut builder = GeoTableBuilder::>::new_with_options(options); + let mut builder = + GeoTableBuilder::::new_with_options(Dimension::XY, options); for geom_and_record in reader.iter_shapes_and_records_as::() @@ -121,7 +125,8 @@ pub fn read_shapefile(shp_reader: T, dbf_reader: T) -> Result { - let mut builder = GeoTableBuilder::>::new_with_options(options); + let mut builder = + GeoTableBuilder::::new_with_options(Dimension::XYZ, options); for geom_and_record in reader.iter_shapes_and_records_as::() From cf636f572fdeb546b94c84d3e790ba6fb6f772c8 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 21:45:30 -0500 Subject: [PATCH 06/14] progress --- rust/geoarrow/src/io/shapefile/reader.rs | 14 ++-- rust/geoarrow/src/io/wkb/writer/geometry.rs | 45 ++++++----- .../src/io/wkb/writer/geometrycollection.rs | 6 +- rust/geoarrow/src/io/wkb/writer/linestring.rs | 12 +-- .../src/io/wkb/writer/multilinestring.rs | 6 +- rust/geoarrow/src/io/wkb/writer/multipoint.rs | 6 +- .../src/io/wkb/writer/multipolygon.rs | 6 +- rust/geoarrow/src/io/wkb/writer/point.rs | 14 ++-- rust/geoarrow/src/io/wkb/writer/polygon.rs | 5 +- rust/geoarrow/src/io/wkt/writer/api.rs | 78 ++++++------------- rust/geoarrow/src/scalar/linestring/scalar.rs | 5 +- .../src/scalar/multilinestring/scalar.rs | 5 +- rust/geoarrow/src/scalar/multipoint/scalar.rs | 5 +- .../src/scalar/multipolygon/scalar.rs | 5 +- rust/geoarrow/src/scalar/polygon/scalar.rs | 5 +- rust/geoarrow/src/scalar/rect/scalar.rs | 2 +- 16 files changed, 111 insertions(+), 108 deletions(-) diff --git a/rust/geoarrow/src/io/shapefile/reader.rs b/rust/geoarrow/src/io/shapefile/reader.rs index acceddd8..c82fe821 100644 --- a/rust/geoarrow/src/io/shapefile/reader.rs +++ b/rust/geoarrow/src/io/shapefile/reader.rs @@ -150,7 +150,7 @@ pub fn read_shapefile(shp_reader: T, dbf_reader: T) -> Result { let mut builder = - GeoTableBuilder::>::new_with_options(options); + GeoTableBuilder::::new_with_options(Dimension::XY, options); for geom_and_record in reader.iter_shapes_and_records_as::() @@ -173,8 +173,10 @@ pub fn read_shapefile(shp_reader: T, dbf_reader: T) -> Result { - let mut builder = - GeoTableBuilder::>::new_with_options(options); + let mut builder = GeoTableBuilder::::new_with_options( + Dimension::XYZ, + options, + ); for geom_and_record in reader.iter_shapes_and_records_as::() @@ -197,7 +199,8 @@ pub fn read_shapefile(shp_reader: T, dbf_reader: T) -> Result { - let mut builder = GeoTableBuilder::>::new_with_options(options); + let mut builder = + GeoTableBuilder::::new_with_options(Dimension::XY, options); for geom_and_record in reader.iter_shapes_and_records_as::() @@ -220,7 +223,8 @@ pub fn read_shapefile(shp_reader: T, dbf_reader: T) -> Result { - let mut builder = GeoTableBuilder::>::new_with_options(options); + let mut builder = + GeoTableBuilder::::new_with_options(Dimension::XYZ, options); for geom_and_record in reader.iter_shapes_and_records_as::() diff --git a/rust/geoarrow/src/io/wkb/writer/geometry.rs b/rust/geoarrow/src/io/wkb/writer/geometry.rs index e790531c..1a0ba823 100644 --- a/rust/geoarrow/src/io/wkb/writer/geometry.rs +++ b/rust/geoarrow/src/io/wkb/writer/geometry.rs @@ -45,21 +45,25 @@ impl From<&MixedGeometryArray> for WKBArray { #[cfg(test)] mod test { use super::*; + use crate::datatypes::Dimension; use crate::test::multilinestring::{ml0, ml1}; use crate::test::point::{p0, p1}; #[test] fn round_trip() { - let orig_arr: MixedGeometryArray = vec![ - Some(geo::Geometry::MultiLineString(ml0())), - Some(geo::Geometry::MultiLineString(ml1())), - Some(geo::Geometry::Point(p0())), - Some(geo::Geometry::Point(p1())), - ] - .try_into() - .unwrap(); + let orig_arr: MixedGeometryArray = ( + vec![ + Some(geo::Geometry::MultiLineString(ml0())), + Some(geo::Geometry::MultiLineString(ml1())), + Some(geo::Geometry::Point(p0())), + Some(geo::Geometry::Point(p1())), + ], + Dimension::XY, + ) + .try_into() + .unwrap(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: MixedGeometryArray = wkb_arr.try_into().unwrap(); + let new_arr: MixedGeometryArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(orig_arr, new_arr); } @@ -67,17 +71,20 @@ mod test { #[ignore = "None not allowed in geometry array."] #[test] fn round_trip_null() { - let orig_arr: MixedGeometryArray = vec![ - Some(geo::Geometry::MultiLineString(ml0())), - Some(geo::Geometry::MultiLineString(ml1())), - Some(geo::Geometry::Point(p0())), - Some(geo::Geometry::Point(p1())), - None, - ] - .try_into() - .unwrap(); + let orig_arr: MixedGeometryArray = ( + vec![ + Some(geo::Geometry::MultiLineString(ml0())), + Some(geo::Geometry::MultiLineString(ml1())), + Some(geo::Geometry::Point(p0())), + Some(geo::Geometry::Point(p1())), + None, + ], + Dimension::XY, + ) + .try_into() + .unwrap(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: MixedGeometryArray = wkb_arr.try_into().unwrap(); + let new_arr: MixedGeometryArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/geometrycollection.rs b/rust/geoarrow/src/io/wkb/writer/geometrycollection.rs index 603f450e..a58f81fc 100644 --- a/rust/geoarrow/src/io/wkb/writer/geometrycollection.rs +++ b/rust/geoarrow/src/io/wkb/writer/geometrycollection.rs @@ -46,6 +46,7 @@ impl From<&GeometryCollectionArray> for WKBArray { #[cfg(test)] mod test { use super::*; + use crate::datatypes::Dimension; use crate::test::multipoint; use crate::test::multipolygon; @@ -61,9 +62,10 @@ mod test { geo::Geometry::MultiPolygon(multipolygon::mp1()), ]); - let orig_arr: GeometryCollectionArray = vec![Some(gc0), Some(gc1), None].into(); + let orig_arr: GeometryCollectionArray = + (vec![Some(gc0), Some(gc1), None], Dimension::XY).into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: GeometryCollectionArray = wkb_arr.try_into().unwrap(); + let new_arr: GeometryCollectionArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/linestring.rs b/rust/geoarrow/src/io/wkb/writer/linestring.rs index e9b6c515..4f0e3aad 100644 --- a/rust/geoarrow/src/io/wkb/writer/linestring.rs +++ b/rust/geoarrow/src/io/wkb/writer/linestring.rs @@ -44,23 +44,25 @@ impl From<&LineStringArray> for WKBArray { #[cfg(test)] mod test { use super::*; + use crate::datatypes::Dimension; use crate::test::linestring::{ls0, ls1}; #[test] fn round_trip() { - let orig_arr: LineStringArray = vec![Some(ls0()), Some(ls1()), None].into(); + let orig_arr: LineStringArray = + (vec![Some(ls0()), Some(ls1()), None], Dimension::XY).into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: LineStringArray = wkb_arr.try_into().unwrap(); + let new_arr: LineStringArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(orig_arr, new_arr); } - // TODO: parsing WKBArray into LineStringArray not yet implemented #[test] fn round_trip_to_i64() { - let orig_arr: LineStringArray = vec![Some(ls0()), Some(ls1()), None].into(); + let orig_arr: LineStringArray = + (vec![Some(ls0()), Some(ls1()), None], Dimension::XY).into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: LineStringArray = wkb_arr.try_into().unwrap(); + let new_arr: LineStringArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/multilinestring.rs b/rust/geoarrow/src/io/wkb/writer/multilinestring.rs index e51db496..990eb78e 100644 --- a/rust/geoarrow/src/io/wkb/writer/multilinestring.rs +++ b/rust/geoarrow/src/io/wkb/writer/multilinestring.rs @@ -46,13 +46,15 @@ impl From<&MultiLineStringArray> for WKBArray { #[cfg(test)] mod test { use super::*; + use crate::datatypes::Dimension; use crate::test::multilinestring::{ml0, ml1}; #[test] fn round_trip() { - let orig_arr: MultiLineStringArray = vec![Some(ml0()), Some(ml1()), None].into(); + let orig_arr: MultiLineStringArray = + (vec![Some(ml0()), Some(ml1()), None], Dimension::XY).into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: MultiLineStringArray = wkb_arr.try_into().unwrap(); + let new_arr: MultiLineStringArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/multipoint.rs b/rust/geoarrow/src/io/wkb/writer/multipoint.rs index 58abbff8..e6dcd138 100644 --- a/rust/geoarrow/src/io/wkb/writer/multipoint.rs +++ b/rust/geoarrow/src/io/wkb/writer/multipoint.rs @@ -44,13 +44,15 @@ impl From<&MultiPointArray> for WKBArray { #[cfg(test)] mod test { use super::*; + use crate::datatypes::Dimension; use crate::test::multipoint::{mp0, mp1}; #[test] fn round_trip() { - let orig_arr: MultiPointArray = vec![Some(mp0()), Some(mp1()), None].into(); + let orig_arr: MultiPointArray = + (vec![Some(mp0()), Some(mp1()), None], Dimension::XY).into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: MultiPointArray = wkb_arr.try_into().unwrap(); + let new_arr: MultiPointArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/multipolygon.rs b/rust/geoarrow/src/io/wkb/writer/multipolygon.rs index 12223d20..e82a3333 100644 --- a/rust/geoarrow/src/io/wkb/writer/multipolygon.rs +++ b/rust/geoarrow/src/io/wkb/writer/multipolygon.rs @@ -46,13 +46,15 @@ impl From<&MultiPolygonArray> for WKBArray { #[cfg(test)] mod test { use super::*; + use crate::datatypes::Dimension; use crate::test::multipolygon::{mp0, mp1}; #[test] fn round_trip() { - let orig_arr: MultiPolygonArray = vec![Some(mp0()), Some(mp1()), None].into(); + let orig_arr: MultiPolygonArray = + (vec![Some(mp0()), Some(mp1()), None], Dimension::XY).into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: MultiPolygonArray = wkb_arr.try_into().unwrap(); + let new_arr: MultiPolygonArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/point.rs b/rust/geoarrow/src/io/wkb/writer/point.rs index e3bcabe1..7a9bb32e 100644 --- a/rust/geoarrow/src/io/wkb/writer/point.rs +++ b/rust/geoarrow/src/io/wkb/writer/point.rs @@ -46,23 +46,27 @@ impl From<&PointArray> for WKBArray { #[cfg(test)] mod test { use super::*; + use crate::datatypes::Dimension; use crate::test::point::{p0, p1, p2}; #[test] fn round_trip() { - // TODO: test with nulls - let orig_arr: PointArray = vec![Some(p0()), Some(p1()), Some(p2())].into(); + let orig_arr: PointArray = (vec![Some(p0()), Some(p1()), Some(p2())], Dimension::XY).into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: PointArray = wkb_arr.try_into().unwrap(); + let new_arr: PointArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(orig_arr, new_arr); } #[test] fn round_trip_with_null() { - let orig_arr: PointArray = vec![Some(p0()), None, Some(p1()), None, Some(p2())].into(); + let orig_arr: PointArray = ( + vec![Some(p0()), None, Some(p1()), None, Some(p2())], + Dimension::XY, + ) + .into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: PointArray = wkb_arr.try_into().unwrap(); + let new_arr: PointArray = (wkb_arr, Dimension::XY).try_into().unwrap(); assert_eq!(orig_arr, new_arr); } diff --git a/rust/geoarrow/src/io/wkb/writer/polygon.rs b/rust/geoarrow/src/io/wkb/writer/polygon.rs index 10a44b0e..4afdf7cf 100644 --- a/rust/geoarrow/src/io/wkb/writer/polygon.rs +++ b/rust/geoarrow/src/io/wkb/writer/polygon.rs @@ -44,15 +44,16 @@ impl From<&PolygonArray> for WKBArray { #[cfg(test)] mod test { use super::*; + use crate::datatypes::Dimension; use crate::test::polygon::{p0, p1}; use crate::trait_::ArrayAccessor; use geozero::{CoordDimensions, ToWkb}; #[test] fn round_trip() { - let orig_arr: PolygonArray = vec![Some(p0()), Some(p1()), None].into(); + let orig_arr: PolygonArray = (vec![Some(p0()), Some(p1()), None], Dimension::XY).into(); let wkb_arr: WKBArray = (&orig_arr).into(); - let new_arr: PolygonArray = wkb_arr.clone().try_into().unwrap(); + let new_arr: PolygonArray = (wkb_arr.clone(), Dimension::XY).try_into().unwrap(); let wkb0 = geo::Geometry::Polygon(p0()) .to_wkb(CoordDimensions::xy()) diff --git a/rust/geoarrow/src/io/wkt/writer/api.rs b/rust/geoarrow/src/io/wkt/writer/api.rs index 07a46ee0..c6b33cbb 100644 --- a/rust/geoarrow/src/io/wkt/writer/api.rs +++ b/rust/geoarrow/src/io/wkt/writer/api.rs @@ -3,7 +3,7 @@ use arrow_array::OffsetSizeTrait; use crate::array::{AsChunkedNativeArray, AsNativeArray, WKTArray}; use crate::chunked_array::{ChunkedGeometryArray, ChunkedNativeArray}; -use crate::datatypes::{Dimension, NativeType}; +use crate::datatypes::NativeType; use crate::io::wkt::writer::scalar::{ geometry_collection_to_wkt, geometry_to_wkt, line_string_to_wkt, multi_line_string_to_wkt, multi_point_to_wkt, multi_polygon_to_wkt, point_to_wkt, polygon_to_wkt, rect_to_wkt, @@ -24,12 +24,11 @@ impl ToWKT for &dyn NativeArray { let metadata = self.metadata(); let mut output_array = GenericStringBuilder::::new(); - use Dimension::*; use NativeType::*; macro_rules! impl_to_wkt { - ($cast_func:ident, $dim:expr, $to_wkt_func:expr) => { - for maybe_geom in self.$cast_func::<$dim>().iter() { + ($cast_func:ident, $to_wkt_func:expr) => { + for maybe_geom in self.$cast_func().iter() { output_array .append_option(maybe_geom.map(|geom| $to_wkt_func(&geom).to_string())); } @@ -37,32 +36,19 @@ impl ToWKT for &dyn NativeArray { } match self.data_type() { - Point(_, XY) => impl_to_wkt!(as_point, 2, point_to_wkt), - LineString(_, XY) => impl_to_wkt!(as_line_string, 2, line_string_to_wkt), - Polygon(_, XY) => impl_to_wkt!(as_polygon, 2, polygon_to_wkt), - MultiPoint(_, XY) => impl_to_wkt!(as_multi_point, 2, multi_point_to_wkt), - MultiLineString(_, XY) => { - impl_to_wkt!(as_multi_line_string, 2, multi_line_string_to_wkt) + Point(_, _) => impl_to_wkt!(as_point, point_to_wkt), + LineString(_, _) => impl_to_wkt!(as_line_string, line_string_to_wkt), + Polygon(_, _) => impl_to_wkt!(as_polygon, polygon_to_wkt), + MultiPoint(_, _) => impl_to_wkt!(as_multi_point, multi_point_to_wkt), + MultiLineString(_, _) => { + impl_to_wkt!(as_multi_line_string, multi_line_string_to_wkt) } - MultiPolygon(_, XY) => impl_to_wkt!(as_multi_polygon, 2, multi_polygon_to_wkt), - Mixed(_, XY) => impl_to_wkt!(as_mixed, 2, geometry_to_wkt), - GeometryCollection(_, XY) => { - impl_to_wkt!(as_geometry_collection, 2, geometry_collection_to_wkt) + MultiPolygon(_, _) => impl_to_wkt!(as_multi_polygon, multi_polygon_to_wkt), + Mixed(_, _) => impl_to_wkt!(as_mixed, geometry_to_wkt), + GeometryCollection(_, _) => { + impl_to_wkt!(as_geometry_collection, geometry_collection_to_wkt) } - Point(_, XYZ) => impl_to_wkt!(as_point, 3, point_to_wkt), - LineString(_, XYZ) => impl_to_wkt!(as_line_string, 3, line_string_to_wkt), - Polygon(_, XYZ) => impl_to_wkt!(as_polygon, 3, polygon_to_wkt), - MultiPoint(_, XYZ) => impl_to_wkt!(as_multi_point, 3, multi_point_to_wkt), - MultiLineString(_, XYZ) => { - impl_to_wkt!(as_multi_line_string, 3, multi_line_string_to_wkt) - } - MultiPolygon(_, XYZ) => impl_to_wkt!(as_multi_polygon, 3, multi_polygon_to_wkt), - Mixed(_, XYZ) => impl_to_wkt!(as_mixed, 3, geometry_to_wkt), - GeometryCollection(_, XYZ) => { - impl_to_wkt!(as_geometry_collection, 3, geometry_collection_to_wkt) - } - Rect(XY) => impl_to_wkt!(as_rect, 2, rect_to_wkt), - Rect(XYZ) => impl_to_wkt!(as_rect, 3, rect_to_wkt), + Rect(_) => impl_to_wkt!(as_rect, rect_to_wkt), } WKTArray::new(output_array.finish(), metadata) @@ -73,38 +59,24 @@ impl ToWKT for &dyn ChunkedNativeArray { type Output = ChunkedGeometryArray>; fn to_wkt(&self) -> Self::Output { - use Dimension::*; use NativeType::*; macro_rules! impl_to_wkt { - ($cast_func:ident, $dim:expr) => { - ChunkedGeometryArray::new( - self.$cast_func::<$dim>() - .map(|chunk| chunk.as_ref().to_wkt()), - ) + ($cast_func:ident) => { + ChunkedGeometryArray::new(self.$cast_func().map(|chunk| chunk.as_ref().to_wkt())) }; } match self.data_type() { - Point(_, XY) => impl_to_wkt!(as_point, 2), - LineString(_, XY) => impl_to_wkt!(as_line_string, 2), - Polygon(_, XY) => impl_to_wkt!(as_polygon, 2), - MultiPoint(_, XY) => impl_to_wkt!(as_multi_point, 2), - MultiLineString(_, XY) => impl_to_wkt!(as_multi_line_string, 2), - MultiPolygon(_, XY) => impl_to_wkt!(as_multi_polygon, 2), - Mixed(_, XY) => impl_to_wkt!(as_mixed, 2), - GeometryCollection(_, XY) => impl_to_wkt!(as_geometry_collection, 2), - Rect(XY) => impl_to_wkt!(as_rect, 2), - - Point(_, XYZ) => impl_to_wkt!(as_point, 3), - LineString(_, XYZ) => impl_to_wkt!(as_line_string, 3), - Polygon(_, XYZ) => impl_to_wkt!(as_polygon, 3), - MultiPoint(_, XYZ) => impl_to_wkt!(as_multi_point, 3), - MultiLineString(_, XYZ) => impl_to_wkt!(as_multi_line_string, 3), - MultiPolygon(_, XYZ) => impl_to_wkt!(as_multi_polygon, 3), - Mixed(_, XYZ) => impl_to_wkt!(as_mixed, 3), - GeometryCollection(_, XYZ) => impl_to_wkt!(as_geometry_collection, 3), - Rect(XYZ) => impl_to_wkt!(as_rect, 3), + Point(_, _) => impl_to_wkt!(as_point), + LineString(_, _) => impl_to_wkt!(as_line_string), + Polygon(_, _) => impl_to_wkt!(as_polygon), + MultiPoint(_, _) => impl_to_wkt!(as_multi_point), + MultiLineString(_, _) => impl_to_wkt!(as_multi_line_string), + MultiPolygon(_, _) => impl_to_wkt!(as_multi_polygon), + Mixed(_, _) => impl_to_wkt!(as_mixed), + GeometryCollection(_, _) => impl_to_wkt!(as_geometry_collection), + Rect(_) => impl_to_wkt!(as_rect), } } } diff --git a/rust/geoarrow/src/scalar/linestring/scalar.rs b/rust/geoarrow/src/scalar/linestring/scalar.rs index 2bc21196..79743961 100644 --- a/rust/geoarrow/src/scalar/linestring/scalar.rs +++ b/rust/geoarrow/src/scalar/linestring/scalar.rs @@ -139,14 +139,15 @@ impl> PartialEq for LineString<'_> { #[cfg(test)] mod test { use crate::array::LineStringArray; + use crate::datatypes::Dimension; use crate::test::linestring::{ls0, ls1}; use crate::trait_::ArrayAccessor; /// Test Eq where the current index is true but another index is false #[test] fn test_eq_other_index_false() { - let arr1: LineStringArray = vec![ls0(), ls1()].as_slice().into(); - let arr2: LineStringArray = vec![ls0(), ls0()].as_slice().into(); + let arr1: LineStringArray = (vec![ls0(), ls1()].as_slice(), Dimension::XY).into(); + let arr2: LineStringArray = (vec![ls0(), ls0()].as_slice(), Dimension::XY).into(); assert_eq!(arr1.value(0), arr2.value(0)); assert_ne!(arr1.value(1), arr2.value(1)); diff --git a/rust/geoarrow/src/scalar/multilinestring/scalar.rs b/rust/geoarrow/src/scalar/multilinestring/scalar.rs index 67edeb37..18c9bbbd 100644 --- a/rust/geoarrow/src/scalar/multilinestring/scalar.rs +++ b/rust/geoarrow/src/scalar/multilinestring/scalar.rs @@ -149,14 +149,15 @@ impl> PartialEq for MultiLineString<'_> { #[cfg(test)] mod test { use crate::array::MultiLineStringArray; + use crate::datatypes::Dimension; use crate::test::multilinestring::{ml0, ml1}; use crate::trait_::ArrayAccessor; /// Test Eq where the current index is true but another index is false #[test] fn test_eq_other_index_false() { - let arr1: MultiLineStringArray = vec![ml0(), ml1()].as_slice().into(); - let arr2: MultiLineStringArray = vec![ml0(), ml0()].as_slice().into(); + let arr1: MultiLineStringArray = (vec![ml0(), ml1()].as_slice(), Dimension::XY).into(); + let arr2: MultiLineStringArray = (vec![ml0(), ml0()].as_slice(), Dimension::XY).into(); assert_eq!(arr1.value(0), arr2.value(0)); assert_ne!(arr1.value(1), arr2.value(1)); diff --git a/rust/geoarrow/src/scalar/multipoint/scalar.rs b/rust/geoarrow/src/scalar/multipoint/scalar.rs index 331ed044..a7ed5605 100644 --- a/rust/geoarrow/src/scalar/multipoint/scalar.rs +++ b/rust/geoarrow/src/scalar/multipoint/scalar.rs @@ -147,14 +147,15 @@ impl> PartialEq for MultiPoint<'_> { #[cfg(test)] mod test { use crate::array::MultiPointArray; + use crate::datatypes::Dimension; use crate::test::multipoint::{mp0, mp1}; use crate::trait_::ArrayAccessor; /// Test Eq where the current index is true but another index is false #[test] fn test_eq_other_index_false() { - let arr1: MultiPointArray = vec![mp0(), mp1()].as_slice().into(); - let arr2: MultiPointArray = vec![mp0(), mp0()].as_slice().into(); + let arr1: MultiPointArray = (vec![mp0(), mp1()].as_slice(), Dimension::XY).into(); + let arr2: MultiPointArray = (vec![mp0(), mp0()].as_slice(), Dimension::XY).into(); assert_eq!(arr1.value(0), arr2.value(0)); assert_ne!(arr1.value(1), arr2.value(1)); diff --git a/rust/geoarrow/src/scalar/multipolygon/scalar.rs b/rust/geoarrow/src/scalar/multipolygon/scalar.rs index 851ab92a..6d2fbb1b 100644 --- a/rust/geoarrow/src/scalar/multipolygon/scalar.rs +++ b/rust/geoarrow/src/scalar/multipolygon/scalar.rs @@ -177,14 +177,15 @@ impl> PartialEq for MultiPolygon<'_> { #[cfg(test)] mod test { use crate::array::MultiPolygonArray; + use crate::datatypes::Dimension; use crate::test::multipolygon::{mp0, mp1}; use crate::trait_::ArrayAccessor; /// Test Eq where the current index is true but another index is false #[test] fn test_eq_other_index_false() { - let arr1: MultiPolygonArray = vec![mp0(), mp1()].as_slice().into(); - let arr2: MultiPolygonArray = vec![mp0(), mp0()].as_slice().into(); + let arr1: MultiPolygonArray = (vec![mp0(), mp1()].as_slice(), Dimension::XY).into(); + let arr2: MultiPolygonArray = (vec![mp0(), mp0()].as_slice(), Dimension::XY).into(); assert_eq!(arr1.value(0), arr2.value(0)); assert_ne!(arr1.value(1), arr2.value(1)); diff --git a/rust/geoarrow/src/scalar/polygon/scalar.rs b/rust/geoarrow/src/scalar/polygon/scalar.rs index cf157d9b..5f8ee130 100644 --- a/rust/geoarrow/src/scalar/polygon/scalar.rs +++ b/rust/geoarrow/src/scalar/polygon/scalar.rs @@ -175,14 +175,15 @@ impl> PartialEq for Polygon<'_> { #[cfg(test)] mod test { use crate::array::PolygonArray; + use crate::datatypes::Dimension; use crate::test::polygon::{p0, p1}; use crate::trait_::ArrayAccessor; /// Test Eq where the current index is true but another index is false #[test] fn test_eq_other_index_false() { - let arr1: PolygonArray = vec![p0(), p1()].as_slice().into(); - let arr2: PolygonArray = vec![p0(), p0()].as_slice().into(); + let arr1: PolygonArray = (vec![p0(), p1()].as_slice(), Dimension::XY).into(); + let arr2: PolygonArray = (vec![p0(), p0()].as_slice(), Dimension::XY).into(); assert_eq!(arr1.value(0), arr2.value(0)); assert_ne!(arr1.value(1), arr2.value(1)); diff --git a/rust/geoarrow/src/scalar/rect/scalar.rs b/rust/geoarrow/src/scalar/rect/scalar.rs index b877d644..6b1c1def 100644 --- a/rust/geoarrow/src/scalar/rect/scalar.rs +++ b/rust/geoarrow/src/scalar/rect/scalar.rs @@ -87,7 +87,7 @@ impl From> for geo::Geometry { } impl RTreeObject for Rect<'_> { - type Envelope = AABB<[f64; D]>; + type Envelope = AABB<[f64; 2]>; fn envelope(&self) -> Self::Envelope { let lower = self.min(); From b7ac9ed60dcd0b2e47941fb4cdd9484cde340756 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 21:55:55 -0500 Subject: [PATCH 07/14] progress --- rust/geoarrow/src/datatypes.rs | 2 +- rust/geoarrow/src/io/geozero/api/ewkb.rs | 37 +++++-- rust/geoarrow/src/io/geozero/api/wkt.rs | 58 +++++++--- .../src/io/geozero/table/builder/table.rs | 2 +- .../src/io/parquet/reader/metadata.rs | 9 +- rust/geoarrow/src/io/parquet/reader/parse.rs | 37 +++---- .../src/io/parquet/reader/spatial_filter.rs | 5 +- rust/geoarrow/src/io/parquet/test.rs | 3 +- .../src/io/parquet/writer/metadata.rs | 29 +---- rust/geoarrow/src/io/postgis/reader.rs | 3 +- rust/geoarrow/src/io/wkb/api.rs | 103 ++++++++++++++---- rust/geoarrow/src/io/wkt/reader/mod.rs | 5 +- rust/geoarrow/src/test/multipoint.rs | 9 +- rust/geoarrow/src/test/multipolygon.rs | 3 +- rust/geoarrow/src/test/point.rs | 2 +- rust/geoarrow/src/test/polygon.rs | 9 +- 16 files changed, 197 insertions(+), 119 deletions(-) diff --git a/rust/geoarrow/src/datatypes.rs b/rust/geoarrow/src/datatypes.rs index f9453d8e..a7969a7b 100644 --- a/rust/geoarrow/src/datatypes.rs +++ b/rust/geoarrow/src/datatypes.rs @@ -990,7 +990,7 @@ mod test { let data_type: NativeType = field.as_ref().try_into().unwrap(); assert_eq!(ml_array.data_type(), data_type); - let mut builder = MixedGeometryBuilder::new(); + let mut builder = MixedGeometryBuilder::new(Dimension::XY); builder.push_point(Some(&crate::test::point::p0())).unwrap(); builder.push_point(Some(&crate::test::point::p1())).unwrap(); builder.push_point(Some(&crate::test::point::p2())).unwrap(); diff --git a/rust/geoarrow/src/io/geozero/api/ewkb.rs b/rust/geoarrow/src/io/geozero/api/ewkb.rs index afcf049c..58ceaf81 100644 --- a/rust/geoarrow/src/io/geozero/api/ewkb.rs +++ b/rust/geoarrow/src/io/geozero/api/ewkb.rs @@ -8,6 +8,7 @@ use crate::array::*; use crate::chunked_array::{ ChunkedGeometryCollectionArray, ChunkedMixedGeometryArray, ChunkedNativeArray, ChunkedWKBArray, }; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geozero::array::MixedGeometryStreamBuilder; use crate::NativeArray; @@ -21,23 +22,25 @@ pub trait FromEWKB: Sized { fn from_ewkb( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result; } -impl FromEWKB for MixedGeometryArray<2> { +impl FromEWKB for MixedGeometryArray { type Input = WKBArray; fn from_ewkb( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { let arr = arr.clone().into_inner(); let mut builder = - MixedGeometryStreamBuilder::new_with_options(coord_type, metadata, prefer_multi); + MixedGeometryStreamBuilder::new_with_options(dim, coord_type, metadata, prefer_multi); for i in 0..arr.len() { if arr.is_valid(i) { process_ewkb_geom(&mut Cursor::new(arr.value(i)), &mut builder)?; @@ -50,19 +53,20 @@ impl FromEWKB for MixedGeometryArray<2> { } } -impl FromEWKB for GeometryCollectionArray<2> { +impl FromEWKB for GeometryCollectionArray { type Input = WKBArray; fn from_ewkb( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { // TODO: Add GeometryCollectionStreamBuilder and use that instead of going through geo let arr = arr.clone().into_inner(); let mut builder = - GeometryCollectionBuilder::new_with_options(coord_type, metadata, prefer_multi); + GeometryCollectionBuilder::new_with_options(dim, coord_type, metadata, prefer_multi); for i in 0..arr.len() { if arr.is_valid(i) { let buf = arr.value(i); @@ -85,40 +89,47 @@ impl FromEWKB for Arc { fn from_ewkb( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { let geom_arr = - GeometryCollectionArray::<2>::from_ewkb(arr, coord_type, metadata, prefer_multi)?; + GeometryCollectionArray::from_ewkb(arr, coord_type, dim, metadata, prefer_multi)?; Ok(geom_arr.downcast(true)) } } -impl FromEWKB for ChunkedMixedGeometryArray<2> { +impl FromEWKB for ChunkedMixedGeometryArray { type Input = ChunkedWKBArray; fn from_ewkb( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { - arr.try_map(|chunk| FromEWKB::from_ewkb(chunk, coord_type, metadata.clone(), prefer_multi))? - .try_into() + arr.try_map(|chunk| { + FromEWKB::from_ewkb(chunk, coord_type, dim, metadata.clone(), prefer_multi) + })? + .try_into() } } -impl FromEWKB for ChunkedGeometryCollectionArray<2> { +impl FromEWKB for ChunkedGeometryCollectionArray { type Input = ChunkedWKBArray; fn from_ewkb( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { - arr.try_map(|chunk| FromEWKB::from_ewkb(chunk, coord_type, metadata.clone(), prefer_multi))? - .try_into() + arr.try_map(|chunk| { + FromEWKB::from_ewkb(chunk, coord_type, dim, metadata.clone(), prefer_multi) + })? + .try_into() } } @@ -128,12 +139,14 @@ impl FromEWKB for Arc { fn from_ewkb( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { - let geom_arr = ChunkedGeometryCollectionArray::<2>::from_ewkb( + let geom_arr = ChunkedGeometryCollectionArray::from_ewkb( arr, coord_type, + dim, metadata, prefer_multi, )?; diff --git a/rust/geoarrow/src/io/geozero/api/wkt.rs b/rust/geoarrow/src/io/geozero/api/wkt.rs index de49ac8e..bb8dc79a 100644 --- a/rust/geoarrow/src/io/geozero/api/wkt.rs +++ b/rust/geoarrow/src/io/geozero/api/wkt.rs @@ -7,6 +7,7 @@ use crate::array::*; use crate::chunked_array::{ ChunkedArray, ChunkedGeometryCollectionArray, ChunkedMixedGeometryArray, ChunkedNativeArray, }; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geozero::array::MixedGeometryStreamBuilder; use crate::NativeArray; @@ -19,22 +20,24 @@ pub trait FromWKT: Sized { fn from_wkt( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result; } -impl FromWKT for MixedGeometryArray<2> { +impl FromWKT for MixedGeometryArray { type Input = GenericStringArray; fn from_wkt( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { let mut builder = - MixedGeometryStreamBuilder::new_with_options(coord_type, metadata, prefer_multi); + MixedGeometryStreamBuilder::new_with_options(dim, coord_type, metadata, prefer_multi); for i in 0..arr.len() { if arr.is_valid(i) { let wkt_str = geozero::wkt::Wkt(arr.value(i)); @@ -48,18 +51,19 @@ impl FromWKT for MixedGeometryArray<2> { } } -impl FromWKT for GeometryCollectionArray<2> { +impl FromWKT for GeometryCollectionArray { type Input = GenericStringArray; fn from_wkt( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { // TODO: Add GeometryCollectionStreamBuilder and use that instead of going through geo let mut builder = - GeometryCollectionBuilder::new_with_options(coord_type, metadata, prefer_multi); + GeometryCollectionBuilder::new_with_options(dim, coord_type, metadata, prefer_multi); for i in 0..arr.len() { if arr.is_valid(i) { let wkt_str = geozero::wkt::Wkt(arr.value(i)); @@ -80,40 +84,47 @@ impl FromWKT for Arc { fn from_wkt( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { let geom_arr = - GeometryCollectionArray::<2>::from_wkt(arr, coord_type, metadata, prefer_multi)?; + GeometryCollectionArray::from_wkt(arr, coord_type, dim, metadata, prefer_multi)?; Ok(geom_arr.downcast(true)) } } -impl FromWKT for ChunkedMixedGeometryArray<2> { +impl FromWKT for ChunkedMixedGeometryArray { type Input = ChunkedArray>; fn from_wkt( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { - arr.try_map(|chunk| FromWKT::from_wkt(chunk, coord_type, metadata.clone(), prefer_multi))? - .try_into() + arr.try_map(|chunk| { + FromWKT::from_wkt(chunk, coord_type, dim, metadata.clone(), prefer_multi) + })? + .try_into() } } -impl FromWKT for ChunkedGeometryCollectionArray<2> { +impl FromWKT for ChunkedGeometryCollectionArray { type Input = ChunkedArray>; fn from_wkt( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { - arr.try_map(|chunk| FromWKT::from_wkt(chunk, coord_type, metadata.clone(), prefer_multi))? - .try_into() + arr.try_map(|chunk| { + FromWKT::from_wkt(chunk, coord_type, dim, metadata.clone(), prefer_multi) + })? + .try_into() } } @@ -123,11 +134,12 @@ impl FromWKT for Arc { fn from_wkt( arr: &Self::Input, coord_type: CoordType, + dim: Dimension, metadata: Arc, prefer_multi: bool, ) -> Result { let geom_arr = - ChunkedGeometryCollectionArray::<2>::from_wkt(arr, coord_type, metadata, prefer_multi)?; + ChunkedGeometryCollectionArray::from_wkt(arr, coord_type, dim, metadata, prefer_multi)?; Ok(geom_arr.downcast(true)) } } @@ -151,9 +163,14 @@ mod test { wkt_geoms.iter().for_each(|s| builder.append_value(s)); let arr = builder.finish(); // dbg!(arr); - let geom_arr = - MixedGeometryArray::<2>::from_wkt(&arr, Default::default(), Default::default(), false) - .unwrap(); + let geom_arr = MixedGeometryArray::from_wkt( + &arr, + Default::default(), + Dimension::XY, + Default::default(), + false, + ) + .unwrap(); let geo_point = geo::Point::try_from(geom_arr.value(0).to_geo().unwrap()).unwrap(); assert_eq!(geo_point.x(), 30.0); assert_eq!(geo_point.y(), 10.0); @@ -166,9 +183,14 @@ mod test { wkt_geoms.iter().for_each(|s| builder.append_value(s)); let arr = builder.finish(); // dbg!(arr); - let geom_arr = - MixedGeometryArray::<2>::from_wkt(&arr, Default::default(), Default::default(), true) - .unwrap(); + let geom_arr = MixedGeometryArray::from_wkt( + &arr, + Default::default(), + Dimension::XY, + Default::default(), + true, + ) + .unwrap(); let geom_arr = geom_arr.downcast(true); assert!(matches!( geom_arr.data_type(), diff --git a/rust/geoarrow/src/io/geozero/table/builder/table.rs b/rust/geoarrow/src/io/geozero/table/builder/table.rs index dd6ad69d..13840e3c 100644 --- a/rust/geoarrow/src/io/geozero/table/builder/table.rs +++ b/rust/geoarrow/src/io/geozero/table/builder/table.rs @@ -238,7 +238,7 @@ impl GeoTableBuilder { impl Default for GeoTableBuilder { fn default() -> Self { - Self::new() + Self::new(Dimension::XY) } } diff --git a/rust/geoarrow/src/io/parquet/reader/metadata.rs b/rust/geoarrow/src/io/parquet/reader/metadata.rs index c2760129..60103171 100644 --- a/rust/geoarrow/src/io/parquet/reader/metadata.rs +++ b/rust/geoarrow/src/io/parquet/reader/metadata.rs @@ -11,6 +11,7 @@ use parquet::schema::types::SchemaDescriptor; use serde_json::Value; use crate::array::{CoordType, RectArray, RectBuilder}; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::io::parquet::metadata::{GeoParquetBboxCovering, GeoParquetMetadata}; use crate::io::parquet::reader::parse::infer_target_schema; @@ -159,10 +160,7 @@ impl GeoParquetReaderMetadata { /// /// As of GeoParquet 1.1 you won't need to pass in these column names, as they'll be specified /// in the metadata. - pub fn row_groups_bounds( - &self, - paths: Option<&GeoParquetBboxCovering>, - ) -> Result> { + pub fn row_groups_bounds(&self, paths: Option<&GeoParquetBboxCovering>) -> Result { let paths = if let Some(paths) = paths { paths } else { @@ -183,7 +181,8 @@ impl GeoParquetReaderMetadata { .iter() .map(|rg_meta| geo_statistics.get_bbox(rg_meta)) .collect::>>()?; - let rect_array = RectBuilder::from_rects(rects.iter(), Default::default()).finish(); + let rect_array = + RectBuilder::from_rects(rects.iter(), Dimension::XY, Default::default()).finish(); Ok(rect_array) } diff --git a/rust/geoarrow/src/io/parquet/reader/parse.rs b/rust/geoarrow/src/io/parquet/reader/parse.rs index c9f9b497..dd4717b9 100644 --- a/rust/geoarrow/src/io/parquet/reader/parse.rs +++ b/rust/geoarrow/src/io/parquet/reader/parse.rs @@ -170,25 +170,18 @@ fn parse_array( orig_field: &Field, target_field: &Field, ) -> Result> { - use Dimension::*; use NativeType::*; let orig_type = AnyType::try_from(orig_field)?; let arr = array.as_ref(); match orig_type { AnyType::Native(t) => match t { - Point(_, XY) => parse_point_column::<2>(arr), - LineString(_, XY) => parse_line_string_column::<2>(arr), - Polygon(_, XY) => parse_polygon_column::<2>(arr), - MultiPoint(_, XY) => parse_multi_point_column::<2>(arr), - MultiLineString(_, XY) => parse_multi_line_string_column::<2>(arr), - MultiPolygon(_, XY) => parse_multi_polygon_column::<2>(arr), - Point(_, XYZ) => parse_point_column::<3>(arr), - LineString(_, XYZ) => parse_line_string_column::<3>(arr), - Polygon(_, XYZ) => parse_polygon_column::<3>(arr), - MultiPoint(_, XYZ) => parse_multi_point_column::<3>(arr), - MultiLineString(_, XYZ) => parse_multi_line_string_column::<3>(arr), - MultiPolygon(_, XYZ) => parse_multi_polygon_column::<3>(arr), + Point(_, dim) => parse_point_column(arr, dim), + LineString(_, dim) => parse_line_string_column(arr, dim), + Polygon(_, dim) => parse_polygon_column(arr, dim), + MultiPoint(_, dim) => parse_multi_point_column(arr, dim), + MultiLineString(_, dim) => parse_multi_line_string_column(arr, dim), + MultiPolygon(_, dim) => parse_multi_polygon_column(arr, dim), other => Err(GeoArrowError::General(format!( "Unexpected geometry encoding: {:?}", other @@ -226,17 +219,17 @@ fn parse_wkb_column(arr: &dyn Array, target_geo_data_type: NativeType) -> Result } } -fn parse_point_column(array: &dyn Array) -> Result> { - let geom_arr: PointArray = array.try_into()?; +fn parse_point_column(array: &dyn Array, dim: Dimension) -> Result> { + let geom_arr: PointArray = (array, dim).try_into()?; Ok(geom_arr.into_array_ref()) } macro_rules! impl_parse_fn { ($fn_name:ident, $geoarrow_type:ty) => { - fn $fn_name(array: &dyn Array) -> Result> { + fn $fn_name(array: &dyn Array, dim: Dimension) -> Result> { match array.data_type() { DataType::List(_) | DataType::LargeList(_) => { - let geom_arr: $geoarrow_type = array.try_into()?; + let geom_arr: $geoarrow_type = (array, dim).try_into()?; Ok(geom_arr.into_array_ref()) } dt => Err(GeoArrowError::General(format!( @@ -248,8 +241,8 @@ macro_rules! impl_parse_fn { }; } -impl_parse_fn!(parse_line_string_column, LineStringArray); -impl_parse_fn!(parse_polygon_column, PolygonArray); -impl_parse_fn!(parse_multi_point_column, MultiPointArray); -impl_parse_fn!(parse_multi_line_string_column, MultiLineStringArray); -impl_parse_fn!(parse_multi_polygon_column, MultiPolygonArray); +impl_parse_fn!(parse_line_string_column, LineStringArray); +impl_parse_fn!(parse_polygon_column, PolygonArray); +impl_parse_fn!(parse_multi_point_column, MultiPointArray); +impl_parse_fn!(parse_multi_line_string_column, MultiLineStringArray); +impl_parse_fn!(parse_multi_polygon_column, MultiPolygonArray); diff --git a/rust/geoarrow/src/io/parquet/reader/spatial_filter.rs b/rust/geoarrow/src/io/parquet/reader/spatial_filter.rs index a85a606a..0868eaa7 100644 --- a/rust/geoarrow/src/io/parquet/reader/spatial_filter.rs +++ b/rust/geoarrow/src/io/parquet/reader/spatial_filter.rs @@ -18,6 +18,7 @@ use parquet::schema::types::{ColumnPath, SchemaDescriptor}; use crate::algorithm::geo::BoundingRect; use crate::array::{NativeArrayDyn, RectArray, RectBuilder}; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::io::parquet::metadata::GeoParquetBboxCovering; use crate::trait_::ArrayAccessor; @@ -147,8 +148,8 @@ impl<'a> ParquetBboxStatistics<'a> { } /// Extract the bounding boxes for a sequence of row groups - pub fn get_bboxes(&self, row_groups: &[RowGroupMetaData]) -> Result> { - let mut builder = RectBuilder::with_capacity(row_groups.len()); + pub fn get_bboxes(&self, row_groups: &[RowGroupMetaData]) -> Result { + let mut builder = RectBuilder::with_capacity(Dimension::XY, row_groups.len()); for rg_meta in row_groups.iter() { builder.push_rect(Some(&self.get_bbox(rg_meta)?)); } diff --git a/rust/geoarrow/src/io/parquet/test.rs b/rust/geoarrow/src/io/parquet/test.rs index 761545e2..7f02eb11 100644 --- a/rust/geoarrow/src/io/parquet/test.rs +++ b/rust/geoarrow/src/io/parquet/test.rs @@ -8,6 +8,7 @@ use bytes::Bytes; use crate::array::MixedGeometryBuilder; use crate::chunked_array::ChunkedNativeArrayDyn; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::parquet::{write_geoparquet, GeoParquetRecordBatchReaderBuilder}; use crate::table::Table; @@ -41,7 +42,7 @@ fn round_trip_nybb() -> Result<()> { // Test from https://github.com/geoarrow/geoarrow-rs/pull/717 #[test] fn mixed_geometry_roundtrip() { - let mut builder = MixedGeometryBuilder::<2>::new(); + let mut builder = MixedGeometryBuilder::new(Dimension::XY); builder .push_point(Some(&geo::point!(x: -105., y: 40.))) .unwrap(); diff --git a/rust/geoarrow/src/io/parquet/writer/metadata.rs b/rust/geoarrow/src/io/parquet/writer/metadata.rs index 7a608d62..91d2c830 100644 --- a/rust/geoarrow/src/io/parquet/writer/metadata.rs +++ b/rust/geoarrow/src/io/parquet/writer/metadata.rs @@ -80,33 +80,8 @@ impl ColumnInfo { // We only have to do this for mixed arrays because other arrays are statically known match array_ref.data_type() { - NativeType::Mixed(_, Dimension::XY) => { - let mixed_arr = array_ref.as_mixed::<2>(); - if mixed_arr.has_points() { - self.geometry_types.insert(GeoParquetGeometryType::Point); - } - if mixed_arr.has_line_strings() { - self.geometry_types - .insert(GeoParquetGeometryType::LineString); - } - if mixed_arr.has_polygons() { - self.geometry_types.insert(GeoParquetGeometryType::Polygon); - } - if mixed_arr.has_multi_points() { - self.geometry_types - .insert(GeoParquetGeometryType::MultiPoint); - } - if mixed_arr.has_multi_line_strings() { - self.geometry_types - .insert(GeoParquetGeometryType::MultiLineString); - } - if mixed_arr.has_multi_polygons() { - self.geometry_types - .insert(GeoParquetGeometryType::MultiPolygon); - } - } - NativeType::Mixed(_, Dimension::XYZ) => { - let mixed_arr = array_ref.as_mixed::<3>(); + NativeType::Mixed(_, _) => { + let mixed_arr = array_ref.as_mixed(); if mixed_arr.has_points() { self.geometry_types.insert(GeoParquetGeometryType::Point); } diff --git a/rust/geoarrow/src/io/postgis/reader.rs b/rust/geoarrow/src/io/postgis/reader.rs index 53945b49..fe3fdd70 100644 --- a/rust/geoarrow/src/io/postgis/reader.rs +++ b/rust/geoarrow/src/io/postgis/reader.rs @@ -10,6 +10,7 @@ use sqlx::{Column, Decode, Executor, Postgres, Row, Type, TypeInfo}; use std::io::Cursor; use std::sync::Arc; +use crate::datatypes::Dimension; use crate::error::{GeoArrowError, Result}; use crate::io::geozero::array::MixedGeometryStreamBuilder; use crate::io::geozero::table::{GeoTableBuilder, GeoTableBuilderOptions}; @@ -160,7 +161,7 @@ impl GeoTableBuilder { options.properties_schema = Some(Arc::new(schema.finish())); // Create builder and add this row - let mut builder = Self::new_with_options(options); + let mut builder = Self::new_with_options(Dimension::XY, options); builder.add_postgres_row(0, row)?; Ok(builder) } diff --git a/rust/geoarrow/src/io/wkb/api.rs b/rust/geoarrow/src/io/wkb/api.rs index 21c30783..de45ee48 100644 --- a/rust/geoarrow/src/io/wkb/api.rs +++ b/rust/geoarrow/src/io/wkb/api.rs @@ -19,15 +19,23 @@ use arrow_array::OffsetSizeTrait; pub trait FromWKB: Sized { type Input; - fn from_wkb(arr: &Self::Input, coord_type: CoordType) -> Result; + fn from_wkb( + arr: &Self::Input, + coord_type: CoordType, + dim: Dimension, + ) -> Result; } impl FromWKB for PointArray { type Input = WKBArray; - fn from_wkb(arr: &WKBArray, coord_type: CoordType) -> Result { + fn from_wkb( + arr: &WKBArray, + coord_type: CoordType, + dim: Dimension, + ) -> Result { let wkb_objects: Vec>> = arr.iter().collect(); - let builder = PointBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + let builder = PointBuilder::from_wkb(&wkb_objects, dim, Some(coord_type), arr.metadata())?; Ok(builder.finish()) } } @@ -40,9 +48,11 @@ macro_rules! impl_from_wkb { fn from_wkb( arr: &WKBArray, coord_type: CoordType, + dim: Dimension, ) -> Result { let wkb_objects: Vec>> = arr.iter().collect(); - let builder = <$builder>::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + let builder = + <$builder>::from_wkb(&wkb_objects, dim, Some(coord_type), arr.metadata())?; Ok(builder.finish()) } } @@ -58,10 +68,19 @@ impl_from_wkb!(MultiPolygonArray, MultiPolygonBuilder); impl FromWKB for MixedGeometryArray { type Input = WKBArray; - fn from_wkb(arr: &WKBArray, coord_type: CoordType) -> Result { + fn from_wkb( + arr: &WKBArray, + coord_type: CoordType, + dim: Dimension, + ) -> Result { let wkb_objects: Vec>> = arr.iter().collect(); - let builder = - MixedGeometryBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata(), true)?; + let builder = MixedGeometryBuilder::from_wkb( + &wkb_objects, + dim, + Some(coord_type), + arr.metadata(), + true, + )?; Ok(builder.finish()) } } @@ -69,10 +88,15 @@ impl FromWKB for MixedGeometryArray { impl FromWKB for GeometryCollectionArray { type Input = WKBArray; - fn from_wkb(arr: &WKBArray, coord_type: CoordType) -> Result { + fn from_wkb( + arr: &WKBArray, + coord_type: CoordType, + dim: Dimension, + ) -> Result { let wkb_objects: Vec>> = arr.iter().collect(); let builder = GeometryCollectionBuilder::from_wkb( &wkb_objects, + dim, Some(coord_type), arr.metadata(), true, @@ -84,10 +108,15 @@ impl FromWKB for GeometryCollectionArray { impl FromWKB for Arc { type Input = WKBArray; - fn from_wkb(arr: &WKBArray, coord_type: CoordType) -> Result { + fn from_wkb( + arr: &WKBArray, + coord_type: CoordType, + dim: Dimension, + ) -> Result { let wkb_objects: Vec>> = arr.iter().collect(); let builder = GeometryCollectionBuilder::from_wkb( &wkb_objects, + dim, Some(coord_type), arr.metadata(), true, @@ -99,8 +128,12 @@ impl FromWKB for Arc { impl FromWKB for ChunkedPointArray { type Input = ChunkedWKBArray; - fn from_wkb(arr: &Self::Input, coord_type: CoordType) -> Result { - arr.try_map(|chunk| FromWKB::from_wkb(chunk, coord_type))? + fn from_wkb( + arr: &Self::Input, + coord_type: CoordType, + dim: Dimension, + ) -> Result { + arr.try_map(|chunk| FromWKB::from_wkb(chunk, coord_type, dim))? .try_into() } } @@ -113,8 +146,9 @@ macro_rules! impl_chunked { fn from_wkb( arr: &ChunkedWKBArray, coord_type: CoordType, + dim: Dimension, ) -> Result { - arr.try_map(|chunk| FromWKB::from_wkb(chunk, coord_type))? + arr.try_map(|chunk| FromWKB::from_wkb(chunk, coord_type, dim))? .try_into() } } @@ -135,8 +169,9 @@ impl FromWKB for Arc { fn from_wkb( arr: &ChunkedWKBArray, coord_type: CoordType, + dim: Dimension, ) -> Result { - let geom_arr = ChunkedGeometryCollectionArray::from_wkb(arr, coord_type)?; + let geom_arr = ChunkedGeometryCollectionArray::from_wkb(arr, coord_type, dim)?; Ok(geom_arr.downcast(true)) } } @@ -155,40 +190,59 @@ pub fn from_wkb( let wkb_objects: Vec>> = arr.iter().collect(); match target_geo_data_type { Point(coord_type, _) => { - let builder = PointBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + let builder = + PointBuilder::from_wkb(&wkb_objects, target_dim, Some(coord_type), arr.metadata())?; Ok(Arc::new(builder.finish())) } LineString(coord_type, _) => { let builder = LineStringBuilder::from_wkb( - target_dim, &wkb_objects, + target_dim, Some(coord_type), arr.metadata(), )?; Ok(Arc::new(builder.finish())) } Polygon(coord_type, _) => { - let builder = PolygonBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + let builder = PolygonBuilder::from_wkb( + &wkb_objects, + target_dim, + Some(coord_type), + arr.metadata(), + )?; Ok(Arc::new(builder.finish())) } MultiPoint(coord_type, _) => { - let builder = - MultiPointBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + let builder = MultiPointBuilder::from_wkb( + &wkb_objects, + target_dim, + Some(coord_type), + arr.metadata(), + )?; Ok(Arc::new(builder.finish())) } MultiLineString(coord_type, _) => { - let builder = - MultiLineStringBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + let builder = MultiLineStringBuilder::from_wkb( + &wkb_objects, + target_dim, + Some(coord_type), + arr.metadata(), + )?; Ok(Arc::new(builder.finish())) } MultiPolygon(coord_type, _) => { - let builder = - MultiPolygonBuilder::from_wkb(&wkb_objects, Some(coord_type), arr.metadata())?; + let builder = MultiPolygonBuilder::from_wkb( + &wkb_objects, + target_dim, + Some(coord_type), + arr.metadata(), + )?; Ok(Arc::new(builder.finish())) } Mixed(coord_type, _) => { let builder = MixedGeometryBuilder::from_wkb( &wkb_objects, + target_dim, Some(coord_type), arr.metadata(), prefer_multi, @@ -198,6 +252,7 @@ pub fn from_wkb( GeometryCollection(coord_type, _) => { let builder = GeometryCollectionBuilder::from_wkb( &wkb_objects, + target_dim, Some(coord_type), arr.metadata(), prefer_multi, @@ -339,7 +394,7 @@ mod test { ) .unwrap(); let rt_ref = roundtrip_mixed.as_ref(); - let rt_mixed_arr = rt_ref.as_mixed::<3>(); + let rt_mixed_arr = rt_ref.as_mixed(); assert!(rt_mixed_arr.has_points()); let roundtrip_point = from_wkb( @@ -349,7 +404,7 @@ mod test { ) .unwrap(); let rt_ref = roundtrip_point.as_ref(); - let rt_arr = rt_ref.as_point::<3>(); + let rt_arr = rt_ref.as_point(); assert_eq!(rt_arr, &arr); } } diff --git a/rust/geoarrow/src/io/wkt/reader/mod.rs b/rust/geoarrow/src/io/wkt/reader/mod.rs index aea8dcaa..54a5edeb 100644 --- a/rust/geoarrow/src/io/wkt/reader/mod.rs +++ b/rust/geoarrow/src/io/wkt/reader/mod.rs @@ -5,6 +5,7 @@ use arrow_array::{Array, GenericStringArray, OffsetSizeTrait}; use crate::array::metadata::ArrayMetadata; use crate::array::{CoordType, MixedGeometryBuilder}; +use crate::datatypes::Dimension; use crate::NativeArray; // mod wkt_trait; @@ -21,7 +22,9 @@ impl ParseWKT for GenericStringArray { fn parse_wkt(&self, coord_type: CoordType, metadata: Arc) -> Self::Output { // TODO: switch this prefer_multi to true when we use downcasting here. - let mut builder = MixedGeometryBuilder::new_with_options(coord_type, metadata, false); + // TODO: Support xyz, xyzm, etc WKT input + let mut builder = + MixedGeometryBuilder::new_with_options(Dimension::XY, coord_type, metadata, false); for i in 0..self.len() { if self.is_valid(i) { let w = wkt::Wkt::::from_str(self.value(i)).unwrap(); diff --git a/rust/geoarrow/src/test/multipoint.rs b/rust/geoarrow/src/test/multipoint.rs index 45e44747..d804f746 100644 --- a/rust/geoarrow/src/test/multipoint.rs +++ b/rust/geoarrow/src/test/multipoint.rs @@ -1,6 +1,7 @@ use geo::{point, MultiPoint}; use crate::array::{MultiPointArray, MultiPointBuilder}; +use crate::datatypes::Dimension; pub(crate) fn mp0() -> MultiPoint { MultiPoint::new(vec![ @@ -26,5 +27,11 @@ pub(crate) fn mp1() -> MultiPoint { pub(crate) fn mp_array() -> MultiPointArray { let geoms = vec![mp0(), mp1()]; - MultiPointBuilder::from_multi_points(&geoms, Default::default(), Default::default()).finish() + MultiPointBuilder::from_multi_points( + &geoms, + Dimension::XY, + Default::default(), + Default::default(), + ) + .finish() } diff --git a/rust/geoarrow/src/test/multipolygon.rs b/rust/geoarrow/src/test/multipolygon.rs index 04c7c113..e906c39c 100644 --- a/rust/geoarrow/src/test/multipolygon.rs +++ b/rust/geoarrow/src/test/multipolygon.rs @@ -1,6 +1,7 @@ use geo::{polygon, MultiPolygon}; use crate::array::MultiPolygonArray; +use crate::datatypes::Dimension; pub(crate) fn mp0() -> MultiPolygon { MultiPolygon::new(vec![ @@ -47,5 +48,5 @@ pub(crate) fn mp1() -> MultiPolygon { } pub(crate) fn mp_array() -> MultiPolygonArray { - vec![mp0(), mp1()].as_slice().into() + (vec![mp0(), mp1()].as_slice(), Dimension::XY).into() } diff --git a/rust/geoarrow/src/test/point.rs b/rust/geoarrow/src/test/point.rs index fb219a4f..708e3695 100644 --- a/rust/geoarrow/src/test/point.rs +++ b/rust/geoarrow/src/test/point.rs @@ -73,7 +73,7 @@ impl CoordTrait for CoordZ { } pub(crate) fn point_z_array() -> PointArray { - let mut builder = PointBuilder::with_capacity(3); + let mut builder = PointBuilder::with_capacity(Dimension::XYZ, 3); let coords = vec![ CoordZ { x: 0., diff --git a/rust/geoarrow/src/test/polygon.rs b/rust/geoarrow/src/test/polygon.rs index 95c23865..07f6aeb5 100644 --- a/rust/geoarrow/src/test/polygon.rs +++ b/rust/geoarrow/src/test/polygon.rs @@ -1,4 +1,5 @@ use crate::array::{PolygonArray, PolygonBuilder}; +use crate::datatypes::Dimension; use geo::{polygon, Polygon}; pub(crate) fn p0() -> Polygon { @@ -31,5 +32,11 @@ pub(crate) fn p1() -> Polygon { pub(crate) fn p_array() -> PolygonArray { let geoms = vec![p0(), p1()]; - PolygonBuilder::from_polygons(&geoms, Default::default(), Default::default()).finish() + PolygonBuilder::from_polygons( + &geoms, + Dimension::XY, + Default::default(), + Default::default(), + ) + .finish() } From 1d0182f06b7d8fcf31e81bd6847b7c50a3ee12f1 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 21:59:02 -0500 Subject: [PATCH 08/14] progress --- rust/geoarrow/src/io/csv/reader.rs | 7 ++- rust/geoarrow/src/io/display/array.rs | 2 +- rust/geoarrow/src/io/display/chunked_array.rs | 21 ++++----- rust/geoarrow/src/io/display/scalar.rs | 3 +- .../src/io/flatgeobuf/reader/async.rs | 46 +++++++++---------- .../geoarrow/src/io/flatgeobuf/reader/sync.rs | 46 +++++++++---------- rust/geoarrow/src/io/geojson/reader.rs | 4 +- rust/geoarrow/src/io/geojson_lines/reader.rs | 4 +- 8 files changed, 65 insertions(+), 68 deletions(-) diff --git a/rust/geoarrow/src/io/csv/reader.rs b/rust/geoarrow/src/io/csv/reader.rs index 189c7edd..a2595adb 100644 --- a/rust/geoarrow/src/io/csv/reader.rs +++ b/rust/geoarrow/src/io/csv/reader.rs @@ -3,6 +3,7 @@ use geozero::GeozeroDatasource; use std::io::Read; use crate::array::CoordType; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geozero::array::MixedGeometryStreamBuilder; use crate::io::geozero::table::{GeoTableBuilder, GeoTableBuilderOptions}; @@ -47,8 +48,10 @@ pub fn read_csv( None, Default::default(), ); - let mut geo_table = - GeoTableBuilder::>::new_with_options(table_builder_options); + let mut geo_table = GeoTableBuilder::::new_with_options( + Dimension::XY, + table_builder_options, + ); csv.process(&mut geo_table)?; geo_table.finish() } diff --git a/rust/geoarrow/src/io/display/array.rs b/rust/geoarrow/src/io/display/array.rs index b1440773..bb77d651 100644 --- a/rust/geoarrow/src/io/display/array.rs +++ b/rust/geoarrow/src/io/display/array.rs @@ -180,7 +180,7 @@ mod test { #[test] fn test_display_ls_array() { - let array = linestring::large_ls_array(); + let array = linestring::ls_array(); let result = array.to_string(); let expected = "LineStringArray([ , diff --git a/rust/geoarrow/src/io/display/chunked_array.rs b/rust/geoarrow/src/io/display/chunked_array.rs index dcbee523..deed1b22 100644 --- a/rust/geoarrow/src/io/display/chunked_array.rs +++ b/rust/geoarrow/src/io/display/chunked_array.rs @@ -3,7 +3,7 @@ use std::fmt; use crate::chunked_array::*; use crate::io::display::array::{write_indented_ellipsis, WriteArray}; -impl fmt::Display for ChunkedPointArray<2> { +impl fmt::Display for ChunkedPointArray { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("ChunkedPointArray")?; writeln!(f, "([")?; @@ -29,7 +29,7 @@ impl fmt::Display for ChunkedPointArray<2> { } } -impl fmt::Display for ChunkedRectArray<2> { +impl fmt::Display for ChunkedRectArray { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.write_str("ChunkedRectArray")?; writeln!(f, "([")?; @@ -85,17 +85,14 @@ macro_rules! impl_fmt_generic { }; } -impl_fmt_generic!(ChunkedLineStringArray<2>, "ChunkedLineStringArray"); -impl_fmt_generic!(ChunkedPolygonArray<2>, "ChunkedPolygonArray"); -impl_fmt_generic!(ChunkedMultiPointArray<2>, "ChunkedMultiPointArray"); +impl_fmt_generic!(ChunkedLineStringArray, "ChunkedLineStringArray"); +impl_fmt_generic!(ChunkedPolygonArray, "ChunkedPolygonArray"); +impl_fmt_generic!(ChunkedMultiPointArray, "ChunkedMultiPointArray"); +impl_fmt_generic!(ChunkedMultiLineStringArray, "ChunkedMultiLineStringArray"); +impl_fmt_generic!(ChunkedMultiPolygonArray, "ChunkedMultiPolygonArray"); +impl_fmt_generic!(ChunkedMixedGeometryArray, "ChunkedMixedGeometryArray"); impl_fmt_generic!( - ChunkedMultiLineStringArray<2>, - "ChunkedMultiLineStringArray" -); -impl_fmt_generic!(ChunkedMultiPolygonArray<2>, "ChunkedMultiPolygonArray"); -impl_fmt_generic!(ChunkedMixedGeometryArray<2>, "ChunkedMixedGeometryArray"); -impl_fmt_generic!( - ChunkedGeometryCollectionArray<2>, + ChunkedGeometryCollectionArray, "ChunkedGeometryCollectionArray" ); // impl_fmt_generic!(ChunkedWKBArray, "ChunkedWKBArray"); diff --git a/rust/geoarrow/src/io/display/scalar.rs b/rust/geoarrow/src/io/display/scalar.rs index 1c359612..5c563b8b 100644 --- a/rust/geoarrow/src/io/display/scalar.rs +++ b/rust/geoarrow/src/io/display/scalar.rs @@ -84,6 +84,7 @@ impl fmt::Display for WKB<'_, O> { #[cfg(test)] mod test { use crate::array::PointArray; + use crate::datatypes::Dimension; use crate::io::wkb::ToWKB; use crate::test::{multipolygon, point}; use crate::trait_::ArrayAccessor; @@ -100,7 +101,7 @@ mod test { #[test] fn test_display_point_5_decimals() { let point = geo::Point::from((0.12345, 1.23456)); - let point_array: PointArray<2> = vec![point].as_slice().into(); + let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); let result = point_array.value(0).to_string(); let expected = ""; assert_eq!(result, expected); diff --git a/rust/geoarrow/src/io/flatgeobuf/reader/async.rs b/rust/geoarrow/src/io/flatgeobuf/reader/async.rs index 75390e95..3bb71f08 100644 --- a/rust/geoarrow/src/io/flatgeobuf/reader/async.rs +++ b/rust/geoarrow/src/io/flatgeobuf/reader/async.rs @@ -63,7 +63,7 @@ pub async fn read_flatgeobuf_async( macro_rules! impl_read { ($builder:ty, $geom_type:ty, $dim:expr) => {{ - let mut builder = GeoTableBuilder::<$builder>::new_with_options(options); + let mut builder = GeoTableBuilder::<$builder>::new_with_options($dim, options); while let Some(feature) = selection.next().await? { feature.process_properties(&mut builder)?; builder.properties_end()?; @@ -83,67 +83,63 @@ pub async fn read_flatgeobuf_async( match (geometry_type, has_z) { (GeometryType::Point, false) => { - impl_read!(PointBuilder<2>, super::core::Point, Dimension::XY) + impl_read!(PointBuilder, super::core::Point, Dimension::XY) } (GeometryType::LineString, false) => { - impl_read!(LineStringBuilder<2>, super::core::LineString, Dimension::XY) + impl_read!(LineStringBuilder, super::core::LineString, Dimension::XY) } (GeometryType::Polygon, false) => { - impl_read!(PolygonBuilder<2>, super::core::Polygon, Dimension::XY) + impl_read!(PolygonBuilder, super::core::Polygon, Dimension::XY) } (GeometryType::MultiPoint, false) => { - impl_read!(MultiPointBuilder<2>, super::core::MultiPoint, Dimension::XY) + impl_read!(MultiPointBuilder, super::core::MultiPoint, Dimension::XY) } (GeometryType::MultiLineString, false) => impl_read!( - MultiLineStringBuilder<2>, + MultiLineStringBuilder, super::core::MultiLineString, Dimension::XY ), (GeometryType::MultiPolygon, false) => impl_read!( - MultiPolygonBuilder<2>, + MultiPolygonBuilder, super::core::MultiPolygon, Dimension::XY ), (GeometryType::Unknown, false) => { - let mut builder = - GeoTableBuilder::>::new_with_options(options); + let mut builder = GeoTableBuilder::::new_with_options( + Dimension::XY, + options, + ); selection.process_features(&mut builder).await?; let table = builder.finish()?; table.downcast(true) } (GeometryType::Point, true) => { - impl_read!(PointBuilder<3>, super::core::Point, Dimension::XYZ) + impl_read!(PointBuilder, super::core::Point, Dimension::XYZ) } (GeometryType::LineString, true) => { - impl_read!( - LineStringBuilder<3>, - super::core::LineString, - Dimension::XYZ - ) + impl_read!(LineStringBuilder, super::core::LineString, Dimension::XYZ) } (GeometryType::Polygon, true) => { - impl_read!(PolygonBuilder<3>, super::core::Polygon, Dimension::XYZ) + impl_read!(PolygonBuilder, super::core::Polygon, Dimension::XYZ) } (GeometryType::MultiPoint, true) => { - impl_read!( - MultiPointBuilder<3>, - super::core::MultiPoint, - Dimension::XYZ - ) + impl_read!(MultiPointBuilder, super::core::MultiPoint, Dimension::XYZ) } (GeometryType::MultiLineString, true) => impl_read!( - MultiLineStringBuilder<3>, + MultiLineStringBuilder, super::core::MultiLineString, Dimension::XYZ ), (GeometryType::MultiPolygon, true) => impl_read!( - MultiPolygonBuilder<3>, + MultiPolygonBuilder, super::core::MultiPolygon, Dimension::XYZ ), (GeometryType::Unknown, true) => { - let mut builder = - GeoTableBuilder::>::new_with_options(options); + let mut builder = GeoTableBuilder::::new_with_options( + Dimension::XYZ, + options, + ); selection.process_features(&mut builder).await?; let table = builder.finish()?; table.downcast(true) diff --git a/rust/geoarrow/src/io/flatgeobuf/reader/sync.rs b/rust/geoarrow/src/io/flatgeobuf/reader/sync.rs index f43281c6..12f54c92 100644 --- a/rust/geoarrow/src/io/flatgeobuf/reader/sync.rs +++ b/rust/geoarrow/src/io/flatgeobuf/reader/sync.rs @@ -69,7 +69,7 @@ pub fn read_flatgeobuf( macro_rules! impl_read { ($builder:ty, $geom_type:ty, $dim:expr) => {{ - let mut builder = GeoTableBuilder::<$builder>::new_with_options(options); + let mut builder = GeoTableBuilder::<$builder>::new_with_options($dim, options); while let Some(feature) = selection.next()? { feature.process_properties(&mut builder)?; builder.properties_end()?; @@ -89,67 +89,63 @@ pub fn read_flatgeobuf( match (geometry_type, has_z) { (GeometryType::Point, false) => { - impl_read!(PointBuilder<2>, super::core::Point, Dimension::XY) + impl_read!(PointBuilder, super::core::Point, Dimension::XY) } (GeometryType::LineString, false) => { - impl_read!(LineStringBuilder<2>, super::core::LineString, Dimension::XY) + impl_read!(LineStringBuilder, super::core::LineString, Dimension::XY) } (GeometryType::Polygon, false) => { - impl_read!(PolygonBuilder<2>, super::core::Polygon, Dimension::XY) + impl_read!(PolygonBuilder, super::core::Polygon, Dimension::XY) } (GeometryType::MultiPoint, false) => { - impl_read!(MultiPointBuilder<2>, super::core::MultiPoint, Dimension::XY) + impl_read!(MultiPointBuilder, super::core::MultiPoint, Dimension::XY) } (GeometryType::MultiLineString, false) => impl_read!( - MultiLineStringBuilder<2>, + MultiLineStringBuilder, super::core::MultiLineString, Dimension::XY ), (GeometryType::MultiPolygon, false) => impl_read!( - MultiPolygonBuilder<2>, + MultiPolygonBuilder, super::core::MultiPolygon, Dimension::XY ), (GeometryType::Unknown, false) => { - let mut builder = - GeoTableBuilder::>::new_with_options(options); + let mut builder = GeoTableBuilder::::new_with_options( + Dimension::XY, + options, + ); selection.process_features(&mut builder)?; let table = builder.finish()?; table.downcast(true) } (GeometryType::Point, true) => { - impl_read!(PointBuilder<3>, super::core::Point, Dimension::XYZ) + impl_read!(PointBuilder, super::core::Point, Dimension::XYZ) } (GeometryType::LineString, true) => { - impl_read!( - LineStringBuilder<3>, - super::core::LineString, - Dimension::XYZ - ) + impl_read!(LineStringBuilder, super::core::LineString, Dimension::XYZ) } (GeometryType::Polygon, true) => { - impl_read!(PolygonBuilder<3>, super::core::Polygon, Dimension::XYZ) + impl_read!(PolygonBuilder, super::core::Polygon, Dimension::XYZ) } (GeometryType::MultiPoint, true) => { - impl_read!( - MultiPointBuilder<3>, - super::core::MultiPoint, - Dimension::XYZ - ) + impl_read!(MultiPointBuilder, super::core::MultiPoint, Dimension::XYZ) } (GeometryType::MultiLineString, true) => impl_read!( - MultiLineStringBuilder<3>, + MultiLineStringBuilder, super::core::MultiLineString, Dimension::XYZ ), (GeometryType::MultiPolygon, true) => impl_read!( - MultiPolygonBuilder<3>, + MultiPolygonBuilder, super::core::MultiPolygon, Dimension::XYZ ), (GeometryType::Unknown, true) => { - let mut builder = - GeoTableBuilder::>::new_with_options(options); + let mut builder = GeoTableBuilder::::new_with_options( + Dimension::XYZ, + options, + ); selection.process_features(&mut builder)?; let table = builder.finish()?; // TODO: 3d downcasting not implemented diff --git a/rust/geoarrow/src/io/geojson/reader.rs b/rust/geoarrow/src/io/geojson/reader.rs index f8b3d8ed..330cd3a6 100644 --- a/rust/geoarrow/src/io/geojson/reader.rs +++ b/rust/geoarrow/src/io/geojson/reader.rs @@ -3,6 +3,7 @@ use geozero::GeozeroDatasource; use std::io::Read; use crate::array::CoordType; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geozero::array::MixedGeometryStreamBuilder; use crate::io::geozero::table::{GeoTableBuilder, GeoTableBuilderOptions}; @@ -20,7 +21,8 @@ pub fn read_geojson(reader: R, batch_size: Option) -> Result>::new_with_options(options); + let mut geo_table = + GeoTableBuilder::::new_with_options(Dimension::XY, options); geojson.process(&mut geo_table)?; geo_table.finish() } diff --git a/rust/geoarrow/src/io/geojson_lines/reader.rs b/rust/geoarrow/src/io/geojson_lines/reader.rs index a7d478ec..f58ececc 100644 --- a/rust/geoarrow/src/io/geojson_lines/reader.rs +++ b/rust/geoarrow/src/io/geojson_lines/reader.rs @@ -3,6 +3,7 @@ use geozero::GeozeroDatasource; use std::io::BufRead; use crate::array::CoordType; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geozero::array::MixedGeometryStreamBuilder; use crate::io::geozero::table::{GeoTableBuilder, GeoTableBuilderOptions}; @@ -24,7 +25,8 @@ pub fn read_geojson_lines(reader: R, batch_size: Option) -> R None, Default::default(), ); - let mut geo_table = GeoTableBuilder::>::new_with_options(options); + let mut geo_table = + GeoTableBuilder::::new_with_options(Dimension::XY, options); geojson_line_reader.process(&mut geo_table)?; geo_table.finish() } From 0a43ff06c2041920ae7d8dfabfeafd654d7f0186 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 22:05:17 -0500 Subject: [PATCH 09/14] progress --- .../src/io/geos/array/geometrycollection.rs | 13 ++++++++----- rust/geoarrow/src/io/geos/array/linestring.rs | 11 ++++++----- rust/geoarrow/src/io/geos/array/mixed.rs | 13 ++++++++----- rust/geoarrow/src/io/geos/array/multilinestring.rs | 11 ++++++----- rust/geoarrow/src/io/geos/array/multipoint.rs | 11 ++++++----- rust/geoarrow/src/io/geos/array/multipolygon.rs | 11 ++++++----- rust/geoarrow/src/io/geos/array/point.rs | 11 ++++++----- rust/geoarrow/src/io/geos/array/polygon.rs | 11 ++++++----- 8 files changed, 52 insertions(+), 40 deletions(-) diff --git a/rust/geoarrow/src/io/geos/array/geometrycollection.rs b/rust/geoarrow/src/io/geos/array/geometrycollection.rs index 3a912d35..527e732d 100644 --- a/rust/geoarrow/src/io/geos/array/geometrycollection.rs +++ b/rust/geoarrow/src/io/geos/array/geometrycollection.rs @@ -1,23 +1,26 @@ use crate::array::{GeometryCollectionArray, GeometryCollectionBuilder}; +use crate::datatypes::Dimension; use crate::error::GeoArrowError; use crate::io::geos::scalar::GEOSGeometryCollection; -impl TryFrom> for GeometryCollectionBuilder { +impl TryFrom<(Vec, Dimension)> for GeometryCollectionBuilder { type Error = GeoArrowError; - fn try_from(value: Vec) -> std::result::Result { + fn try_from( + (value, dim): (Vec, Dimension), + ) -> std::result::Result { let geoms: Vec = value .into_iter() .map(GEOSGeometryCollection::new_unchecked) .collect(); - Self::from_geometry_collections(&geoms, Default::default(), Default::default(), false) + Self::from_geometry_collections(&geoms, dim, Default::default(), Default::default(), false) } } -impl TryFrom> for GeometryCollectionArray { +impl TryFrom<(Vec, Dimension)> for GeometryCollectionArray { type Error = GeoArrowError; - fn try_from(value: Vec) -> std::result::Result { + fn try_from(value: (Vec, Dimension)) -> std::result::Result { let mutable_arr: GeometryCollectionBuilder = value.try_into()?; Ok(mutable_arr.into()) } diff --git a/rust/geoarrow/src/io/geos/array/linestring.rs b/rust/geoarrow/src/io/geos/array/linestring.rs index a0402be7..9a2e899c 100644 --- a/rust/geoarrow/src/io/geos/array/linestring.rs +++ b/rust/geoarrow/src/io/geos/array/linestring.rs @@ -1,21 +1,22 @@ use crate::array::{LineStringArray, LineStringBuilder}; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geos::scalar::GEOSLineString; impl LineStringBuilder { - pub fn from_geos(value: Vec>) -> Result { + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value .into_iter() .map(|geom| geom.map(GEOSLineString::new_unchecked)) .collect(); - Ok(geos_objects.into()) + Ok((geos_objects, dim).into()) } } impl LineStringArray { - pub fn from_geos(value: Vec>) -> Result { - let mutable_arr = LineStringBuilder::from_geos(value)?; + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { + let mutable_arr = LineStringBuilder::from_geos(value, dim)?; Ok(mutable_arr.into()) } } @@ -34,7 +35,7 @@ mod test { .iter() .map(|opt_x| opt_x.map(|x| x.to_geos().unwrap())) .collect(); - let round_trip = LineStringArray::from_geos(geos_geoms).unwrap(); + let round_trip = LineStringArray::from_geos(geos_geoms, Dimension::XY).unwrap(); assert_eq!(arr, round_trip); } } diff --git a/rust/geoarrow/src/io/geos/array/mixed.rs b/rust/geoarrow/src/io/geos/array/mixed.rs index 492178b0..8b9efa44 100644 --- a/rust/geoarrow/src/io/geos/array/mixed.rs +++ b/rust/geoarrow/src/io/geos/array/mixed.rs @@ -1,20 +1,23 @@ use crate::array::{MixedGeometryArray, MixedGeometryBuilder}; +use crate::datatypes::Dimension; use crate::error::GeoArrowError; use crate::io::geos::scalar::GEOSGeometry; -impl TryFrom> for MixedGeometryBuilder { +impl TryFrom<(Vec, Dimension)> for MixedGeometryBuilder { type Error = GeoArrowError; - fn try_from(value: Vec) -> std::result::Result { + fn try_from( + (value, dim): (Vec, Dimension), + ) -> std::result::Result { let geoms: Vec = value.into_iter().map(GEOSGeometry::new).collect(); - Self::from_geometries(&geoms, Default::default(), Default::default(), false) + Self::from_geometries(&geoms, dim, Default::default(), Default::default(), false) } } -impl TryFrom> for MixedGeometryArray { +impl TryFrom<(Vec, Dimension)> for MixedGeometryArray { type Error = GeoArrowError; - fn try_from(value: Vec) -> std::result::Result { + fn try_from(value: (Vec, Dimension)) -> std::result::Result { let mutable_arr: MixedGeometryBuilder = value.try_into()?; Ok(mutable_arr.into()) } diff --git a/rust/geoarrow/src/io/geos/array/multilinestring.rs b/rust/geoarrow/src/io/geos/array/multilinestring.rs index 0dda7b1c..d5eda1a8 100644 --- a/rust/geoarrow/src/io/geos/array/multilinestring.rs +++ b/rust/geoarrow/src/io/geos/array/multilinestring.rs @@ -1,21 +1,22 @@ use crate::array::{MultiLineStringArray, MultiLineStringBuilder}; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geos::scalar::GEOSMultiLineString; impl MultiLineStringBuilder { - pub fn from_geos(value: Vec>) -> Result { + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value .into_iter() .map(|geom| geom.map(GEOSMultiLineString::new_unchecked)) .collect(); - Ok(geos_objects.into()) + Ok((geos_objects, dim).into()) } } impl MultiLineStringArray { - pub fn from_geos(value: Vec>) -> Result { - let mutable_arr = MultiLineStringBuilder::from_geos(value)?; + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { + let mutable_arr = MultiLineStringBuilder::from_geos(value, dim)?; Ok(mutable_arr.into()) } } @@ -34,7 +35,7 @@ mod test { .iter() .map(|opt_x| opt_x.map(|x| x.to_geos().unwrap())) .collect(); - let round_trip = MultiLineStringArray::<2>::from_geos(geos_geoms).unwrap(); + let round_trip = MultiLineStringArray::from_geos(geos_geoms, Dimension::XY).unwrap(); assert_eq!(arr, round_trip); } } diff --git a/rust/geoarrow/src/io/geos/array/multipoint.rs b/rust/geoarrow/src/io/geos/array/multipoint.rs index 387e7756..58a7ad4a 100644 --- a/rust/geoarrow/src/io/geos/array/multipoint.rs +++ b/rust/geoarrow/src/io/geos/array/multipoint.rs @@ -1,21 +1,22 @@ use crate::array::{MultiPointArray, MultiPointBuilder}; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geos::scalar::GEOSMultiPoint; impl MultiPointBuilder { - pub fn from_geos(value: Vec>) -> Result { + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value .into_iter() .map(|geom| geom.map(GEOSMultiPoint::new_unchecked)) .collect(); - Ok(geos_objects.into()) + Ok((geos_objects, dim).into()) } } impl MultiPointArray { - pub fn from_geos(value: Vec>) -> Result { - let mutable_arr = MultiPointBuilder::from_geos(value)?; + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { + let mutable_arr = MultiPointBuilder::from_geos(value, dim)?; Ok(mutable_arr.into()) } } @@ -34,7 +35,7 @@ mod test { .iter() .map(|opt_x| opt_x.map(|x| x.to_geos().unwrap())) .collect(); - let round_trip = MultiPointArray::<2>::from_geos(geos_geoms).unwrap(); + let round_trip = MultiPointArray::from_geos(geos_geoms, Dimension::XY).unwrap(); assert_eq!(arr, round_trip); } } diff --git a/rust/geoarrow/src/io/geos/array/multipolygon.rs b/rust/geoarrow/src/io/geos/array/multipolygon.rs index 40ed7de3..5ddd91a4 100644 --- a/rust/geoarrow/src/io/geos/array/multipolygon.rs +++ b/rust/geoarrow/src/io/geos/array/multipolygon.rs @@ -1,21 +1,22 @@ use crate::array::{MultiPolygonArray, MultiPolygonBuilder}; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geos::scalar::GEOSMultiPolygon; impl MultiPolygonBuilder { - pub fn from_geos(value: Vec>) -> Result { + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value .into_iter() .map(|geom| geom.map(GEOSMultiPolygon::new_unchecked)) .collect(); - Ok(geos_objects.into()) + Ok((geos_objects, dim).into()) } } impl MultiPolygonArray { - pub fn from_geos(value: Vec>) -> Result { - let mutable_arr = MultiPolygonBuilder::from_geos(value)?; + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { + let mutable_arr = MultiPolygonBuilder::from_geos(value, dim)?; Ok(mutable_arr.into()) } } @@ -34,7 +35,7 @@ mod test { .iter() .map(|opt_x| opt_x.map(|x| x.to_geos().unwrap())) .collect(); - let round_trip = MultiPolygonArray::<2>::from_geos(geos_geoms).unwrap(); + let round_trip = MultiPolygonArray::from_geos(geos_geoms, Dimension::XY).unwrap(); assert_eq!(arr, round_trip); } } diff --git a/rust/geoarrow/src/io/geos/array/point.rs b/rust/geoarrow/src/io/geos/array/point.rs index f387b17d..d70558e2 100644 --- a/rust/geoarrow/src/io/geos/array/point.rs +++ b/rust/geoarrow/src/io/geos/array/point.rs @@ -1,21 +1,22 @@ use crate::array::{PointArray, PointBuilder}; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geos::scalar::GEOSPoint; impl PointBuilder { - pub fn from_geos(value: Vec>) -> Result { + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { // TODO: don't use new_unchecked let geos_linestring_objects: Vec> = value .into_iter() .map(|geom| geom.map(GEOSPoint::new_unchecked)) .collect(); - Ok(geos_linestring_objects.into()) + Ok((geos_linestring_objects, dim).into()) } } impl PointArray { - pub fn from_geos(value: Vec>) -> Result { - let mutable_arr = PointBuilder::from_geos(value)?; + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { + let mutable_arr = PointBuilder::from_geos(value, dim)?; Ok(mutable_arr.into()) } } @@ -33,7 +34,7 @@ mod test { .iter() .map(|opt_x| opt_x.map(|x| x.to_geos().unwrap())) .collect(); - let round_trip = PointArray::<2>::from_geos(geos_geoms).unwrap(); + let round_trip = PointArray::from_geos(geos_geoms, Dimension::XY).unwrap(); assert_eq!(arr, round_trip); } } diff --git a/rust/geoarrow/src/io/geos/array/polygon.rs b/rust/geoarrow/src/io/geos/array/polygon.rs index aef53b04..afc83b6d 100644 --- a/rust/geoarrow/src/io/geos/array/polygon.rs +++ b/rust/geoarrow/src/io/geos/array/polygon.rs @@ -1,22 +1,23 @@ use crate::array::{PolygonArray, PolygonBuilder}; +use crate::datatypes::Dimension; use crate::error::Result; use crate::io::geos::scalar::GEOSPolygon; impl PolygonBuilder { - pub fn from_geos(value: Vec>) -> Result { + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value .into_iter() .map(|geom| geom.map(GEOSPolygon::new_unchecked)) .collect(); - Ok(geos_objects.into()) + Ok((geos_objects, dim).into()) } } impl PolygonArray { - pub fn from_geos(value: Vec>) -> Result { - let mutable_arr = PolygonBuilder::from_geos(value)?; + pub fn from_geos(value: Vec>, dim: Dimension) -> Result { + let mutable_arr = PolygonBuilder::from_geos(value, dim)?; Ok(mutable_arr.into()) } } @@ -35,7 +36,7 @@ mod test { .iter() .map(|opt_x| opt_x.map(|x| x.to_geos().unwrap())) .collect(); - let round_trip = PolygonArray::<2>::from_geos(geos_geoms).unwrap(); + let round_trip = PolygonArray::from_geos(geos_geoms, Dimension::XY).unwrap(); assert_eq!(arr, round_trip); } } From b4bce058146185ea645f8402d5c58744c628556c Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 22:15:40 -0500 Subject: [PATCH 10/14] progress --- rust/geoarrow/benches/area.rs | 4 +- rust/geoarrow/benches/from_geo.rs | 11 ++-- rust/geoarrow/benches/geos_buffer.rs | 4 +- rust/geoarrow/benches/nybb.rs | 7 +-- rust/geoarrow/benches/translate.rs | 5 +- .../src/algorithm/native/concatenate.rs | 18 ++++++- rust/geoarrow/src/array/mixed/array.rs | 12 ++--- .../src/io/parquet/writer/metadata.rs | 50 +++++++++---------- rust/geoarrow/src/test/geoarrow_data/mod.rs | 38 +++++++++++--- rust/geoarrow/src/test/point.rs | 2 +- rust/geoarrow/src/trait_.rs | 1 + 11 files changed, 99 insertions(+), 53 deletions(-) diff --git a/rust/geoarrow/benches/area.rs b/rust/geoarrow/benches/area.rs index ee923912..8b2415a4 100644 --- a/rust/geoarrow/benches/area.rs +++ b/rust/geoarrow/benches/area.rs @@ -4,14 +4,14 @@ use geoarrow::array::{AsChunkedNativeArray, MultiPolygonArray}; use geoarrow::io::flatgeobuf::read_flatgeobuf; use std::fs::File; -fn load_file() -> MultiPolygonArray<2> { +fn load_file() -> MultiPolygonArray { let mut file = File::open("fixtures/flatgeobuf/countries.fgb").unwrap(); let table = read_flatgeobuf(&mut file, Default::default()).unwrap(); table .geometry_column(None) .unwrap() .as_ref() - .as_multi_polygon::<2>() + .as_multi_polygon() .chunks() .first() .unwrap() diff --git a/rust/geoarrow/benches/from_geo.rs b/rust/geoarrow/benches/from_geo.rs index 8f379a4e..ee9bf76c 100644 --- a/rust/geoarrow/benches/from_geo.rs +++ b/rust/geoarrow/benches/from_geo.rs @@ -2,6 +2,7 @@ use geo::polygon; use criterion::{criterion_group, criterion_main, Criterion}; use geoarrow::array::{PolygonArray, PolygonBuilder}; +use geoarrow::datatypes::Dimension; fn create_data() -> Vec { // An L shape @@ -24,9 +25,13 @@ pub fn criterion_benchmark(c: &mut Criterion) { c.bench_function("convert Vec to PolygonArray", |b| { b.iter(|| { - let mut_arr = - PolygonBuilder::<2>::from_polygons(&data, Default::default(), Default::default()); - let _arr: PolygonArray<2> = mut_arr.into(); + let mut_arr = PolygonBuilder::from_polygons( + &data, + Dimension::XY, + Default::default(), + Default::default(), + ); + let _arr: PolygonArray = mut_arr.into(); }) }); } diff --git a/rust/geoarrow/benches/geos_buffer.rs b/rust/geoarrow/benches/geos_buffer.rs index 4c6962b6..00257939 100644 --- a/rust/geoarrow/benches/geos_buffer.rs +++ b/rust/geoarrow/benches/geos_buffer.rs @@ -3,7 +3,7 @@ use geoarrow::algorithm::geos::Buffer; use geoarrow::array::{CoordBuffer, InterleavedCoordBuffer, PointArray, PolygonArray}; use geoarrow::datatypes::Dimension; -fn generate_data() -> PointArray<2> { +fn generate_data() -> PointArray { let coords = vec![0.0; 100_000]; let coord_buffer = CoordBuffer::Interleaved(InterleavedCoordBuffer::new(coords.into(), Dimension::XY)); @@ -15,7 +15,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { c.bench_function("buffer", |b| { b.iter(|| { - let _buffered: PolygonArray<2> = point_array.buffer(1.0, 8).unwrap(); + let _buffered: PolygonArray = point_array.buffer(1.0, 8).unwrap(); }) }); } diff --git a/rust/geoarrow/benches/nybb.rs b/rust/geoarrow/benches/nybb.rs index 8b8b4ed0..4a37ef6c 100644 --- a/rust/geoarrow/benches/nybb.rs +++ b/rust/geoarrow/benches/nybb.rs @@ -4,9 +4,10 @@ use arrow_ipc::reader::FileReader; use criterion::{criterion_group, criterion_main, Criterion}; use geoarrow::algorithm::geo::EuclideanDistance; use geoarrow::array::{MultiPolygonArray, PointArray}; +use geoarrow::datatypes::Dimension; use geoarrow::trait_::ArrayAccessor; -fn load_nybb() -> MultiPolygonArray<2> { +fn load_nybb() -> MultiPolygonArray { let file = File::open("fixtures/nybb.arrow").unwrap(); let reader = FileReader::try_new(file, None).unwrap(); @@ -20,7 +21,7 @@ fn load_nybb() -> MultiPolygonArray<2> { .position(|field| field.name() == "geometry") .unwrap(); let arr = record_batch.column(geom_idx); - let multi_poly_arr: MultiPolygonArray<2> = arr.as_ref().try_into().unwrap(); + let multi_poly_arr: MultiPolygonArray = (arr.as_ref(), Dimension::XY).try_into().unwrap(); arrays.push(multi_poly_arr); } @@ -39,7 +40,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { c.bench_function("euclidean distance to scalar point", |b| { b.iter(|| { let point = geo::Point::new(0.0f64, 0.0f64); - let point_array = PointArray::from(vec![point].as_slice()); + let point_array = PointArray::from((vec![point].as_slice(), Dimension::XY)); let _distances = array.euclidean_distance(&point_array.value(0)); }) diff --git a/rust/geoarrow/benches/translate.rs b/rust/geoarrow/benches/translate.rs index fd860036..bbcef5ac 100644 --- a/rust/geoarrow/benches/translate.rs +++ b/rust/geoarrow/benches/translate.rs @@ -3,8 +3,9 @@ use geo::polygon; use criterion::{criterion_group, criterion_main, Criterion}; use geoarrow::algorithm::geo::Translate; use geoarrow::array::PolygonArray; +use geoarrow::datatypes::Dimension; -fn create_data() -> PolygonArray<2> { +fn create_data() -> PolygonArray { // An L shape // https://github.com/georust/geo/blob/7cb7d0ffa6bf1544c5ca9922bd06100c36f815d7/README.md?plain=1#L40 let poly = polygon![ @@ -17,7 +18,7 @@ fn create_data() -> PolygonArray<2> { (x: 0.0, y: 0.0), ]; let v = vec![poly; 1000]; - v.as_slice().into() + (v.as_slice(), Dimension::XY).into() } pub fn criterion_benchmark(c: &mut Criterion) { diff --git a/rust/geoarrow/src/algorithm/native/concatenate.rs b/rust/geoarrow/src/algorithm/native/concatenate.rs index 50507875..1973ea1c 100644 --- a/rust/geoarrow/src/algorithm/native/concatenate.rs +++ b/rust/geoarrow/src/algorithm/native/concatenate.rs @@ -1,5 +1,8 @@ +use std::collections::HashSet; + use crate::array::*; use crate::chunked_array::*; +use crate::datatypes::Dimension; use crate::error::Result; use crate::trait_::ArrayAccessor; @@ -13,8 +16,10 @@ impl Concatenate for &[PointArray] { type Output = Result; fn concatenate(&self) -> Self::Output { + let common_dimension = infer_common_dimension(self.iter().map(|arr| arr.dimension())); + let output_capacity = self.iter().fold(0, |sum, val| sum + val.buffer_lengths()); - let mut builder = PointBuilder::with_capacity(output_capacity); + let mut builder = PointBuilder::with_capacity(common_dimension, output_capacity); self.iter() .for_each(|chunk| chunk.iter().for_each(|p| builder.push_point(p.as_ref()))); Ok(builder.finish()) @@ -27,10 +32,13 @@ macro_rules! impl_concatenate { type Output = Result<$array>; fn concatenate(&self) -> Self::Output { + let common_dimension = + infer_common_dimension(self.iter().map(|arr| arr.dimension())); + let output_capacity = self.iter().fold(<$capacity>::new_empty(), |sum, val| { sum + val.buffer_lengths() }); - let mut builder = <$builder>::with_capacity(output_capacity); + let mut builder = <$builder>::with_capacity(common_dimension, output_capacity); for chunk in self.iter() { for geom in chunk.iter() { builder.$push_func(geom.as_ref())?; @@ -80,6 +88,12 @@ impl_concatenate!( push_geometry_collection ); +fn infer_common_dimension(dimensions: impl Iterator) -> Dimension { + let dimensions: HashSet = HashSet::from_iter(dimensions); + assert_eq!(dimensions.len(), 1); + dimensions.into_iter().next().unwrap() +} + impl Concatenate for ChunkedPointArray { type Output = Result; diff --git a/rust/geoarrow/src/array/mixed/array.rs b/rust/geoarrow/src/array/mixed/array.rs index db39061c..e5609020 100644 --- a/rust/geoarrow/src/array/mixed/array.rs +++ b/rust/geoarrow/src/array/mixed/array.rs @@ -659,12 +659,12 @@ impl TryFrom<&UnionArray> for MixedGeometryArray { Ok(Self::new( type_ids, offsets, - points.get(0).cloned().unwrap_or_default(), - line_strings.get(0).cloned().unwrap_or_default(), - polygons.get(0).cloned().unwrap_or_default(), - multi_points.get(0).cloned().unwrap_or_default(), - multi_line_strings.get(0).cloned().unwrap_or_default(), - multi_polygons.get(0).cloned().unwrap_or_default(), + points.first().cloned().unwrap_or_default(), + line_strings.first().cloned().unwrap_or_default(), + polygons.first().cloned().unwrap_or_default(), + multi_points.first().cloned().unwrap_or_default(), + multi_line_strings.first().cloned().unwrap_or_default(), + multi_polygons.first().cloned().unwrap_or_default(), Default::default(), )) } diff --git a/rust/geoarrow/src/io/parquet/writer/metadata.rs b/rust/geoarrow/src/io/parquet/writer/metadata.rs index 91d2c830..ac7df611 100644 --- a/rust/geoarrow/src/io/parquet/writer/metadata.rs +++ b/rust/geoarrow/src/io/parquet/writer/metadata.rs @@ -79,34 +79,32 @@ impl ColumnInfo { let array_ref = array.as_ref(); // We only have to do this for mixed arrays because other arrays are statically known - match array_ref.data_type() { - NativeType::Mixed(_, _) => { - let mixed_arr = array_ref.as_mixed(); - if mixed_arr.has_points() { - self.geometry_types.insert(GeoParquetGeometryType::Point); - } - if mixed_arr.has_line_strings() { - self.geometry_types - .insert(GeoParquetGeometryType::LineString); - } - if mixed_arr.has_polygons() { - self.geometry_types.insert(GeoParquetGeometryType::Polygon); - } - if mixed_arr.has_multi_points() { - self.geometry_types - .insert(GeoParquetGeometryType::MultiPoint); - } - if mixed_arr.has_multi_line_strings() { - self.geometry_types - .insert(GeoParquetGeometryType::MultiLineString); - } - if mixed_arr.has_multi_polygons() { - self.geometry_types - .insert(GeoParquetGeometryType::MultiPolygon); - } + if let NativeType::Mixed(_, _) = array_ref.data_type() { + let mixed_arr = array_ref.as_mixed(); + if mixed_arr.has_points() { + self.geometry_types.insert(GeoParquetGeometryType::Point); + } + if mixed_arr.has_line_strings() { + self.geometry_types + .insert(GeoParquetGeometryType::LineString); + } + if mixed_arr.has_polygons() { + self.geometry_types.insert(GeoParquetGeometryType::Polygon); + } + if mixed_arr.has_multi_points() { + self.geometry_types + .insert(GeoParquetGeometryType::MultiPoint); + } + if mixed_arr.has_multi_line_strings() { + self.geometry_types + .insert(GeoParquetGeometryType::MultiLineString); + } + if mixed_arr.has_multi_polygons() { + self.geometry_types + .insert(GeoParquetGeometryType::MultiPolygon); } - _ => (), } + Ok(()) } diff --git a/rust/geoarrow/src/test/geoarrow_data/mod.rs b/rust/geoarrow/src/test/geoarrow_data/mod.rs index b73cac74..2e229dee 100644 --- a/rust/geoarrow/src/test/geoarrow_data/mod.rs +++ b/rust/geoarrow/src/test/geoarrow_data/mod.rs @@ -17,12 +17,22 @@ macro_rules! geoarrow_data_impl { .unwrap() } }; + ($fn_name:ident, $file_part:tt, $return_type:ty, "WKB") => { + pub(crate) fn $fn_name() -> $return_type { + let path = format!( + "fixtures/geoarrow-data/example/example-{}.arrow", + $file_part + ); + let geometry_dyn_column = read_geometry_column(&path); + geometry_dyn_column.as_ref().try_into().unwrap() + } + }; } // Point geoarrow_data_impl!(example_point_interleaved, "point-interleaved", PointArray); geoarrow_data_impl!(example_point_separated, "point", PointArray); -geoarrow_data_impl!(example_point_wkb, "point-wkb", WKBArray); +geoarrow_data_impl!(example_point_wkb, "point-wkb", WKBArray, "WKB"); // LineString geoarrow_data_impl!( @@ -31,7 +41,12 @@ geoarrow_data_impl!( LineStringArray ); geoarrow_data_impl!(example_linestring_separated, "linestring", LineStringArray); -geoarrow_data_impl!(example_linestring_wkb, "linestring-wkb", WKBArray); +geoarrow_data_impl!( + example_linestring_wkb, + "linestring-wkb", + WKBArray, + "WKB" +); // Polygon geoarrow_data_impl!( @@ -40,7 +55,7 @@ geoarrow_data_impl!( PolygonArray ); geoarrow_data_impl!(example_polygon_separated, "polygon", PolygonArray); -geoarrow_data_impl!(example_polygon_wkb, "polygon-wkb", WKBArray); +geoarrow_data_impl!(example_polygon_wkb, "polygon-wkb", WKBArray, "WKB"); // MultiPoint geoarrow_data_impl!( @@ -49,7 +64,12 @@ geoarrow_data_impl!( MultiPointArray ); geoarrow_data_impl!(example_multipoint_separated, "multipoint", MultiPointArray); -geoarrow_data_impl!(example_multipoint_wkb, "multipoint-wkb", WKBArray); +geoarrow_data_impl!( + example_multipoint_wkb, + "multipoint-wkb", + WKBArray, + "WKB" +); // MultiLineString geoarrow_data_impl!( @@ -65,7 +85,8 @@ geoarrow_data_impl!( geoarrow_data_impl!( example_multilinestring_wkb, "multilinestring-wkb", - WKBArray + WKBArray, + "WKB" ); // MultiPolygon @@ -79,4 +100,9 @@ geoarrow_data_impl!( "multipolygon", MultiPolygonArray ); -geoarrow_data_impl!(example_multipolygon_wkb, "multipolygon-wkb", WKBArray); +geoarrow_data_impl!( + example_multipolygon_wkb, + "multipolygon-wkb", + WKBArray, + "WKB" +); diff --git a/rust/geoarrow/src/test/point.rs b/rust/geoarrow/src/test/point.rs index 708e3695..9e396e05 100644 --- a/rust/geoarrow/src/test/point.rs +++ b/rust/geoarrow/src/test/point.rs @@ -31,7 +31,7 @@ pub(crate) fn p2() -> Point { } pub(crate) fn point_array() -> PointArray { - let geoms = vec![p0(), p1(), p2()]; + let geoms = [p0(), p1(), p2()]; PointBuilder::from_points( geoms.iter(), Dimension::XY, diff --git a/rust/geoarrow/src/trait_.rs b/rust/geoarrow/src/trait_.rs index dc95d8a4..ab50ddb9 100644 --- a/rust/geoarrow/src/trait_.rs +++ b/rust/geoarrow/src/trait_.rs @@ -265,6 +265,7 @@ pub trait NativeArray: ArrayBase { /// ``` fn coord_type(&self) -> CoordType; + /// The dimension of this array. fn dimension(&self) -> Dimension { self.data_type().dimension() } From 63ae5456e0d043b993e4dae633705dfac2e06b1d Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 22:39:43 -0500 Subject: [PATCH 11/14] fix tests --- rust/geoarrow/src/algorithm/geo/area.rs | 5 +- rust/geoarrow/src/algorithm/geo/centroid.rs | 6 +- .../geo/chamberlain_duquette_area.rs | 53 ++----- .../src/algorithm/geo/euclidean_distance.rs | 2 +- .../src/algorithm/geo/euclidean_length.rs | 3 +- .../src/algorithm/geo/geodesic_area.rs | 54 ++----- .../src/algorithm/geo/geodesic_length.rs | 3 +- .../src/algorithm/geo/haversine_length.rs | 3 +- rust/geoarrow/src/algorithm/geo/simplify.rs | 3 +- .../geoarrow/src/algorithm/geo/simplify_vw.rs | 3 +- .../src/algorithm/geo/vincenty_length.rs | 3 +- rust/geoarrow/src/chunked_array/dynamic.rs | 8 +- rust/geoarrow/src/chunked_array/mod.rs | 105 ++++++++------ rust/geoarrow/src/lib.rs | 7 +- rust/geoarrow/src/table.rs | 6 +- rust/geoarrow/src/trait_.rs | 137 ++++++++++++------ 16 files changed, 224 insertions(+), 177 deletions(-) diff --git a/rust/geoarrow/src/algorithm/geo/area.rs b/rust/geoarrow/src/algorithm/geo/area.rs index 33065117..59a763ba 100644 --- a/rust/geoarrow/src/algorithm/geo/area.rs +++ b/rust/geoarrow/src/algorithm/geo/area.rs @@ -18,6 +18,7 @@ use geo::prelude::Area as GeoArea; /// /// use geoarrow::algorithm::geo::Area; /// use geoarrow::array::PolygonArray; +/// use geoarrow::datatypes::Dimension; /// /// let polygon = polygon![ /// (x: 0., y: 0.), @@ -32,8 +33,8 @@ use geo::prelude::Area as GeoArea; /// line_string.0.reverse(); /// }); /// -/// let polygon_array: PolygonArray = vec![polygon].as_slice().into(); -/// let reversed_polygon_array: PolygonArray = vec![reversed_polygon].as_slice().into(); +/// let polygon_array: PolygonArray = (vec![polygon].as_slice(), Dimension::XY).into(); +/// let reversed_polygon_array: PolygonArray = (vec![reversed_polygon].as_slice(), Dimension::XY).into(); /// /// assert_eq!(polygon_array.signed_area().value(0), 30.); /// assert_eq!(polygon_array.unsigned_area().value(0), 30.); diff --git a/rust/geoarrow/src/algorithm/geo/centroid.rs b/rust/geoarrow/src/algorithm/geo/centroid.rs index 1e8f8224..41c4c72f 100644 --- a/rust/geoarrow/src/algorithm/geo/centroid.rs +++ b/rust/geoarrow/src/algorithm/geo/centroid.rs @@ -20,6 +20,7 @@ use geo::algorithm::centroid::Centroid as GeoCentroid; /// use geoarrow::algorithm::geo::Centroid; /// use geoarrow::array::PolygonArray; /// use geoarrow::trait_::ArrayAccessor; +/// use geoarrow::datatypes::Dimension; /// use geo::{point, polygon}; /// /// // rhombus shaped polygon @@ -30,7 +31,7 @@ use geo::algorithm::centroid::Centroid as GeoCentroid; /// (x: 1., y: -1.), /// (x: -2., y: 1.), /// ]; -/// let polygon_array: PolygonArray = vec![polygon].as_slice().into(); +/// let polygon_array: PolygonArray = (vec![polygon].as_slice(), Dimension::XY).into(); /// /// assert_eq!( /// Some(point!(x: 1., y: 1.)), @@ -48,13 +49,14 @@ pub trait Centroid { /// use geoarrow::algorithm::geo::Centroid; /// use geoarrow::array::LineStringArray; /// use geoarrow::trait_::ArrayAccessor; + /// use geoarrow::datatypes::Dimension; /// use geo::{line_string, point}; /// /// let line_string = line_string![ /// (x: 40.02f64, y: 116.34), /// (x: 40.02f64, y: 118.23), /// ]; - /// let line_string_array: LineStringArray = vec![line_string].as_slice().into(); + /// let line_string_array: LineStringArray = (vec![line_string].as_slice(), Dimension::XY).into(); /// /// assert_eq!( /// Some(point!(x: 40.02, y: 117.285)), diff --git a/rust/geoarrow/src/algorithm/geo/chamberlain_duquette_area.rs b/rust/geoarrow/src/algorithm/geo/chamberlain_duquette_area.rs index 6f1f18ba..99aeb07c 100644 --- a/rust/geoarrow/src/algorithm/geo/chamberlain_duquette_area.rs +++ b/rust/geoarrow/src/algorithm/geo/chamberlain_duquette_area.rs @@ -28,6 +28,7 @@ use geo::prelude::ChamberlainDuquetteArea as GeoChamberlainDuquetteArea; /// use geoarrow::array::PolygonArray; /// use geoarrow::NativeArray; /// use geoarrow::algorithm::geo::ChamberlainDuquetteArea; +/// use geoarrow::datatypes::Dimension; /// /// // The O2 in London /// let mut polygon: Polygon = polygon![ @@ -47,8 +48,8 @@ use geo::prelude::ChamberlainDuquetteArea as GeoChamberlainDuquetteArea; /// line_string.0.reverse(); /// }); /// -/// let polygon_array: PolygonArray = vec![polygon].as_slice().into(); -/// let reversed_polygon_array: PolygonArray = vec![reversed_polygon].as_slice().into(); +/// let polygon_array: PolygonArray = (vec![polygon].as_slice(), Dimension::XY).into(); +/// let reversed_polygon_array: PolygonArray = (vec![reversed_polygon].as_slice(), Dimension::XY).into(); /// /// // 78,478 meters² /// assert_eq!(78_478., polygon_array.chamberlain_duquette_unsigned_area().value(0).round()); @@ -128,19 +129,13 @@ impl ChamberlainDuquetteArea for &dyn NativeArray { let result = match self.data_type() { Point(_, XY) => self.as_point().chamberlain_duquette_signed_area(), - LineString(_, XY) => self - .as_line_string() - .chamberlain_duquette_signed_area(), + LineString(_, XY) => self.as_line_string().chamberlain_duquette_signed_area(), Polygon(_, XY) => self.as_polygon().chamberlain_duquette_signed_area(), - MultiPoint(_, XY) => self - .as_multi_point() - .chamberlain_duquette_signed_area(), + MultiPoint(_, XY) => self.as_multi_point().chamberlain_duquette_signed_area(), MultiLineString(_, XY) => self .as_multi_line_string() .chamberlain_duquette_signed_area(), - MultiPolygon(_, XY) => self - .as_multi_polygon() - .chamberlain_duquette_signed_area(), + MultiPolygon(_, XY) => self.as_multi_polygon().chamberlain_duquette_signed_area(), Mixed(_, XY) => self.as_mixed().chamberlain_duquette_signed_area(), GeometryCollection(_, XY) => self .as_geometry_collection() @@ -156,19 +151,13 @@ impl ChamberlainDuquetteArea for &dyn NativeArray { let result = match self.data_type() { Point(_, XY) => self.as_point().chamberlain_duquette_unsigned_area(), - LineString(_, XY) => self - .as_line_string() - .chamberlain_duquette_unsigned_area(), + LineString(_, XY) => self.as_line_string().chamberlain_duquette_unsigned_area(), Polygon(_, XY) => self.as_polygon().chamberlain_duquette_unsigned_area(), - MultiPoint(_, XY) => self - .as_multi_point() - .chamberlain_duquette_unsigned_area(), + MultiPoint(_, XY) => self.as_multi_point().chamberlain_duquette_unsigned_area(), MultiLineString(_, XY) => self .as_multi_line_string() .chamberlain_duquette_unsigned_area(), - MultiPolygon(_, XY) => self - .as_multi_polygon() - .chamberlain_duquette_unsigned_area(), + MultiPolygon(_, XY) => self.as_multi_polygon().chamberlain_duquette_unsigned_area(), Mixed(_, XY) => self.as_mixed().chamberlain_duquette_unsigned_area(), GeometryCollection(_, XY) => self .as_geometry_collection() @@ -210,19 +199,13 @@ impl ChamberlainDuquetteArea for &dyn ChunkedNativeArray { match self.data_type() { Point(_, XY) => self.as_point().chamberlain_duquette_signed_area(), - LineString(_, XY) => self - .as_line_string() - .chamberlain_duquette_signed_area(), + LineString(_, XY) => self.as_line_string().chamberlain_duquette_signed_area(), Polygon(_, XY) => self.as_polygon().chamberlain_duquette_signed_area(), - MultiPoint(_, XY) => self - .as_multi_point() - .chamberlain_duquette_signed_area(), + MultiPoint(_, XY) => self.as_multi_point().chamberlain_duquette_signed_area(), MultiLineString(_, XY) => self .as_multi_line_string() .chamberlain_duquette_signed_area(), - MultiPolygon(_, XY) => self - .as_multi_polygon() - .chamberlain_duquette_signed_area(), + MultiPolygon(_, XY) => self.as_multi_polygon().chamberlain_duquette_signed_area(), Mixed(_, XY) => self.as_mixed().chamberlain_duquette_signed_area(), GeometryCollection(_, XY) => self .as_geometry_collection() @@ -237,19 +220,13 @@ impl ChamberlainDuquetteArea for &dyn ChunkedNativeArray { match self.data_type() { Point(_, XY) => self.as_point().chamberlain_duquette_unsigned_area(), - LineString(_, XY) => self - .as_line_string() - .chamberlain_duquette_unsigned_area(), + LineString(_, XY) => self.as_line_string().chamberlain_duquette_unsigned_area(), Polygon(_, XY) => self.as_polygon().chamberlain_duquette_unsigned_area(), - MultiPoint(_, XY) => self - .as_multi_point() - .chamberlain_duquette_unsigned_area(), + MultiPoint(_, XY) => self.as_multi_point().chamberlain_duquette_unsigned_area(), MultiLineString(_, XY) => self .as_multi_line_string() .chamberlain_duquette_unsigned_area(), - MultiPolygon(_, XY) => self - .as_multi_polygon() - .chamberlain_duquette_unsigned_area(), + MultiPolygon(_, XY) => self.as_multi_polygon().chamberlain_duquette_unsigned_area(), Mixed(_, XY) => self.as_mixed().chamberlain_duquette_unsigned_area(), GeometryCollection(_, XY) => self .as_geometry_collection() diff --git a/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs b/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs index 054c48a6..3affbeb4 100644 --- a/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs +++ b/rust/geoarrow/src/algorithm/geo/euclidean_distance.rs @@ -57,7 +57,7 @@ pub trait EuclideanDistance { /// /// let distance = point.euclidean_distance(&polygon); /// - /// assert_relative_eq!(distance.1213203435596424); + /// assert_relative_eq!(distance, 2.1213203435596424); /// ``` /// /// `Point` to `LineString`: diff --git a/rust/geoarrow/src/algorithm/geo/euclidean_length.rs b/rust/geoarrow/src/algorithm/geo/euclidean_length.rs index 744a12bb..2a097a85 100644 --- a/rust/geoarrow/src/algorithm/geo/euclidean_length.rs +++ b/rust/geoarrow/src/algorithm/geo/euclidean_length.rs @@ -20,12 +20,13 @@ pub trait EuclideanLength { /// use geo::line_string; /// use geoarrow::array::LineStringArray; /// use geoarrow::algorithm::geo::EuclideanLength; + /// use geoarrow::datatypes::Dimension; /// /// let line_string = line_string![ /// (x: 40.02f64, y: 116.34), /// (x: 42.02f64, y: 116.34), /// ]; - /// let linestring_array: LineStringArray = vec![line_string].as_slice().into(); + /// let linestring_array: LineStringArray = (vec![line_string].as_slice(), Dimension::XY).into(); /// /// let length_array = linestring_array.euclidean_length(); /// diff --git a/rust/geoarrow/src/algorithm/geo/geodesic_area.rs b/rust/geoarrow/src/algorithm/geo/geodesic_area.rs index 01c0dec3..809a1930 100644 --- a/rust/geoarrow/src/algorithm/geo/geodesic_area.rs +++ b/rust/geoarrow/src/algorithm/geo/geodesic_area.rs @@ -46,6 +46,7 @@ pub trait GeodesicArea { /// use geo::{polygon, Polygon}; /// use geoarrow::array::PolygonArray; /// use geoarrow::algorithm::geo::GeodesicArea; + /// use geoarrow::datatypes::Dimension; /// /// // The O2 in London /// let polygon: Polygon = polygon![ @@ -60,7 +61,7 @@ pub trait GeodesicArea { /// (x: 0.00185608, y: 51.501770), /// (x: 0.00388383, y: 51.501574), /// ]; - /// let polygon_array: PolygonArray = vec![polygon].as_slice().into(); + /// let polygon_array: PolygonArray = (vec![polygon].as_slice(), Dimension::XY).into(); /// /// let area_array = polygon_array.geodesic_area_signed(); /// @@ -91,6 +92,7 @@ pub trait GeodesicArea { /// use geo::{polygon, Polygon}; /// use geoarrow::array::PolygonArray; /// use geoarrow::algorithm::geo::GeodesicArea; + /// use geoarrow::datatypes::Dimension; /// /// // Describe a polygon that covers all of the earth EXCEPT this small square. /// // The outside of the polygon is in this square, the inside of the polygon is the rest of the earth. @@ -100,7 +102,7 @@ pub trait GeodesicArea { /// (x: 1.0, y: 1.0), /// (x: 1.0, y: 0.0), /// ]; - /// let polygon_array: PolygonArray = vec![polygon].as_slice().into(); + /// let polygon_array: PolygonArray = (vec![polygon].as_slice(), Dimension::XY).into(); /// /// let area_array = polygon_array.geodesic_area_unsigned(); /// @@ -331,9 +333,7 @@ impl GeodesicArea for &dyn NativeArray { MultiLineString(_, XY) => self.as_multi_line_string().geodesic_area_unsigned(), MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_area_unsigned(), Mixed(_, XY) => self.as_mixed().geodesic_area_unsigned(), - GeometryCollection(_, XY) => { - self.as_geometry_collection().geodesic_area_unsigned() - } + GeometryCollection(_, XY) => self.as_geometry_collection().geodesic_area_unsigned(), _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -366,12 +366,8 @@ impl GeodesicArea for &dyn NativeArray { LineString(_, XY) => self.as_line_string().geodesic_perimeter_area_signed(), Polygon(_, XY) => self.as_polygon().geodesic_perimeter_area_signed(), MultiPoint(_, XY) => self.as_multi_point().geodesic_perimeter_area_signed(), - MultiLineString(_, XY) => self - .as_multi_line_string() - .geodesic_perimeter_area_signed(), - MultiPolygon(_, XY) => self - .as_multi_polygon() - .geodesic_perimeter_area_signed(), + MultiLineString(_, XY) => self.as_multi_line_string().geodesic_perimeter_area_signed(), + MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_perimeter_area_signed(), Mixed(_, XY) => self.as_mixed().geodesic_perimeter_area_signed(), GeometryCollection(_, XY) => self .as_geometry_collection() @@ -387,19 +383,13 @@ impl GeodesicArea for &dyn NativeArray { let result = match self.data_type() { Point(_, XY) => self.as_point().geodesic_perimeter_area_unsigned(), - LineString(_, XY) => self - .as_line_string() - .geodesic_perimeter_area_unsigned(), + LineString(_, XY) => self.as_line_string().geodesic_perimeter_area_unsigned(), Polygon(_, XY) => self.as_polygon().geodesic_perimeter_area_unsigned(), - MultiPoint(_, XY) => self - .as_multi_point() - .geodesic_perimeter_area_unsigned(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_perimeter_area_unsigned(), MultiLineString(_, XY) => self .as_multi_line_string() .geodesic_perimeter_area_unsigned(), - MultiPolygon(_, XY) => self - .as_multi_polygon() - .geodesic_perimeter_area_unsigned(), + MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_perimeter_area_unsigned(), Mixed(_, XY) => self.as_mixed().geodesic_perimeter_area_unsigned(), GeometryCollection(_, XY) => self .as_geometry_collection() @@ -479,9 +469,7 @@ impl GeodesicArea for &dyn ChunkedNativeArray { MultiLineString(_, XY) => self.as_multi_line_string().geodesic_area_unsigned(), MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_area_unsigned(), Mixed(_, XY) => self.as_mixed().geodesic_area_unsigned(), - GeometryCollection(_, XY) => { - self.as_geometry_collection().geodesic_area_unsigned() - } + GeometryCollection(_, XY) => self.as_geometry_collection().geodesic_area_unsigned(), _ => Err(GeoArrowError::IncorrectType("".into())), } } @@ -512,12 +500,8 @@ impl GeodesicArea for &dyn ChunkedNativeArray { LineString(_, XY) => self.as_line_string().geodesic_perimeter_area_signed(), Polygon(_, XY) => self.as_polygon().geodesic_perimeter_area_signed(), MultiPoint(_, XY) => self.as_multi_point().geodesic_perimeter_area_signed(), - MultiLineString(_, XY) => self - .as_multi_line_string() - .geodesic_perimeter_area_signed(), - MultiPolygon(_, XY) => self - .as_multi_polygon() - .geodesic_perimeter_area_signed(), + MultiLineString(_, XY) => self.as_multi_line_string().geodesic_perimeter_area_signed(), + MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_perimeter_area_signed(), Mixed(_, XY) => self.as_mixed().geodesic_perimeter_area_signed(), GeometryCollection(_, XY) => self .as_geometry_collection() @@ -532,19 +516,13 @@ impl GeodesicArea for &dyn ChunkedNativeArray { match self.data_type() { Point(_, XY) => self.as_point().geodesic_perimeter_area_unsigned(), - LineString(_, XY) => self - .as_line_string() - .geodesic_perimeter_area_unsigned(), + LineString(_, XY) => self.as_line_string().geodesic_perimeter_area_unsigned(), Polygon(_, XY) => self.as_polygon().geodesic_perimeter_area_unsigned(), - MultiPoint(_, XY) => self - .as_multi_point() - .geodesic_perimeter_area_unsigned(), + MultiPoint(_, XY) => self.as_multi_point().geodesic_perimeter_area_unsigned(), MultiLineString(_, XY) => self .as_multi_line_string() .geodesic_perimeter_area_unsigned(), - MultiPolygon(_, XY) => self - .as_multi_polygon() - .geodesic_perimeter_area_unsigned(), + MultiPolygon(_, XY) => self.as_multi_polygon().geodesic_perimeter_area_unsigned(), Mixed(_, XY) => self.as_mixed().geodesic_perimeter_area_unsigned(), GeometryCollection(_, XY) => self .as_geometry_collection() diff --git a/rust/geoarrow/src/algorithm/geo/geodesic_length.rs b/rust/geoarrow/src/algorithm/geo/geodesic_length.rs index 873fe83a..39816bac 100644 --- a/rust/geoarrow/src/algorithm/geo/geodesic_length.rs +++ b/rust/geoarrow/src/algorithm/geo/geodesic_length.rs @@ -34,6 +34,7 @@ pub trait GeodesicLength { /// use geo::LineString; /// use geoarrow::array::LineStringArray; /// use geoarrow::algorithm::geo::GeodesicLength; + /// use geoarrow::datatypes::Dimension; /// /// let linestring = LineString::from(vec![ /// // New York City @@ -43,7 +44,7 @@ pub trait GeodesicLength { /// // Osaka /// (135.5244559, 34.687455) /// ]); - /// let linestring_array: LineStringArray = vec![linestring].as_slice().into(); + /// let linestring_array: LineStringArray = (vec![linestring].as_slice(), Dimension::XY).into(); /// /// let length_array = linestring_array.geodesic_length(); /// diff --git a/rust/geoarrow/src/algorithm/geo/haversine_length.rs b/rust/geoarrow/src/algorithm/geo/haversine_length.rs index 7bdd0ead..9110834b 100644 --- a/rust/geoarrow/src/algorithm/geo/haversine_length.rs +++ b/rust/geoarrow/src/algorithm/geo/haversine_length.rs @@ -30,6 +30,7 @@ pub trait HaversineLength { /// use geo::LineString; /// use geoarrow::array::LineStringArray; /// use geoarrow::algorithm::geo::HaversineLength; + /// use geoarrow::datatypes::Dimension; /// /// let linestring = LineString::::from(vec![ /// // New York City @@ -37,7 +38,7 @@ pub trait HaversineLength { /// // London /// (-0.1278, 51.5074), /// ]); - /// let linestring_array: LineStringArray = vec![linestring].as_slice().into(); + /// let linestring_array: LineStringArray = (vec![linestring].as_slice(), Dimension::XY).into(); /// /// let length_array = linestring_array.haversine_length(); /// diff --git a/rust/geoarrow/src/algorithm/geo/simplify.rs b/rust/geoarrow/src/algorithm/geo/simplify.rs index 7c363705..e2da1060 100644 --- a/rust/geoarrow/src/algorithm/geo/simplify.rs +++ b/rust/geoarrow/src/algorithm/geo/simplify.rs @@ -30,6 +30,7 @@ pub trait Simplify { /// use geoarrow::array::LineStringArray; /// use geoarrow::trait_::ArrayAccessor; /// use geo::line_string; + /// use geoarrow::datatypes::Dimension; /// /// let line_string = line_string![ /// (x: 0.0, y: 0.0), @@ -38,7 +39,7 @@ pub trait Simplify { /// (x: 17.3, y: 3.2), /// (x: 27.8, y: 0.1), /// ]; - /// let line_string_array: LineStringArray = vec![line_string].as_slice().into(); + /// let line_string_array: LineStringArray = (vec![line_string].as_slice(), Dimension::XY).into(); /// /// let simplified_array = line_string_array.simplify(&1.0); /// diff --git a/rust/geoarrow/src/algorithm/geo/simplify_vw.rs b/rust/geoarrow/src/algorithm/geo/simplify_vw.rs index d3a256fc..a4ee33bf 100644 --- a/rust/geoarrow/src/algorithm/geo/simplify_vw.rs +++ b/rust/geoarrow/src/algorithm/geo/simplify_vw.rs @@ -29,6 +29,7 @@ pub trait SimplifyVw { /// use geoarrow::array::LineStringArray; /// use geoarrow::trait_::ArrayAccessor; /// use geo::line_string; + /// use geoarrow::datatypes::Dimension; /// /// let line_string = line_string![ /// (x: 5.0, y: 2.0), @@ -37,7 +38,7 @@ pub trait SimplifyVw { /// (x: 7.0, y: 25.0), /// (x: 10.0, y: 10.0), /// ]; - /// let line_string_array: LineStringArray = vec![line_string].as_slice().into(); + /// let line_string_array: LineStringArray = (vec![line_string].as_slice(), Dimension::XY).into(); /// /// let simplified_array = line_string_array.simplify_vw(&30.0); /// diff --git a/rust/geoarrow/src/algorithm/geo/vincenty_length.rs b/rust/geoarrow/src/algorithm/geo/vincenty_length.rs index 2ef83d52..7576ce15 100644 --- a/rust/geoarrow/src/algorithm/geo/vincenty_length.rs +++ b/rust/geoarrow/src/algorithm/geo/vincenty_length.rs @@ -27,6 +27,7 @@ pub trait VincentyLength { /// use geo::LineString; /// use geoarrow::array::LineStringArray; /// use geoarrow::algorithm::geo::VincentyLength; + /// use geoarrow::datatypes::Dimension; /// /// let linestring = LineString::::from(vec![ /// // New York City @@ -36,7 +37,7 @@ pub trait VincentyLength { /// // Osaka /// (135.5244559, 34.687455) /// ]); - /// let linestring_array: LineStringArray = vec![linestring].as_slice().into(); + /// let linestring_array: LineStringArray = (vec![linestring].as_slice(), Dimension::XY).into(); /// /// let length_array = linestring_array.vincenty_length().unwrap(); /// diff --git a/rust/geoarrow/src/chunked_array/dynamic.rs b/rust/geoarrow/src/chunked_array/dynamic.rs index bff97c9d..80755983 100644 --- a/rust/geoarrow/src/chunked_array/dynamic.rs +++ b/rust/geoarrow/src/chunked_array/dynamic.rs @@ -28,9 +28,10 @@ impl ChunkedNativeArrayDyn { /// ``` /// use geoarrow::{ArrayBase, NativeArray, array::PointArray}; /// use geoarrow::chunked_array::ChunkedNativeArrayDyn; + /// use geoarrow::datatypes::Dimension; /// use std::sync::Arc; /// - /// let array: PointArray = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); + /// let array: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); /// let field = array.extension_field(); /// let array = array.into_array_ref(); /// let chunks = vec![array.as_ref()]; @@ -79,9 +80,10 @@ impl ChunkedNativeArrayDyn { /// ``` /// use geoarrow::{NativeArray, array::PointArray}; /// use geoarrow::chunked_array::ChunkedNativeArrayDyn; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunks = vec![array_0.as_ref(), array_1.as_ref()]; /// let chunked_array = ChunkedNativeArrayDyn::from_geoarrow_chunks(chunks.as_slice()).unwrap(); /// ``` diff --git a/rust/geoarrow/src/chunked_array/mod.rs b/rust/geoarrow/src/chunked_array/mod.rs index ec8c0b54..c7f822a4 100644 --- a/rust/geoarrow/src/chunked_array/mod.rs +++ b/rust/geoarrow/src/chunked_array/mod.rs @@ -280,9 +280,10 @@ impl ChunkedGeometryArray { /// /// ``` /// use geoarrow::{chunked_array::ChunkedGeometryArray, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// ``` pub fn new(chunks: Vec) -> Self { @@ -301,9 +302,10 @@ impl ChunkedGeometryArray { /// /// ``` /// use geoarrow::{chunked_array::ChunkedGeometryArray, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let field = chunked_array.extension_field(); /// assert_eq!(field.name(), "geometry"); @@ -318,9 +320,10 @@ impl ChunkedGeometryArray { /// /// ``` /// use geoarrow::{chunked_array::ChunkedGeometryArray, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let chunks = chunked_array.into_inner(); /// assert_eq!(chunks.len(), 2); @@ -335,9 +338,10 @@ impl ChunkedGeometryArray { /// /// ``` /// use geoarrow::{chunked_array::ChunkedGeometryArray, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.), &geo::point!(x: 5., y: 6.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.), &geo::point!(x: 5., y: 6.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// assert_eq!(chunked_array.len(), 3); /// ``` @@ -351,9 +355,10 @@ impl ChunkedGeometryArray { /// /// ``` /// use geoarrow::{chunked_array::ChunkedGeometryArray, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// assert!(!chunked_array.is_empty()); /// ``` @@ -367,9 +372,10 @@ impl ChunkedGeometryArray { /// /// ``` /// use geoarrow::{chunked_array::ChunkedGeometryArray, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let chunks = chunked_array.chunks(); /// ``` @@ -388,9 +394,10 @@ impl ChunkedGeometryArray { /// trait_::ArrayBase, /// datatypes::NativeType, /// }; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let lengths = chunked_array.into_map(|chunk| chunk.len()); // chunked_array is consumed /// assert_eq!(lengths, vec![1, 1]); @@ -423,9 +430,10 @@ impl ChunkedGeometryArray { /// trait_::ArrayBase, /// datatypes::NativeType, /// }; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let lengths = chunked_array.map(|chunk| chunk.len()); /// assert_eq!(lengths, vec![1, 1]); @@ -458,9 +466,10 @@ impl ChunkedGeometryArray { /// trait_::ArrayBase, /// datatypes::NativeType, /// }; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let lengths = chunked_array.try_map(|chunk| Ok(chunk.len())).unwrap(); /// assert_eq!(lengths, vec![1, 1]); @@ -488,9 +497,10 @@ impl ChunkedGeometryArray { /// /// ``` /// use geoarrow::{chunked_array::ChunkedGeometryArray, array::PointArray, datatypes::NativeType}; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// assert!(matches!(chunked_array.data_type(), NativeType::Point(_, _))); /// ``` @@ -506,11 +516,12 @@ impl<'a, G: NativeArray + ArrayAccessor<'a>> ChunkedGeometryArray { /// /// ``` /// use geoarrow::{chunked_array::ChunkedGeometryArray, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); - /// let value = chunked_array.value(1); // geoarrow::scalar::Point<2> + /// let value = chunked_array.value(1); // geoarrow::scalar::Point /// ``` /// /// # Panics @@ -535,11 +546,12 @@ impl<'a, G: NativeArray + ArrayAccessor<'a>> ChunkedGeometryArray { /// /// ``` /// use geoarrow::{chunked_array::ChunkedGeometryArray, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); - /// let value = chunked_array.get(1).unwrap(); // geoarrow::scalar::Point<2> + /// let value = chunked_array.get(1).unwrap(); // geoarrow::scalar::Point /// ``` /// /// # Panics @@ -606,9 +618,10 @@ pub trait ChunkedArrayBase: std::fmt::Debug + Send + Sync { /// chunked_array::{ChunkedGeometryArray, ChunkedNativeArray, ChunkedArrayBase}, /// array::PointArray /// }; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let any = chunked_array.as_any(); /// ``` @@ -626,9 +639,10 @@ pub trait ChunkedArrayBase: std::fmt::Debug + Send + Sync { /// chunked_array::{ChunkedGeometryArray, ChunkedNativeArray}, /// array::PointArray /// }; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let field = chunked_array.extension_field(); /// assert_eq!(field.metadata()["ARROW:extension:name"], "geoarrow.point"); @@ -641,9 +655,10 @@ pub trait ChunkedArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{array::PointArray, NativeArray, ArrayBase}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert_eq!(point_array.len(), 1); /// ``` fn len(&self) -> usize; @@ -654,9 +669,10 @@ pub trait ChunkedArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{array::PointArray, ArrayBase}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert!(!point_array.is_empty()); /// ``` fn is_empty(&self) -> bool { @@ -672,9 +688,10 @@ pub trait ChunkedArrayBase: std::fmt::Debug + Send + Sync { /// chunked_array::{ChunkedGeometryArray, ChunkedArrayBase}, /// array::PointArray /// }; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// assert_eq!(chunked_array.num_chunks(), 2); /// ``` @@ -689,9 +706,10 @@ pub trait ChunkedArrayBase: std::fmt::Debug + Send + Sync { /// chunked_array::{ChunkedGeometryArray, ChunkedArrayBase}, /// array::PointArray /// }; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let arrays = chunked_array.array_refs(); /// ``` @@ -714,9 +732,10 @@ pub trait ChunkedNativeArray: ChunkedArrayBase { /// chunked_array::{ChunkedGeometryArray, ChunkedNativeArray}, /// array::PointArray /// }; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let data_type = chunked_array.data_type(); /// ``` @@ -731,9 +750,10 @@ pub trait ChunkedNativeArray: ChunkedArrayBase { /// chunked_array::{ChunkedGeometryArray, ChunkedNativeArray}, /// array::PointArray /// }; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let chunks = chunked_array.geometry_chunks(); /// assert_eq!(chunks.len(), 2); @@ -749,9 +769,10 @@ pub trait ChunkedNativeArray: ChunkedArrayBase { /// chunked_array::{ChunkedGeometryArray, ChunkedNativeArray}, /// array::PointArray /// }; + /// use geoarrow::datatypes::Dimension; /// - /// let array_0: PointArray<2> = vec![&geo::point!(x: 1., y: 2.)].as_slice().into(); - /// let array_1: PointArray<2> = vec![&geo::point!(x: 3., y: 4.)].as_slice().into(); + /// let array_0: PointArray = (vec![&geo::point!(x: 1., y: 2.)].as_slice(), Dimension::XY).into(); + /// let array_1: PointArray = (vec![&geo::point!(x: 3., y: 4.)].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array_0, array_1]); /// let array_ref = chunked_array.as_ref(); /// ``` diff --git a/rust/geoarrow/src/lib.rs b/rust/geoarrow/src/lib.rs index fb90ceb2..f728eed8 100644 --- a/rust/geoarrow/src/lib.rs +++ b/rust/geoarrow/src/lib.rs @@ -39,16 +39,19 @@ //! //! ``` //! use geoarrow::array::PointArray; +//! use geoarrow::datatypes::Dimension; //! //! let point = geo::point!(x: 1., y: 2.); -//! let array: PointArray<2> = vec![point].as_slice().into(); +//! let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); //! ``` //! //! Or you can use builders, e.g. [PointBuilder](crate::array::PointBuilder): //! //! ``` //! use geoarrow::array::PointBuilder; -//! let mut builder = PointBuilder::<2>::new(); +//! use geoarrow::datatypes::Dimension; +//! +//! let mut builder = PointBuilder::new(Dimension::XY); //! builder.push_point(Some(&geo::point!(x: 1., y: 2.))); //! let array = builder.finish(); //! ``` diff --git a/rust/geoarrow/src/table.rs b/rust/geoarrow/src/table.rs index 60a7b7f6..76834a0d 100644 --- a/rust/geoarrow/src/table.rs +++ b/rust/geoarrow/src/table.rs @@ -55,9 +55,10 @@ impl Table { /// use arrow_array::RecordBatch; /// use arrow_schema::{Schema, SchemaRef}; /// use geoarrow::{NativeArray, ArrayBase, array::PointArray, table::Table}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let field = array.extension_field(); /// let schema: SchemaRef = Schema::new(vec![field]).into(); /// let columns = vec![array.into_array_ref()]; @@ -95,10 +96,11 @@ impl Table { /// table::Table, /// chunked_array::ChunkedGeometryArray /// }; + /// use geoarrow::datatypes::Dimension; /// use std::sync::Arc; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let chunked_array = ChunkedGeometryArray::new(vec![array]); /// /// let id_array = Int32Array::from(vec![1]); diff --git a/rust/geoarrow/src/trait_.rs b/rust/geoarrow/src/trait_.rs index ab50ddb9..99b2b097 100644 --- a/rust/geoarrow/src/trait_.rs +++ b/rust/geoarrow/src/trait_.rs @@ -44,10 +44,11 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{array::PointArray, datatypes::NativeType, ArrayBase}; + /// use geoarrow::datatypes::Dimension; /// use arrow_schema::DataType; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert!(matches!(point_array.storage_type(), DataType::FixedSizeList(_, _))); /// ``` fn storage_type(&self) -> DataType; @@ -59,9 +60,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{array::PointArray, ArrayBase}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let field = point_array.extension_field(); /// assert_eq!(field.name(), "geometry"); /// ``` @@ -73,9 +75,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{array::PointArray, ArrayBase}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert_eq!(point_array.extension_name(), "geoarrow.point"); /// ``` fn extension_name(&self) -> &str; @@ -89,9 +92,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// ``` /// /// use geoarrow::{array::PointArray, ArrayBase}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let array_ref = point_array.into_array_ref(); /// ``` #[must_use] @@ -106,9 +110,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// ``` /// /// use geoarrow::{array::PointArray, ArrayBase}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let array_ref = point_array.to_array_ref(); /// ``` #[must_use] @@ -120,9 +125,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{array::PointArray, ArrayBase}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert_eq!(point_array.len(), 1); /// ``` fn len(&self) -> usize; @@ -133,9 +139,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{array::PointArray, ArrayBase}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert!(!point_array.is_empty()); /// ``` fn is_empty(&self) -> bool { @@ -152,9 +159,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{ArrayBase, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert!(array.nulls().is_none()); /// ``` fn nulls(&self) -> Option<&NullBuffer>; @@ -165,9 +173,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{ArrayBase, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let metadata = array.metadata(); /// ``` fn metadata(&self) -> Arc; @@ -180,9 +189,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{ArrayBase, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert_eq!(array.null_count(), 0); /// ``` #[inline] @@ -196,9 +206,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{ArrayBase, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert!(!array.is_null(0)); /// ``` /// @@ -216,9 +227,10 @@ pub trait ArrayBase: std::fmt::Debug + Send + Sync { /// /// ``` /// use geoarrow::{ArrayBase, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert!(array.is_valid(0)); /// ``` /// @@ -245,9 +257,10 @@ pub trait NativeArray: ArrayBase { /// /// ``` /// use geoarrow::{array::PointArray, datatypes::NativeType, NativeArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert!(matches!(point_array.data_type(), NativeType::Point(_, _))); /// ``` fn data_type(&self) -> NativeType; @@ -258,9 +271,10 @@ pub trait NativeArray: ArrayBase { /// /// ``` /// use geoarrow::{array::{PointArray, CoordType}, NativeArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert_eq!(point_array.coord_type(), CoordType::Interleaved); /// ``` fn coord_type(&self) -> CoordType; @@ -276,9 +290,10 @@ pub trait NativeArray: ArrayBase { /// /// ``` /// use geoarrow::{array::{PointArray, CoordType}, NativeArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let point_array: PointArray<2> = vec![point].as_slice().into(); + /// let point_array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let point_array = point_array.to_coord_type(CoordType::Separated); /// ``` #[must_use] @@ -290,9 +305,10 @@ pub trait NativeArray: ArrayBase { /// /// ``` /// use geoarrow::{NativeArray, array::{PointArray, metadata::{ArrayMetadata, Edges}}}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let metadata = ArrayMetadata { /// crs: None, /// edges: Some(Edges::Spherical), @@ -308,9 +324,10 @@ pub trait NativeArray: ArrayBase { /// /// ``` /// use geoarrow::{NativeArray, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let array_ref = array.as_ref(); /// ``` fn as_ref(&self) -> &dyn NativeArray; @@ -324,10 +341,11 @@ pub trait NativeArray: ArrayBase { /// array::PointArray, /// trait_::{GeometryArraySelfMethods, ArrayAccessor, NativeArray, ArrayBase} /// }; + /// use geoarrow::datatypes::Dimension; /// /// let point_0 = geo::point!(x: 1., y: 2.); /// let point_1 = geo::point!(x: 3., y: 4.); - /// let array: PointArray<2> = vec![point_0, point_1].as_slice().into(); + /// let array: PointArray = (vec![point_0, point_1].as_slice(), Dimension::XY).into(); /// let smaller_array = array.slice(1, 1); /// assert_eq!(smaller_array.len(), 1); /// let value = smaller_array.value_as_geo(0); @@ -347,10 +365,11 @@ pub trait NativeArray: ArrayBase { /// /// ``` /// use geoarrow::{array::PointArray, trait_::GeometryArraySelfMethods}; + /// use geoarrow::datatypes::Dimension; /// /// let point_0 = geo::point!(x: 1., y: 2.); /// let point_1 = geo::point!(x: 3., y: 4.); - /// let array: PointArray<2> = vec![point_0, point_1].as_slice().into(); + /// let array: PointArray = (vec![point_0, point_1].as_slice(), Dimension::XY).into(); /// let smaller_array = array.owned_slice(1, 1); /// ``` #[must_use] @@ -373,9 +392,10 @@ pub trait SerializedArray: ArrayBase { /// /// ``` /// use geoarrow::{NativeArray, array::{PointArray, metadata::{ArrayMetadata, Edges}}}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let metadata = ArrayMetadata { /// crs: None, /// edges: Some(Edges::Spherical), @@ -391,9 +411,10 @@ pub trait SerializedArray: ArrayBase { /// /// ``` /// use geoarrow::{NativeArray, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let array_ref = array.as_ref(); /// ``` fn as_ref(&self) -> &dyn SerializedArray; @@ -514,10 +535,11 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// ``` /// use geoarrow::{trait_::ArrayAccessor, array::PointArray}; /// use geo_traits::{PointTrait, CoordTrait}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); - /// let value = array.value(0); // geoarrow::scalar::Point<2> + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); + /// let value = array.value(0); // geoarrow::scalar::Point /// assert_eq!(value.coord().x(), 1.); /// assert_eq!(value.coord().y(), 2.); /// ``` @@ -536,11 +558,12 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// /// ``` /// use geoarrow::{trait_::ArrayAccessor, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// unsafe { - /// let value = array.value_unchecked(0); // geoarrow::scalar::Point<2> + /// let value = array.value_unchecked(0); // geoarrow::scalar::Point /// } /// ``` /// @@ -555,9 +578,10 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// /// ``` /// use geoarrow::{trait_::ArrayAccessor, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert!(array.get(0).is_some()); /// ``` fn get(&'a self, index: usize) -> Option { @@ -574,9 +598,10 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// /// ``` /// use geoarrow::{trait_::ArrayAccessor, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// unsafe { /// assert!(array.get_unchecked(0).is_some()); /// } @@ -600,9 +625,10 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// ``` /// use geoarrow::{trait_::ArrayAccessor, array::PointArray}; /// use geo_traits::{PointTrait, CoordTrait}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let value = array.value_as_geo(0); // geo::Point /// assert_eq!(value.coord().unwrap().x(), 1.); /// assert_eq!(value.coord().unwrap().y(), 2.); @@ -617,9 +643,10 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// /// ``` /// use geoarrow::{trait_::ArrayAccessor, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// assert!(array.get_as_geo(0).is_some()); /// ``` fn get_as_geo(&'a self, i: usize) -> Option { @@ -636,9 +663,10 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// /// ``` /// use geoarrow::{trait_::ArrayAccessor, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let maybe_points: Vec> = array.iter().collect(); /// ``` fn iter(&'a self) -> impl ExactSizeIterator> + 'a { @@ -651,9 +679,10 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// /// ``` /// use geoarrow::{trait_::ArrayAccessor, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let points: Vec<_> = array.iter_values().collect(); /// ``` fn iter_values(&'a self) -> impl ExactSizeIterator + 'a { @@ -666,9 +695,10 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// /// ``` /// use geoarrow::{trait_::ArrayAccessor, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let maybe_points: Vec> = array.iter_geo().collect(); /// ``` fn iter_geo(&'a self) -> impl ExactSizeIterator> + 'a { @@ -681,9 +711,10 @@ pub trait ArrayAccessor<'a>: ArrayBase { /// /// ``` /// use geoarrow::{trait_::ArrayAccessor, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let points: Vec<_> = array.iter_geo_values().collect(); /// ``` fn iter_geo_values(&'a self) -> impl ExactSizeIterator + 'a { @@ -710,7 +741,7 @@ pub trait GeometryArraySelfMethods { /// }; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let coords = CoordBuffer::Interleaved(InterleavedCoordBuffer::new(vec![3., 4.].into(), Dimension::XY)); /// let array = array.with_coords(coords); /// let value = array.value_as_geo(0); @@ -728,10 +759,11 @@ pub trait GeometryArraySelfMethods { /// array::{PointArray, CoordType, CoordBuffer}, /// trait_::{ArrayAccessor, GeometryArraySelfMethods}, /// }; + /// use geoarrow::datatypes::Dimension; /// /// let point_0 = geo::point!(x: 1., y: 2.); /// let point_1 = geo::point!(x: 3., y: 4.); - /// let array_interleaved: PointArray<2> = vec![point_0, point_1].as_slice().into(); + /// let array_interleaved: PointArray = (vec![point_0, point_1].as_slice(), Dimension::XY).into(); /// let array_separated = array_interleaved.into_coord_type(CoordType::Separated); /// assert!(matches!(array_separated.coords(), &CoordBuffer::Separated(_))); /// ``` @@ -749,9 +781,10 @@ pub trait IntoArrow { /// /// ``` /// use geoarrow::{trait_::IntoArrow, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let arrow_array = array.into_arrow(); /// ``` fn into_arrow(self) -> Self::ArrowArray; @@ -768,9 +801,10 @@ pub trait NativeScalar { /// /// ``` /// use geoarrow::{trait_::{NativeScalar, ArrayAccessor}, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let point = array.value(0).to_geo(); // array.value_as_geo(0) does the same thing /// assert_eq!(point.x(), 1.); /// assert_eq!(point.y(), 2.); @@ -783,9 +817,10 @@ pub trait NativeScalar { /// /// ``` /// use geoarrow::{trait_::{NativeScalar, ArrayAccessor}, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let geometry = array.value(0).to_geo_geometry(); /// ``` fn to_geo_geometry(&self) -> geo::Geometry; @@ -796,9 +831,10 @@ pub trait NativeScalar { /// /// ``` /// use geoarrow::{trait_::{NativeScalar, ArrayAccessor}, array::PointArray}; + /// use geoarrow::datatypes::Dimension; /// /// let point = geo::point!(x: 1., y: 2.); - /// let array: PointArray<2> = vec![point].as_slice().into(); + /// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into(); /// let geometry = array.value(0).to_geos().unwrap(); /// ``` #[cfg(feature = "geos")] @@ -818,6 +854,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; + /// use geoarrow::datatypes::Dimension; /// /// let mut builder = PointBuilder::new(Dimension::XY); /// assert_eq!(builder.len(), 0); @@ -832,6 +869,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; + /// use geoarrow::datatypes::Dimension; /// /// let mut builder = PointBuilder::new(Dimension::XY); /// assert!(builder.is_empty()); @@ -848,6 +886,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; + /// use geoarrow::datatypes::Dimension; /// /// let builder = PointBuilder::new(Dimension::XY); /// assert!(builder.nulls().is_empty()); @@ -860,6 +899,8 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; + /// use geoarrow::datatypes::Dimension; + /// /// let builder = PointBuilder::new(Dimension::XY); /// ``` fn new(dim: Dimension) -> Self; @@ -873,11 +914,14 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// array::{PointBuilder, CoordType, metadata::{ArrayMetadata, Edges}}, /// trait_::GeometryArrayBuilder, /// }; + /// use geoarrow::datatypes::Dimension; + /// /// let metadata = ArrayMetadata { /// crs: None, /// edges: Some(Edges::Spherical), /// }; - /// let builder = PointBuilder::<2>::with_geom_capacity_and_options( + /// let builder = PointBuilder::with_geom_capacity_and_options( + /// Dimension::XY, /// 2, /// CoordType::Interleaved, /// metadata.into() @@ -899,7 +943,9 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// array::PointBuilder, /// trait_::GeometryArrayBuilder, /// }; - /// let builder = PointBuilder::<2>::with_geom_capacity(2); + /// use geoarrow::datatypes::Dimension; + /// + /// let builder = PointBuilder::with_geom_capacity(Dimension::XY, 2); /// ``` fn with_geom_capacity(dim: Dimension, geom_capacity: usize) -> Self { GeometryArrayBuilder::with_geom_capacity_and_options( @@ -922,6 +968,8 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// array::{PointBuilder, metadata::{ArrayMetadata, Edges}}, /// trait_::GeometryArrayBuilder, /// }; + /// use geoarrow::datatypes::Dimension; + /// /// let mut builder = PointBuilder::new(Dimension::XY); /// let metadata = ArrayMetadata { /// crs: None, @@ -937,6 +985,7 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::PointBuilder, trait_::{GeometryArrayBuilder, NativeArray, ArrayBase}}; + /// use geoarrow::datatypes::Dimension; /// /// let mut builder = PointBuilder::new(Dimension::XY); /// builder.push_point(Some(&geo::point!(x: 1., y: 2.))); @@ -951,6 +1000,8 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::{PointBuilder, CoordType}, trait_::GeometryArrayBuilder}; + /// use geoarrow::datatypes::Dimension; + /// /// let builder = PointBuilder::new(Dimension::XY); /// assert_eq!(builder.coord_type(), CoordType::Interleaved); /// ``` @@ -962,6 +1013,8 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::{PointBuilder, CoordType}, trait_::GeometryArrayBuilder}; + /// use geoarrow::datatypes::Dimension; + /// /// let builder = PointBuilder::new(Dimension::XY); /// let metadata = builder.metadata(); /// ``` @@ -987,6 +1040,8 @@ pub trait GeometryArrayBuilder: std::fmt::Debug + Send + Sync + Sized { /// /// ``` /// use geoarrow::{array::PointBuilder, trait_::GeometryArrayBuilder}; + /// use geoarrow::datatypes::Dimension; + /// /// let builder = PointBuilder::new(Dimension::XY); /// let array_ref = builder.into_array_ref(); /// ``` From 5139145ce9737b3cca617758d777b41bf72272ab Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 22:43:01 -0500 Subject: [PATCH 12/14] fmt --- rust/geoarrow/src/algorithm/geo/contains.rs | 28 +++++-------------- .../src/algorithm/geo/frechet_distance.rs | 18 +++++------- .../src/algorithm/geo/line_locate_point.rs | 7 ++--- .../src/io/geos/scalar/multipolygon.rs | 4 +-- 4 files changed, 18 insertions(+), 39 deletions(-) diff --git a/rust/geoarrow/src/algorithm/geo/contains.rs b/rust/geoarrow/src/algorithm/geo/contains.rs index d50fa89e..f4c33c70 100644 --- a/rust/geoarrow/src/algorithm/geo/contains.rs +++ b/rust/geoarrow/src/algorithm/geo/contains.rs @@ -175,9 +175,7 @@ impl> ContainsPoint for &dyn NativeArray { LineString(_, XY) => ContainsPoint::contains(self.as_line_string(), rhs), Polygon(_, XY) => ContainsPoint::contains(self.as_polygon(), rhs), MultiPoint(_, XY) => ContainsPoint::contains(self.as_multi_point(), rhs), - MultiLineString(_, XY) => { - ContainsPoint::contains(self.as_multi_line_string(), rhs) - } + MultiLineString(_, XY) => ContainsPoint::contains(self.as_multi_line_string(), rhs), MultiPolygon(_, XY) => ContainsPoint::contains(self.as_multi_polygon(), rhs), Mixed(_, XY) => ContainsPoint::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { @@ -291,9 +289,7 @@ impl> ContainsPolygon for &dyn NativeArray { LineString(_, XY) => ContainsPolygon::contains(self.as_line_string(), rhs), Polygon(_, XY) => ContainsPolygon::contains(self.as_polygon(), rhs), MultiPoint(_, XY) => ContainsPolygon::contains(self.as_multi_point(), rhs), - MultiLineString(_, XY) => { - ContainsPolygon::contains(self.as_multi_line_string(), rhs) - } + MultiLineString(_, XY) => ContainsPolygon::contains(self.as_multi_line_string(), rhs), MultiPolygon(_, XY) => ContainsPolygon::contains(self.as_multi_polygon(), rhs), Mixed(_, XY) => ContainsPolygon::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { @@ -404,9 +400,7 @@ impl> ContainsMultiLineString for &dyn Nativ MultiLineString(_, XY) => { ContainsMultiLineString::contains(self.as_multi_line_string(), rhs) } - MultiPolygon(_, XY) => { - ContainsMultiLineString::contains(self.as_multi_polygon(), rhs) - } + MultiPolygon(_, XY) => ContainsMultiLineString::contains(self.as_multi_polygon(), rhs), Mixed(_, XY) => ContainsMultiLineString::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { ContainsMultiLineString::contains(self.as_geometry_collection(), rhs) @@ -461,9 +455,7 @@ impl> ContainsMultiPolygon for &dyn NativeArray MultiLineString(_, XY) => { ContainsMultiPolygon::contains(self.as_multi_line_string(), rhs) } - MultiPolygon(_, XY) => { - ContainsMultiPolygon::contains(self.as_multi_polygon(), rhs) - } + MultiPolygon(_, XY) => ContainsMultiPolygon::contains(self.as_multi_polygon(), rhs), Mixed(_, XY) => ContainsMultiPolygon::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { ContainsMultiPolygon::contains(self.as_geometry_collection(), rhs) @@ -515,9 +507,7 @@ impl> ContainsGeometry for &dyn NativeArray { LineString(_, XY) => ContainsGeometry::contains(self.as_line_string(), rhs), Polygon(_, XY) => ContainsGeometry::contains(self.as_polygon(), rhs), MultiPoint(_, XY) => todo!(), // ContainsGeometry::contains(self.as_multi_point(), rhs), - MultiLineString(_, XY) => { - ContainsGeometry::contains(self.as_multi_line_string(), rhs) - } + MultiLineString(_, XY) => ContainsGeometry::contains(self.as_multi_line_string(), rhs), MultiPolygon(_, XY) => todo!(), // ContainsGeometry::contains(self.as_multi_polygon(), rhs), Mixed(_, XY) => ContainsGeometry::contains(self.as_mixed(), rhs), GeometryCollection(_, XY) => { @@ -567,13 +557,9 @@ impl> ContainsGeometryCollection for &dyn match self.data_type() { Point(_, XY) => ContainsGeometryCollection::contains(self.as_point(), rhs), - LineString(_, XY) => { - ContainsGeometryCollection::contains(self.as_line_string(), rhs) - } + LineString(_, XY) => ContainsGeometryCollection::contains(self.as_line_string(), rhs), Polygon(_, XY) => ContainsGeometryCollection::contains(self.as_polygon(), rhs), - MultiPoint(_, XY) => { - ContainsGeometryCollection::contains(self.as_multi_point(), rhs) - } + MultiPoint(_, XY) => ContainsGeometryCollection::contains(self.as_multi_point(), rhs), MultiLineString(_, XY) => { ContainsGeometryCollection::contains(self.as_multi_line_string(), rhs) } diff --git a/rust/geoarrow/src/algorithm/geo/frechet_distance.rs b/rust/geoarrow/src/algorithm/geo/frechet_distance.rs index 7b792124..5624272f 100644 --- a/rust/geoarrow/src/algorithm/geo/frechet_distance.rs +++ b/rust/geoarrow/src/algorithm/geo/frechet_distance.rs @@ -55,10 +55,9 @@ impl FrechetDistance for &dyn NativeArray { use NativeType::*; let result = match (self.data_type(), rhs.data_type()) { - (LineString(_, XY), LineString(_, XY)) => FrechetDistance::frechet_distance( - self.as_line_string(), - rhs.as_line_string(), - ), + (LineString(_, XY), LineString(_, XY)) => { + FrechetDistance::frechet_distance(self.as_line_string(), rhs.as_line_string()) + } _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -73,10 +72,9 @@ impl FrechetDistance for &dyn ChunkedNativeArray { use NativeType::*; let result = match (self.data_type(), rhs.data_type()) { - (LineString(_, XY), LineString(_, XY)) => FrechetDistance::frechet_distance( - self.as_line_string(), - rhs.as_line_string(), - ), + (LineString(_, XY), LineString(_, XY)) => { + FrechetDistance::frechet_distance(self.as_line_string(), rhs.as_line_string()) + } _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) @@ -105,9 +103,7 @@ impl> FrechetDistanceLineString for LineStringArr } } -impl + Sync> FrechetDistanceLineString - for ChunkedLineStringArray -{ +impl + Sync> FrechetDistanceLineString for ChunkedLineStringArray { type Output = ChunkedArray; fn frechet_distance(&self, rhs: &G) -> Self::Output { diff --git a/rust/geoarrow/src/algorithm/geo/line_locate_point.rs b/rust/geoarrow/src/algorithm/geo/line_locate_point.rs index 3b8d369d..774daea2 100644 --- a/rust/geoarrow/src/algorithm/geo/line_locate_point.rs +++ b/rust/geoarrow/src/algorithm/geo/line_locate_point.rs @@ -84,10 +84,9 @@ impl LineLocatePoint<&dyn ChunkedNativeArray> for &dyn ChunkedNativeArray { use NativeType::*; let result = match (self.data_type(), rhs.data_type()) { - (LineString(_, XY), Point(_, XY)) => LineLocatePoint::line_locate_point( - self.as_line_string(), - &rhs.as_point().chunks, - ), + (LineString(_, XY), Point(_, XY)) => { + LineLocatePoint::line_locate_point(self.as_line_string(), &rhs.as_point().chunks) + } _ => return Err(GeoArrowError::IncorrectType("".into())), }; Ok(result) diff --git a/rust/geoarrow/src/io/geos/scalar/multipolygon.rs b/rust/geoarrow/src/io/geos/scalar/multipolygon.rs index 02855bb9..0b745a1d 100644 --- a/rust/geoarrow/src/io/geos/scalar/multipolygon.rs +++ b/rust/geoarrow/src/io/geos/scalar/multipolygon.rs @@ -7,9 +7,7 @@ use geos::{Geom, GeometryTypes}; impl<'a> TryFrom<&'a MultiPolygon<'_>> for geos::Geometry { type Error = geos::Error; - fn try_from( - value: &'a MultiPolygon<'_>, - ) -> std::result::Result { + fn try_from(value: &'a MultiPolygon<'_>) -> std::result::Result { geos::Geometry::create_multipolygon( value .polygons() From 9ee2a1de0e74128c3c4c7441002b6a209271793a Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 23:07:13 -0500 Subject: [PATCH 13/14] bindings --- js/Cargo.lock | 1197 +++++++++++++---- js/src/data/mod.rs | 32 +- js/src/io/parquet/async_file_reader/mod.rs | 9 +- js/src/scalar/linestring.rs | 10 +- js/src/scalar/multilinestring.rs | 10 +- js/src/scalar/multipoint.rs | 10 +- js/src/scalar/multipolygon.rs | 10 +- js/src/scalar/point.rs | 10 +- js/src/scalar/polygon.rs | 10 +- js/src/vector/mod.rs | 18 +- python/Cargo.lock | 890 ++++++++---- .../src/algorithm/geo/convex_hull.rs | 4 +- python/geoarrow-core/src/interop/ewkb.rs | 18 +- .../src/interop/shapely/to_shapely.rs | 60 +- python/geoarrow-core/src/interop/wkb.rs | 10 +- python/geoarrow-core/src/interop/wkt.rs | 5 +- .../src/ffi/from_python/scalar.rs | 5 +- 17 files changed, 1641 insertions(+), 667 deletions(-) diff --git a/js/Cargo.lock b/js/Cargo.lock index cf436464..3d2a7e40 100644 --- a/js/Cargo.lock +++ b/js/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] @@ -57,9 +57,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "android-tzdata" @@ -78,9 +78,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.6.15" +version = "0.6.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64e15c1ab1f89faffbf04a634d5e1962e9074f2741eef6d97f3c4e322426d526" +checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b" dependencies = [ "anstyle", "anstyle-parse", @@ -93,43 +93,43 @@ dependencies = [ [[package]] name = "anstyle" -version = "1.0.8" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bec1de6f59aedf83baf9ff929c98f2ad654b97c9510f4e70cf6f661d49fd5b1" +checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9" [[package]] name = "anstyle-parse" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eb47de1e80c2b463c735db5b217a0ddc39d612e7ac9e2e96a5aed1f57616c1cb" +checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9" dependencies = [ "utf8parse", ] [[package]] name = "anstyle-query" -version = "1.1.1" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d36fc52c7f6c869915e99412912f22093507da8d9e942ceaf66fe4b7c14422a" +checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anstyle-wincon" -version = "3.0.4" +version = "3.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf74e1b6e971609db8ca7a9ce79fd5768ab6ae46441c572e46cf596f59e57f8" +checksum = "2109dbce0e72be3ec00bed26e6a7479ca384ad226efdd66db8fa2e3a38c83125" dependencies = [ "anstyle", - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "approx" @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "arrow" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45aef0d9cf9a039bf6cd1acc451b137aca819977b0928dece52bd92811b640ba" +checksum = "4caf25cdc4a985f91df42ed9e9308e1adbcd341a31a72605c697033fcef163e3" dependencies = [ "arrow-arith", "arrow-array", @@ -163,9 +163,9 @@ dependencies = [ [[package]] name = "arrow-arith" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03675e42d1560790f3524800e41403b40d0da1c793fe9528929fde06d8c7649a" +checksum = "91f2dfd1a7ec0aca967dfaa616096aec49779adc8eccec005e2f5e4111b1192a" dependencies = [ "arrow-array", "arrow-buffer", @@ -178,9 +178,9 @@ dependencies = [ [[package]] name = "arrow-array" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd2bf348cf9f02a5975c5962c7fa6dee107a2009a7b41ac5fb1a027e12dc033f" +checksum = "d39387ca628be747394890a6e47f138ceac1aa912eab64f02519fed24b637af8" dependencies = [ "ahash", "arrow-buffer", @@ -189,15 +189,15 @@ dependencies = [ "chrono", "chrono-tz", "half", - "hashbrown", + "hashbrown 0.14.5", "num", ] [[package]] name = "arrow-buffer" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3092e37715f168976012ce52273c3989b5793b0db5f06cbaa246be25e5f0924d" +checksum = "9e51e05228852ffe3eb391ce7178a0f97d2cf80cc6ef91d3c4a6b3cb688049ec" dependencies = [ "bytes", "half", @@ -206,9 +206,9 @@ dependencies = [ [[package]] name = "arrow-cast" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ce1018bb710d502f9db06af026ed3561552e493e989a79d0d0f5d9cf267a785" +checksum = "d09aea56ec9fa267f3f3f6cdab67d8a9974cbba90b3aa38c8fe9d0bb071bd8c1" dependencies = [ "arrow-array", "arrow-buffer", @@ -219,16 +219,16 @@ dependencies = [ "base64 0.22.1", "chrono", "half", - "lexical-core", + "lexical-core 1.0.2", "num", "ryu", ] [[package]] name = "arrow-csv" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd178575f45624d045e4ebee714e246a05d9652e41363ee3f57ec18cca97f740" +checksum = "c07b5232be87d115fde73e32f2ca7f1b353bff1b44ac422d3c6fc6ae38f11f0d" dependencies = [ "arrow-array", "arrow-buffer", @@ -239,15 +239,15 @@ dependencies = [ "csv", "csv-core", "lazy_static", - "lexical-core", + "lexical-core 1.0.2", "regex", ] [[package]] name = "arrow-data" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4ac0c4ee79150afe067dc4857154b3ee9c1cd52b5f40d59a77306d0ed18d65" +checksum = "b98ae0af50890b494cebd7d6b04b35e896205c1d1df7b29a6272c5d0d0249ef5" dependencies = [ "arrow-buffer", "arrow-schema", @@ -257,9 +257,9 @@ dependencies = [ [[package]] name = "arrow-ipc" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb307482348a1267f91b0912e962cd53440e5de0f7fb24c5f7b10da70b38c94a" +checksum = "0ed91bdeaff5a1c00d28d8f73466bcb64d32bbd7093b5a30156b4b9f4dba3eee" dependencies = [ "arrow-array", "arrow-buffer", @@ -271,9 +271,9 @@ dependencies = [ [[package]] name = "arrow-json" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24805ba326758effdd6f2cbdd482fcfab749544f21b134701add25b33f474e6" +checksum = "0471f51260a5309307e5d409c9dc70aede1cd9cf1d4ff0f0a1e8e1a2dd0e0d3c" dependencies = [ "arrow-array", "arrow-buffer", @@ -283,7 +283,7 @@ dependencies = [ "chrono", "half", "indexmap", - "lexical-core", + "lexical-core 1.0.2", "num", "serde", "serde_json", @@ -291,9 +291,9 @@ dependencies = [ [[package]] name = "arrow-ord" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644046c479d80ae8ed02a7f1e1399072ea344ca6a7b0e293ab2d5d9ed924aa3b" +checksum = "2883d7035e0b600fb4c30ce1e50e66e53d8656aa729f2bfa4b51d359cf3ded52" dependencies = [ "arrow-array", "arrow-buffer", @@ -306,9 +306,9 @@ dependencies = [ [[package]] name = "arrow-row" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a29791f8eb13b340ce35525b723f5f0df17ecb955599e11f65c2a94ab34e2efb" +checksum = "552907e8e587a6fde4f8843fd7a27a576a260f65dab6c065741ea79f633fc5be" dependencies = [ "ahash", "arrow-array", @@ -320,18 +320,18 @@ dependencies = [ [[package]] name = "arrow-schema" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85320a3a2facf2b2822b57aa9d6d9d55edb8aee0b6b5d3b8df158e503d10858" +checksum = "539ada65246b949bd99ffa0881a9a15a4a529448af1a07a9838dd78617dafab1" dependencies = [ "bitflags 2.6.0", ] [[package]] name = "arrow-select" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cc7e6b582e23855fd1625ce46e51647aa440c20ea2e71b1d748e0839dd73cba" +checksum = "6259e566b752da6dceab91766ed8b2e67bf6270eb9ad8a6e07a33c1bede2b125" dependencies = [ "ahash", "arrow-array", @@ -343,9 +343,9 @@ dependencies = [ [[package]] name = "arrow-string" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0775b6567c66e56ded19b87a954b6b1beffbdd784ef95a3a2b03f59570c1d230" +checksum = "f3179ccbd18ebf04277a095ba7321b93fd1f774f18816bd5f6b3ce2f594edb6c" dependencies = [ "arrow-array", "arrow-buffer", @@ -375,9 +375,9 @@ dependencies = [ [[package]] name = "async-stream" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd56dd203fef61ac097dd65721a419ddccb106b2d2b70ba60a6b529f03961a51" +checksum = "0b5a71a6f37880a80d1d7f19efd781e4b5de42c88f0722cc13bcb6cc2cfe8476" dependencies = [ "async-stream-impl", "futures-core", @@ -386,24 +386,24 @@ dependencies = [ [[package]] name = "async-stream-impl" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" +checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "async-trait" -version = "0.1.82" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27b8a3a6e1a44fa4c8baf1f653e4172e81486d4941f2237e20dc2d0cf4ddff1" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -415,11 +415,17 @@ dependencies = [ "num-traits", ] +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + [[package]] name = "autocfg" -version = "1.3.0" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "backon" @@ -474,9 +480,9 @@ checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "brotli" -version = "6.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" +checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -501,9 +507,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" [[package]] name = "byteorder" @@ -513,15 +519,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cc" -version = "1.1.21" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07b1695e2c7e8fc85310cde85aeaab7e3097f593c91d209d3f9df76c928100f0" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -550,9 +556,9 @@ dependencies = [ [[package]] name = "chrono-tz" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" +checksum = "cd6dd8046d00723a59a2f8c5f295c515b9bb9a331ee4f8f3d4dd49e428acd3b6" dependencies = [ "chrono", "chrono-tz-build", @@ -561,20 +567,19 @@ dependencies = [ [[package]] name = "chrono-tz-build" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" +checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7" dependencies = [ "parse-zoneinfo", - "phf", "phf_codegen", ] [[package]] name = "clap" -version = "4.5.17" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e5a21b8495e732f1b3c364c9949b201ca7bae518c502c80256c96ad79eaf6ac" +checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f" dependencies = [ "clap_builder", "clap_derive", @@ -582,9 +587,9 @@ dependencies = [ [[package]] name = "clap-verbosity-flag" -version = "2.2.1" +version = "2.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "63d19864d6b68464c59f7162c9914a0b569ddc2926b4a2d71afe62a9738eff53" +checksum = "34c77f67047557f62582784fd7482884697731b2932c7d37ced54bce2312e1e2" dependencies = [ "clap", "log", @@ -592,9 +597,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.5.17" +version = "4.5.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8cf2dd12af7a047ad9d6da2b6b249759a22a7abc0f474c1dae1777afa4b21a73" +checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec" dependencies = [ "anstream", "anstyle", @@ -604,27 +609,27 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.5.13" +version = "4.5.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "501d359d5f3dcaf6ecdeee48833ae73ec6e42723a1e52419c79abf9507eec0a0" +checksum = "4ac6a0c7b1a9e9a5186361f67dfa1b88213572f427fb9ab038efb2bd8c582dab" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "clap_lex" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97" +checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7" [[package]] name = "colorchoice" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fd119d74b830634cea2a0f58bbd0d54540518a14397557951e79340abc28c0" +checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990" [[package]] name = "console_error_panic_hook" @@ -689,9 +694,9 @@ checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" [[package]] name = "csv" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" dependencies = [ "csv-core", "itoa", @@ -747,6 +752,17 @@ dependencies = [ "winapi", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "doc-comment" version = "0.3.3" @@ -771,9 +787,9 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" [[package]] name = "encoding_rs" -version = "0.8.34" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ "cfg-if", ] @@ -787,7 +803,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -827,9 +843,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "flatbuffers" @@ -843,9 +859,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", @@ -909,9 +925,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -924,9 +940,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -934,15 +950,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -951,38 +967,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -1037,9 +1053,9 @@ dependencies = [ [[package]] name = "geo-types" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff16065e5720f376fbced200a5ae0f47ace85fd70b7e54269790281353b6d61" +checksum = "b6f47c611187777bbca61ea7aba780213f5f3441fd36294ab333e96cfa791b65" dependencies = [ "approx", "num-traits", @@ -1070,7 +1086,7 @@ dependencies = [ "geozero", "half", "indexmap", - "lexical-core", + "lexical-core 0.8.5", "parquet", "phf", "rstar", @@ -1080,7 +1096,7 @@ dependencies = [ "thiserror", "tokio", "wkb", - "wkt 0.11.1", + "wkt 0.11.1 (git+https://github.com/georust/wkt?branch=kyle/geo-traits-writer)", ] [[package]] @@ -1103,7 +1119,7 @@ dependencies = [ "object_store", "parquet", "range-reader", - "reqwest", + "reqwest 0.12.9", "serde", "serde-wasm-bindgen", "thiserror", @@ -1169,7 +1185,7 @@ dependencies = [ "scroll", "serde_json", "thiserror", - "wkt 0.11.0", + "wkt 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1187,9 +1203,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "h2" @@ -1202,7 +1218,26 @@ dependencies = [ "futures-core", "futures-sink", "futures-util", - "http", + "http 0.2.12", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "h2" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "524e8ac6999421f49a846c2d4411f337e53497d8ec55d67753beffa43c5d9205" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http 1.1.0", "indexmap", "slab", "tokio", @@ -1240,6 +1275,12 @@ dependencies = [ "allocator-api2", ] +[[package]] +name = "hashbrown" +version = "0.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" + [[package]] name = "heapless" version = "0.8.0" @@ -1285,6 +1326,17 @@ dependencies = [ "itoa", ] +[[package]] +name = "http" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21b9ddb458710bc376481b842f5da65cdf31522de232c1ca8146abce2a358258" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + [[package]] name = "http-body" version = "0.4.6" @@ -1292,15 +1344,38 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" dependencies = [ "bytes", - "http", + "http 0.2.12", + "pin-project-lite", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http 1.1.0", +] + +[[package]] +name = "http-body-util" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" +dependencies = [ + "bytes", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", "pin-project-lite", ] [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -1316,17 +1391,17 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", "futures-core", "futures-util", - "h2", - "http", - "http-body", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", "httparse", "httpdate", "itoa", @@ -1338,17 +1413,76 @@ dependencies = [ "want", ] +[[package]] +name = "hyper" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08afdbb5c31130e3034af566421053ab03787c640246a446327f550d11bcb333" +dependencies = [ + "futures-util", + "http 1.1.0", + "hyper 1.5.0", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + [[package]] name = "hyper-tls" -version = "0.5.0" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" dependencies = [ "bytes", - "hyper", + "http-body-util", + "hyper 1.5.0", + "hyper-util", "native-tls", "tokio", "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "http 1.1.0", + "http-body 1.0.1", + "hyper 1.5.0", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", ] [[package]] @@ -1374,24 +1508,153 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] name = "indexmap" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68b900aa2f7301e21c36462b170ee99994de34dff39a4a6a528e80e7376d07e5" +checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown", + "hashbrown 0.15.1", ] [[package]] @@ -1402,9 +1665,9 @@ checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" [[package]] name = "ipnet" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is-terminal" @@ -1458,9 +1721,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -1477,11 +1740,24 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" dependencies = [ - "lexical-parse-float", - "lexical-parse-integer", - "lexical-util", - "lexical-write-float", - "lexical-write-integer", + "lexical-parse-float 0.8.5", + "lexical-parse-integer 0.8.6", + "lexical-util 0.8.5", + "lexical-write-float 0.8.5", + "lexical-write-integer 0.8.5", +] + +[[package]] +name = "lexical-core" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0431c65b318a590c1de6b8fd6e72798c92291d27762d94c9e6c37ed7a73d8458" +dependencies = [ + "lexical-parse-float 1.0.2", + "lexical-parse-integer 1.0.2", + "lexical-util 1.0.3", + "lexical-write-float 1.0.2", + "lexical-write-integer 1.0.2", ] [[package]] @@ -1490,8 +1766,19 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" dependencies = [ - "lexical-parse-integer", - "lexical-util", + "lexical-parse-integer 0.8.6", + "lexical-util 0.8.5", + "static_assertions", +] + +[[package]] +name = "lexical-parse-float" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb17a4bdb9b418051aa59d41d65b1c9be5affab314a872e5ad7f06231fb3b4e0" +dependencies = [ + "lexical-parse-integer 1.0.2", + "lexical-util 1.0.3", "static_assertions", ] @@ -1501,7 +1788,17 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" dependencies = [ - "lexical-util", + "lexical-util 0.8.5", + "static_assertions", +] + +[[package]] +name = "lexical-parse-integer" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5df98f4a4ab53bf8b175b363a34c7af608fe31f93cc1fb1bf07130622ca4ef61" +dependencies = [ + "lexical-util 1.0.3", "static_assertions", ] @@ -1514,14 +1811,34 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "lexical-util" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85314db53332e5c192b6bca611fb10c114a80d1b831ddac0af1e9be1b9232ca0" +dependencies = [ + "static_assertions", +] + [[package]] name = "lexical-write-float" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" dependencies = [ - "lexical-util", - "lexical-write-integer", + "lexical-util 0.8.5", + "lexical-write-integer 0.8.5", + "static_assertions", +] + +[[package]] +name = "lexical-write-float" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e7c3ad4e37db81c1cbe7cf34610340adc09c322871972f74877a712abc6c809" +dependencies = [ + "lexical-util 1.0.3", + "lexical-write-integer 1.0.2", "static_assertions", ] @@ -1531,21 +1848,31 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" dependencies = [ - "lexical-util", + "lexical-util 0.8.5", + "static_assertions", +] + +[[package]] +name = "lexical-write-integer" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb89e9f6958b83258afa3deed90b5de9ef68eef090ad5086c791cd2345610162" +dependencies = [ + "lexical-util 1.0.3", "static_assertions", ] [[package]] name = "libc" -version = "0.2.158" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libm" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libredox" @@ -1563,6 +1890,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" version = "0.4.12" @@ -1602,9 +1935,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "minicov" -version = "0.3.5" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c71e683cd655513b99affab7d317deb690528255a0d5f717f1024093c12b169" +checksum = "f27fe9f1cc3c22e1687f9446c2083c4c5fc7f0bcf1c7a86bdbded14985895b4b" dependencies = [ "cc", "walkdir", @@ -1746,14 +2079,14 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] @@ -1770,7 +2103,7 @@ dependencies = [ "futures", "js-sys", "object_store", - "reqwest", + "reqwest 0.11.27", "serde", "serde-wasm-bindgen", "snafu 0.7.5", @@ -1784,9 +2117,9 @@ dependencies = [ [[package]] name = "object_store" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a0c4b3a0e31f8b66f71ad8064521efa773910196e2cde791436f13409f3b45" +checksum = "6eb4c22c6154a1e759d7099f9ffad7cc5ef8245f9efbab4a41b92623079c82f3" dependencies = [ "async-trait", "bytes", @@ -1796,7 +2129,7 @@ dependencies = [ "itertools 0.13.0", "parking_lot", "percent-encoding", - "snafu 0.8.4", + "snafu 0.8.5", "tokio", "tracing", "url", @@ -1805,15 +2138,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.19.0" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "openssl" -version = "0.10.66" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -1832,7 +2165,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -1843,9 +2176,9 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.103" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -1887,9 +2220,9 @@ dependencies = [ [[package]] name = "parquet" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0fbf928021131daaa57d334ca8e3904fe9ae22f73c56244fc7db9b04eedc3d8" +checksum = "dea02606ba6f5e856561d8d507dba8bac060aefca2a6c0f1aa1d361fed91ff3e" dependencies = [ "ahash", "arrow-array", @@ -1906,7 +2239,7 @@ dependencies = [ "flate2", "futures", "half", - "hashbrown", + "hashbrown 0.14.5", "lz4_flex", "num", "num-bigint", @@ -1982,7 +2315,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -1996,29 +2329,29 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "be57f64e946e500c8ee36ef6331845d40a93055567ec57e8fae13efd33759b95" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -2028,9 +2361,9 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "powerfmt" @@ -2049,9 +2382,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] @@ -2091,9 +2424,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.5.4" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0884ad60e090bf1345b93da0a5de8923c93884cd03f40dfcfddd3b4bee661853" +checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f" dependencies = [ "bitflags 2.6.0", ] @@ -2111,9 +2444,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.10.6" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -2123,9 +2456,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.7" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -2134,9 +2467,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" @@ -2149,11 +2482,52 @@ dependencies = [ "encoding_rs", "futures-core", "futures-util", - "h2", - "http", - "http-body", - "hyper", + "h2 0.3.26", + "http 0.2.12", + "http-body 0.4.6", + "hyper 0.14.31", + "ipnet", + "js-sys", + "log", + "mime", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper 0.1.2", + "system-configuration 0.5.1", + "tokio", + "tokio-util", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "wasm-streams", + "web-sys", + "winreg", +] + +[[package]] +name = "reqwest" +version = "0.12.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" +dependencies = [ + "base64 0.22.1", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2 0.4.6", + "http 1.1.0", + "http-body 1.0.1", + "http-body-util", + "hyper 1.5.0", + "hyper-rustls", "hyper-tls", + "hyper-util", "ipnet", "js-sys", "log", @@ -2166,18 +2540,31 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "sync_wrapper", - "system-configuration", + "sync_wrapper 1.0.1", + "system-configuration 0.6.1", "tokio", "tokio-native-tls", - "tokio-util", "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", - "wasm-streams", "web-sys", - "winreg", + "windows-registry", +] + +[[package]] +name = "ring" +version = "0.17.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d" +dependencies = [ + "cc", + "cfg-if", + "getrandom", + "libc", + "spin", + "untrusted", + "windows-sys 0.52.0", ] [[package]] @@ -2188,9 +2575,9 @@ checksum = "cbf4a6aa5f6d6888f39e980649f3ad6b666acdce1d78e95b8a2cb076e687ae30" [[package]] name = "rstar" -version = "0.12.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "133315eb94c7b1e8d0cb097e5a710d850263372fd028fff18969de708afc7008" +checksum = "421400d13ccfd26dfa5858199c30a5d76f9c54e0dba7575273025b43c5175dbb" dependencies = [ "heapless", "num-traits", @@ -2214,9 +2601,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ "bitflags 2.6.0", "errno", @@ -2225,13 +2612,43 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "rustls" +version = "0.23.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + [[package]] name = "rustls-pemfile" -version = "1.0.4" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c" +checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50" dependencies = [ - "base64 0.21.7", + "rustls-pki-types", +] + +[[package]] +name = "rustls-pki-types" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" + +[[package]] +name = "rustls-webpki" +version = "0.102.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", ] [[package]] @@ -2251,9 +2668,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ "windows-sys 0.59.0", ] @@ -2291,9 +2708,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" dependencies = [ "core-foundation-sys", "libc", @@ -2313,9 +2730,9 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] @@ -2333,20 +2750,20 @@ dependencies = [ [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -2415,11 +2832,11 @@ dependencies = [ [[package]] name = "snafu" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b835cb902660db3415a672d862905e791e54d306c6e8189168c7f3d9ae1c79d" +checksum = "223891c85e2a29c3fe8fb900c1fae5e69c2e42415e3177752e8718475efa5019" dependencies = [ - "snafu-derive 0.8.4", + "snafu-derive 0.8.5", ] [[package]] @@ -2436,14 +2853,14 @@ dependencies = [ [[package]] name = "snafu-derive" -version = "0.8.4" +version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d1e02fca405f6280643174a50c942219f0bbf4dbf7d480f1dd864d6f211ae5" +checksum = "03c3c6b7927ffe7ecaa769ee0e3994da3b8cafc8f444578982c83ecb161af917" dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2468,12 +2885,18 @@ version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "93f5ef1f863aca7d1d7dda7ccfc36a0a4279bd6d3c375176e5e0712e25cb4889" dependencies = [ - "hashbrown", + "hashbrown 0.14.5", "num-traits", "robust", "smallvec", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "stable_deref_trait" version = "1.2.0" @@ -2492,6 +2915,12 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + [[package]] name = "syn" version = "1.0.109" @@ -2505,9 +2934,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.77" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -2520,6 +2949,26 @@ version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" +[[package]] +name = "sync_wrapper" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "system-configuration" version = "0.5.1" @@ -2528,7 +2977,18 @@ checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7" dependencies = [ "bitflags 1.3.2", "core-foundation", - "system-configuration-sys", + "system-configuration-sys 0.5.0", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags 2.6.0", + "core-foundation", + "system-configuration-sys 0.6.0", ] [[package]] @@ -2541,11 +3001,21 @@ dependencies = [ "libc", ] +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + [[package]] name = "tempfile" -version = "3.12.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", @@ -2565,22 +3035,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.63" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2622,6 +3092,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -2639,9 +3119,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", @@ -2661,7 +3141,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2674,6 +3154,17 @@ dependencies = [ "tokio", ] +[[package]] +name = "tokio-rustls" +version = "0.26.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" +dependencies = [ + "rustls", + "rustls-pki-types", + "tokio", +] + [[package]] name = "tokio-util" version = "0.7.12" @@ -2695,9 +3186,9 @@ checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" [[package]] name = "toml_edit" -version = "0.22.21" +version = "0.22.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b072cee73c449a636ffd6f32bd8de3a9f7119139aff882f44943ce2986dc5cf" +checksum = "4ae48d6208a266e853d946088ed816055e556cc6028c5e8e2b84d9fa5dd7c7f5" dependencies = [ "indexmap", "toml_datetime", @@ -2729,7 +3220,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] @@ -2757,12 +3248,6 @@ dependencies = [ "static_assertions", ] -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-ident" version = "1.0.13" @@ -2770,25 +3255,34 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe" [[package]] -name = "unicode-normalization" -version = "0.1.24" +name = "untrusted" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" -dependencies = [ - "tinyvec", -] +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", "idna", "percent-encoding", ] +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "utf8parse" version = "0.2.2" @@ -2797,9 +3291,9 @@ checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" [[package]] name = "uuid" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" +checksum = "f8c5f0a0af699448548ad1a2fbf920fb4bee257eae39953ba95cb84891a0446a" dependencies = [ "getrandom", "wasm-bindgen", @@ -2844,9 +3338,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -2857,24 +3351,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -2884,9 +3378,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -2894,28 +3388,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-bindgen-test" -version = "0.3.43" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68497a05fb21143a08a7d24fc81763384a3072ee43c44e86aad1744d6adef9d9" +checksum = "d381749acb0943d357dcbd8f0b100640679883fcdeeef04def49daf8d33a5426" dependencies = [ "console_error_panic_hook", "js-sys", @@ -2928,20 +3422,20 @@ dependencies = [ [[package]] name = "wasm-bindgen-test-macro" -version = "0.3.43" +version = "0.3.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b8220be1fa9e4c889b30fd207d4906657e7e90b12e0e6b0c8b8d8709f5de021" +checksum = "c97b2ef2c8d627381e51c071c2ab328eac606d3f69dd82bcbca20a9e389d95f0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", ] [[package]] name = "wasm-streams" -version = "0.4.0" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b65dc4c90b63b118468cf747d8bf3566c1913ef60be765b5730ead9e0a3ba129" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" dependencies = [ "futures-util", "js-sys", @@ -2952,9 +3446,9 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" dependencies = [ "js-sys", "wasm-bindgen", @@ -3000,6 +3494,36 @@ dependencies = [ "windows-targets 0.52.6", ] +[[package]] +name = "windows-registry" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0" +dependencies = [ + "windows-result", + "windows-strings", + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-result" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e" +dependencies = [ + "windows-targets 0.52.6", +] + +[[package]] +name = "windows-strings" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10" +dependencies = [ + "windows-result", + "windows-targets 0.52.6", +] + [[package]] name = "windows-sys" version = "0.48.0" @@ -3150,9 +3674,9 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" [[package]] name = "winnow" -version = "0.6.18" +version = "0.6.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68a9bda4691f099d435ad181000724da8e5899daa10713c2d432552b9ccd3a6f" +checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b" dependencies = [ "memchr", ] @@ -3180,9 +3704,9 @@ dependencies = [ [[package]] name = "wkt" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "296937617013271141d1145d9c05861f5ed3b1bc4297e81c692aa3cff9270a9c" +checksum = "54f7f1ff4ea4c18936d6cd26a6fd24f0003af37e951a8e0e8b9e9a2d0bd0a46d" dependencies = [ "geo-types", "log", @@ -3193,7 +3717,7 @@ dependencies = [ [[package]] name = "wkt" version = "0.11.1" -source = "git+https://github.com/georust/wkt?branch=kyle/geo-traits-writer#63b13243568470d6da5a44fcc9fe7b903aa53eea" +source = "git+https://github.com/georust/wkt?branch=kyle/geo-traits-writer#f3434f5283d070f1accd64cd1bd09303f0f0547c" dependencies = [ "geo-traits", "geo-types", @@ -3202,6 +3726,42 @@ dependencies = [ "thiserror", ] +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + [[package]] name = "zerocopy" version = "0.7.35" @@ -3219,7 +3779,56 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.77", + "syn 2.0.87", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] diff --git a/js/src/data/mod.rs b/js/src/data/mod.rs index a7e04ce5..f750f1f1 100644 --- a/js/src/data/mod.rs +++ b/js/src/data/mod.rs @@ -3,6 +3,7 @@ pub mod coord; use arrow_array::BinaryArray; use arrow_buffer::Buffer; pub use coord::{CoordBuffer, InterleavedCoordBuffer, SeparatedCoordBuffer}; +use geoarrow::datatypes::Dimension; use crate::error::WasmResult; use crate::utils::vec_to_offsets; @@ -45,42 +46,42 @@ macro_rules! impl_data { impl_data! { /// An immutable array of Point geometries in WebAssembly memory using GeoArrow's in-memory /// representation. - pub struct PointData(pub(crate) geoarrow::array::PointArray<2>); + pub struct PointData(pub(crate) geoarrow::array::PointArray); } impl_data! { /// An immutable array of LineString geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct LineStringData(pub(crate) geoarrow::array::LineStringArray<2>); + pub struct LineStringData(pub(crate) geoarrow::array::LineStringArray); } impl_data! { /// An immutable array of Polygon geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct PolygonData(pub(crate) geoarrow::array::PolygonArray<2>); + pub struct PolygonData(pub(crate) geoarrow::array::PolygonArray); } impl_data! { /// An immutable array of MultiPoint geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct MultiPointData(pub(crate) geoarrow::array::MultiPointArray<2>); + pub struct MultiPointData(pub(crate) geoarrow::array::MultiPointArray); } impl_data! { /// An immutable array of MultiLineString geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct MultiLineStringData(pub(crate) geoarrow::array::MultiLineStringArray<2>); + pub struct MultiLineStringData(pub(crate) geoarrow::array::MultiLineStringArray); } impl_data! { /// An immutable array of MultiPolygon geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct MultiPolygonData(pub(crate) geoarrow::array::MultiPolygonArray<2>); + pub struct MultiPolygonData(pub(crate) geoarrow::array::MultiPolygonArray); } impl_data! { /// An immutable array of Geometry geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct MixedGeometryData(pub(crate) geoarrow::array::MixedGeometryArray<2>); + pub struct MixedGeometryData(pub(crate) geoarrow::array::MixedGeometryArray); } impl_data! { /// An immutable array of GeometryCollection geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct GeometryCollectionData(pub(crate) geoarrow::array::GeometryCollectionArray<2>); + pub struct GeometryCollectionData(pub(crate) geoarrow::array::GeometryCollectionArray); } impl_data! { /// An immutable array of WKB-encoded geometries in WebAssembly memory using GeoArrow's @@ -90,7 +91,7 @@ impl_data! { impl_data! { /// An immutable array of Rect geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct RectData(pub(crate) geoarrow::array::RectArray<2>); + pub struct RectData(pub(crate) geoarrow::array::RectArray); } #[wasm_bindgen] @@ -205,7 +206,7 @@ impl WKBData { /// and the original wkb array's memory does not need to be freed manually. #[wasm_bindgen(js_name = intoPointArray)] pub fn into_point_array(self) -> WasmResult { - let arr: geoarrow::array::PointArray<2> = self.0.try_into().unwrap(); + let arr: geoarrow::array::PointArray = (self.0, Dimension::XY).try_into().unwrap(); Ok(arr.into()) } @@ -217,7 +218,7 @@ impl WKBData { /// and the original wkb array's memory does not need to be freed manually. #[wasm_bindgen(js_name = intoLineStringArray)] pub fn into_line_string_array(self) -> WasmResult { - let arr: geoarrow::array::LineStringArray<2> = self.0.try_into().unwrap(); + let arr: geoarrow::array::LineStringArray = (self.0, Dimension::XY).try_into().unwrap(); Ok(arr.into()) } @@ -229,7 +230,7 @@ impl WKBData { /// and the original wkb array's memory does not need to be freed manually. #[wasm_bindgen(js_name = intoPolygonArray)] pub fn into_polygon_array(self) -> WasmResult { - let arr: geoarrow::array::PolygonArray<2> = self.0.try_into().unwrap(); + let arr: geoarrow::array::PolygonArray = (self.0, Dimension::XY).try_into().unwrap(); Ok(arr.into()) } @@ -241,7 +242,7 @@ impl WKBData { /// and the original wkb array's memory does not need to be freed manually. #[wasm_bindgen(js_name = intoMultiPointArray)] pub fn into_multi_point_array(self) -> WasmResult { - let arr: geoarrow::array::MultiPointArray<2> = self.0.try_into().unwrap(); + let arr: geoarrow::array::MultiPointArray = (self.0, Dimension::XY).try_into().unwrap(); Ok(arr.into()) } @@ -253,7 +254,8 @@ impl WKBData { /// and the original wkb array's memory does not need to be freed manually. #[wasm_bindgen(js_name = intoMultiLineStringArray)] pub fn into_multi_line_string_array(self) -> WasmResult { - let arr: geoarrow::array::MultiLineStringArray<2> = self.0.try_into().unwrap(); + let arr: geoarrow::array::MultiLineStringArray = + (self.0, Dimension::XY).try_into().unwrap(); Ok(arr.into()) } @@ -265,7 +267,7 @@ impl WKBData { /// and the original wkb array's memory does not need to be freed manually. #[wasm_bindgen(js_name = intoMultiPolygonArray)] pub fn into_multi_polygon_array(self) -> WasmResult { - let arr: geoarrow::array::MultiPolygonArray<2> = self.0.try_into().unwrap(); + let arr: geoarrow::array::MultiPolygonArray = (self.0, Dimension::XY).try_into().unwrap(); Ok(arr.into()) } } diff --git a/js/src/io/parquet/async_file_reader/mod.rs b/js/src/io/parquet/async_file_reader/mod.rs index 291c3974..50e439be 100644 --- a/js/src/io/parquet/async_file_reader/mod.rs +++ b/js/src/io/parquet/async_file_reader/mod.rs @@ -21,8 +21,7 @@ use futures::{stream, FutureExt}; use parquet::arrow::arrow_reader::ArrowReaderMetadata; use parquet::arrow::async_reader::{AsyncFileReader, ParquetRecordBatchStreamBuilder}; -use parquet::file::footer::{decode_footer, decode_metadata}; -use parquet::file::metadata::ParquetMetaData; +use parquet::file::metadata::{ParquetMetaData, ParquetMetaDataReader}; use reqwest::Client; use async_trait::async_trait; @@ -553,7 +552,7 @@ pub async fn fetch_parquet_metadata( let mut footer = [0; 8]; footer.copy_from_slice(&suffix[suffix_len - 8..suffix_len]); - let metadata_byte_length = decode_footer(&footer)?; + let metadata_byte_length = ParquetMetaDataReader::decode_footer(&footer)?; // Did not fetch the entire file metadata in the initial read, need to make a second request let metadata = if metadata_byte_length > suffix_len - 8 { @@ -564,12 +563,12 @@ pub async fn fetch_parquet_metadata( .await .unwrap(); - decode_metadata(&meta_bytes[0..meta_bytes.len() - 8])? + ParquetMetaDataReader::decode_metadata(&meta_bytes[0..meta_bytes.len() - 8])? } else { let metadata_start = suffix_len - metadata_byte_length - 8; let slice = &suffix[metadata_start..suffix_len - 8]; - decode_metadata(slice)? + ParquetMetaDataReader::decode_metadata(slice)? }; Ok(metadata) diff --git a/js/src/scalar/linestring.rs b/js/src/scalar/linestring.rs index a73adac5..c998c32d 100644 --- a/js/src/scalar/linestring.rs +++ b/js/src/scalar/linestring.rs @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedLineString; use wasm_bindgen::prelude::*; #[wasm_bindgen] -pub struct LineString(pub(crate) OwnedLineString<2>); +pub struct LineString(pub(crate) OwnedLineString); -impl<'a> From<&'a LineString> for geoarrow::scalar::LineString<'a, 2> { +impl<'a> From<&'a LineString> for geoarrow::scalar::LineString<'a> { fn from(value: &'a LineString) -> Self { (&value.0).into() } } -impl From for geoarrow::scalar::OwnedLineString<2> { +impl From for geoarrow::scalar::OwnedLineString { fn from(value: LineString) -> Self { value.0 } } -impl<'a> From> for LineString { - fn from(value: geoarrow::scalar::LineString<'a, 2>) -> Self { +impl<'a> From> for LineString { + fn from(value: geoarrow::scalar::LineString<'a>) -> Self { LineString(value.into()) } } diff --git a/js/src/scalar/multilinestring.rs b/js/src/scalar/multilinestring.rs index e5e3ac0c..683aeda3 100644 --- a/js/src/scalar/multilinestring.rs +++ b/js/src/scalar/multilinestring.rs @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedMultiLineString; use wasm_bindgen::prelude::*; #[wasm_bindgen] -pub struct MultiLineString(pub(crate) OwnedMultiLineString<2>); +pub struct MultiLineString(pub(crate) OwnedMultiLineString); -impl<'a> From<&'a MultiLineString> for geoarrow::scalar::MultiLineString<'a, 2> { +impl<'a> From<&'a MultiLineString> for geoarrow::scalar::MultiLineString<'a> { fn from(value: &'a MultiLineString) -> Self { (&value.0).into() } } -impl From for geoarrow::scalar::OwnedMultiLineString<2> { +impl From for geoarrow::scalar::OwnedMultiLineString { fn from(value: MultiLineString) -> Self { value.0 } } -impl<'a> From> for MultiLineString { - fn from(value: geoarrow::scalar::MultiLineString<'a, 2>) -> Self { +impl<'a> From> for MultiLineString { + fn from(value: geoarrow::scalar::MultiLineString<'a>) -> Self { MultiLineString(value.into()) } } diff --git a/js/src/scalar/multipoint.rs b/js/src/scalar/multipoint.rs index 5ea24ee2..2b25b204 100644 --- a/js/src/scalar/multipoint.rs +++ b/js/src/scalar/multipoint.rs @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedMultiPoint; use wasm_bindgen::prelude::*; #[wasm_bindgen] -pub struct MultiPoint(pub(crate) OwnedMultiPoint<2>); +pub struct MultiPoint(pub(crate) OwnedMultiPoint); -impl<'a> From<&'a MultiPoint> for geoarrow::scalar::MultiPoint<'a, 2> { +impl<'a> From<&'a MultiPoint> for geoarrow::scalar::MultiPoint<'a> { fn from(value: &'a MultiPoint) -> Self { (&value.0).into() } } -impl From for geoarrow::scalar::OwnedMultiPoint<2> { +impl From for geoarrow::scalar::OwnedMultiPoint { fn from(value: MultiPoint) -> Self { value.0 } } -impl<'a> From> for MultiPoint { - fn from(value: geoarrow::scalar::MultiPoint<'a, 2>) -> Self { +impl<'a> From> for MultiPoint { + fn from(value: geoarrow::scalar::MultiPoint<'a>) -> Self { MultiPoint(value.into()) } } diff --git a/js/src/scalar/multipolygon.rs b/js/src/scalar/multipolygon.rs index 7c435b30..be7c4690 100644 --- a/js/src/scalar/multipolygon.rs +++ b/js/src/scalar/multipolygon.rs @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedMultiPolygon; use wasm_bindgen::prelude::*; #[wasm_bindgen] -pub struct MultiPolygon(pub(crate) OwnedMultiPolygon<2>); +pub struct MultiPolygon(pub(crate) OwnedMultiPolygon); -impl<'a> From<&'a MultiPolygon> for geoarrow::scalar::MultiPolygon<'a, 2> { +impl<'a> From<&'a MultiPolygon> for geoarrow::scalar::MultiPolygon<'a> { fn from(value: &'a MultiPolygon) -> Self { (&value.0).into() } } -impl From for geoarrow::scalar::OwnedMultiPolygon<2> { +impl From for geoarrow::scalar::OwnedMultiPolygon { fn from(value: MultiPolygon) -> Self { value.0 } } -impl<'a> From> for MultiPolygon { - fn from(value: geoarrow::scalar::MultiPolygon<'a, 2>) -> Self { +impl<'a> From> for MultiPolygon { + fn from(value: geoarrow::scalar::MultiPolygon<'a>) -> Self { MultiPolygon(value.into()) } } diff --git a/js/src/scalar/point.rs b/js/src/scalar/point.rs index ed125716..f7bde8b5 100644 --- a/js/src/scalar/point.rs +++ b/js/src/scalar/point.rs @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedPoint; use wasm_bindgen::prelude::*; #[wasm_bindgen] -pub struct Point(pub(crate) OwnedPoint<2>); +pub struct Point(pub(crate) OwnedPoint); -impl<'a> From<&'a Point> for geoarrow::scalar::Point<'a, 2> { +impl<'a> From<&'a Point> for geoarrow::scalar::Point<'a> { fn from(value: &'a Point) -> Self { (&value.0).into() } } -impl From for geoarrow::scalar::OwnedPoint<2> { +impl From for geoarrow::scalar::OwnedPoint { fn from(value: Point) -> Self { value.0 } } -impl<'a> From> for Point { - fn from(value: geoarrow::scalar::Point<'a, 2>) -> Self { +impl<'a> From> for Point { + fn from(value: geoarrow::scalar::Point<'a>) -> Self { Point(value.into()) } } diff --git a/js/src/scalar/polygon.rs b/js/src/scalar/polygon.rs index bf0ac5cd..ec51be1a 100644 --- a/js/src/scalar/polygon.rs +++ b/js/src/scalar/polygon.rs @@ -2,22 +2,22 @@ use geoarrow::scalar::OwnedPolygon; use wasm_bindgen::prelude::*; #[wasm_bindgen] -pub struct Polygon(pub(crate) OwnedPolygon<2>); +pub struct Polygon(pub(crate) OwnedPolygon); -impl<'a> From<&'a Polygon> for geoarrow::scalar::Polygon<'a, 2> { +impl<'a> From<&'a Polygon> for geoarrow::scalar::Polygon<'a> { fn from(value: &'a Polygon) -> Self { (&value.0).into() } } -impl From for geoarrow::scalar::OwnedPolygon<2> { +impl From for geoarrow::scalar::OwnedPolygon { fn from(value: Polygon) -> Self { value.0 } } -impl<'a> From> for Polygon { - fn from(value: geoarrow::scalar::Polygon<'a, 2>) -> Self { +impl<'a> From> for Polygon { + fn from(value: geoarrow::scalar::Polygon<'a>) -> Self { Polygon(value.into()) } } diff --git a/js/src/vector/mod.rs b/js/src/vector/mod.rs index 06e64dfd..c61e81c6 100644 --- a/js/src/vector/mod.rs +++ b/js/src/vector/mod.rs @@ -26,42 +26,42 @@ macro_rules! impl_vector { impl_vector! { /// An immutable chunked array of Point geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct PointVector(pub(crate) geoarrow::chunked_array::ChunkedPointArray<2>); + pub struct PointVector(pub(crate) geoarrow::chunked_array::ChunkedPointArray); } impl_vector! { /// An immutable chunked array of LineString geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct LineStringVector(pub(crate) geoarrow::chunked_array::ChunkedLineStringArray<2>); + pub struct LineStringVector(pub(crate) geoarrow::chunked_array::ChunkedLineStringArray); } impl_vector! { /// An immutable chunked array of Polygon geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct PolygonVector(pub(crate) geoarrow::chunked_array::ChunkedPolygonArray<2>); + pub struct PolygonVector(pub(crate) geoarrow::chunked_array::ChunkedPolygonArray); } impl_vector! { /// An immutable chunked array of MultiPoint geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct MultiPointVector(pub(crate) geoarrow::chunked_array::ChunkedMultiPointArray<2>); + pub struct MultiPointVector(pub(crate) geoarrow::chunked_array::ChunkedMultiPointArray); } impl_vector! { /// An immutable chunked array of MultiLineString geometries in WebAssembly memory using /// GeoArrow's in-memory representation. - pub struct MultiLineStringVector(pub(crate) geoarrow::chunked_array::ChunkedMultiLineStringArray<2>); + pub struct MultiLineStringVector(pub(crate) geoarrow::chunked_array::ChunkedMultiLineStringArray); } impl_vector! { /// An immutable chunked array of MultiPolygon geometries in WebAssembly memory using /// GeoArrow's in-memory representation. - pub struct MultiPolygonVector(pub(crate) geoarrow::chunked_array::ChunkedMultiPolygonArray<2>); + pub struct MultiPolygonVector(pub(crate) geoarrow::chunked_array::ChunkedMultiPolygonArray); } impl_vector! { /// An immutable chunked array of Geometry geometries in WebAssembly memory using /// GeoArrow's in-memory representation. - pub struct MixedGeometryVector(pub(crate) geoarrow::chunked_array::ChunkedMixedGeometryArray<2>); + pub struct MixedGeometryVector(pub(crate) geoarrow::chunked_array::ChunkedMixedGeometryArray); } impl_vector! { /// An immutable chunked array of GeometryCollection geometries in WebAssembly memory using /// GeoArrow's in-memory representation. - pub struct GeometryCollectionVector(pub(crate) geoarrow::chunked_array::ChunkedGeometryCollectionArray<2>); + pub struct GeometryCollectionVector(pub(crate) geoarrow::chunked_array::ChunkedGeometryCollectionArray); } impl_vector! { /// An immutable chunked array of WKB-encoded geometries in WebAssembly memory using GeoArrow's @@ -71,5 +71,5 @@ impl_vector! { impl_vector! { /// An immutable chunked array of Rect geometries in WebAssembly memory using GeoArrow's /// in-memory representation. - pub struct RectVector(pub(crate) geoarrow::chunked_array::ChunkedRectArray<2>); + pub struct RectVector(pub(crate) geoarrow::chunked_array::ChunkedRectArray); } diff --git a/python/Cargo.lock b/python/Cargo.lock index 5e81d65c..8b761993 100644 --- a/python/Cargo.lock +++ b/python/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "addr2line" -version = "0.24.1" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f5fb1d8e4442bd405fdfd1dacb42792696b0cf9cb15882e5d097b742a676d375" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] @@ -57,9 +57,9 @@ dependencies = [ [[package]] name = "allocator-api2" -version = "0.2.18" +version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" +checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9" [[package]] name = "android-tzdata" @@ -78,9 +78,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.89" +version = "1.0.93" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86fdf8605db99b54d3cd748a44c6d04df638eb5dafb219b135d0149bd0db01f6" +checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775" [[package]] name = "approx" @@ -93,9 +93,9 @@ dependencies = [ [[package]] name = "arrow" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45aef0d9cf9a039bf6cd1acc451b137aca819977b0928dece52bd92811b640ba" +checksum = "4caf25cdc4a985f91df42ed9e9308e1adbcd341a31a72605c697033fcef163e3" dependencies = [ "arrow-arith", "arrow-array", @@ -114,9 +114,9 @@ dependencies = [ [[package]] name = "arrow-arith" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03675e42d1560790f3524800e41403b40d0da1c793fe9528929fde06d8c7649a" +checksum = "91f2dfd1a7ec0aca967dfaa616096aec49779adc8eccec005e2f5e4111b1192a" dependencies = [ "arrow-array", "arrow-buffer", @@ -129,9 +129,9 @@ dependencies = [ [[package]] name = "arrow-array" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd2bf348cf9f02a5975c5962c7fa6dee107a2009a7b41ac5fb1a027e12dc033f" +checksum = "d39387ca628be747394890a6e47f138ceac1aa912eab64f02519fed24b637af8" dependencies = [ "ahash", "arrow-buffer", @@ -146,9 +146,9 @@ dependencies = [ [[package]] name = "arrow-buffer" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3092e37715f168976012ce52273c3989b5793b0db5f06cbaa246be25e5f0924d" +checksum = "9e51e05228852ffe3eb391ce7178a0f97d2cf80cc6ef91d3c4a6b3cb688049ec" dependencies = [ "bytes", "half", @@ -157,9 +157,9 @@ dependencies = [ [[package]] name = "arrow-cast" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ce1018bb710d502f9db06af026ed3561552e493e989a79d0d0f5d9cf267a785" +checksum = "d09aea56ec9fa267f3f3f6cdab67d8a9974cbba90b3aa38c8fe9d0bb071bd8c1" dependencies = [ "arrow-array", "arrow-buffer", @@ -170,16 +170,16 @@ dependencies = [ "base64 0.22.1", "chrono", "half", - "lexical-core", + "lexical-core 1.0.2", "num", "ryu", ] [[package]] name = "arrow-csv" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd178575f45624d045e4ebee714e246a05d9652e41363ee3f57ec18cca97f740" +checksum = "c07b5232be87d115fde73e32f2ca7f1b353bff1b44ac422d3c6fc6ae38f11f0d" dependencies = [ "arrow-array", "arrow-buffer", @@ -190,15 +190,15 @@ dependencies = [ "csv", "csv-core", "lazy_static", - "lexical-core", + "lexical-core 1.0.2", "regex", ] [[package]] name = "arrow-data" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e4ac0c4ee79150afe067dc4857154b3ee9c1cd52b5f40d59a77306d0ed18d65" +checksum = "b98ae0af50890b494cebd7d6b04b35e896205c1d1df7b29a6272c5d0d0249ef5" dependencies = [ "arrow-buffer", "arrow-schema", @@ -208,9 +208,9 @@ dependencies = [ [[package]] name = "arrow-ipc" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb307482348a1267f91b0912e962cd53440e5de0f7fb24c5f7b10da70b38c94a" +checksum = "0ed91bdeaff5a1c00d28d8f73466bcb64d32bbd7093b5a30156b4b9f4dba3eee" dependencies = [ "arrow-array", "arrow-buffer", @@ -224,9 +224,9 @@ dependencies = [ [[package]] name = "arrow-json" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d24805ba326758effdd6f2cbdd482fcfab749544f21b134701add25b33f474e6" +checksum = "0471f51260a5309307e5d409c9dc70aede1cd9cf1d4ff0f0a1e8e1a2dd0e0d3c" dependencies = [ "arrow-array", "arrow-buffer", @@ -236,7 +236,7 @@ dependencies = [ "chrono", "half", "indexmap", - "lexical-core", + "lexical-core 1.0.2", "num", "serde", "serde_json", @@ -244,9 +244,9 @@ dependencies = [ [[package]] name = "arrow-ord" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "644046c479d80ae8ed02a7f1e1399072ea344ca6a7b0e293ab2d5d9ed924aa3b" +checksum = "2883d7035e0b600fb4c30ce1e50e66e53d8656aa729f2bfa4b51d359cf3ded52" dependencies = [ "arrow-array", "arrow-buffer", @@ -259,9 +259,9 @@ dependencies = [ [[package]] name = "arrow-row" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a29791f8eb13b340ce35525b723f5f0df17ecb955599e11f65c2a94ab34e2efb" +checksum = "552907e8e587a6fde4f8843fd7a27a576a260f65dab6c065741ea79f633fc5be" dependencies = [ "ahash", "arrow-array", @@ -273,18 +273,18 @@ dependencies = [ [[package]] name = "arrow-schema" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c85320a3a2facf2b2822b57aa9d6d9d55edb8aee0b6b5d3b8df158e503d10858" +checksum = "539ada65246b949bd99ffa0881a9a15a4a529448af1a07a9838dd78617dafab1" dependencies = [ "bitflags 2.6.0", ] [[package]] name = "arrow-select" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cc7e6b582e23855fd1625ce46e51647aa440c20ea2e71b1d748e0839dd73cba" +checksum = "6259e566b752da6dceab91766ed8b2e67bf6270eb9ad8a6e07a33c1bede2b125" dependencies = [ "ahash", "arrow-array", @@ -296,9 +296,9 @@ dependencies = [ [[package]] name = "arrow-string" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0775b6567c66e56ded19b87a954b6b1beffbdd784ef95a3a2b03f59570c1d230" +checksum = "f3179ccbd18ebf04277a095ba7321b93fd1f774f18816bd5f6b3ce2f594edb6c" dependencies = [ "arrow-array", "arrow-buffer", @@ -330,7 +330,7 @@ checksum = "c7c24de15d275a1ecfd47a380fb4d5ec9bfe0933f309ed5e705b775596a3574d" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -341,7 +341,7 @@ checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -424,9 +424,9 @@ dependencies = [ [[package]] name = "brotli" -version = "6.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" +checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -451,9 +451,9 @@ checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" [[package]] name = "bytemuck" -version = "1.18.0" +version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94bbb0ad554ad961ddc5da507a12a29b14e4ae5bda06b19f575a3e6079d2e2ae" +checksum = "8334215b81e418a0a7bdb8ef0849474f40bb10c8b71f1c4ed315cff49f32494d" [[package]] name = "byteorder" @@ -463,15 +463,15 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.2" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" +checksum = "9ac0150caa2ae65ca5bd83f25c7de183dea78d4d366469f148435e2acfbad0da" [[package]] name = "cc" -version = "1.1.24" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "812acba72f0a070b003d3697490d2b55b837230ae7c6c6497f05cc2ddbb8d938" +checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47" dependencies = [ "jobserver", "libc", @@ -484,6 +484,12 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "cfg_aliases" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724" + [[package]] name = "chrono" version = "0.4.38" @@ -501,9 +507,9 @@ dependencies = [ [[package]] name = "chrono-tz" -version = "0.9.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93698b29de5e97ad0ae26447b344c482a7284c737d9ddc5f9e52b74a336671bb" +checksum = "cd6dd8046d00723a59a2f8c5f295c515b9bb9a331ee4f8f3d4dd49e428acd3b6" dependencies = [ "chrono", "chrono-tz-build", @@ -512,12 +518,11 @@ dependencies = [ [[package]] name = "chrono-tz-build" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c088aee841df9c3041febbb73934cfc39708749bf96dc827e3359cd39ef11b1" +checksum = "e94fea34d77a245229e7746bd2beb786cd2a896f306ff491fb8cecb3074b10a7" dependencies = [ "parse-zoneinfo", - "phf", "phf_codegen", ] @@ -565,9 +570,9 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" [[package]] name = "cpufeatures" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "608697df725056feaccfa42cffdaeeec3fccc4ffc38358ecd19b243e716a78e0" +checksum = "0ca741a962e1b0bff6d724a1a0958b686406e853bb14061f218562e1896f95e6" dependencies = [ "libc", ] @@ -648,9 +653,9 @@ dependencies = [ [[package]] name = "csv" -version = "1.3.0" +version = "1.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac574ff4d437a7b5ad237ef331c17ccca63c46479e5b5453eb8e10bb99a759fe" +checksum = "acdc4883a9c96732e4733212c01447ebd805833b7275a73ca3ee080fd77afdaf" dependencies = [ "csv-core", "itoa", @@ -709,6 +714,17 @@ dependencies = [ "subtle", ] +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "dotenvy" version = "0.15.7" @@ -736,9 +752,9 @@ dependencies = [ [[package]] name = "encoding_rs" -version = "0.8.34" +version = "0.8.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" dependencies = [ "cfg-if", ] @@ -752,7 +768,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -796,9 +812,9 @@ checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" [[package]] name = "fastrand" -version = "2.1.1" +version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6" +checksum = "486f806e73c5707928240ddc295403b1b93c96a02038563881c4a2fd84b81ac4" [[package]] name = "flatbuffers" @@ -812,9 +828,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.34" +version = "1.0.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" +checksum = "c936bfdafb507ebbf50b8074c54fa31c5be9a1e7e5f467dd659697041407d07c" dependencies = [ "crc32fast", "miniz_oxide", @@ -845,9 +861,9 @@ checksum = "8bf7cc16383c4b8d58b9905a8509f02926ce3058053c056376248d958c9df1e8" [[package]] name = "flume" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55ac459de2512911e4b674ce33cf20befaba382d05b62b008afc1c8b57cbf181" +checksum = "da0e4dd2a88388a1f4ccc7c9ce104604dab68d9f408dc34cd45823d5a9069095" dependencies = [ "futures-core", "futures-sink", @@ -886,9 +902,9 @@ dependencies = [ [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -901,9 +917,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -911,15 +927,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -939,38 +955,38 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -1020,7 +1036,7 @@ dependencies = [ "bytemuck", "float_next_after", "num-traits", - "thiserror", + "thiserror 1.0.69", "tinyvec", ] @@ -1035,9 +1051,9 @@ dependencies = [ [[package]] name = "geo-types" -version = "0.7.13" +version = "0.7.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ff16065e5720f376fbced200a5ae0f47ace85fd70b7e54269790281353b6d61" +checksum = "b6f47c611187777bbca61ea7aba780213f5f3441fd36294ab333e96cfa791b65" dependencies = [ "approx", "num-traits", @@ -1071,7 +1087,7 @@ dependencies = [ "half", "http-range-client", "indexmap", - "lexical-core", + "lexical-core 0.8.5", "object_store", "parquet", "phf", @@ -1082,10 +1098,10 @@ dependencies = [ "serde_json", "shapefile", "sqlx", - "thiserror", + "thiserror 1.0.69", "tokio", "wkb", - "wkt 0.11.1", + "wkt 0.11.1 (git+https://github.com/georust/wkt?branch=kyle/geo-traits-writer)", ] [[package]] @@ -1103,7 +1119,7 @@ dependencies = [ "pyo3-arrow", "pyo3-geoarrow", "serde_json", - "thiserror", + "thiserror 1.0.69", "url", ] @@ -1122,7 +1138,7 @@ dependencies = [ "pyo3-arrow", "pyo3-geoarrow", "serde_json", - "thiserror", + "thiserror 1.0.69", "url", ] @@ -1148,7 +1164,7 @@ dependencies = [ "reqwest", "serde_json", "sqlx", - "thiserror", + "thiserror 1.0.69", "tokio", "url", ] @@ -1171,7 +1187,7 @@ dependencies = [ "log", "serde", "serde_json", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -1186,8 +1202,8 @@ dependencies = [ "log", "scroll", "serde_json", - "thiserror", - "wkt 0.11.0", + "thiserror 1.0.69", + "wkt 0.11.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -1197,15 +1213,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", + "js-sys", "libc", "wasi", + "wasm-bindgen", ] [[package]] name = "gimli" -version = "0.31.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32085ea23f3234fc7846555e85283ba4de91e21016dc0455a16286d87a292d64" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "h2" @@ -1258,9 +1276,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.15.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb" +checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3" [[package]] name = "hashlink" @@ -1380,7 +1398,7 @@ dependencies = [ "bytes", "read-logger", "reqwest", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -1397,9 +1415,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05" +checksum = "bbbff0a806a4728c99295b254c8838933b5b082d75e3cb70c8dab21fdfbcfa9a" dependencies = [ "bytes", "futures-channel", @@ -1425,7 +1443,7 @@ dependencies = [ "http", "hyper", "hyper-util", - "rustls 0.23.13", + "rustls 0.23.16", "rustls-native-certs", "rustls-pki-types", "tokio", @@ -1451,9 +1469,9 @@ dependencies = [ [[package]] name = "hyper-util" -version = "0.1.9" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41296eb09f183ac68eec06e03cdbea2e759633d4067b2f6552fc2e009bcad08b" +checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4" dependencies = [ "bytes", "futures-channel", @@ -1491,14 +1509,143 @@ dependencies = [ "cc", ] +[[package]] +name = "icu_collections" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locid" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_locid_transform" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_locid_transform_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_locid_transform_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e" + +[[package]] +name = "icu_normalizer" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "utf16_iter", + "utf8_iter", + "write16", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516" + +[[package]] +name = "icu_properties" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93d6020766cfc6302c15dbbc9c8778c37e62c14427cb7f6e601d849e092aeef5" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locid_transform", + "icu_properties_data", + "icu_provider", + "tinystr", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569" + +[[package]] +name = "icu_provider" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9" +dependencies = [ + "displaydoc", + "icu_locid", + "icu_provider_macros", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_provider_macros" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "idna" -version = "0.5.0" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" dependencies = [ - "unicode-bidi", - "unicode-normalization", + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daca1df1c957320b2cf139ac61e7bd64fed304c5040df000a745aa1de3b4ef71" +dependencies = [ + "icu_normalizer", + "icu_properties", ] [[package]] @@ -1508,7 +1655,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da" dependencies = [ "equivalent", - "hashbrown 0.15.0", + "hashbrown 0.15.1", ] [[package]] @@ -1525,9 +1672,9 @@ checksum = "8bb03732005da905c88227371639bf1ad885cc712789c011c31c5fb3ab3ccf02" [[package]] name = "ipnet" -version = "2.10.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "187674a687eed5fe42285b40c6291f9a01517d415fad1c3cbc6a9f778af7fcd4" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "itertools" @@ -1564,9 +1711,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.70" +version = "0.3.72" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1868808506b929d7b0cfa8f75951347aa71bb21144b7791bae35d9bccfcfe37a" +checksum = "6a88f1bda2bd75b0452a14784937d796722fdebfe50df998aeb3f0b7603019a9" dependencies = [ "wasm-bindgen", ] @@ -1586,11 +1733,24 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2cde5de06e8d4c2faabc400238f9ae1c74d5412d03a7bd067645ccbc47070e46" dependencies = [ - "lexical-parse-float", - "lexical-parse-integer", - "lexical-util", - "lexical-write-float", - "lexical-write-integer", + "lexical-parse-float 0.8.5", + "lexical-parse-integer 0.8.6", + "lexical-util 0.8.5", + "lexical-write-float 0.8.5", + "lexical-write-integer 0.8.5", +] + +[[package]] +name = "lexical-core" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0431c65b318a590c1de6b8fd6e72798c92291d27762d94c9e6c37ed7a73d8458" +dependencies = [ + "lexical-parse-float 1.0.2", + "lexical-parse-integer 1.0.2", + "lexical-util 1.0.3", + "lexical-write-float 1.0.2", + "lexical-write-integer 1.0.2", ] [[package]] @@ -1599,8 +1759,19 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "683b3a5ebd0130b8fb52ba0bdc718cc56815b6a097e28ae5a6997d0ad17dc05f" dependencies = [ - "lexical-parse-integer", - "lexical-util", + "lexical-parse-integer 0.8.6", + "lexical-util 0.8.5", + "static_assertions", +] + +[[package]] +name = "lexical-parse-float" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb17a4bdb9b418051aa59d41d65b1c9be5affab314a872e5ad7f06231fb3b4e0" +dependencies = [ + "lexical-parse-integer 1.0.2", + "lexical-util 1.0.3", "static_assertions", ] @@ -1610,7 +1781,17 @@ version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6d0994485ed0c312f6d965766754ea177d07f9c00c9b82a5ee62ed5b47945ee9" dependencies = [ - "lexical-util", + "lexical-util 0.8.5", + "static_assertions", +] + +[[package]] +name = "lexical-parse-integer" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5df98f4a4ab53bf8b175b363a34c7af608fe31f93cc1fb1bf07130622ca4ef61" +dependencies = [ + "lexical-util 1.0.3", "static_assertions", ] @@ -1623,14 +1804,34 @@ dependencies = [ "static_assertions", ] +[[package]] +name = "lexical-util" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85314db53332e5c192b6bca611fb10c114a80d1b831ddac0af1e9be1b9232ca0" +dependencies = [ + "static_assertions", +] + [[package]] name = "lexical-write-float" version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accabaa1c4581f05a3923d1b4cfd124c329352288b7b9da09e766b0668116862" dependencies = [ - "lexical-util", - "lexical-write-integer", + "lexical-util 0.8.5", + "lexical-write-integer 0.8.5", + "static_assertions", +] + +[[package]] +name = "lexical-write-float" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e7c3ad4e37db81c1cbe7cf34610340adc09c322871972f74877a712abc6c809" +dependencies = [ + "lexical-util 1.0.3", + "lexical-write-integer 1.0.2", "static_assertions", ] @@ -1640,21 +1841,31 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e1b6f3d1f4422866b68192d62f77bc5c700bee84f3069f2469d7bc8c77852446" dependencies = [ - "lexical-util", + "lexical-util 0.8.5", + "static_assertions", +] + +[[package]] +name = "lexical-write-integer" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb89e9f6958b83258afa3deed90b5de9ef68eef090ad5086c791cd2345610162" +dependencies = [ + "lexical-util 1.0.3", "static_assertions", ] [[package]] name = "libc" -version = "0.2.159" +version = "0.2.162" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5" +checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398" [[package]] name = "libm" -version = "0.2.8" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" +checksum = "8355be11b20d696c8f18f6cc018c4e372165b1fa8126cef092399c9951984ffa" [[package]] name = "libsqlite3-sys" @@ -1673,6 +1884,12 @@ version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +[[package]] +name = "litemap" +version = "0.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704" + [[package]] name = "lock_api" version = "0.4.12" @@ -1785,14 +2002,16 @@ dependencies = [ [[package]] name = "ndarray" -version = "0.15.6" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "adb12d4e967ec485a5f71c6311fe28158e9d6f4bc4a447b474184d0f91a8fa32" +checksum = "882ed72dce9365842bf196bdeedf5055305f11fc8c03dee7bb0194a6cad34841" dependencies = [ "matrixmultiply", "num-complex", "num-integer", "num-traits", + "portable-atomic", + "portable-atomic-util", "rawpointer", ] @@ -1921,7 +2140,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -1942,18 +2161,18 @@ dependencies = [ [[package]] name = "object" -version = "0.36.4" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "084f1a5821ac4c651660a94a7153d27ac9d8a53736203f58b31945ded098070a" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] [[package]] name = "object_store" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25a0c4b3a0e31f8b66f71ad8064521efa773910196e2cde791436f13409f3b45" +checksum = "6eb4c22c6154a1e759d7099f9ffad7cc5ef8245f9efbab4a41b92623079c82f3" dependencies = [ "async-trait", "base64 0.22.1", @@ -1982,18 +2201,15 @@ dependencies = [ [[package]] name = "once_cell" -version = "1.20.1" +version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1" -dependencies = [ - "portable-atomic", -] +checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" [[package]] name = "openssl" -version = "0.10.66" +version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1" +checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ "bitflags 2.6.0", "cfg-if", @@ -2012,7 +2228,7 @@ checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -2023,18 +2239,18 @@ checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-src" -version = "300.3.2+3.3.2" +version = "300.4.0+3.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a211a18d945ef7e648cc6e0058f4c548ee46aab922ea203e0d30e966ea23647b" +checksum = "a709e02f2b4aca747929cca5ed248880847c650233cf8b8cdc48f40aaf4898a6" dependencies = [ "cc", ] [[package]] name = "openssl-sys" -version = "0.9.103" +version = "0.9.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" +checksum = "45abf306cbf99debc8195b66b7346498d7b10c210de50418b5ccd7ceba08c741" dependencies = [ "cc", "libc", @@ -2077,9 +2293,9 @@ dependencies = [ [[package]] name = "parquet" -version = "53.0.0" +version = "53.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0fbf928021131daaa57d334ca8e3904fe9ae22f73c56244fc7db9b04eedc3d8" +checksum = "dea02606ba6f5e856561d8d507dba8bac060aefca2a6c0f1aa1d361fed91ff3e" dependencies = [ "ahash", "arrow-array", @@ -2181,7 +2397,7 @@ dependencies = [ "phf_shared", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -2195,9 +2411,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" +checksum = "915a1e146535de9163f3987b8944ed8cf49a18bb0056bcebcdcece385cece4ff" [[package]] name = "pin-utils" @@ -2240,7 +2456,7 @@ checksum = "20b682daed9c6adcacc2c546410d7692babe5bf946e71a5e3b8b5c9b20d604b2" dependencies = [ "geo", "num-traits", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -2249,6 +2465,15 @@ version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" +[[package]] +name = "portable-atomic-util" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90a7d5beecc52a491b54d6dd05c7a45ba1801666a5baad9fdbfc6fef8d2d206c" +dependencies = [ + "portable-atomic", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -2275,18 +2500,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.86" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "f139b0662de085916d1fb67d2b4169d1addddda1919e696f3252b740b629986e" dependencies = [ "unicode-ident", ] [[package]] name = "pyo3" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d922163ba1f79c04bc49073ba7b32fd5a8d3b76a87c955921234b8e77333c51" +checksum = "f402062616ab18202ae8319da13fa4279883a2b8a9d9f83f20dbade813ce1884" dependencies = [ "anyhow", "cfg-if", @@ -2319,7 +2544,7 @@ dependencies = [ "indexmap", "numpy", "pyo3", - "thiserror", + "thiserror 1.0.69", ] [[package]] @@ -2337,9 +2562,9 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc38c5feeb496c8321091edf3d63e9a6829eab4b863b4a6a65f26f3e9cc6b179" +checksum = "b14b5775b5ff446dd1056212d778012cbe8a0fbffd368029fd9e25b514479c38" dependencies = [ "once_cell", "target-lexicon", @@ -2347,9 +2572,9 @@ dependencies = [ [[package]] name = "pyo3-ffi" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94845622d88ae274d2729fcefc850e63d7a3ddff5e3ce11bd88486db9f1d357d" +checksum = "9ab5bcf04a2cdcbb50c7d6105de943f543f9ed92af55818fd17b660390fc8636" dependencies = [ "libc", "pyo3-build-config", @@ -2370,33 +2595,33 @@ dependencies = [ "pyo3", "pyo3-arrow", "serde_json", - "thiserror", + "thiserror 1.0.69", "url", ] [[package]] name = "pyo3-macros" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e655aad15e09b94ffdb3ce3d217acf652e26bbc37697ef012f5e5e348c716e5e" +checksum = "0fd24d897903a9e6d80b968368a34e1525aeb719d568dba8b3d4bfa5dc67d453" dependencies = [ "proc-macro2", "pyo3-macros-backend", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] name = "pyo3-macros-backend" -version = "0.22.5" +version = "0.22.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ae1e3f09eecd94618f60a455a23def79f79eba4dc561a97324bf9ac8c6df30ce" +checksum = "36c011a03ba1e50152b4b394b479826cad97e7a21eb52df179cd91ac411cbfbe" dependencies = [ "heck 0.5.0", "proc-macro2", "pyo3-build-config", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -2409,7 +2634,7 @@ dependencies = [ "object_store", "pyo3", "pyo3-async-runtimes", - "thiserror", + "thiserror 1.0.69", "url", ] @@ -2435,45 +2660,49 @@ dependencies = [ [[package]] name = "quinn" -version = "0.11.5" +version = "0.11.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c7c5fdde3cdae7203427dc4f0a68fe0ed09833edc525a03456b153b79828684" +checksum = "62e96808277ec6f97351a2380e6c25114bc9e67037775464979f3037c92d05ef" dependencies = [ "bytes", "pin-project-lite", "quinn-proto", "quinn-udp", "rustc-hash 2.0.0", - "rustls 0.23.13", + "rustls 0.23.16", "socket2", - "thiserror", + "thiserror 2.0.3", "tokio", "tracing", ] [[package]] name = "quinn-proto" -version = "0.11.8" +version = "0.11.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fadfaed2cd7f389d0161bb73eeb07b7b78f8691047a6f3e73caaeae55310a4a6" +checksum = "a2fe5ef3495d7d2e377ff17b1a8ce2ee2ec2a18cde8b6ad6619d65d0701c135d" dependencies = [ "bytes", + "getrandom", "rand", "ring", "rustc-hash 2.0.0", - "rustls 0.23.13", + "rustls 0.23.16", + "rustls-pki-types", "slab", - "thiserror", + "thiserror 2.0.3", "tinyvec", "tracing", + "web-time", ] [[package]] name = "quinn-udp" -version = "0.5.5" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fe68c2e9e1a1234e218683dbdf9f9dfcb094113c5ac2b938dfcb9bab4c4140b" +checksum = "7d5a626c6807713b15cac82a6acaccd6043c9a5408c24baae07611fec3f243da" dependencies = [ + "cfg_aliases", "libc", "once_cell", "socket2", @@ -2566,9 +2795,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.11.0" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" dependencies = [ "aho-corasick", "memchr", @@ -2578,9 +2807,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.8" +version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" dependencies = [ "aho-corasick", "memchr", @@ -2595,9 +2824,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" [[package]] name = "reqwest" -version = "0.12.8" +version = "0.12.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f713147fbe92361e52392c73b8c9e48c04c6625bce969ef54dc901e58e042a7b" +checksum = "a77c62af46e79de0a562e1a9849205ffcb7fc1238876e9bd743357570e04046f" dependencies = [ "base64 0.22.1", "bytes", @@ -2622,7 +2851,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.13", + "rustls 0.23.16", "rustls-native-certs", "rustls-pemfile 2.2.0", "rustls-pki-types", @@ -2687,9 +2916,9 @@ dependencies = [ [[package]] name = "rstar" -version = "0.12.0" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "133315eb94c7b1e8d0cb097e5a710d850263372fd028fff18969de708afc7008" +checksum = "421400d13ccfd26dfa5858199c30a5d76f9c54e0dba7575273025b43c5175dbb" dependencies = [ "heapless", "num-traits", @@ -2725,9 +2954,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.37" +version = "0.38.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" +checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0" dependencies = [ "bitflags 2.6.0", "errno", @@ -2749,9 +2978,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.13" +version = "0.23.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" +checksum = "eee87ff5d9b36712a58574e12e9f0ea80f915a5b0ac518d322b24a465617925e" dependencies = [ "once_cell", "ring", @@ -2794,9 +3023,12 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e696e35370c65c9c541198af4543ccd580cf17fc25d8e05c5a242b202488c55" +checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +dependencies = [ + "web-time", +] [[package]] name = "rustls-webpki" @@ -2836,9 +3068,9 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.24" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ "windows-sys 0.59.0", ] @@ -2880,9 +3112,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.12.0" +version = "2.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" +checksum = "fa39c7303dc58b5543c94d22c1766b0d31f2ee58306363ea622b10bbc075eaa2" dependencies = [ "core-foundation-sys", "libc", @@ -2902,29 +3134,29 @@ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4" [[package]] name = "serde" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a" +checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.210" +version = "1.0.215" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f" +checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] name = "serde_json" -version = "1.0.128" +version = "1.0.132" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ff5456707a1de34e7e37f2a6fd3d3f808c318259cbd01ab6377795054b483d8" +checksum = "d726bfaff4b320266d395898905d0eba0345aae23b54aee3a737e260fd46db03" dependencies = [ "itoa", "memchr", @@ -3031,7 +3263,7 @@ dependencies = [ "heck 0.5.0", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -3139,7 +3371,7 @@ dependencies = [ "sha2", "smallvec", "sqlformat", - "thiserror", + "thiserror 1.0.69", "tokio", "tokio-stream", "tracing", @@ -3224,7 +3456,7 @@ dependencies = [ "smallvec", "sqlx-core", "stringprep", - "thiserror", + "thiserror 1.0.69", "tracing", "whoami", ] @@ -3263,7 +3495,7 @@ dependencies = [ "smallvec", "sqlx-core", "stringprep", - "thiserror", + "thiserror 1.0.69", "tracing", "whoami", ] @@ -3334,9 +3566,9 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.79" +version = "2.0.87" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590" +checksum = "25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d" dependencies = [ "proc-macro2", "quote", @@ -3352,6 +3584,17 @@ dependencies = [ "futures-core", ] +[[package]] +name = "synstructure" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "system-configuration" version = "0.6.1" @@ -3381,9 +3624,9 @@ checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" [[package]] name = "tempfile" -version = "3.13.0" +version = "3.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" +checksum = "28cce251fcbc87fac86a866eeb0d6c2d536fc16d06f184bb61aeae11aa4cee0c" dependencies = [ "cfg-if", "fastrand", @@ -3394,22 +3637,42 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.64" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d50af8abc119fb8bb6dbabcfa89656f46f84aa0ac7688088608076ad2b459a84" +checksum = "c006c85c7651b3cf2ada4584faa36773bd07bac24acfb39f3c431b36d7e667aa" dependencies = [ - "thiserror-impl", + "thiserror-impl 2.0.3", ] [[package]] name = "thiserror-impl" -version = "1.0.64" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08904e7672f5eb876eaaf87e0ce17857500934f4981c4a0ab2b4aa98baac7fc3" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f077553d607adc1caf65430528a576c757a71ed73944b66ebb58ef2bbd243568" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", ] [[package]] @@ -3451,6 +3714,16 @@ dependencies = [ "crunchy", ] +[[package]] +name = "tinystr" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" +dependencies = [ + "displaydoc", + "zerovec", +] + [[package]] name = "tinyvec" version = "1.8.0" @@ -3468,9 +3741,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.40.0" +version = "1.41.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" +checksum = "22cfb5bee7a6a52939ca9224d6ac897bb669134078daa8735560897f69de4d33" dependencies = [ "backtrace", "bytes", @@ -3490,7 +3763,7 @@ checksum = "693d596312e88961bc67d7f1f97af8a70227d9f90c31bba5806eec004978d752" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -3509,7 +3782,7 @@ version = "0.26.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4" dependencies = [ - "rustls 0.23.13", + "rustls 0.23.16", "rustls-pki-types", "tokio", ] @@ -3581,7 +3854,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", ] [[package]] @@ -3617,9 +3890,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" @@ -3668,9 +3941,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "url" -version = "2.5.2" +version = "2.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" +checksum = "8d157f1b96d14500ffdc1f10ba712e780825526c03d9a49b4d0324b0d9113ada" dependencies = [ "form_urlencoded", "idna", @@ -3683,6 +3956,18 @@ version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" +[[package]] +name = "utf16_iter" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + [[package]] name = "vcpkg" version = "0.2.15" @@ -3728,9 +4013,9 @@ checksum = "b8dad83b4f25e74f184f64c43b150b91efe7647395b42289f38e50566d82855b" [[package]] name = "wasm-bindgen" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a82edfc16a6c469f5f44dc7b571814045d60404b55a0ee849f9bcfa2e63dd9b5" +checksum = "128d1e363af62632b8eb57219c8fd7877144af57558fb2ef0368d0087bddeb2e" dependencies = [ "cfg-if", "once_cell", @@ -3739,24 +4024,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9de396da306523044d3302746f1208fa71d7532227f15e347e2d93e4145dd77b" +checksum = "cb6dd4d3ca0ddffd1dd1c9c04f94b868c37ff5fac97c30b97cff2d74fce3a358" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-futures" -version = "0.4.43" +version = "0.4.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61e9300f63a621e96ed275155c108eb6f843b6a26d053f122ab69724559dc8ed" +checksum = "cc7ec4f8827a71586374db3e87abdb5a2bb3a15afed140221307c3ec06b1f63b" dependencies = [ "cfg-if", "js-sys", @@ -3766,9 +4051,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "585c4c91a46b072c92e908d99cb1dcdf95c5218eeb6f3bf1efa991ee7a68cccf" +checksum = "e79384be7f8f5a9dd5d7167216f022090cf1f9ec128e6e6a482a2cb5c5422c56" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3776,28 +4061,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afc340c74d9005395cf9dd098506f7f44e38f2b4a21c6aaacf9a105ea5e1e836" +checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.93" +version = "0.2.95" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c62a0a307cb4a311d3a07867860911ca130c3494e8c2719593806c08bc5d0484" +checksum = "65fc09f10666a9f147042251e0dda9c18f166ff7de300607007e96bdebc1068d" [[package]] name = "wasm-streams" -version = "0.4.1" +version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4e072d4e72f700fb3443d8fe94a39315df013eef1104903cdb0a2abd322bbecd" +checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65" dependencies = [ "futures-util", "js-sys", @@ -3808,9 +4093,19 @@ dependencies = [ [[package]] name = "web-sys" -version = "0.3.70" +version = "0.3.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6488b90108c040df0fe62fa815cbdee25124641df01814dd7282749234c6112" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26fdeaafd9bd129f65e7c031593c24d62186301e0c72c8978fa1678be7d532c0" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" dependencies = [ "js-sys", "wasm-bindgen", @@ -4045,31 +4340,67 @@ dependencies = [ "byteorder", "geo-traits", "num_enum", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "wkt" -version = "0.11.0" +version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "296937617013271141d1145d9c05861f5ed3b1bc4297e81c692aa3cff9270a9c" +checksum = "54f7f1ff4ea4c18936d6cd26a6fd24f0003af37e951a8e0e8b9e9a2d0bd0a46d" dependencies = [ "geo-types", "log", "num-traits", - "thiserror", + "thiserror 1.0.69", ] [[package]] name = "wkt" version = "0.11.1" -source = "git+https://github.com/georust/wkt?branch=kyle/geo-traits-writer#63b13243568470d6da5a44fcc9fe7b903aa53eea" +source = "git+https://github.com/georust/wkt?branch=kyle/geo-traits-writer#f3434f5283d070f1accd64cd1bd09303f0f0547c" dependencies = [ "geo-traits", "geo-types", "log", "num-traits", - "thiserror", + "thiserror 1.0.69", +] + +[[package]] +name = "write16" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936" + +[[package]] +name = "writeable" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51" + +[[package]] +name = "yoke" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", ] [[package]] @@ -4090,7 +4421,28 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.87", +] + +[[package]] +name = "zerofrom" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", + "synstructure", ] [[package]] @@ -4099,6 +4451,28 @@ version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" +[[package]] +name = "zerovec" +version = "0.10.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa2b893d79df23bfb12d5461018d408ea19dfafe76c2c7ef6d4eba614f8ff079" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.10.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6eafa6dfb17584ea3e2bd6e76e0cc15ad7af12b09abdd1ca55961bed9b1063c6" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.87", +] + [[package]] name = "zstd" version = "0.13.2" @@ -4119,9 +4493,9 @@ dependencies = [ [[package]] name = "zstd-sys" -version = "2.0.12+zstd.1.5.6" +version = "2.0.13+zstd.1.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a4e40c320c3cb459d9a9ff6de98cff88f4751ee9275d140e2be94a2b74e4c13" +checksum = "38ff0f21cfee8f97d94cef41359e0c89aa6113028ab0291aa8ca0038995a95aa" dependencies = [ "cc", "pkg-config", diff --git a/python/geoarrow-compute/src/algorithm/geo/convex_hull.rs b/python/geoarrow-compute/src/algorithm/geo/convex_hull.rs index 0abc135d..c9550e16 100644 --- a/python/geoarrow-compute/src/algorithm/geo/convex_hull.rs +++ b/python/geoarrow-compute/src/algorithm/geo/convex_hull.rs @@ -12,11 +12,11 @@ use pyo3_geoarrow::PyGeoArrowResult; pub fn convex_hull(py: Python, input: AnyNativeInput) -> PyGeoArrowResult { match input { AnyNativeInput::Array(arr) => { - let out: PolygonArray<2> = arr.as_ref().convex_hull()?; + let out: PolygonArray = arr.as_ref().convex_hull()?; return_geometry_array(py, Arc::new(out)) } AnyNativeInput::Chunked(arr) => { - let out: ChunkedGeometryArray> = arr.as_ref().convex_hull()?; + let out: ChunkedGeometryArray = arr.as_ref().convex_hull()?; return_chunked_geometry_array(py, Arc::new(out)) } } diff --git a/python/geoarrow-core/src/interop/ewkb.rs b/python/geoarrow-core/src/interop/ewkb.rs index 6a4322ee..906d73c1 100644 --- a/python/geoarrow-core/src/interop/ewkb.rs +++ b/python/geoarrow-core/src/interop/ewkb.rs @@ -1,5 +1,5 @@ use geoarrow::array::{CoordType, WKBArray}; -use geoarrow::datatypes::SerializedType; +use geoarrow::datatypes::{Dimension, SerializedType}; use geoarrow::io::geozero::FromEWKB; use pyo3::exceptions::PyValueError; use pyo3::prelude::*; @@ -15,11 +15,23 @@ pub fn from_ewkb(py: Python, input: PyArray) -> PyGeoArrowResult { let geo_array = match typ { SerializedType::WKB => { let wkb_arr = WKBArray::::try_from((array.as_ref(), field.as_ref()))?; - FromEWKB::from_ewkb(&wkb_arr, CoordType::Interleaved, Default::default(), false)? + FromEWKB::from_ewkb( + &wkb_arr, + CoordType::Interleaved, + Dimension::XY, + Default::default(), + false, + )? } SerializedType::LargeWKB => { let wkb_arr = WKBArray::::try_from((array.as_ref(), field.as_ref()))?; - FromEWKB::from_ewkb(&wkb_arr, CoordType::Interleaved, Default::default(), false)? + FromEWKB::from_ewkb( + &wkb_arr, + CoordType::Interleaved, + Dimension::XY, + Default::default(), + false, + )? } _ => return Err(PyValueError::new_err("Expected a WKB array").into()), }; diff --git a/python/geoarrow-core/src/interop/shapely/to_shapely.rs b/python/geoarrow-core/src/interop/shapely/to_shapely.rs index 640bc59c..2aa6703a 100644 --- a/python/geoarrow-core/src/interop/shapely/to_shapely.rs +++ b/python/geoarrow-core/src/interop/shapely/to_shapely.rs @@ -6,7 +6,7 @@ use arrow_buffer::NullBuffer; use geoarrow::array::{ AsNativeArray, AsSerializedArray, CoordBuffer, NativeArrayDyn, SerializedArrayDyn, }; -use geoarrow::datatypes::{AnyType, Dimension, NativeType, SerializedType}; +use geoarrow::datatypes::{AnyType, NativeType, SerializedType}; use geoarrow::io::wkb::to_wkb; use geoarrow::NativeArray; use numpy::PyArrayMethods; @@ -88,41 +88,21 @@ fn pyarray_to_shapely(py: Python, input: PyArray) -> PyGeoArrowResult { let array = NativeArrayDyn::from_arrow_array(&array, &field)?.into_inner(); - use Dimension::*; use NativeType::*; match typ { - Point(_, XY) => point_arr(py, array.as_ref().as_point::<2>().clone()), - LineString(_, XY) => { - linestring_arr(py, array.as_ref().as_line_string::<2>().clone()) + Point(_, _) => point_arr(py, array.as_ref().as_point().clone()), + LineString(_, _) => linestring_arr(py, array.as_ref().as_line_string().clone()), + Polygon(_, _) => polygon_arr(py, array.as_ref().as_polygon().clone()), + MultiPoint(_, _) => multipoint_arr(py, array.as_ref().as_multi_point().clone()), + MultiLineString(_, _) => { + multilinestring_arr(py, array.as_ref().as_multi_line_string().clone()) } - Polygon(_, XY) => polygon_arr(py, array.as_ref().as_polygon::<2>().clone()), - MultiPoint(_, XY) => { - multipoint_arr(py, array.as_ref().as_multi_point::<2>().clone()) - } - MultiLineString(_, XY) => { - multilinestring_arr(py, array.as_ref().as_multi_line_string::<2>().clone()) - } - MultiPolygon(_, XY) => { - multipolygon_arr(py, array.as_ref().as_multi_polygon::<2>().clone()) - } - Rect(XY) => rect_arr(py, array.as_ref().as_rect::<2>().clone()), - Point(_, XYZ) => point_arr(py, array.as_ref().as_point::<3>().clone()), - LineString(_, XYZ) => { - linestring_arr(py, array.as_ref().as_line_string::<3>().clone()) - } - Polygon(_, XYZ) => polygon_arr(py, array.as_ref().as_polygon::<3>().clone()), - MultiPoint(_, XYZ) => { - multipoint_arr(py, array.as_ref().as_multi_point::<3>().clone()) - } - MultiLineString(_, XYZ) => { - multilinestring_arr(py, array.as_ref().as_multi_line_string::<3>().clone()) - } - MultiPolygon(_, XYZ) => { - multipolygon_arr(py, array.as_ref().as_multi_polygon::<3>().clone()) + MultiPolygon(_, _) => { + multipolygon_arr(py, array.as_ref().as_multi_polygon().clone()) } + Rect(_) => rect_arr(py, array.as_ref().as_rect().clone()), Mixed(_, _) => via_wkb(py, array), GeometryCollection(_, _) => via_wkb(py, array), - t => Err(PyValueError::new_err(format!("unsupported type {:?}", t)).into()), } } AnyType::Serialized(typ) => { @@ -135,10 +115,7 @@ fn pyarray_to_shapely(py: Python, input: PyArray) -> PyGeoArrowResult, -) -> PyGeoArrowResult> { +fn point_arr(py: Python, arr: geoarrow::array::PointArray) -> PyGeoArrowResult> { let shapely_mod = import_shapely(py)?; let shapely_geom_type_enum = shapely_mod.getattr(intern!(py, "GeometryType"))?; @@ -152,7 +129,7 @@ fn point_arr( fn linestring_arr( py: Python, - arr: geoarrow::array::LineStringArray, + arr: geoarrow::array::LineStringArray, ) -> PyGeoArrowResult> { let shapely_mod = import_shapely(py)?; let shapely_geom_type_enum = shapely_mod.getattr(intern!(py, "GeometryType"))?; @@ -168,10 +145,7 @@ fn linestring_arr( Ok(shapely_mod.call_method1(intern!(py, "from_ragged_array"), args)?) } -fn polygon_arr( - py: Python, - arr: geoarrow::array::PolygonArray, -) -> PyGeoArrowResult> { +fn polygon_arr(py: Python, arr: geoarrow::array::PolygonArray) -> PyGeoArrowResult> { let shapely_mod = import_shapely(py)?; let shapely_geom_type_enum = shapely_mod.getattr(intern!(py, "GeometryType"))?; @@ -191,7 +165,7 @@ fn polygon_arr( fn multipoint_arr( py: Python, - arr: geoarrow::array::MultiPointArray, + arr: geoarrow::array::MultiPointArray, ) -> PyGeoArrowResult> { let shapely_mod = import_shapely(py)?; let shapely_geom_type_enum = shapely_mod.getattr(intern!(py, "GeometryType"))?; @@ -209,7 +183,7 @@ fn multipoint_arr( fn multilinestring_arr( py: Python, - arr: geoarrow::array::MultiLineStringArray, + arr: geoarrow::array::MultiLineStringArray, ) -> PyGeoArrowResult> { let shapely_mod = import_shapely(py)?; let shapely_geom_type_enum = shapely_mod.getattr(intern!(py, "GeometryType"))?; @@ -230,7 +204,7 @@ fn multilinestring_arr( fn multipolygon_arr( py: Python, - arr: geoarrow::array::MultiPolygonArray, + arr: geoarrow::array::MultiPolygonArray, ) -> PyGeoArrowResult> { let shapely_mod = import_shapely(py)?; let shapely_geom_type_enum = shapely_mod.getattr(intern!(py, "GeometryType"))?; @@ -250,7 +224,7 @@ fn multipolygon_arr( Ok(shapely_mod.call_method1(intern!(py, "from_ragged_array"), args)?) } -fn rect_arr(py: Python, arr: geoarrow::array::RectArray<2>) -> PyGeoArrowResult> { +fn rect_arr(py: Python, arr: geoarrow::array::RectArray) -> PyGeoArrowResult> { let shapely_mod = import_shapely(py)?; let lower = arr.lower(); diff --git a/python/geoarrow-core/src/interop/wkb.rs b/python/geoarrow-core/src/interop/wkb.rs index a70a4cf6..b7804785 100644 --- a/python/geoarrow-core/src/interop/wkb.rs +++ b/python/geoarrow-core/src/interop/wkb.rs @@ -1,6 +1,6 @@ use geoarrow::array::WKBArray; use geoarrow::chunked_array::{ChunkedArrayBase, ChunkedWKBArray}; -use geoarrow::datatypes::SerializedType; +use geoarrow::datatypes::{Dimension, SerializedType}; use geoarrow::io::wkb::{to_wkb as _to_wkb, FromWKB, ToWKB}; use geoarrow::ArrayBase; use pyo3::exceptions::PyValueError; @@ -31,11 +31,11 @@ pub fn from_wkb( let geo_array = match typ { SerializedType::WKB => { let wkb_arr = WKBArray::::try_from((arr.as_ref(), field.as_ref()))?; - FromWKB::from_wkb(&wkb_arr, coord_type)? + FromWKB::from_wkb(&wkb_arr, coord_type, Dimension::XY)? } SerializedType::LargeWKB => { let wkb_arr = WKBArray::::try_from((arr.as_ref(), field.as_ref()))?; - FromWKB::from_wkb(&wkb_arr, coord_type)? + FromWKB::from_wkb(&wkb_arr, coord_type, Dimension::XY)? } _ => return Err(PyValueError::new_err("Expected a WKB array").into()), }; @@ -50,14 +50,14 @@ pub fn from_wkb( .into_iter() .map(|chunk| WKBArray::::try_from((chunk.as_ref(), field.as_ref()))) .collect::, _>>()?; - FromWKB::from_wkb(&ChunkedWKBArray::new(chunks), coord_type)? + FromWKB::from_wkb(&ChunkedWKBArray::new(chunks), coord_type, Dimension::XY)? } SerializedType::LargeWKB => { let chunks = chunks .into_iter() .map(|chunk| WKBArray::::try_from((chunk.as_ref(), field.as_ref()))) .collect::, _>>()?; - FromWKB::from_wkb(&ChunkedWKBArray::new(chunks), coord_type)? + FromWKB::from_wkb(&ChunkedWKBArray::new(chunks), coord_type, Dimension::XY)? } _ => return Err(PyValueError::new_err("Expected a WKB array").into()), }; diff --git a/python/geoarrow-core/src/interop/wkt.rs b/python/geoarrow-core/src/interop/wkt.rs index 7c187bd5..6c501fb8 100644 --- a/python/geoarrow-core/src/interop/wkt.rs +++ b/python/geoarrow-core/src/interop/wkt.rs @@ -4,6 +4,7 @@ use arrow::datatypes::DataType; use arrow_array::cast::AsArray; use geoarrow::array::metadata::ArrayMetadata; use geoarrow::chunked_array::{ChunkedArray, ChunkedMixedGeometryArray}; +use geoarrow::datatypes::Dimension; use geoarrow::io::geozero::FromWKT; use geoarrow::io::wkt::reader::ParseWKT; use geoarrow::io::wkt::ToWKT; @@ -47,7 +48,7 @@ pub fn from_wkt( let chunked_arr = s.into_chunked_array()?; let (chunks, field) = chunked_arr.into_inner(); let metadata = Arc::new(ArrayMetadata::try_from(field.as_ref())?); - let geo_array: ChunkedMixedGeometryArray<2> = match field.data_type() { + let geo_array: ChunkedMixedGeometryArray = match field.data_type() { DataType::Utf8 => { let string_chunks = chunks .iter() @@ -56,6 +57,7 @@ pub fn from_wkt( FromWKT::from_wkt( &ChunkedArray::new(string_chunks), coord_type, + Dimension::XY, metadata, false, )? @@ -68,6 +70,7 @@ pub fn from_wkt( FromWKT::from_wkt( &ChunkedArray::new(string_chunks), coord_type, + Dimension::XY, metadata, false, )? diff --git a/python/pyo3-geoarrow/src/ffi/from_python/scalar.rs b/python/pyo3-geoarrow/src/ffi/from_python/scalar.rs index 87cffe6d..b837e28b 100644 --- a/python/pyo3-geoarrow/src/ffi/from_python/scalar.rs +++ b/python/pyo3-geoarrow/src/ffi/from_python/scalar.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use crate::array::*; use crate::scalar::*; use geoarrow::array::MixedGeometryArray; +use geoarrow::datatypes::Dimension; use geoarrow::io::geozero::ToMixedArray; use geoarrow::scalar::GeometryScalar; use geozero::geojson::GeoJsonString; @@ -25,8 +26,8 @@ impl<'a> FromPyObject<'a> for PyGeometry { let reader = GeoJsonString(json_string); // TODO: we need a dynamic dimensionality reader - let arr: MixedGeometryArray<2> = reader - .to_mixed_geometry_array() + let arr: MixedGeometryArray = reader + .to_mixed_geometry_array(Dimension::XY) .map_err(|err| PyValueError::new_err(err.to_string()))?; Ok(Self( GeometryScalar::try_new(Arc::new(arr)) From ea1ef6221945facc5f14721bda803e3617a33dec Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Fri, 15 Nov 2024 23:17:18 -0500 Subject: [PATCH 14/14] remove todo --- rust/geoarrow/src/array/geometrycollection/array.rs | 2 +- rust/geoarrow/src/array/linestring/array.rs | 2 +- rust/geoarrow/src/array/mixed/array.rs | 4 ---- rust/geoarrow/src/array/multilinestring/array.rs | 2 +- rust/geoarrow/src/array/polygon/array.rs | 2 +- rust/geoarrow/src/scalar/geometrycollection/owned.rs | 3 ++- rust/geoarrow/src/scalar/geometrycollection/scalar.rs | 5 +++-- 7 files changed, 9 insertions(+), 11 deletions(-) diff --git a/rust/geoarrow/src/array/geometrycollection/array.rs b/rust/geoarrow/src/array/geometrycollection/array.rs index 6af2ef6e..5f85126b 100644 --- a/rust/geoarrow/src/array/geometrycollection/array.rs +++ b/rust/geoarrow/src/array/geometrycollection/array.rs @@ -53,7 +53,7 @@ impl GeometryCollectionArray { metadata: Arc, ) -> Self { let coord_type = array.coord_type(); - let data_type = NativeType::GeometryCollection(coord_type, array.dim()); + let data_type = NativeType::GeometryCollection(coord_type, array.dimension()); Self { data_type, array, diff --git a/rust/geoarrow/src/array/linestring/array.rs b/rust/geoarrow/src/array/linestring/array.rs index 9e32753d..a05e3ca3 100644 --- a/rust/geoarrow/src/array/linestring/array.rs +++ b/rust/geoarrow/src/array/linestring/array.rs @@ -515,7 +515,7 @@ impl TryFrom for LineStringArray { capacity.geom_capacity += buffer_lengths.ring_capacity; let mut builder = LineStringBuilder::with_capacity_and_options( - value.dim(), + value.dimension(), capacity, value.coord_type(), value.metadata(), diff --git a/rust/geoarrow/src/array/mixed/array.rs b/rust/geoarrow/src/array/mixed/array.rs index e5609020..7a34fe53 100644 --- a/rust/geoarrow/src/array/mixed/array.rs +++ b/rust/geoarrow/src/array/mixed/array.rs @@ -286,10 +286,6 @@ impl MixedGeometryArray { && self.has_multi_polygons() } - pub fn dim(&self) -> Dimension { - todo!() - } - /// The number of bytes occupied by this array. pub fn num_bytes(&self) -> usize { self.buffer_lengths().num_bytes() diff --git a/rust/geoarrow/src/array/multilinestring/array.rs b/rust/geoarrow/src/array/multilinestring/array.rs index 36f8c61a..b623ba17 100644 --- a/rust/geoarrow/src/array/multilinestring/array.rs +++ b/rust/geoarrow/src/array/multilinestring/array.rs @@ -564,7 +564,7 @@ impl TryFrom for MultiLineStringArray { capacity += value.line_strings.buffer_lengths(); let mut builder = MultiLineStringBuilder::with_capacity_and_options( - value.dim(), + value.dimension(), capacity, value.coord_type(), value.metadata(), diff --git a/rust/geoarrow/src/array/polygon/array.rs b/rust/geoarrow/src/array/polygon/array.rs index 679745a3..79f3911f 100644 --- a/rust/geoarrow/src/array/polygon/array.rs +++ b/rust/geoarrow/src/array/polygon/array.rs @@ -581,7 +581,7 @@ impl TryFrom for PolygonArray { type Error = GeoArrowError; fn try_from(value: MixedGeometryArray) -> Result { - let dim = value.dim(); + let dim = value.dimension(); if value.has_points() || value.has_line_strings() diff --git a/rust/geoarrow/src/scalar/geometrycollection/owned.rs b/rust/geoarrow/src/scalar/geometrycollection/owned.rs index 09408e8a..e14c908a 100644 --- a/rust/geoarrow/src/scalar/geometrycollection/owned.rs +++ b/rust/geoarrow/src/scalar/geometrycollection/owned.rs @@ -2,6 +2,7 @@ use crate::algorithm::native::eq::geometry_collection_eq; use crate::array::{GeometryCollectionArray, MixedGeometryArray}; use crate::datatypes::Dimension; use crate::scalar::{Geometry, GeometryCollection}; +use crate::NativeArray; use arrow_buffer::OffsetBuffer; use geo_traits::GeometryCollectionTrait; @@ -60,7 +61,7 @@ impl GeometryCollectionTrait for OwnedGeometryCollection { type GeometryType<'b> = Geometry<'b> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - match self.array.dim() { + match self.array.dimension() { Dimension::XY => geo_traits::Dimensions::Xy, Dimension::XYZ => geo_traits::Dimensions::Xyz, } diff --git a/rust/geoarrow/src/scalar/geometrycollection/scalar.rs b/rust/geoarrow/src/scalar/geometrycollection/scalar.rs index 2a3ca9b3..f3443026 100644 --- a/rust/geoarrow/src/scalar/geometrycollection/scalar.rs +++ b/rust/geoarrow/src/scalar/geometrycollection/scalar.rs @@ -6,6 +6,7 @@ use crate::io::geo::geometry_collection_to_geo; use crate::scalar::Geometry; use crate::trait_::ArrayAccessor; use crate::trait_::NativeScalar; +use crate::NativeArray; use arrow_buffer::OffsetBuffer; use geo_traits::GeometryCollectionTrait; use rstar::{RTreeObject, AABB}; @@ -65,7 +66,7 @@ impl<'a> GeometryCollectionTrait for GeometryCollection<'a> { type GeometryType<'b> = Geometry<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - match self.array.dim() { + match self.array.dimension() { Dimension::XY => geo_traits::Dimensions::Xy, Dimension::XYZ => geo_traits::Dimensions::Xyz, } @@ -86,7 +87,7 @@ impl<'a> GeometryCollectionTrait for &'a GeometryCollection<'a> { type GeometryType<'b> = Geometry<'a> where Self: 'b; fn dim(&self) -> geo_traits::Dimensions { - match self.array.dim() { + match self.array.dimension() { Dimension::XY => geo_traits::Dimensions::Xy, Dimension::XYZ => geo_traits::Dimensions::Xyz, }