From 23c226b3a481aa48fa5f2a32cf3bf86acfb94fe4 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Thu, 2 May 2024 21:48:27 -0400 Subject: [PATCH] Update geos to 9.0 (#626) We can remove a lot of lifetime definitions thanks to https://github.com/georust/geos/pull/153 --- Cargo.lock | 4 +- Cargo.toml | 2 +- js/src/io/parquet/async_file_reader/mod.rs | 3 ++ src/algorithm/geos/buffer.rs | 4 +- src/algorithm/native/mod.rs | 1 + src/array/point/builder.rs | 4 +- src/array/rect/builder.rs | 4 +- src/io/geos/array/linestring.rs | 8 ++-- src/io/geos/array/multilinestring.rs | 8 ++-- src/io/geos/array/multipoint.rs | 8 ++-- src/io/geos/array/multipolygon.rs | 8 ++-- src/io/geos/array/point.rs | 26 ++++++------ src/io/geos/array/polygon.rs | 16 ++++---- src/io/geos/scalar/binary.rs | 8 ++-- src/io/geos/scalar/coord/combined.rs | 2 +- src/io/geos/scalar/coord/interleaved.rs | 2 +- src/io/geos/scalar/coord/mod.rs | 6 +-- src/io/geos/scalar/coord/separated.rs | 2 +- src/io/geos/scalar/geometry.rs | 10 ++--- src/io/geos/scalar/geometrycollection.rs | 8 ++-- src/io/geos/scalar/linearring.rs | 12 +++--- src/io/geos/scalar/linestring.rs | 46 +++++++++++----------- src/io/geos/scalar/multilinestring.rs | 24 ++++++----- src/io/geos/scalar/multipoint.rs | 26 ++++++------ src/io/geos/scalar/multipolygon.rs | 22 +++++------ src/io/geos/scalar/point.rs | 42 ++++++++++---------- src/io/geos/scalar/polygon.rs | 36 ++++++++--------- 27 files changed, 166 insertions(+), 176 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6ffad58c..234e4a8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1392,9 +1392,9 @@ dependencies = [ [[package]] name = "geos" -version = "8.3.1" +version = "9.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b57a162bbfe8866b1ab898aad47e7fe634a9177c4b1bacc80af04d2b45772a46" +checksum = "468b7ac7233c0f417b2c161d28b6d1e88c025eaf79303b69e6e1aa40a2ac1367" dependencies = [ "c_vec", "geo-types", diff --git a/Cargo.toml b/Cargo.toml index ac35c967..39bbef4b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,7 +66,7 @@ gdal = { version = "0.16", optional = true } geo = "0.28" geo-index = "0.1.1" geodesy = { version = "0.12", optional = true } -geos = { version = "8.3", features = ["v3_10_0", "geo"], optional = true } +geos = { version = "9.0", features = ["v3_11_0", "geo"], optional = true } geozero = { version = "0.12", features = ["with-wkb"], optional = true } http-range-client = { version = "0.7.2", optional = true } indexmap = "2" diff --git a/js/src/io/parquet/async_file_reader/mod.rs b/js/src/io/parquet/async_file_reader/mod.rs index 7df8e727..291c3974 100644 --- a/js/src/io/parquet/async_file_reader/mod.rs +++ b/js/src/io/parquet/async_file_reader/mod.rs @@ -27,6 +27,9 @@ use reqwest::Client; use async_trait::async_trait; +// This was used until we switched to object store for making requests. When we're happy with the +// object store implementation and believe it's stable, we can remove this. +#[allow(dead_code)] #[async_trait(?Send)] trait SharedIO { fn generate_builder( diff --git a/src/algorithm/geos/buffer.rs b/src/algorithm/geos/buffer.rs index 49ffb846..aaa5308e 100644 --- a/src/algorithm/geos/buffer.rs +++ b/src/algorithm/geos/buffer.rs @@ -10,7 +10,7 @@ pub trait Buffer { fn buffer(&self, width: f64, quadsegs: i32) -> Self::Output; - fn buffer_with_params(&self, width: f64, buffer_params: &BufferParams<'_>) -> Self::Output; + fn buffer_with_params(&self, width: f64, buffer_params: &BufferParams) -> Self::Output; } impl Buffer for PointArray { @@ -32,7 +32,7 @@ impl Buffer for PointArray { Ok(builder.finish()) } - fn buffer_with_params(&self, width: f64, buffer_params: &BufferParams<'_>) -> Self::Output { + fn buffer_with_params(&self, width: f64, buffer_params: &BufferParams) -> Self::Output { let mut builder = PolygonBuilder::new(); for maybe_g in self.iter() { diff --git a/src/algorithm/native/mod.rs b/src/algorithm/native/mod.rs index e23ae32c..95c24310 100644 --- a/src/algorithm/native/mod.rs +++ b/src/algorithm/native/mod.rs @@ -28,4 +28,5 @@ pub use map_coords::MapCoords; pub use rechunk::Rechunk; pub use take::Take; pub use total_bounds::TotalBounds; +pub use type_id::TypeIds; pub use unary::Unary; diff --git a/src/array/point/builder.rs b/src/array/point/builder.rs index 2422dd91..04aa4188 100644 --- a/src/array/point/builder.rs +++ b/src/array/point/builder.rs @@ -169,7 +169,7 @@ impl PointBuilder { } pub fn from_points<'a>( - geoms: impl ExactSizeIterator + Iterator + 'a)>, + geoms: impl ExactSizeIterator + 'a)>, coord_type: Option, metadata: Arc, ) -> Self { @@ -182,7 +182,7 @@ impl PointBuilder { } pub fn from_nullable_points<'a>( - geoms: impl ExactSizeIterator + Iterator + 'a)>>, + geoms: impl ExactSizeIterator + 'a)>>, coord_type: Option, metadata: Arc, ) -> Self { diff --git a/src/array/rect/builder.rs b/src/array/rect/builder.rs index 88d4169a..1602e5d1 100644 --- a/src/array/rect/builder.rs +++ b/src/array/rect/builder.rs @@ -127,7 +127,7 @@ impl RectBuilder { /// Create this builder from a iterator of Rects. pub fn from_rects<'a>( - geoms: impl ExactSizeIterator + Iterator + 'a)>, + geoms: impl ExactSizeIterator + 'a)>, metadata: Arc, ) -> Self { let mut mutable_array = Self::with_capacity(geoms.len(), metadata); @@ -139,7 +139,7 @@ impl RectBuilder { /// Create this builder from a iterator of nullable Rects. pub fn from_nullable_rects<'a>( - geoms: impl ExactSizeIterator + Iterator + 'a)>>, + geoms: impl ExactSizeIterator + 'a)>>, metadata: Arc, ) -> Self { let mut mutable_array = Self::with_capacity(geoms.len(), metadata); diff --git a/src/io/geos/array/linestring.rs b/src/io/geos/array/linestring.rs index cc3206dd..789965de 100644 --- a/src/io/geos/array/linestring.rs +++ b/src/io/geos/array/linestring.rs @@ -4,10 +4,10 @@ use crate::array::{LineStringArray, LineStringBuilder}; use crate::error::{GeoArrowError, Result}; use crate::io::geos::scalar::GEOSLineString; -impl TryFrom>>> for LineStringBuilder { +impl TryFrom>> for LineStringBuilder { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> Result { + fn try_from(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value .into_iter() @@ -17,10 +17,10 @@ impl TryFrom>>> for LineString } } -impl<'a, O: OffsetSizeTrait> TryFrom>>> for LineStringArray { +impl TryFrom>> for LineStringArray { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> std::result::Result { + fn try_from(value: Vec>) -> std::result::Result { let mutable_arr: LineStringBuilder = value.try_into()?; Ok(mutable_arr.into()) } diff --git a/src/io/geos/array/multilinestring.rs b/src/io/geos/array/multilinestring.rs index fe7fd127..4d815632 100644 --- a/src/io/geos/array/multilinestring.rs +++ b/src/io/geos/array/multilinestring.rs @@ -4,10 +4,10 @@ use crate::array::{MultiLineStringArray, MultiLineStringBuilder}; use crate::error::{GeoArrowError, Result}; use crate::io::geos::scalar::GEOSMultiLineString; -impl TryFrom>>> for MultiLineStringBuilder { +impl TryFrom>> for MultiLineStringBuilder { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> Result { + fn try_from(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value .into_iter() @@ -17,10 +17,10 @@ impl TryFrom>>> for MultiLineS } } -impl TryFrom>>> for MultiLineStringArray { +impl TryFrom>> for MultiLineStringArray { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> Result { + fn try_from(value: Vec>) -> Result { let mutable_arr: MultiLineStringBuilder = value.try_into()?; Ok(mutable_arr.into()) } diff --git a/src/io/geos/array/multipoint.rs b/src/io/geos/array/multipoint.rs index 5325e490..390327d1 100644 --- a/src/io/geos/array/multipoint.rs +++ b/src/io/geos/array/multipoint.rs @@ -4,10 +4,10 @@ use crate::array::{MultiPointArray, MultiPointBuilder}; use crate::error::GeoArrowError; use crate::io::geos::scalar::GEOSMultiPoint; -impl<'a, O: OffsetSizeTrait> TryFrom>>> for MultiPointBuilder { +impl TryFrom>> for MultiPointBuilder { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> std::result::Result { + fn try_from(value: Vec>) -> std::result::Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value .into_iter() @@ -17,10 +17,10 @@ impl<'a, O: OffsetSizeTrait> TryFrom>>> for MultiP } } -impl<'a, O: OffsetSizeTrait> TryFrom>>> for MultiPointArray { +impl TryFrom>> for MultiPointArray { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> std::result::Result { + fn try_from(value: Vec>) -> std::result::Result { let mutable_arr: MultiPointBuilder = value.try_into()?; Ok(mutable_arr.into()) } diff --git a/src/io/geos/array/multipolygon.rs b/src/io/geos/array/multipolygon.rs index a5da4e4a..650f225f 100644 --- a/src/io/geos/array/multipolygon.rs +++ b/src/io/geos/array/multipolygon.rs @@ -4,10 +4,10 @@ use crate::array::{MultiPolygonArray, MultiPolygonBuilder}; use crate::error::{GeoArrowError, Result}; use crate::io::geos::scalar::GEOSMultiPolygon; -impl TryFrom>>> for MultiPolygonBuilder { +impl TryFrom>> for MultiPolygonBuilder { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> Result { + fn try_from(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value .into_iter() @@ -17,10 +17,10 @@ impl TryFrom>>> for MultiPolyg } } -impl TryFrom>>> for MultiPolygonArray { +impl TryFrom>> for MultiPolygonArray { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> Result { + fn try_from(value: Vec>) -> Result { let mutable_arr: MultiPolygonBuilder = value.try_into()?; Ok(mutable_arr.into()) } diff --git a/src/io/geos/array/point.rs b/src/io/geos/array/point.rs index dd0a1cfc..ddba9db2 100644 --- a/src/io/geos/array/point.rs +++ b/src/io/geos/array/point.rs @@ -2,10 +2,10 @@ use crate::array::{PointArray, PointBuilder}; use crate::error::GeoArrowError; use crate::io::geos::scalar::GEOSPoint; -impl<'a> TryFrom>>> for PointBuilder { +impl TryFrom>> for PointBuilder { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> std::result::Result { + fn try_from(value: Vec>) -> std::result::Result { // TODO: don't use new_unchecked let geos_linestring_objects: Vec> = value .into_iter() @@ -15,33 +15,29 @@ impl<'a> TryFrom>>> for PointBuilder { } } -impl<'a> TryFrom>>> for PointArray { +impl TryFrom>> for PointArray { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> std::result::Result { + fn try_from(value: Vec>) -> std::result::Result { let mutable_arr: PointBuilder = value.try_into()?; Ok(mutable_arr.into()) } } -#[allow(unused_imports)] #[cfg(test)] mod test { use super::*; use crate::test::point::point_array; use crate::trait_::{GeometryArrayAccessor, GeometryScalarTrait}; - #[ignore = "geos lifetime error"] #[test] fn geos_round_trip() { - let _arr = point_array(); - todo!() - - // let geos_geoms: Vec> = arr - // .iter() - // .map(|opt_x| opt_x.map(|x| x.to_geos().unwrap())) - // .collect(); - // let round_trip: PointArray = geos_geoms.try_into().unwrap(); - // assert_eq!(arr, round_trip); + let arr = point_array(); + let geos_geoms: Vec> = arr + .iter() + .map(|opt_x| opt_x.map(|x| x.to_geos().unwrap())) + .collect(); + let round_trip: PointArray = geos_geoms.try_into().unwrap(); + assert_eq!(arr, round_trip); } } diff --git a/src/io/geos/array/polygon.rs b/src/io/geos/array/polygon.rs index 05a30cbe..29f76a26 100644 --- a/src/io/geos/array/polygon.rs +++ b/src/io/geos/array/polygon.rs @@ -5,10 +5,10 @@ use crate::array::{PolygonArray, PolygonBuilder}; use crate::error::{GeoArrowError, Result}; use crate::io::geos::scalar::GEOSPolygon; -impl TryFrom>>> for PolygonBuilder { +impl TryFrom>> for PolygonBuilder { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> Result { + fn try_from(value: Vec>) -> Result { // TODO: don't use new_unchecked let geos_objects: Vec> = value .into_iter() @@ -19,21 +19,21 @@ impl TryFrom>>> for PolygonBui } } -impl TryFrom>>> for PolygonArray { +impl TryFrom>> for PolygonArray { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> Result { + fn try_from(value: Vec>) -> Result { let mutable_arr: PolygonBuilder = value.try_into()?; Ok(mutable_arr.into()) } } -impl<'a, O: OffsetSizeTrait> TryFrom>>> +impl<'a, O: OffsetSizeTrait> TryFrom>> for PolygonBuilder { type Error = GeoArrowError; - fn try_from(value: bumpalo::collections::Vec<'a, Option>>) -> Result { + fn try_from(value: bumpalo::collections::Vec<'a, Option>) -> Result { let bump = bumpalo::Bump::new(); // TODO: avoid creating GEOSPolygon objects at all? @@ -47,12 +47,12 @@ impl<'a, O: OffsetSizeTrait> TryFrom TryFrom>>> +impl<'a, O: OffsetSizeTrait> TryFrom>> for PolygonArray { type Error = GeoArrowError; - fn try_from(value: bumpalo::collections::Vec<'a, Option>>) -> Result { + fn try_from(value: bumpalo::collections::Vec<'a, Option>) -> Result { let mutable_arr: PolygonBuilder = value.try_into()?; Ok(mutable_arr.into()) } diff --git a/src/io/geos/scalar/binary.rs b/src/io/geos/scalar/binary.rs index 15e16abd..63da9cae 100644 --- a/src/io/geos/scalar/binary.rs +++ b/src/io/geos/scalar/binary.rs @@ -1,18 +1,18 @@ use crate::scalar::WKB; use arrow_array::OffsetSizeTrait; -impl<'b, O: OffsetSizeTrait> TryFrom> for geos::Geometry<'b> { +impl TryFrom> for geos::Geometry { type Error = geos::Error; - fn try_from(value: WKB<'_, O>) -> std::result::Result, geos::Error> { + fn try_from(value: WKB<'_, O>) -> std::result::Result { geos::Geometry::try_from(&value) } } -impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a WKB<'_, O>> for geos::Geometry<'b> { +impl<'a, O: OffsetSizeTrait> TryFrom<&'a WKB<'_, O>> for geos::Geometry { type Error = geos::Error; - fn try_from(value: &'a WKB<'_, O>) -> std::result::Result, geos::Error> { + fn try_from(value: &'a WKB<'_, O>) -> std::result::Result { geos::Geometry::new_from_wkb(value.arr.value(value.geom_index)) } } diff --git a/src/io/geos/scalar/coord/combined.rs b/src/io/geos/scalar/coord/combined.rs index 4eda504a..c76a905c 100644 --- a/src/io/geos/scalar/coord/combined.rs +++ b/src/io/geos/scalar/coord/combined.rs @@ -1,7 +1,7 @@ use crate::array::CoordBuffer; use geos::CoordSeq; -impl TryFrom for CoordSeq<'_> { +impl TryFrom for CoordSeq { type Error = geos::Error; fn try_from(value: CoordBuffer) -> std::result::Result { diff --git a/src/io/geos/scalar/coord/interleaved.rs b/src/io/geos/scalar/coord/interleaved.rs index 652481c9..933f4793 100644 --- a/src/io/geos/scalar/coord/interleaved.rs +++ b/src/io/geos/scalar/coord/interleaved.rs @@ -2,7 +2,7 @@ use crate::array::InterleavedCoordBuffer; use crate::GeometryArrayTrait; use geos::CoordSeq; -impl TryFrom for CoordSeq<'_> { +impl TryFrom for CoordSeq { type Error = geos::Error; fn try_from(value: InterleavedCoordBuffer) -> std::result::Result { diff --git a/src/io/geos/scalar/coord/mod.rs b/src/io/geos/scalar/coord/mod.rs index 3381cf6a..d7941a50 100644 --- a/src/io/geos/scalar/coord/mod.rs +++ b/src/io/geos/scalar/coord/mod.rs @@ -5,12 +5,12 @@ mod interleaved; mod separated; #[derive(Clone)] -pub struct GEOSConstCoord<'a> { - pub(crate) coords: geos::CoordSeq<'a>, +pub struct GEOSConstCoord { + pub(crate) coords: geos::CoordSeq, pub(crate) geom_index: usize, } -impl<'a> CoordTrait for GEOSConstCoord<'a> { +impl CoordTrait for GEOSConstCoord { type T = f64; fn x(&self) -> Self::T { diff --git a/src/io/geos/scalar/coord/separated.rs b/src/io/geos/scalar/coord/separated.rs index 56cf487d..b4814f4b 100644 --- a/src/io/geos/scalar/coord/separated.rs +++ b/src/io/geos/scalar/coord/separated.rs @@ -1,7 +1,7 @@ use crate::array::SeparatedCoordBuffer; use geos::CoordSeq; -impl TryFrom for CoordSeq<'_> { +impl TryFrom for CoordSeq { type Error = geos::Error; fn try_from(value: SeparatedCoordBuffer) -> std::result::Result { diff --git a/src/io/geos/scalar/geometry.rs b/src/io/geos/scalar/geometry.rs index 1ccc5f0a..892bda95 100644 --- a/src/io/geos/scalar/geometry.rs +++ b/src/io/geos/scalar/geometry.rs @@ -1,20 +1,18 @@ use crate::scalar::Geometry; use arrow_array::OffsetSizeTrait; -impl<'b, O: OffsetSizeTrait> TryFrom> for geos::Geometry<'b> { +impl TryFrom> for geos::Geometry { type Error = geos::Error; - fn try_from(value: Geometry<'_, O>) -> std::result::Result, geos::Error> { + fn try_from(value: Geometry<'_, O>) -> std::result::Result { geos::Geometry::try_from(&value) } } -impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a Geometry<'_, O>> for geos::Geometry<'b> { +impl<'a, O: OffsetSizeTrait> TryFrom<&'a Geometry<'_, O>> for geos::Geometry { type Error = geos::Error; - fn try_from( - value: &'a Geometry<'_, O>, - ) -> std::result::Result, geos::Error> { + fn try_from(value: &'a Geometry<'_, O>) -> std::result::Result { match value { Geometry::Point(g) => g.try_into(), Geometry::LineString(g) => g.try_into(), diff --git a/src/io/geos/scalar/geometrycollection.rs b/src/io/geos/scalar/geometrycollection.rs index c50de1fd..624d1cde 100644 --- a/src/io/geos/scalar/geometrycollection.rs +++ b/src/io/geos/scalar/geometrycollection.rs @@ -2,22 +2,22 @@ use crate::geo_traits::GeometryCollectionTrait; use crate::scalar::GeometryCollection; use arrow_array::OffsetSizeTrait; -impl<'b, O: OffsetSizeTrait> TryFrom> for geos::Geometry<'b> { +impl TryFrom> for geos::Geometry { type Error = geos::Error; fn try_from( value: GeometryCollection<'_, O>, - ) -> std::result::Result, geos::Error> { + ) -> std::result::Result { geos::Geometry::try_from(&value) } } -impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a GeometryCollection<'_, O>> for geos::Geometry<'b> { +impl<'a, O: OffsetSizeTrait> TryFrom<&'a GeometryCollection<'_, O>> for geos::Geometry { type Error = geos::Error; fn try_from( value: &'a GeometryCollection<'_, O>, - ) -> std::result::Result, geos::Error> { + ) -> std::result::Result { geos::Geometry::create_geometry_collection( value .geometries() diff --git a/src/io/geos/scalar/linearring.rs b/src/io/geos/scalar/linearring.rs index ae0f1632..0777d57b 100644 --- a/src/io/geos/scalar/linearring.rs +++ b/src/io/geos/scalar/linearring.rs @@ -3,15 +3,15 @@ use crate::geo_traits::LineStringTrait; use crate::io::geos::scalar::coord::GEOSConstCoord; use geos::{Geom, GeometryTypes}; -pub struct GEOSConstLinearRing<'a, 'b>(pub(crate) geos::ConstGeometry<'a, 'b>); +pub struct GEOSConstLinearRing<'a>(pub(crate) geos::ConstGeometry<'a>); -impl<'a, 'b> GEOSConstLinearRing<'a, 'b> { - pub fn new_unchecked(geom: geos::ConstGeometry<'a, 'b>) -> Self { +impl<'a> GEOSConstLinearRing<'a> { + pub fn new_unchecked(geom: geos::ConstGeometry<'a>) -> Self { Self(geom) } #[allow(dead_code)] - pub fn try_new(geom: geos::ConstGeometry<'a, 'b>) -> Result { + pub fn try_new(geom: geos::ConstGeometry<'a>) -> Result { if matches!(geom.geometry_type(), GeometryTypes::LinearRing) { Ok(Self(geom)) } else { @@ -22,9 +22,9 @@ impl<'a, 'b> GEOSConstLinearRing<'a, 'b> { } } -impl<'a, 'b> LineStringTrait for GEOSConstLinearRing<'a, 'b> { +impl<'a> LineStringTrait for GEOSConstLinearRing<'a> { type T = f64; - type ItemType<'c> = GEOSConstCoord<'a> where Self: 'c; + type ItemType<'c> = GEOSConstCoord where Self: 'c; fn num_coords(&self) -> usize { self.0.get_num_coordinates().unwrap() diff --git a/src/io/geos/scalar/linestring.rs b/src/io/geos/scalar/linestring.rs index 78893dd7..9ca11d62 100644 --- a/src/io/geos/scalar/linestring.rs +++ b/src/io/geos/scalar/linestring.rs @@ -7,21 +7,19 @@ use crate::trait_::GeometryArraySelfMethods; use arrow_array::OffsetSizeTrait; use geos::{Geom, GeometryTypes}; -impl<'b, O: OffsetSizeTrait> TryFrom> for geos::Geometry<'b> { +impl TryFrom> for geos::Geometry { type Error = geos::Error; - fn try_from(value: LineString<'_, O>) -> std::result::Result, geos::Error> { + fn try_from(value: LineString<'_, O>) -> std::result::Result { geos::Geometry::try_from(&value) } } // TODO: maybe this should use traits instead of a manual approach via coordbuffer? -impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a LineString<'_, O>> for geos::Geometry<'b> { +impl<'a, O: OffsetSizeTrait> TryFrom<&'a LineString<'_, O>> for geos::Geometry { type Error = geos::Error; - fn try_from( - value: &'a LineString<'_, O>, - ) -> std::result::Result, geos::Error> { + fn try_from(value: &'a LineString<'_, O>) -> std::result::Result { let (start, end) = value.geom_offsets.start_end(value.geom_index); let sliced_coords = value.coords.clone().to_mut().slice(start, end - start); @@ -30,8 +28,8 @@ impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a LineString<'_, O>> for geos::Geomet } } -impl<'b, O: OffsetSizeTrait> LineString<'_, O> { - pub fn to_geos_linear_ring(&self) -> std::result::Result, geos::Error> { +impl LineString<'_, O> { + pub fn to_geos_linear_ring(&self) -> std::result::Result { let (start, end) = self.geom_offsets.start_end(self.geom_index); let sliced_coords = self.coords.clone().to_mut().slice(start, end - start); @@ -41,13 +39,13 @@ impl<'b, O: OffsetSizeTrait> LineString<'_, O> { } #[derive(Clone)] -pub struct GEOSLineString<'a>(geos::Geometry<'a>); +pub struct GEOSLineString(geos::Geometry); -impl<'a> GEOSLineString<'a> { - pub fn new_unchecked(geom: geos::Geometry<'a>) -> Self { +impl GEOSLineString { + pub fn new_unchecked(geom: geos::Geometry) -> Self { Self(geom) } - pub fn try_new(geom: geos::Geometry<'a>) -> Result { + pub fn try_new(geom: geos::Geometry) -> Result { if matches!(geom.geometry_type(), GeometryTypes::LineString) { Ok(Self(geom)) } else { @@ -58,9 +56,9 @@ impl<'a> GEOSLineString<'a> { } } -impl<'a> LineStringTrait for GEOSLineString<'a> { +impl LineStringTrait for GEOSLineString { type T = f64; - type ItemType<'b> = GEOSPoint<'a> where Self: 'b; + type ItemType<'b> = GEOSPoint where Self: 'b; fn num_coords(&self) -> usize { self.0.get_num_points().unwrap() @@ -72,9 +70,9 @@ impl<'a> LineStringTrait for GEOSLineString<'a> { } } -impl<'a> LineStringTrait for &'a GEOSLineString<'a> { +impl LineStringTrait for &GEOSLineString { type T = f64; - type ItemType<'b> = GEOSPoint<'a> where Self: 'b; + type ItemType<'b> = GEOSPoint where Self: 'b; fn num_coords(&self) -> usize { self.0.get_num_points().unwrap() @@ -86,15 +84,15 @@ impl<'a> LineStringTrait for &'a GEOSLineString<'a> { } } -pub struct GEOSConstLineString<'a, 'b>(geos::ConstGeometry<'a, 'b>); +pub struct GEOSConstLineString<'a>(geos::ConstGeometry<'a>); -impl<'a, 'b> GEOSConstLineString<'a, 'b> { - pub fn new_unchecked(geom: geos::ConstGeometry<'a, 'b>) -> Self { +impl<'a> GEOSConstLineString<'a> { + pub fn new_unchecked(geom: geos::ConstGeometry<'a>) -> Self { Self(geom) } #[allow(dead_code)] - pub fn try_new(geom: geos::ConstGeometry<'a, 'b>) -> Result { + pub fn try_new(geom: geos::ConstGeometry<'a>) -> Result { if matches!(geom.geometry_type(), GeometryTypes::LineString) { Ok(Self(geom)) } else { @@ -105,9 +103,9 @@ impl<'a, 'b> GEOSConstLineString<'a, 'b> { } } -impl<'a, 'b> LineStringTrait for GEOSConstLineString<'a, 'b> { +impl<'a> LineStringTrait for GEOSConstLineString<'a> { type T = f64; - type ItemType<'c> = GEOSPoint<'a> where Self: 'c; + type ItemType<'c> = GEOSPoint where Self: 'c; fn num_coords(&self) -> usize { self.0.get_num_points().unwrap() @@ -119,9 +117,9 @@ impl<'a, 'b> LineStringTrait for GEOSConstLineString<'a, 'b> { } } -impl<'a, 'b> LineStringTrait for &'a GEOSConstLineString<'a, 'b> { +impl<'a> LineStringTrait for &'a GEOSConstLineString<'a> { type T = f64; - type ItemType<'c> = GEOSPoint<'a> where Self: 'c; + type ItemType<'c> = GEOSPoint where Self: 'c; fn num_coords(&self) -> usize { self.0.get_num_points().unwrap() diff --git a/src/io/geos/scalar/multilinestring.rs b/src/io/geos/scalar/multilinestring.rs index 2cefde20..61029472 100644 --- a/src/io/geos/scalar/multilinestring.rs +++ b/src/io/geos/scalar/multilinestring.rs @@ -5,22 +5,20 @@ use crate::scalar::MultiLineString; use arrow_array::OffsetSizeTrait; use geos::{Geom, GeometryTypes}; -impl<'b, O: OffsetSizeTrait> TryFrom> for geos::Geometry<'b> { +impl TryFrom> for geos::Geometry { type Error = geos::Error; - fn try_from( - value: MultiLineString<'_, O>, - ) -> std::result::Result, geos::Error> { + fn try_from(value: MultiLineString<'_, O>) -> std::result::Result { geos::Geometry::try_from(&value) } } -impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a MultiLineString<'_, O>> for geos::Geometry<'b> { +impl<'a, O: OffsetSizeTrait> TryFrom<&'a MultiLineString<'_, O>> for geos::Geometry { type Error = geos::Error; fn try_from( value: &'a MultiLineString<'_, O>, - ) -> std::result::Result, geos::Error> { + ) -> std::result::Result { geos::Geometry::create_multiline_string( value .lines() @@ -31,15 +29,15 @@ impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a MultiLineString<'_, O>> for geos::G } /// A GEOS geometry known to be a MultiLineString #[derive(Clone)] -pub struct GEOSMultiLineString<'a>(pub(crate) geos::Geometry<'a>); +pub struct GEOSMultiLineString(pub(crate) geos::Geometry); -impl<'a> GEOSMultiLineString<'a> { - pub fn new_unchecked(geom: geos::Geometry<'a>) -> Self { +impl GEOSMultiLineString { + pub fn new_unchecked(geom: geos::Geometry) -> Self { Self(geom) } #[allow(dead_code)] - pub fn try_new(geom: geos::Geometry<'a>) -> Result { + pub fn try_new(geom: geos::Geometry) -> Result { if matches!(geom.geometry_type(), GeometryTypes::MultiLineString) { Ok(Self(geom)) } else { @@ -54,7 +52,7 @@ impl<'a> GEOSMultiLineString<'a> { } #[allow(dead_code)] - pub fn line(&'a self, i: usize) -> Option> { + pub fn line(&self, i: usize) -> Option> { if i > (self.num_lines()) { return None; } @@ -65,9 +63,9 @@ impl<'a> GEOSMultiLineString<'a> { } } -impl<'a> MultiLineStringTrait for GEOSMultiLineString<'a> { +impl MultiLineStringTrait for GEOSMultiLineString { type T = f64; - type ItemType<'c> = GEOSConstLineString<'a, 'c> where Self: 'c; + type ItemType<'a> = GEOSConstLineString<'a> where Self: 'a; fn num_lines(&self) -> usize { self.0.get_num_geometries().unwrap() diff --git a/src/io/geos/scalar/multipoint.rs b/src/io/geos/scalar/multipoint.rs index aa828ee0..30b22dca 100644 --- a/src/io/geos/scalar/multipoint.rs +++ b/src/io/geos/scalar/multipoint.rs @@ -5,20 +5,18 @@ use crate::scalar::MultiPoint; use arrow_array::OffsetSizeTrait; use geos::{Geom, GeometryTypes}; -impl<'b, O: OffsetSizeTrait> TryFrom> for geos::Geometry<'b> { +impl TryFrom> for geos::Geometry { type Error = geos::Error; - fn try_from(value: MultiPoint<'_, O>) -> std::result::Result, geos::Error> { + fn try_from(value: MultiPoint<'_, O>) -> std::result::Result { geos::Geometry::try_from(&value) } } -impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a MultiPoint<'_, O>> for geos::Geometry<'b> { +impl<'a, O: OffsetSizeTrait> TryFrom<&'a MultiPoint<'_, O>> for geos::Geometry { type Error = geos::Error; - fn try_from( - value: &'a MultiPoint<'_, O>, - ) -> std::result::Result, geos::Error> { + fn try_from(value: &'a MultiPoint<'_, O>) -> std::result::Result { geos::Geometry::create_multipoint( value .points() @@ -29,15 +27,15 @@ impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a MultiPoint<'_, O>> for geos::Geomet } #[derive(Clone)] -pub struct GEOSMultiPoint<'a>(pub(crate) geos::Geometry<'a>); +pub struct GEOSMultiPoint(pub(crate) geos::Geometry); -impl<'a> GEOSMultiPoint<'a> { - pub fn new_unchecked(geom: geos::Geometry<'a>) -> Self { +impl GEOSMultiPoint { + pub fn new_unchecked(geom: geos::Geometry) -> Self { Self(geom) } #[allow(dead_code)] - pub fn try_new(geom: geos::Geometry<'a>) -> Result { + pub fn try_new(geom: geos::Geometry) -> Result { if matches!(geom.geometry_type(), GeometryTypes::MultiPoint) { Ok(Self(geom)) } else { @@ -52,9 +50,9 @@ impl<'a> GEOSMultiPoint<'a> { } } -impl<'a> MultiPointTrait for GEOSMultiPoint<'a> { +impl MultiPointTrait for GEOSMultiPoint { type T = f64; - type ItemType<'c> = GEOSConstPoint<'a, 'c> where Self: 'c; + type ItemType<'a> = GEOSConstPoint<'a> where Self: 'a; fn num_points(&self) -> usize { self.0.get_num_geometries().unwrap() @@ -66,9 +64,9 @@ impl<'a> MultiPointTrait for GEOSMultiPoint<'a> { } } -impl<'a> MultiPointTrait for &GEOSMultiPoint<'a> { +impl MultiPointTrait for &GEOSMultiPoint { type T = f64; - type ItemType<'c> = GEOSConstPoint<'a, 'c> where Self: 'c; + type ItemType<'a> = GEOSConstPoint<'a> where Self: 'a; fn num_points(&self) -> usize { self.0.get_num_geometries().unwrap() diff --git a/src/io/geos/scalar/multipolygon.rs b/src/io/geos/scalar/multipolygon.rs index 369cda8a..5efeca78 100644 --- a/src/io/geos/scalar/multipolygon.rs +++ b/src/io/geos/scalar/multipolygon.rs @@ -5,22 +5,20 @@ use crate::scalar::MultiPolygon; use arrow_array::OffsetSizeTrait; use geos::{Geom, GeometryTypes}; -impl<'b, O: OffsetSizeTrait> TryFrom> for geos::Geometry<'b> { +impl TryFrom> for geos::Geometry { type Error = geos::Error; - fn try_from( - value: MultiPolygon<'_, O>, - ) -> std::result::Result, geos::Error> { + fn try_from(value: MultiPolygon<'_, O>) -> std::result::Result { geos::Geometry::try_from(&value) } } -impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a MultiPolygon<'_, O>> for geos::Geometry<'b> { +impl<'a, O: OffsetSizeTrait> TryFrom<&'a MultiPolygon<'_, O>> for geos::Geometry { type Error = geos::Error; fn try_from( value: &'a MultiPolygon<'_, O>, - ) -> std::result::Result, geos::Error> { + ) -> std::result::Result { geos::Geometry::create_multipolygon( value .polygons() @@ -31,15 +29,15 @@ impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a MultiPolygon<'_, O>> for geos::Geom } #[derive(Clone)] -pub struct GEOSMultiPolygon<'a>(pub(crate) geos::Geometry<'a>); +pub struct GEOSMultiPolygon(pub(crate) geos::Geometry); -impl<'a> GEOSMultiPolygon<'a> { - pub fn new_unchecked(geom: geos::Geometry<'a>) -> Self { +impl GEOSMultiPolygon { + pub fn new_unchecked(geom: geos::Geometry) -> Self { Self(geom) } #[allow(dead_code)] - pub fn try_new(geom: geos::Geometry<'a>) -> Result { + pub fn try_new(geom: geos::Geometry) -> Result { if matches!(geom.geometry_type(), GeometryTypes::MultiPolygon) { Ok(Self(geom)) } else { @@ -50,9 +48,9 @@ impl<'a> GEOSMultiPolygon<'a> { } } -impl<'a> MultiPolygonTrait for GEOSMultiPolygon<'a> { +impl MultiPolygonTrait for GEOSMultiPolygon { type T = f64; - type ItemType<'c> = GEOSConstPolygon<'a, 'c> where Self: 'c; + type ItemType<'a> = GEOSConstPolygon<'a> where Self: 'a; fn num_polygons(&self) -> usize { self.0.get_num_geometries().unwrap() diff --git a/src/io/geos/scalar/point.rs b/src/io/geos/scalar/point.rs index 14623d1c..6c6d2962 100644 --- a/src/io/geos/scalar/point.rs +++ b/src/io/geos/scalar/point.rs @@ -3,18 +3,18 @@ use crate::geo_traits::{CoordTrait, PointTrait}; use crate::scalar::Point; use geos::{CoordDimensions, CoordSeq, Geom, GeometryTypes}; -impl<'b> TryFrom> for geos::Geometry<'b> { +impl TryFrom> for geos::Geometry { type Error = geos::Error; - fn try_from(value: Point<'_>) -> std::result::Result, geos::Error> { + fn try_from(value: Point<'_>) -> std::result::Result { geos::Geometry::try_from(&value) } } -impl<'a, 'b> TryFrom<&'a Point<'_>> for geos::Geometry<'b> { +impl<'a> TryFrom<&'a Point<'_>> for geos::Geometry { type Error = geos::Error; - fn try_from(value: &'a Point<'_>) -> std::result::Result, geos::Error> { + fn try_from(value: &'a Point<'_>) -> std::result::Result { let mut coord_seq = CoordSeq::new(1, CoordDimensions::TwoD)?; coord_seq.set_x(0, PointTrait::x(&value))?; coord_seq.set_y(0, PointTrait::y(&value))?; @@ -24,14 +24,14 @@ impl<'a, 'b> TryFrom<&'a Point<'_>> for geos::Geometry<'b> { } #[derive(Clone)] -pub struct GEOSPoint<'a>(geos::Geometry<'a>); +pub struct GEOSPoint(geos::Geometry); -impl<'a> GEOSPoint<'a> { - pub fn new_unchecked(geom: geos::Geometry<'a>) -> Self { +impl GEOSPoint { + pub fn new_unchecked(geom: geos::Geometry) -> Self { Self(geom) } - pub fn try_new(geom: geos::Geometry<'a>) -> Result { + pub fn try_new(geom: geos::Geometry) -> Result { if matches!(geom.geometry_type(), GeometryTypes::Point) { Ok(Self(geom)) } else { @@ -42,7 +42,7 @@ impl<'a> GEOSPoint<'a> { } } -impl<'a> PointTrait for GEOSPoint<'a> { +impl PointTrait for GEOSPoint { type T = f64; fn x(&self) -> Self::T { @@ -54,7 +54,7 @@ impl<'a> PointTrait for GEOSPoint<'a> { } } -impl<'a> PointTrait for &GEOSPoint<'a> { +impl PointTrait for &GEOSPoint { type T = f64; fn x(&self) -> Self::T { @@ -66,7 +66,7 @@ impl<'a> PointTrait for &GEOSPoint<'a> { } } -impl<'a> CoordTrait for GEOSPoint<'a> { +impl CoordTrait for GEOSPoint { type T = f64; fn x(&self) -> Self::T { @@ -78,7 +78,7 @@ impl<'a> CoordTrait for GEOSPoint<'a> { } } -impl<'a> CoordTrait for &GEOSPoint<'a> { +impl CoordTrait for &GEOSPoint { type T = f64; fn x(&self) -> Self::T { @@ -90,14 +90,14 @@ impl<'a> CoordTrait for &GEOSPoint<'a> { } } -pub struct GEOSConstPoint<'a, 'b>(geos::ConstGeometry<'a, 'b>); +pub struct GEOSConstPoint<'a>(geos::ConstGeometry<'a>); -impl<'a, 'b> GEOSConstPoint<'a, 'b> { - pub fn new_unchecked(geom: geos::ConstGeometry<'a, 'b>) -> Self { +impl<'a> GEOSConstPoint<'a> { + pub fn new_unchecked(geom: geos::ConstGeometry<'a>) -> Self { Self(geom) } - pub fn try_new(geom: geos::ConstGeometry<'a, 'b>) -> Result { + pub fn try_new(geom: geos::ConstGeometry<'a>) -> Result { if matches!(geom.geometry_type(), GeometryTypes::Point) { Ok(Self(geom)) } else { @@ -108,7 +108,7 @@ impl<'a, 'b> GEOSConstPoint<'a, 'b> { } } -impl<'a, 'b> PointTrait for GEOSConstPoint<'a, 'b> { +impl<'a> PointTrait for GEOSConstPoint<'a> { type T = f64; fn x(&self) -> Self::T { @@ -120,7 +120,7 @@ impl<'a, 'b> PointTrait for GEOSConstPoint<'a, 'b> { } } -impl<'a, 'b> PointTrait for &GEOSConstPoint<'a, 'b> { +impl<'a> PointTrait for &GEOSConstPoint<'a> { type T = f64; fn x(&self) -> Self::T { @@ -132,7 +132,7 @@ impl<'a, 'b> PointTrait for &GEOSConstPoint<'a, 'b> { } } -impl<'a, 'b> CoordTrait for GEOSConstPoint<'a, 'b> { +impl<'a> CoordTrait for GEOSConstPoint<'a> { type T = f64; fn x(&self) -> Self::T { @@ -144,7 +144,7 @@ impl<'a, 'b> CoordTrait for GEOSConstPoint<'a, 'b> { } } -impl<'a, 'b> CoordTrait for &GEOSConstPoint<'a, 'b> { +impl<'a> CoordTrait for &GEOSConstPoint<'a> { type T = f64; fn x(&self) -> Self::T { @@ -156,7 +156,7 @@ impl<'a, 'b> CoordTrait for &GEOSConstPoint<'a, 'b> { } } -impl Clone for GEOSConstPoint<'_, '_> { +impl Clone for GEOSConstPoint<'_> { fn clone(&self) -> Self { todo!() } diff --git a/src/io/geos/scalar/polygon.rs b/src/io/geos/scalar/polygon.rs index 7b0e29ef..23381a0f 100644 --- a/src/io/geos/scalar/polygon.rs +++ b/src/io/geos/scalar/polygon.rs @@ -5,18 +5,18 @@ use crate::scalar::Polygon; use arrow_array::OffsetSizeTrait; use geos::{Geom, GeometryTypes}; -impl<'b, O: OffsetSizeTrait> TryFrom> for geos::Geometry<'b> { +impl TryFrom> for geos::Geometry { type Error = geos::Error; - fn try_from(value: Polygon<'_, O>) -> std::result::Result, geos::Error> { + fn try_from(value: Polygon<'_, O>) -> std::result::Result { geos::Geometry::try_from(&value) } } -impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a Polygon<'_, O>> for geos::Geometry<'b> { +impl<'a, O: OffsetSizeTrait> TryFrom<&'a Polygon<'_, O>> for geos::Geometry { type Error = geos::Error; - fn try_from(value: &'a Polygon<'_, O>) -> std::result::Result, geos::Error> { + fn try_from(value: &'a Polygon<'_, O>) -> std::result::Result { if let Some(exterior) = value.exterior() { let exterior = exterior.to_geos_linear_ring()?; let interiors = value @@ -31,15 +31,15 @@ impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a Polygon<'_, O>> for geos::Geometry< } #[derive(Clone)] -pub struct GEOSPolygon<'a>(pub(crate) geos::Geometry<'a>); +pub struct GEOSPolygon(pub(crate) geos::Geometry); -impl<'a> GEOSPolygon<'a> { - pub fn new_unchecked(geom: geos::Geometry<'a>) -> Self { +impl GEOSPolygon { + pub fn new_unchecked(geom: geos::Geometry) -> Self { Self(geom) } #[allow(dead_code)] - pub fn try_new(geom: geos::Geometry<'a>) -> Result { + pub fn try_new(geom: geos::Geometry) -> Result { if matches!(geom.geometry_type(), GeometryTypes::Polygon) { Ok(Self(geom)) } else { @@ -56,7 +56,7 @@ impl<'a> GEOSPolygon<'a> { } #[allow(dead_code)] - pub fn exterior(&self) -> Option> { + pub fn exterior(&self) -> Option> { if self.0.is_empty().unwrap() { return None; } @@ -67,7 +67,7 @@ impl<'a> GEOSPolygon<'a> { } #[allow(dead_code)] - pub fn interior(&self, i: usize) -> Option> { + pub fn interior(&self, i: usize) -> Option> { if i > self.num_interiors() { return None; } @@ -78,9 +78,9 @@ impl<'a> GEOSPolygon<'a> { } } -impl<'a> PolygonTrait for GEOSPolygon<'a> { +impl PolygonTrait for GEOSPolygon { type T = f64; - type ItemType<'c> = GEOSConstLinearRing<'a, 'c> where Self: 'c; + type ItemType<'a> = GEOSConstLinearRing<'a> where Self: 'a; fn num_interiors(&self) -> usize { self.0.get_num_interior_rings().unwrap() @@ -103,15 +103,15 @@ impl<'a> PolygonTrait for GEOSPolygon<'a> { } } -pub struct GEOSConstPolygon<'a, 'b>(pub(crate) geos::ConstGeometry<'a, 'b>); +pub struct GEOSConstPolygon<'a>(pub(crate) geos::ConstGeometry<'a>); -impl<'a, 'b> GEOSConstPolygon<'a, 'b> { - pub fn new_unchecked(geom: geos::ConstGeometry<'a, 'b>) -> Self { +impl<'a> GEOSConstPolygon<'a> { + pub fn new_unchecked(geom: geos::ConstGeometry<'a>) -> Self { Self(geom) } #[allow(dead_code)] - pub fn try_new(geom: geos::ConstGeometry<'a, 'b>) -> Result { + pub fn try_new(geom: geos::ConstGeometry<'a>) -> Result { if matches!(geom.geometry_type(), GeometryTypes::Polygon) { Ok(Self(geom)) } else { @@ -122,9 +122,9 @@ impl<'a, 'b> GEOSConstPolygon<'a, 'b> { } } -impl<'a, 'b> PolygonTrait for GEOSConstPolygon<'a, 'b> { +impl<'a> PolygonTrait for GEOSConstPolygon<'a> { type T = f64; - type ItemType<'c> = GEOSConstLinearRing<'a, 'c> where Self: 'c; + type ItemType<'c> = GEOSConstLinearRing< 'c> where Self: 'c; fn num_interiors(&self) -> usize { self.0.get_num_interior_rings().unwrap()