diff --git a/Cargo.lock b/Cargo.lock index ba6db875..bf1cafa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -89,9 +89,9 @@ dependencies = [ [[package]] name = "arrow" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edb738d83750ec705808f6d44046d165e6bb8623f64e29a4d53fcb136ab22dfb" +checksum = "a8919668503a4f2d8b6da96fa7c16e93046bfb3412ffcfa1e5dc7d2e3adcb378" dependencies = [ "ahash", "arrow-arith", @@ -111,9 +111,9 @@ dependencies = [ [[package]] name = "arrow-arith" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c5c3d17fc5b006e7beeaebfb1d2edfc92398b981f82d9744130437909b72a468" +checksum = "ef983914f477d4278b068f13b3224b7d19eb2b807ac9048544d3bfebdf2554c4" dependencies = [ "arrow-array", "arrow-buffer", @@ -126,9 +126,9 @@ dependencies = [ [[package]] name = "arrow-array" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55705ada5cdde4cb0f202ffa6aa756637e33fea30e13d8d0d0fd6a24ffcee1e3" +checksum = "d6eaf89041fa5937940ae390294ece29e1db584f46d995608d6e5fe65a2e0e9b" dependencies = [ "ahash", "arrow-buffer", @@ -142,9 +142,9 @@ dependencies = [ [[package]] name = "arrow-buffer" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a722f90a09b94f295ab7102542e97199d3500128843446ef63e410ad546c5333" +checksum = "55512d988c6fbd76e514fd3ff537ac50b0a675da5a245e4fdad77ecfd654205f" dependencies = [ "bytes", "half 2.3.1", @@ -153,9 +153,9 @@ dependencies = [ [[package]] name = "arrow-cast" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af01fc1a06f6f2baf31a04776156d47f9f31ca5939fe6d00cd7a059f95a46ff1" +checksum = "655ee51a2156ba5375931ce21c1b2494b1d9260e6dcdc6d4db9060c37dc3325b" dependencies = [ "arrow-array", "arrow-buffer", @@ -170,9 +170,9 @@ dependencies = [ [[package]] name = "arrow-csv" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "83cbbfde86f9ecd3f875c42a73d8aeab3d95149cd80129b18d09e039ecf5391b" +checksum = "258bb689997ad5b6660b3ce3638bd6b383d668ec555ed41ad7c6559cbb2e4f91" dependencies = [ "arrow-array", "arrow-buffer", @@ -189,9 +189,9 @@ dependencies = [ [[package]] name = "arrow-data" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0a547195e607e625e7fafa1a7269b8df1a4a612c919efd9b26bd86e74538f3a" +checksum = "6dc2b9fec74763427e2e5575b8cc31ce96ba4c9b4eb05ce40e0616d9fad12461" dependencies = [ "arrow-buffer", "arrow-schema", @@ -201,9 +201,9 @@ dependencies = [ [[package]] name = "arrow-ipc" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e36bf091502ab7e37775ff448413ef1ffff28ff93789acb669fffdd51b394d51" +checksum = "6eaa6ab203cc6d89b7eaa1ac781c1dfeef325454c5d5a0419017f95e6bafc03c" dependencies = [ "arrow-array", "arrow-buffer", @@ -215,9 +215,9 @@ dependencies = [ [[package]] name = "arrow-json" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ac346bc84846ab425ab3c8c7b6721db90643bc218939677ed7e071ccbfb919d" +checksum = "fb64e30d9b73f66fdc5c52d5f4cf69bbf03d62f64ffeafa0715590a5320baed7" dependencies = [ "arrow-array", "arrow-buffer", @@ -235,9 +235,9 @@ dependencies = [ [[package]] name = "arrow-ord" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4502123d2397319f3a13688432bc678c61cb1582f2daa01253186da650bf5841" +checksum = "f9a818951c0d11c428dda03e908175969c262629dd20bd0850bd6c7a8c3bfe48" dependencies = [ "arrow-array", "arrow-buffer", @@ -250,9 +250,9 @@ dependencies = [ [[package]] name = "arrow-row" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "249fc5a07906ab3f3536a6e9f118ec2883fbcde398a97a5ba70053f0276abda4" +checksum = "a5d664318bc05f930559fc088888f0f7174d3c5bc888c0f4f9ae8f23aa398ba3" dependencies = [ "ahash", "arrow-array", @@ -265,18 +265,18 @@ dependencies = [ [[package]] name = "arrow-schema" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d7a8c3f97f5ef6abd862155a6f39aaba36b029322462d72bbcfa69782a50614" +checksum = "aaf4d737bba93da59f16129bec21e087aed0be84ff840e74146d4703879436cb" dependencies = [ "bitflags 2.4.0", ] [[package]] name = "arrow-select" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f868f4a5001429e20f7c1994b5cd1aa68b82e3db8cf96c559cdb56dc8be21410" +checksum = "374c4c3b812ecc2118727b892252a4a4308f87a8aca1dbf09f3ce4bc578e668a" dependencies = [ "ahash", "arrow-array", @@ -288,9 +288,9 @@ dependencies = [ [[package]] name = "arrow-string" -version = "48.0.0" +version = "48.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a27fdf8fc70040a2dee78af2e217479cb5b263bd7ab8711c7999e74056eb688a" +checksum = "b15aed5624bb23da09142f58502b59c23f5bea607393298bb81dab1ce60fc769" dependencies = [ "arrow-array", "arrow-buffer", diff --git a/src/algorithm/native/eq.rs b/src/algorithm/native/eq.rs index 8f7232df..0a6b7cf3 100644 --- a/src/algorithm/native/eq.rs +++ b/src/algorithm/native/eq.rs @@ -48,9 +48,9 @@ pub fn point_eq( } #[inline] -pub fn line_string_eq<'a, T: CoordFloat>( - left: impl LineStringTrait<'a, T = T>, - right: impl LineStringTrait<'a, T = T>, +pub fn line_string_eq( + left: impl LineStringTrait, + right: impl LineStringTrait, ) -> bool { if left.num_coords() != right.num_coords() { return false; @@ -68,9 +68,9 @@ pub fn line_string_eq<'a, T: CoordFloat>( } #[inline] -pub fn polygon_eq<'a, T: CoordFloat>( - left: impl PolygonTrait<'a, T = T>, - right: impl PolygonTrait<'a, T = T>, +pub fn polygon_eq( + left: impl PolygonTrait, + right: impl PolygonTrait, ) -> bool { if left.num_interiors() != right.num_interiors() { return false; @@ -101,9 +101,9 @@ pub fn polygon_eq<'a, T: CoordFloat>( } #[inline] -pub fn multi_point_eq<'a, T: CoordFloat>( - left: impl MultiPointTrait<'a, T = T>, - right: impl MultiPointTrait<'a, T = T>, +pub fn multi_point_eq( + left: impl MultiPointTrait, + right: impl MultiPointTrait, ) -> bool { if left.num_points() != right.num_points() { return false; @@ -121,9 +121,9 @@ pub fn multi_point_eq<'a, T: CoordFloat>( } #[inline] -pub fn multi_line_string_eq<'a, T: CoordFloat>( - left: impl MultiLineStringTrait<'a, T = T>, - right: impl MultiLineStringTrait<'a, T = T>, +pub fn multi_line_string_eq( + left: impl MultiLineStringTrait, + right: impl MultiLineStringTrait, ) -> bool { if left.num_lines() != right.num_lines() { return false; @@ -139,9 +139,9 @@ pub fn multi_line_string_eq<'a, T: CoordFloat>( } #[inline] -pub fn multi_polygon_eq<'a, T: CoordFloat>( - left: impl MultiPolygonTrait<'a, T = T>, - right: impl MultiPolygonTrait<'a, T = T>, +pub fn multi_polygon_eq( + left: impl MultiPolygonTrait, + right: impl MultiPolygonTrait, ) -> bool { if left.num_polygons() != right.num_polygons() { return false; diff --git a/src/array/binary/mutable.rs b/src/array/binary/mutable.rs index 60cffb0e..36d67e49 100644 --- a/src/array/binary/mutable.rs +++ b/src/array/binary/mutable.rs @@ -71,7 +71,7 @@ impl MutableWKBArray { /// /// It is expected to be considerably faster if you convert whole geometry arrays at a time. /// E.g. using the `From` implementation from LineStringArray. - pub fn push_line_string<'a>(&mut self, geom: impl LineStringTrait<'a, T = f64>) { + pub fn push_line_string(&mut self, geom: impl LineStringTrait) { // TODO: figure out how to write directly to the underlying vec without a copy let mut buf = Vec::with_capacity(line_string_wkb_size(&geom)); write_line_string_as_wkb(&mut buf, &geom).unwrap(); @@ -84,7 +84,7 @@ impl MutableWKBArray { /// /// It is expected to be considerably faster if you convert whole geometry arrays at a time. /// E.g. using the `From` implementation from PolygonArray. - pub fn push_polygon<'a>(&mut self, geom: impl PolygonTrait<'a, T = f64>) { + pub fn push_polygon(&mut self, geom: impl PolygonTrait) { // TODO: figure out how to write directly to the underlying vec without a copy let mut buf = Vec::with_capacity(polygon_wkb_size(&geom)); write_polygon_as_wkb(&mut buf, &geom).unwrap(); @@ -97,7 +97,7 @@ impl MutableWKBArray { /// /// It is expected to be considerably faster if you convert whole geometry arrays at a time. /// E.g. using the `From` implementation from MultiPointArray. - pub fn push_multi_point<'a>(&mut self, geom: impl MultiPointTrait<'a, T = f64>) { + pub fn push_multi_point(&mut self, geom: impl MultiPointTrait) { // TODO: figure out how to write directly to the underlying vec without a copy let mut buf = Vec::with_capacity(multi_point_wkb_size(&geom)); write_multi_point_as_wkb(&mut buf, &geom).unwrap(); @@ -110,7 +110,7 @@ impl MutableWKBArray { /// /// It is expected to be considerably faster if you convert whole geometry arrays at a time. /// E.g. using the `From` implementation from MultiLineStringArray. - pub fn push_multi_line_string<'a>(&mut self, geom: impl MultiLineStringTrait<'a, T = f64>) { + pub fn push_multi_line_string(&mut self, geom: impl MultiLineStringTrait) { // TODO: figure out how to write directly to the underlying vec without a copy let mut buf = Vec::with_capacity(multi_line_string_wkb_size(&geom)); write_multi_line_string_as_wkb(&mut buf, &geom).unwrap(); @@ -123,7 +123,7 @@ impl MutableWKBArray { /// /// It is expected to be considerably faster if you convert whole geometry arrays at a time. /// E.g. using the `From` implementation from MultiPolygonArray. - pub fn push_multi_polygon<'a>(&mut self, geom: impl MultiPolygonTrait<'a, T = f64>) { + pub fn push_multi_polygon(&mut self, geom: impl MultiPolygonTrait) { // TODO: figure out how to write directly to the underlying vec without a copy let mut buf = Vec::with_capacity(multi_polygon_wkb_size(&geom)); write_multi_polygon_as_wkb(&mut buf, &geom).unwrap(); diff --git a/src/array/linestring/mutable.rs b/src/array/linestring/mutable.rs index 5ee9d05f..410423d5 100644 --- a/src/array/linestring/mutable.rs +++ b/src/array/linestring/mutable.rs @@ -19,16 +19,16 @@ use std::sync::Arc; /// Converting a [`MutableLineStringArray`] into a [`LineStringArray`] is `O(1)`. #[derive(Debug)] pub struct MutableLineStringArray { - coords: MutableCoordBuffer, + pub(crate) coords: MutableCoordBuffer, /// Offsets into the coordinate array where each geometry starts - geom_offsets: OffsetsBuilder, + pub(crate) geom_offsets: OffsetsBuilder, /// Validity is only defined at the geometry level - validity: NullBufferBuilder, + pub(crate) validity: NullBufferBuilder, } -impl<'a, O: OffsetSizeTrait> MutableLineStringArray { +impl MutableLineStringArray { /// Creates a new empty [`MutableLineStringArray`]. pub fn new() -> Self { Self::with_capacities(0, 0) @@ -112,7 +112,7 @@ impl<'a, O: OffsetSizeTrait> MutableLineStringArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_line_string( &mut self, - value: Option<&impl LineStringTrait<'a, T = f64>>, + value: Option<&impl LineStringTrait>, ) -> Result<()> { if let Some(line_string) = value { let num_coords = line_string.num_coords(); @@ -148,7 +148,7 @@ impl<'a, O: OffsetSizeTrait> MutableLineStringArray { } #[inline] - fn push_null(&mut self) { + pub(crate) fn push_null(&mut self) { self.geom_offsets.extend_constant(1); self.validity.append(false); } @@ -186,8 +186,8 @@ impl From> for GenericListArray } } -pub(crate) fn first_pass<'a>( - geoms: impl Iterator>>, +pub(crate) fn first_pass( + geoms: impl Iterator>, geoms_length: usize, ) -> (usize, usize) { let mut coord_capacity = 0; @@ -200,8 +200,8 @@ pub(crate) fn first_pass<'a>( (coord_capacity, geom_capacity) } -pub(crate) fn second_pass<'a, O: OffsetSizeTrait>( - geoms: impl Iterator>>, +pub(crate) fn second_pass( + geoms: impl Iterator>>, coord_capacity: usize, geom_capacity: usize, ) -> MutableLineStringArray { diff --git a/src/array/mixed/mutable.rs b/src/array/mixed/mutable.rs index d6a2a935..98c4bbc0 100644 --- a/src/array/mixed/mutable.rs +++ b/src/array/mixed/mutable.rs @@ -196,7 +196,7 @@ impl<'a, O: OffsetSizeTrait> MutableMixedGeometryArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_line_string( &mut self, - value: Option<&impl LineStringTrait<'a, T = f64>>, + value: Option<&impl LineStringTrait>, ) -> Result<()> { self.offsets.push(self.line_string_counter); self.line_string_counter += 1; @@ -213,7 +213,7 @@ impl<'a, O: OffsetSizeTrait> MutableMixedGeometryArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_line_string_as_multi_line_string( &mut self, - value: Option<&impl LineStringTrait<'a, T = f64>>, + value: Option<&impl LineStringTrait>, ) -> Result<()> { self.offsets.push(self.multi_line_string_counter); self.multi_line_string_counter += 1; @@ -229,7 +229,7 @@ impl<'a, O: OffsetSizeTrait> MutableMixedGeometryArray { /// # Errors /// /// This function errors iff the new last item is larger than what O supports. - pub fn push_polygon(&mut self, value: Option<&impl PolygonTrait<'a, T = f64>>) -> Result<()> { + pub fn push_polygon(&mut self, value: Option<&impl PolygonTrait>) -> Result<()> { self.offsets.push(self.polygon_counter); self.polygon_counter += 1; @@ -245,7 +245,7 @@ impl<'a, O: OffsetSizeTrait> MutableMixedGeometryArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_polygon_as_multi_polygon( &mut self, - value: Option<&impl PolygonTrait<'a, T = f64>>, + value: Option<&impl PolygonTrait>, ) -> Result<()> { self.offsets.push(self.multi_polygon_counter); self.multi_polygon_counter += 1; @@ -262,7 +262,7 @@ impl<'a, O: OffsetSizeTrait> MutableMixedGeometryArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_multi_point( &mut self, - value: Option<&impl MultiPointTrait<'a, T = f64>>, + value: Option<&impl MultiPointTrait>, ) -> Result<()> { self.offsets.push(self.multi_point_counter); self.multi_point_counter += 1; @@ -278,7 +278,7 @@ impl<'a, O: OffsetSizeTrait> MutableMixedGeometryArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_multi_line_string( &mut self, - value: Option<&impl MultiLineStringTrait<'a, T = f64>>, + value: Option<&impl MultiLineStringTrait>, ) -> Result<()> { self.offsets.push(self.multi_line_string_counter); self.multi_line_string_counter += 1; @@ -295,7 +295,7 @@ impl<'a, O: OffsetSizeTrait> MutableMixedGeometryArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_multi_polygon( &mut self, - value: Option<&impl MultiPolygonTrait<'a, T = f64>>, + value: Option<&impl MultiPolygonTrait>, ) -> Result<()> { self.offsets.push(self.multi_polygon_counter); self.multi_polygon_counter += 1; @@ -305,7 +305,7 @@ impl<'a, O: OffsetSizeTrait> MutableMixedGeometryArray { self.multi_polygons.push_multi_polygon(value) } - pub fn push_geometry(&mut self, value: &'a impl GeometryTrait<'a, T = f64>) -> Result<()> { + pub fn push_geometry(&mut self, value: &'a impl GeometryTrait) -> Result<()> { match value.as_type() { crate::geo_traits::GeometryType::Point(g) => self.push_point(Some(g)), crate::geo_traits::GeometryType::LineString(g) => self.push_line_string(Some(g))?, @@ -355,7 +355,7 @@ impl From> for MixedGeometryArr // TODO: figure out these trait impl errors // fn from_geometry_trait_iterator<'a, O: OffsetSizeTrait>( -// geoms: impl Iterator + 'a>, +// geoms: impl Iterator + 'a>, // prefer_multi: bool // ) -> MutableMixedGeometryArray { // let mut array = MutableMixedGeometryArray::new(); diff --git a/src/array/multilinestring/mutable.rs b/src/array/multilinestring/mutable.rs index 71a0f97b..0b45c63b 100644 --- a/src/array/multilinestring/mutable.rs +++ b/src/array/multilinestring/mutable.rs @@ -36,7 +36,7 @@ pub type MultiLineStringInner = ( NullBufferBuilder, ); -impl<'a, O: OffsetSizeTrait> MutableMultiLineStringArray { +impl MutableMultiLineStringArray { /// Creates a new empty [`MutableMultiLineStringArray`]. pub fn new() -> Self { MutablePolygonArray::new().into() @@ -149,7 +149,7 @@ impl<'a, O: OffsetSizeTrait> MutableMultiLineStringArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_line_string( &mut self, - value: Option<&impl LineStringTrait<'a, T = f64>>, + value: Option<&impl LineStringTrait>, ) -> Result<()> { if let Some(line_string) = value { // Total number of linestrings in this multilinestring @@ -184,7 +184,7 @@ impl<'a, O: OffsetSizeTrait> MutableMultiLineStringArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_multi_line_string( &mut self, - value: Option<&impl MultiLineStringTrait<'a, T = f64>>, + value: Option<&impl MultiLineStringTrait>, ) -> Result<()> { if let Some(multi_line_string) = value { // Total number of linestrings in this multilinestring @@ -286,7 +286,7 @@ impl From> for MultiLineStrin } fn first_pass<'a>( - geoms: impl Iterator + 'a>>, + geoms: impl Iterator>, geoms_length: usize, ) -> (usize, usize, usize) { // Total number of coordinates @@ -310,7 +310,7 @@ fn first_pass<'a>( } fn second_pass<'a, O: OffsetSizeTrait>( - geoms: impl Iterator + 'a>>, + geoms: impl Iterator + 'a>>, coord_capacity: usize, ring_capacity: usize, geom_capacity: usize, diff --git a/src/array/multipoint/mutable.rs b/src/array/multipoint/mutable.rs index 40716e3a..78cddd5d 100644 --- a/src/array/multipoint/mutable.rs +++ b/src/array/multipoint/mutable.rs @@ -26,7 +26,7 @@ pub struct MutableMultiPointArray { validity: NullBufferBuilder, } -impl<'a, O: OffsetSizeTrait> MutableMultiPointArray { +impl MutableMultiPointArray { /// Creates a new empty [`MutableMultiPointArray`]. pub fn new() -> Self { Self::with_capacities(0, 0) @@ -130,7 +130,7 @@ impl<'a, O: OffsetSizeTrait> MutableMultiPointArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_multi_point( &mut self, - value: Option<&impl MultiPointTrait<'a, T = f64>>, + value: Option<&impl MultiPointTrait>, ) -> Result<()> { if let Some(multi_point) = value { let num_points = multi_point.num_points(); @@ -244,7 +244,7 @@ impl From> for GenericListArray } fn first_pass<'a>( - geoms: impl Iterator + 'a>>, + geoms: impl Iterator>, geoms_length: usize, ) -> (usize, usize) { let mut coord_capacity = 0; @@ -258,7 +258,7 @@ fn first_pass<'a>( } fn second_pass<'a, O: OffsetSizeTrait>( - geoms: impl Iterator + 'a>>, + geoms: impl Iterator + 'a>>, coord_capacity: usize, geom_capacity: usize, ) -> MutableMultiPointArray { diff --git a/src/array/multipolygon/mutable.rs b/src/array/multipolygon/mutable.rs index 9f0a85ed..b08665b3 100644 --- a/src/array/multipolygon/mutable.rs +++ b/src/array/multipolygon/mutable.rs @@ -41,7 +41,7 @@ pub struct MutableMultiPolygonArray { pub(crate) validity: NullBufferBuilder, } -impl<'a, O: OffsetSizeTrait> MutableMultiPolygonArray { +impl MutableMultiPolygonArray { /// Creates a new empty [`MutableMultiPolygonArray`]. pub fn new() -> Self { Self::with_capacities(0, 0, 0, 0) @@ -163,7 +163,7 @@ impl<'a, O: OffsetSizeTrait> MutableMultiPolygonArray { /// # Errors /// /// This function errors iff the new last item is larger than what O supports. - pub fn push_polygon(&mut self, value: Option<&impl PolygonTrait<'a, T = f64>>) -> Result<()> { + pub fn push_polygon(&mut self, value: Option<&impl PolygonTrait>) -> Result<()> { if let Some(polygon) = value { let exterior_ring = polygon.exterior(); if exterior_ring.is_none() { @@ -215,7 +215,7 @@ impl<'a, O: OffsetSizeTrait> MutableMultiPolygonArray { /// This function errors iff the new last item is larger than what O supports. pub fn push_multi_polygon( &mut self, - value: Option<&impl MultiPolygonTrait<'a, T = f64>>, + value: Option<&impl MultiPolygonTrait>, ) -> Result<()> { if let Some(multi_polygon) = value { // Total number of polygons in this MultiPolygon @@ -357,7 +357,7 @@ impl From> for MultiPolygonArray } fn first_pass<'a>( - geoms: impl Iterator + 'a>>, + geoms: impl Iterator>, geoms_length: usize, ) -> (usize, usize, usize, usize) { let mut coord_capacity = 0; @@ -397,7 +397,7 @@ fn first_pass<'a>( } fn second_pass<'a, O: OffsetSizeTrait>( - geoms: impl Iterator + 'a>>, + geoms: impl Iterator + 'a>>, coord_capacity: usize, ring_capacity: usize, polygon_capacity: usize, diff --git a/src/array/polygon/mutable.rs b/src/array/polygon/mutable.rs index 4bdabc44..b1d066a4 100644 --- a/src/array/polygon/mutable.rs +++ b/src/array/polygon/mutable.rs @@ -37,7 +37,7 @@ pub struct MutablePolygonArray { pub(crate) validity: NullBufferBuilder, } -impl<'a, O: OffsetSizeTrait> MutablePolygonArray { +impl MutablePolygonArray { /// Creates a new empty [`MutablePolygonArray`]. pub fn new() -> Self { Self::with_capacities(0, 0, 0) @@ -147,7 +147,7 @@ impl<'a, O: OffsetSizeTrait> MutablePolygonArray { /// # Errors /// /// This function errors iff the new last item is larger than what O supports. - pub fn push_polygon(&mut self, value: Option<&impl PolygonTrait<'a, T = f64>>) -> Result<()> { + pub fn push_polygon(&mut self, value: Option<&impl PolygonTrait>) -> Result<()> { if let Some(polygon) = value { let exterior_ring = polygon.exterior(); if exterior_ring.is_none() { @@ -267,7 +267,7 @@ impl From> for PolygonArray { } fn first_pass<'a>( - geoms: impl Iterator + 'a>>, + geoms: impl Iterator>, geoms_length: usize, ) -> (usize, usize, usize) { // Total number of coordinates @@ -296,7 +296,7 @@ fn first_pass<'a>( } fn second_pass<'a, O: OffsetSizeTrait>( - geoms: impl Iterator + 'a>>, + geoms: impl Iterator + 'a>>, coord_capacity: usize, ring_capacity: usize, geom_capacity: usize, diff --git a/src/array/rect/mutable.rs b/src/array/rect/mutable.rs index 2729c3c0..c8dc7e5e 100644 --- a/src/array/rect/mutable.rs +++ b/src/array/rect/mutable.rs @@ -81,7 +81,7 @@ impl MutableRectArray { /// Add a new point to the end of this array. #[inline] - pub fn push_rect<'a>(&mut self, value: Option<&impl RectTrait<'a, T = f64>>) { + pub fn push_rect(&mut self, value: Option<&impl RectTrait>) { if let Some(value) = value { let min_coord = value.lower(); let max_coord = value.upper(); @@ -134,7 +134,7 @@ impl From for RectArray { } fn first_pass<'a>( - geoms: impl Iterator + 'a>>, + geoms: impl Iterator + 'a>>, num_geoms: usize, ) -> MutableRectArray { let mut array = MutableRectArray::with_capacity(num_geoms); diff --git a/src/geo_traits/geometry.rs b/src/geo_traits/geometry.rs index 6efa4f9c..16a7aef7 100644 --- a/src/geo_traits/geometry.rs +++ b/src/geo_traits/geometry.rs @@ -9,29 +9,45 @@ use super::{ }; #[allow(clippy::type_complexity)] -pub trait GeometryTrait<'a> { +pub trait GeometryTrait { type T: CoordNum; - type Point: 'a + PointTrait; - type LineString: 'a + LineStringTrait<'a, T = Self::T>; - type Polygon: 'a + PolygonTrait<'a, T = Self::T>; - type MultiPoint: 'a + MultiPointTrait<'a, T = Self::T>; - type MultiLineString: 'a + MultiLineStringTrait<'a, T = Self::T>; - type MultiPolygon: 'a + MultiPolygonTrait<'a, T = Self::T>; - type GeometryCollection: 'a + GeometryCollectionTrait<'a, T = Self::T>; - type Rect: 'a + RectTrait<'a, T = Self::T>; + type Point<'a>: 'a + PointTrait + where + Self: 'a; + type LineString<'a>: 'a + LineStringTrait + where + Self: 'a; + type Polygon<'a>: 'a + PolygonTrait + where + Self: 'a; + type MultiPoint<'a>: 'a + MultiPointTrait + where + Self: 'a; + type MultiLineString<'a>: 'a + MultiLineStringTrait + where + Self: 'a; + type MultiPolygon<'a>: 'a + MultiPolygonTrait + where + Self: 'a; + type GeometryCollection<'a>: 'a + GeometryCollectionTrait + where + Self: 'a; + type Rect<'a>: 'a + RectTrait + where + Self: 'a; fn as_type( - &'a self, + &self, ) -> GeometryType< - 'a, - Self::Point, - Self::LineString, - Self::Polygon, - Self::MultiPoint, - Self::MultiLineString, - Self::MultiPolygon, - Self::GeometryCollection, - Self::Rect, + '_, + Self::Point<'_>, + Self::LineString<'_>, + Self::Polygon<'_>, + Self::MultiPoint<'_>, + Self::MultiLineString<'_>, + Self::MultiPolygon<'_>, + Self::GeometryCollection<'_>, + Self::Rect<'_>, >; } @@ -39,13 +55,13 @@ pub trait GeometryTrait<'a> { pub enum GeometryType<'a, P, L, Y, MP, ML, MY, GC, R> where P: PointTrait, - L: LineStringTrait<'a>, - Y: PolygonTrait<'a>, - MP: MultiPointTrait<'a>, - ML: MultiLineStringTrait<'a>, - MY: MultiPolygonTrait<'a>, - GC: GeometryCollectionTrait<'a>, - R: RectTrait<'a>, + L: LineStringTrait, + Y: PolygonTrait, + MP: MultiPointTrait, + ML: MultiLineStringTrait, + MY: MultiPolygonTrait, + GC: GeometryCollectionTrait, + R: RectTrait, { Point(&'a P), LineString(&'a L), @@ -57,21 +73,21 @@ where Rect(&'a R), } -impl<'a, T: CoordNum + 'a> GeometryTrait<'a> for Geometry { +impl<'a, T: CoordNum + 'a> GeometryTrait for Geometry { type T = T; - type Point = Point; - type LineString = LineString; - type Polygon = Polygon; - type MultiPoint = MultiPoint; - type MultiLineString = MultiLineString; - type MultiPolygon = MultiPolygon; - type GeometryCollection = GeometryCollection; - type Rect = Rect; + type Point<'b> = Point where Self: 'b; + type LineString<'b> = LineString where Self: 'b; + type Polygon<'b> = Polygon where Self: 'b; + type MultiPoint<'b> = MultiPoint where Self: 'b; + type MultiLineString<'b> = MultiLineString where Self: 'b; + type MultiPolygon<'b> = MultiPolygon where Self: 'b; + type GeometryCollection<'b> = GeometryCollection where Self: 'b; + type Rect<'b> = Rect where Self: 'b; fn as_type( - &'a self, + &self, ) -> GeometryType< - 'a, + '_, Point, LineString, Polygon, diff --git a/src/geo_traits/geometry_collection.rs b/src/geo_traits/geometry_collection.rs index 8e6cfb60..77c39cce 100644 --- a/src/geo_traits/geometry_collection.rs +++ b/src/geo_traits/geometry_collection.rs @@ -3,28 +3,35 @@ use geo::{CoordNum, Geometry, GeometryCollection}; use std::iter::Cloned; use std::slice::Iter; -pub trait GeometryCollectionTrait<'a> { +pub trait GeometryCollectionTrait { type T: CoordNum; - type ItemType: 'a + GeometryTrait<'a, T = Self::T>; - type Iter: ExactSizeIterator; + type ItemType<'a>: 'a + GeometryTrait + where + Self: 'a; + type Iter<'a>: ExactSizeIterator> + where + Self: 'a; /// An iterator over the geometries in this GeometryCollection - fn geometries(&'a self) -> Self::Iter; + fn geometries(&self) -> Self::Iter<'_>; /// The number of geometries in this GeometryCollection fn num_geometries(&self) -> usize; /// Access to a specified geometry in this GeometryCollection /// Will return None if the provided index is out of bounds - fn geometry(&self, i: usize) -> Option; + fn geometry(&self, i: usize) -> Option>; } -impl<'a, T: CoordNum + 'a> GeometryCollectionTrait<'a> for GeometryCollection { +impl GeometryCollectionTrait for GeometryCollection { type T = T; - type ItemType = Geometry; - type Iter = Cloned>; + type ItemType<'a> = Geometry + where + Self: 'a; + type Iter<'a> = Cloned>> + where T: 'a; - fn geometries(&'a self) -> Self::Iter { + fn geometries(&self) -> Self::Iter<'_> { self.0.iter().cloned() } @@ -32,17 +39,19 @@ impl<'a, T: CoordNum + 'a> GeometryCollectionTrait<'a> for GeometryCollection self.0.len() } - fn geometry(&self, i: usize) -> Option { + fn geometry(&self, i: usize) -> Option> { self.0.get(i).cloned() } } -impl<'a, T: CoordNum + 'a> GeometryCollectionTrait<'a> for &GeometryCollection { +impl<'a, T: CoordNum> GeometryCollectionTrait for &'a GeometryCollection { type T = T; - type ItemType = Geometry; - type Iter = Cloned>; + type ItemType<'b> = Geometry where + Self: 'b; + type Iter<'b> = Cloned>> where + Self: 'b; - fn geometries(&'a self) -> Self::Iter { + fn geometries(&self) -> Self::Iter<'_> { self.0.iter().cloned() } @@ -50,7 +59,7 @@ impl<'a, T: CoordNum + 'a> GeometryCollectionTrait<'a> for &GeometryCollection Option { + fn geometry(&self, i: usize) -> Option> { self.0.get(i).cloned() } } diff --git a/src/geo_traits/line_string.rs b/src/geo_traits/line_string.rs index 62c4c6da..b3328da9 100644 --- a/src/geo_traits/line_string.rs +++ b/src/geo_traits/line_string.rs @@ -3,28 +3,33 @@ use geo::{Coord, CoordNum, LineString}; use std::iter::Cloned; use std::slice::Iter; -pub trait LineStringTrait<'a> { +pub trait LineStringTrait { type T: CoordNum; - type ItemType: 'a + CoordTrait; - type Iter: ExactSizeIterator; + type ItemType<'a>: 'a + CoordTrait + where + Self: 'a; + type Iter<'a>: ExactSizeIterator> + where + Self: 'a; /// An iterator over the coords in this LineString - fn coords(&'a self) -> Self::Iter; + fn coords(&self) -> Self::Iter<'_>; /// The number of coords in this LineString fn num_coords(&self) -> usize; /// Access to a specified point in this LineString /// Will return None if the provided index is out of bounds - fn coord(&self, i: usize) -> Option; + fn coord(&self, i: usize) -> Option>; } -impl<'a, T: CoordNum + 'a> LineStringTrait<'a> for LineString { +impl LineStringTrait for LineString { type T = T; - type ItemType = Coord; - type Iter = Cloned>; + type ItemType<'a> = Coord where Self: 'a; + type Iter<'a> = Cloned>> where T: 'a; - fn coords(&'a self) -> Self::Iter { + fn coords(&self) -> Self::Iter<'_> { + // TODO: remove cloned self.0.iter().cloned() } @@ -32,17 +37,17 @@ impl<'a, T: CoordNum + 'a> LineStringTrait<'a> for LineString { self.0.len() } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { self.0.get(i).cloned() } } -impl<'a, T: CoordNum + 'a> LineStringTrait<'a> for &LineString { +impl<'a, T: CoordNum> LineStringTrait for &'a LineString { type T = T; - type ItemType = Coord; - type Iter = Cloned>; + type ItemType<'b> = Coord where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; - fn coords(&'a self) -> Self::Iter { + fn coords(&self) -> Self::Iter<'_> { self.0.iter().cloned() } @@ -50,7 +55,7 @@ impl<'a, T: CoordNum + 'a> LineStringTrait<'a> for &LineString { self.0.len() } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { self.0.get(i).cloned() } } diff --git a/src/geo_traits/multi_line_string.rs b/src/geo_traits/multi_line_string.rs index d3887a39..032ec68c 100644 --- a/src/geo_traits/multi_line_string.rs +++ b/src/geo_traits/multi_line_string.rs @@ -3,28 +3,32 @@ use geo::{CoordNum, LineString, MultiLineString}; use std::iter::Cloned; use std::slice::Iter; -pub trait MultiLineStringTrait<'a> { +pub trait MultiLineStringTrait { type T: CoordNum; - type ItemType: 'a + LineStringTrait<'a, T = Self::T>; - type Iter: ExactSizeIterator; + type ItemType<'a>: 'a + LineStringTrait + where + Self: 'a; + type Iter<'a>: ExactSizeIterator> + where + Self: 'a; /// An iterator over the LineStrings in this MultiLineString - fn lines(&'a self) -> Self::Iter; + fn lines(&self) -> Self::Iter<'_>; /// The number of lines in this MultiLineString fn num_lines(&self) -> usize; /// Access to a specified line in this MultiLineString /// Will return None if the provided index is out of bounds - fn line(&self, i: usize) -> Option; + fn line(&self, i: usize) -> Option>; } -impl<'a, T: CoordNum + 'a> MultiLineStringTrait<'a> for MultiLineString { +impl MultiLineStringTrait for MultiLineString { type T = T; - type ItemType = LineString; - type Iter = Cloned>; + type ItemType<'a> = LineString where Self: 'a; + type Iter<'a> = Cloned>> where T: 'a; - fn lines(&'a self) -> Self::Iter { + fn lines(&self) -> Self::Iter<'_> { self.0.iter().cloned() } @@ -32,17 +36,17 @@ impl<'a, T: CoordNum + 'a> MultiLineStringTrait<'a> for MultiLineString { self.0.len() } - fn line(&self, i: usize) -> Option { + fn line(&self, i: usize) -> Option> { self.0.get(i).cloned() } } -impl<'a, T: CoordNum + 'a> MultiLineStringTrait<'a> for &MultiLineString { +impl<'a, T: CoordNum> MultiLineStringTrait for &'a MultiLineString { type T = T; - type ItemType = LineString; - type Iter = Cloned>; + type ItemType<'b> = LineString where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; - fn lines(&'a self) -> Self::Iter { + fn lines(&self) -> Self::Iter<'_> { self.0.iter().cloned() } @@ -50,7 +54,7 @@ impl<'a, T: CoordNum + 'a> MultiLineStringTrait<'a> for &MultiLineString { self.0.len() } - fn line(&self, i: usize) -> Option { + fn line(&self, i: usize) -> Option> { self.0.get(i).cloned() } } diff --git a/src/geo_traits/multi_point.rs b/src/geo_traits/multi_point.rs index 931df412..427cf74f 100644 --- a/src/geo_traits/multi_point.rs +++ b/src/geo_traits/multi_point.rs @@ -3,28 +3,32 @@ use geo::{CoordNum, MultiPoint, Point}; use std::iter::Cloned; use std::slice::Iter; -pub trait MultiPointTrait<'a> { +pub trait MultiPointTrait { type T: CoordNum; - type ItemType: 'a + PointTrait; - type Iter: ExactSizeIterator; + type ItemType<'a>: 'a + PointTrait + where + Self: 'a; + type Iter<'a>: ExactSizeIterator> + where + Self: 'a; /// An iterator over the points in this MultiPoint - fn points(&'a self) -> Self::Iter; + fn points(&self) -> Self::Iter<'_>; /// The number of points in this MultiPoint fn num_points(&self) -> usize; /// Access to a specified point in this MultiPoint /// Will return None if the provided index is out of bounds - fn point(&self, i: usize) -> Option; + fn point(&self, i: usize) -> Option>; } -impl<'a, T: CoordNum + 'a> MultiPointTrait<'a> for MultiPoint { +impl MultiPointTrait for MultiPoint { type T = T; - type ItemType = Point; - type Iter = Cloned>; + type ItemType<'a> = Point where Self: 'a; + type Iter<'a> = Cloned>> where T: 'a; - fn points(&'a self) -> Self::Iter { + fn points(&self) -> Self::Iter<'_> { self.0.iter().cloned() } @@ -32,17 +36,17 @@ impl<'a, T: CoordNum + 'a> MultiPointTrait<'a> for MultiPoint { self.0.len() } - fn point(&self, i: usize) -> Option { + fn point(&self, i: usize) -> Option> { self.0.get(i).cloned() } } -impl<'a, T: CoordNum + 'a> MultiPointTrait<'a> for &MultiPoint { +impl<'a, T: CoordNum> MultiPointTrait for &'a MultiPoint { type T = T; - type ItemType = Point; - type Iter = Cloned>; + type ItemType<'b> = Point where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; - fn points(&'a self) -> Self::Iter { + fn points(&self) -> Self::Iter<'_> { self.0.iter().cloned() } @@ -50,7 +54,7 @@ impl<'a, T: CoordNum + 'a> MultiPointTrait<'a> for &MultiPoint { self.0.len() } - fn point(&self, i: usize) -> Option { + fn point(&self, i: usize) -> Option> { self.0.get(i).cloned() } } diff --git a/src/geo_traits/multi_polygon.rs b/src/geo_traits/multi_polygon.rs index dc838c09..6cc3df7e 100644 --- a/src/geo_traits/multi_polygon.rs +++ b/src/geo_traits/multi_polygon.rs @@ -3,28 +3,32 @@ use geo::{CoordNum, MultiPolygon, Polygon}; use std::iter::Cloned; use std::slice::Iter; -pub trait MultiPolygonTrait<'a> { +pub trait MultiPolygonTrait { type T: CoordNum; - type ItemType: 'a + PolygonTrait<'a, T = Self::T>; - type Iter: ExactSizeIterator; + type ItemType<'a>: 'a + PolygonTrait + where + Self: 'a; + type Iter<'a>: ExactSizeIterator> + where + Self: 'a; /// An iterator over the Polygons in this MultiPolygon - fn polygons(&'a self) -> Self::Iter; + fn polygons(&self) -> Self::Iter<'_>; /// The number of polygons in this MultiPolygon fn num_polygons(&self) -> usize; /// Access to a specified polygon in this MultiPolygon /// Will return None if the provided index is out of bounds - fn polygon(&self, i: usize) -> Option; + fn polygon(&self, i: usize) -> Option>; } -impl<'a, T: CoordNum + 'a> MultiPolygonTrait<'a> for MultiPolygon { +impl MultiPolygonTrait for MultiPolygon { type T = T; - type ItemType = Polygon; - type Iter = Cloned>; + type ItemType<'a> = Polygon where Self: 'a; + type Iter<'a> = Cloned>> where T: 'a; - fn polygons(&'a self) -> Self::Iter { + fn polygons(&self) -> Self::Iter<'_> { self.0.iter().cloned() } @@ -32,17 +36,17 @@ impl<'a, T: CoordNum + 'a> MultiPolygonTrait<'a> for MultiPolygon { self.0.len() } - fn polygon(&self, i: usize) -> Option { + fn polygon(&self, i: usize) -> Option> { self.0.get(i).cloned() } } -impl<'a, T: CoordNum + 'a> MultiPolygonTrait<'a> for &MultiPolygon { +impl<'a, T: CoordNum> MultiPolygonTrait for &'a MultiPolygon { type T = T; - type ItemType = Polygon; - type Iter = Cloned>; + type ItemType<'b> = Polygon where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; - fn polygons(&'a self) -> Self::Iter { + fn polygons(&self) -> Self::Iter<'_> { self.0.iter().cloned() } @@ -50,7 +54,7 @@ impl<'a, T: CoordNum + 'a> MultiPolygonTrait<'a> for &MultiPolygon { self.0.len() } - fn polygon(&self, i: usize) -> Option { + fn polygon(&self, i: usize) -> Option> { self.0.get(i).cloned() } } diff --git a/src/geo_traits/polygon.rs b/src/geo_traits/polygon.rs index c0807903..310c5092 100644 --- a/src/geo_traits/polygon.rs +++ b/src/geo_traits/polygon.rs @@ -3,36 +3,40 @@ use geo::{CoordNum, LineString, Polygon}; use std::iter::Cloned; use std::slice::Iter; -pub trait PolygonTrait<'a> { +pub trait PolygonTrait { type T: CoordNum; - type ItemType: 'a + LineStringTrait<'a, T = Self::T>; - type Iter: ExactSizeIterator; + type ItemType<'a>: 'a + LineStringTrait + where + Self: 'a; + type Iter<'a>: ExactSizeIterator> + where + Self: 'a; /// The exterior ring of the polygon - fn exterior(&self) -> Option; + fn exterior(&self) -> Option>; /// An iterator of the interior rings of this Polygon - fn interiors(&'a self) -> Self::Iter; + fn interiors(&self) -> Self::Iter<'_>; /// The number of interior rings in this Polygon fn num_interiors(&self) -> usize; /// Access to a specified interior ring in this Polygon /// Will return None if the provided index is out of bounds - fn interior(&self, i: usize) -> Option; + fn interior(&self, i: usize) -> Option>; } -impl<'a, T: CoordNum + 'a> PolygonTrait<'a> for Polygon { +impl PolygonTrait for Polygon { type T = T; - type ItemType = LineString; - type Iter = Cloned>; + type ItemType<'a> = LineString where Self: 'a; + type Iter<'a> = Cloned>> where T: 'a; - fn exterior(&self) -> Option { + fn exterior(&self) -> Option> { // geo-types doesn't really have a way to describe an empty polygon Some(Polygon::exterior(self).clone()) } - fn interiors(&'a self) -> Self::Iter { + fn interiors(&self) -> Self::Iter<'_> { Polygon::interiors(self).iter().cloned() } @@ -40,21 +44,23 @@ impl<'a, T: CoordNum + 'a> PolygonTrait<'a> for Polygon { Polygon::interiors(self).len() } - fn interior(&self, i: usize) -> Option { + fn interior(&self, i: usize) -> Option> { Polygon::interiors(self).get(i).cloned() } } -impl<'a, T: CoordNum + 'a> PolygonTrait<'a> for &Polygon { +impl<'a, T: CoordNum> PolygonTrait for &'a Polygon { type T = T; - type ItemType = LineString; - type Iter = Cloned>; + type ItemType<'b> = LineString where + Self: 'b; + type Iter<'b> = Cloned>> where + Self: 'b; - fn exterior(&self) -> Option { + fn exterior(&self) -> Option> { Some(Polygon::exterior(self).clone()) } - fn interiors(&'a self) -> Self::Iter { + fn interiors(&self) -> Self::Iter<'_> { Polygon::interiors(self).iter().cloned() } @@ -62,7 +68,7 @@ impl<'a, T: CoordNum + 'a> PolygonTrait<'a> for &Polygon { Polygon::interiors(self).len() } - fn interior(&self, i: usize) -> Option { + fn interior(&self, i: usize) -> Option> { Polygon::interiors(self).get(i).cloned() } } diff --git a/src/geo_traits/rect.rs b/src/geo_traits/rect.rs index bf9d50ad..2d3f5852 100644 --- a/src/geo_traits/rect.rs +++ b/src/geo_traits/rect.rs @@ -2,37 +2,39 @@ use geo::{Coord, CoordNum, Rect}; use crate::geo_traits::CoordTrait; -pub trait RectTrait<'a> { +pub trait RectTrait { type T: CoordNum; - type ItemType: 'a + CoordTrait; + type ItemType<'a>: 'a + CoordTrait + where + Self: 'a; - fn lower(&self) -> Self::ItemType; + fn lower(&self) -> Self::ItemType<'_>; - fn upper(&self) -> Self::ItemType; + fn upper(&self) -> Self::ItemType<'_>; } -impl<'a, T: CoordNum + 'a> RectTrait<'a> for Rect { +impl<'a, T: CoordNum + 'a> RectTrait for Rect { type T = T; - type ItemType = Coord; + type ItemType<'b> = Coord where Self: 'b; - fn lower(&self) -> Self::ItemType { + fn lower(&self) -> Self::ItemType<'_> { self.min() } - fn upper(&self) -> Self::ItemType { + fn upper(&self) -> Self::ItemType<'_> { self.max() } } -impl<'a, T: CoordNum + 'a> RectTrait<'a> for &Rect { +impl<'a, T: CoordNum + 'a> RectTrait for &'a Rect { type T = T; - type ItemType = Coord; + type ItemType<'b> = Coord where Self: 'b; - fn lower(&self) -> Self::ItemType { + fn lower(&self) -> Self::ItemType<'_> { self.min() } - fn upper(&self) -> Self::ItemType { + fn upper(&self) -> Self::ItemType<'_> { self.max() } } diff --git a/src/io/geos/array/linestring.rs b/src/io/geos/array/linestring.rs index 350c2c69..25ab5167 100644 --- a/src/io/geos/array/linestring.rs +++ b/src/io/geos/array/linestring.rs @@ -1,28 +1,85 @@ use arrow_array::OffsetSizeTrait; -use crate::array::linestring::mutable::{first_pass, second_pass}; use crate::array::{LineStringArray, MutableLineStringArray}; -use crate::error::GeoArrowError; +use crate::error::{GeoArrowError, Result}; +use crate::geo_traits::{CoordTrait, LineStringTrait}; use crate::io::geos::scalar::GEOSLineString; -impl<'a, O: OffsetSizeTrait> TryFrom>>> - for MutableLineStringArray -{ +// NOTE: this, `first_pass`, and `second_pass` are copied from their main implementations, because +// implementing geometry access traits on GEOS geometries that yield ConstGeometry objects with two +// lifetimes seemed really, really hard. Ideally one day we can unify the two branches! + +impl MutableLineStringArray { + /// Add a new GEOS LineString to the end of this array. + /// + /// # Errors + /// + /// This function errors iff the new last item is larger than what O supports. + #[allow(dead_code)] + fn push_geos_line_string(&mut self, value: Option<&GEOSLineString>) -> Result<()> { + if let Some(line_string) = value { + // For each ring: + // - Get ring + // - Add ring's # of coords to self.ring_offsets + // - Push ring's coords to self.coords + + self.geom_offsets + .try_push_usize(line_string.num_coords()) + .unwrap(); + + for coord_idx in 0..line_string.num_coords() { + let coord = line_string.coord(coord_idx).unwrap(); + self.coords.push_xy(coord.x(), coord.y()); + } + + self.validity.append(true); + } else { + self.push_null(); + } + Ok(()) + } +} + +pub(crate) fn first_pass(geoms: &[Option], geoms_length: usize) -> (usize, usize) { + let mut coord_capacity = 0; + let geom_capacity = geoms_length; + + for line_string in geoms.iter().flatten() { + coord_capacity += line_string.num_coords(); + } + + (coord_capacity, geom_capacity) +} + +pub(crate) fn second_pass<'a, O: OffsetSizeTrait>( + geoms: impl Iterator>>, + coord_capacity: usize, + geom_capacity: usize, +) -> MutableLineStringArray { + let mut array = MutableLineStringArray::with_capacities(coord_capacity, geom_capacity); + + geoms + .into_iter() + .try_for_each(|maybe_multi_point| array.push_line_string(maybe_multi_point.as_ref())) + .unwrap(); + + array +} + +impl TryFrom>>> for MutableLineStringArray { type Error = GeoArrowError; - fn try_from(value: Vec>>) -> std::result::Result { + fn try_from(value: Vec>>) -> Result { let length = value.len(); // TODO: don't use new_unchecked - let geos_linestring_objects: Vec> = value + let geos_objects: Vec> = value .into_iter() .map(|geom| geom.map(GEOSLineString::new_unchecked)) .collect(); - let (coord_capacity, geom_capacity) = first_pass( - geos_linestring_objects.iter().map(|item| item.as_ref()), - length, - ); + + let (coord_capacity, geom_capacity) = first_pass(&geos_objects, length); Ok(second_pass( - geos_linestring_objects.into_iter(), + geos_objects.into_iter(), coord_capacity, geom_capacity, )) diff --git a/src/io/geos/scalar/linestring.rs b/src/io/geos/scalar/linestring.rs index 3b4075c9..c0c4c0ab 100644 --- a/src/io/geos/scalar/linestring.rs +++ b/src/io/geos/scalar/linestring.rs @@ -61,16 +61,16 @@ impl<'a> GEOSLineString<'a> { } } -impl<'a> LineStringTrait<'a> for GEOSLineString<'a> { +impl<'a> LineStringTrait for GEOSLineString<'a> { type T = f64; - type ItemType = GEOSPoint<'a>; - type Iter = Cloned>; + type ItemType<'b> = GEOSPoint<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_coords(&self) -> usize { self.0.get_num_points().unwrap() } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { if i > (self.num_coords()) { return None; } @@ -79,21 +79,21 @@ impl<'a> LineStringTrait<'a> for GEOSLineString<'a> { Some(GEOSPoint::new_unchecked(point)) } - fn coords(&'a self) -> Self::Iter { + fn coords(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> LineStringTrait<'a> for &GEOSLineString<'a> { +impl<'a> LineStringTrait for &'a GEOSLineString<'a> { type T = f64; - type ItemType = GEOSPoint<'a>; - type Iter = Cloned>; + type ItemType<'b> = GEOSPoint<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_coords(&self) -> usize { self.0.get_num_points().unwrap() } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { if i > (self.num_coords()) { return None; } @@ -102,7 +102,7 @@ impl<'a> LineStringTrait<'a> for &GEOSLineString<'a> { Some(GEOSPoint::new_unchecked(point)) } - fn coords(&'a self) -> Self::Iter { + fn coords(&self) -> Self::Iter<'_> { todo!() } } @@ -126,16 +126,30 @@ impl<'a, 'b> GEOSConstLineString<'a, 'b> { } } -impl<'a, 'b> LineStringTrait<'a> for GEOSConstLineString<'a, 'b> { +// TODO: uncomment + +// error[E0477]: the type `io::geos::scalar::linestring::GEOSConstLineString<'a, 'b>` does not fulfill the required lifetime +// --> src/io/geos/scalar/linestring.rs:147:25 +// | +// 147 | fn coords(&self) -> Self::Iter<'_> { +// | ^^^^^^^^^^^^^^ +// | +// note: type must outlive the lifetime `'a` as defined here as required by this binding +// --> src/io/geos/scalar/linestring.rs:129:6 +// | +// 129 | impl<'a, 'b> LineStringTrait for GEOSConstLineString<'a, 'b> { +// | ^^ + +impl<'a, 'b> LineStringTrait for GEOSConstLineString<'a, 'b> { type T = f64; - type ItemType = GEOSPoint<'a>; - type Iter = Cloned>; + type ItemType<'c> = GEOSPoint<'a> where Self: 'c; + type Iter<'c> = Cloned>> where Self: 'c; fn num_coords(&self) -> usize { self.0.get_num_points().unwrap() } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { if i > (self.num_coords()) { return None; } @@ -144,21 +158,21 @@ impl<'a, 'b> LineStringTrait<'a> for GEOSConstLineString<'a, 'b> { Some(GEOSPoint::new_unchecked(point)) } - fn coords(&'a self) -> Self::Iter { + fn coords(&self) -> Self::Iter<'_> { todo!() } } -impl<'a, 'b> LineStringTrait<'a> for &GEOSConstLineString<'a, 'b> { +impl<'a, 'b> LineStringTrait for &'a GEOSConstLineString<'a, 'b> { type T = f64; - type ItemType = GEOSPoint<'a>; - type Iter = Cloned>; + type ItemType<'c> = GEOSPoint<'a> where Self: 'c; + type Iter<'c> = Cloned>> where Self: 'c; fn num_coords(&self) -> usize { self.0.get_num_points().unwrap() } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { if i > (self.num_coords()) { return None; } @@ -167,7 +181,7 @@ impl<'a, 'b> LineStringTrait<'a> for &GEOSConstLineString<'a, 'b> { Some(GEOSPoint::new_unchecked(point)) } - fn coords(&'a self) -> Self::Iter { + fn coords(&self) -> Self::Iter<'_> { todo!() } } diff --git a/src/io/geos/scalar/multipoint.rs b/src/io/geos/scalar/multipoint.rs index bb0cc1b5..4b0aa88a 100644 --- a/src/io/geos/scalar/multipoint.rs +++ b/src/io/geos/scalar/multipoint.rs @@ -56,7 +56,7 @@ impl<'a> GEOSMultiPoint<'a> { // which then has _two_ lifetime parameters, and it looks like a total black hole to get that // working with these traits. -// impl<'a> MultiPointTrait<'a> for GEOSMultiPoint<'a> { +// impl<'a> MultiPointTrait for GEOSMultiPoint<'a> { // type T = f64; // type ItemType = GEOSConstPoint<'a, 'a>; // type Iter = Cloned>; @@ -79,7 +79,7 @@ impl<'a> GEOSMultiPoint<'a> { // } // } -// impl<'a> MultiPointTrait<'a> for &GEOSMultiPoint<'a> { +// impl<'a> MultiPointTrait for &GEOSMultiPoint<'a> { // type T = f64; // type ItemType = GEOSConstPoint<'a, 'a>; // type Iter = Cloned>; diff --git a/src/io/geozero/scalar/geometry.rs b/src/io/geozero/scalar/geometry.rs index 0edbc8f9..d03c0d99 100644 --- a/src/io/geozero/scalar/geometry.rs +++ b/src/io/geozero/scalar/geometry.rs @@ -9,8 +9,8 @@ use crate::scalar::Geometry; use arrow_array::OffsetSizeTrait; use geozero::{GeomProcessor, GeozeroGeometry}; -pub(crate) fn process_geometry<'a, P: GeomProcessor>( - geom: &'a impl GeometryTrait<'a, T = f64>, +pub(crate) fn process_geometry( + geom: &impl GeometryTrait, geom_idx: usize, processor: &mut P, ) -> geozero::error::Result<()> { @@ -33,6 +33,6 @@ impl GeozeroGeometry for Geometry<'_, O> { where Self: Sized, { - process_geometry(self, 0, processor) + process_geometry(&self, 0, processor) } } diff --git a/src/io/geozero/scalar/linestring.rs b/src/io/geozero/scalar/linestring.rs index 5262985a..d450239f 100644 --- a/src/io/geozero/scalar/linestring.rs +++ b/src/io/geozero/scalar/linestring.rs @@ -3,8 +3,8 @@ use crate::scalar::LineString; use arrow_array::OffsetSizeTrait; use geozero::{GeomProcessor, GeozeroGeometry}; -pub(crate) fn process_line_string<'a, P: GeomProcessor>( - geom: &impl LineStringTrait<'a, T = f64>, +pub(crate) fn process_line_string( + geom: &impl LineStringTrait, geom_idx: usize, processor: &mut P, ) -> geozero::error::Result<()> { diff --git a/src/io/geozero/scalar/multilinestring.rs b/src/io/geozero/scalar/multilinestring.rs index d0f16087..7547e113 100644 --- a/src/io/geozero/scalar/multilinestring.rs +++ b/src/io/geozero/scalar/multilinestring.rs @@ -3,8 +3,8 @@ use crate::scalar::MultiLineString; use arrow_array::OffsetSizeTrait; use geozero::{GeomProcessor, GeozeroGeometry}; -pub(crate) fn process_multi_line_string<'a, P: GeomProcessor>( - geom: &impl MultiLineStringTrait<'a, T = f64>, +pub(crate) fn process_multi_line_string( + geom: &impl MultiLineStringTrait, geom_idx: usize, processor: &mut P, ) -> geozero::error::Result<()> { diff --git a/src/io/geozero/scalar/multipoint.rs b/src/io/geozero/scalar/multipoint.rs index f2bee144..4eb9374f 100644 --- a/src/io/geozero/scalar/multipoint.rs +++ b/src/io/geozero/scalar/multipoint.rs @@ -3,8 +3,8 @@ use crate::scalar::MultiPoint; use arrow_array::OffsetSizeTrait; use geozero::{GeomProcessor, GeozeroGeometry}; -pub(crate) fn process_multi_point<'a, P: GeomProcessor>( - geom: &impl MultiPointTrait<'a, T = f64>, +pub(crate) fn process_multi_point( + geom: &impl MultiPointTrait, geom_idx: usize, processor: &mut P, ) -> geozero::error::Result<()> { diff --git a/src/io/geozero/scalar/multipolygon.rs b/src/io/geozero/scalar/multipolygon.rs index ffce7239..8cb21112 100644 --- a/src/io/geozero/scalar/multipolygon.rs +++ b/src/io/geozero/scalar/multipolygon.rs @@ -4,8 +4,8 @@ use crate::scalar::MultiPolygon; use arrow_array::OffsetSizeTrait; use geozero::{GeomProcessor, GeozeroGeometry}; -pub(crate) fn process_multi_polygon<'a, P: GeomProcessor>( - geom: &impl MultiPolygonTrait<'a, T = f64>, +pub(crate) fn process_multi_polygon( + geom: &impl MultiPolygonTrait, geom_idx: usize, processor: &mut P, ) -> geozero::error::Result<()> { diff --git a/src/io/geozero/scalar/polygon.rs b/src/io/geozero/scalar/polygon.rs index 061d2fe4..8b239329 100644 --- a/src/io/geozero/scalar/polygon.rs +++ b/src/io/geozero/scalar/polygon.rs @@ -3,8 +3,8 @@ use crate::scalar::Polygon; use arrow_array::OffsetSizeTrait; use geozero::{GeomProcessor, GeozeroGeometry}; -fn process_ring<'a, P: GeomProcessor>( - ring: impl LineStringTrait<'a, T = f64>, +fn process_ring( + ring: impl LineStringTrait, ring_idx: usize, processor: &mut P, ) -> geozero::error::Result<()> { @@ -19,8 +19,8 @@ fn process_ring<'a, P: GeomProcessor>( Ok(()) } -pub(crate) fn process_polygon<'a, P: GeomProcessor>( - geom: &impl PolygonTrait<'a, T = f64>, +pub(crate) fn process_polygon( + geom: &impl PolygonTrait, tagged: bool, geom_idx: usize, processor: &mut P, diff --git a/src/io/wkb/reader/geometry.rs b/src/io/wkb/reader/geometry.rs index 2ddba18a..557c1670 100644 --- a/src/io/wkb/reader/geometry.rs +++ b/src/io/wkb/reader/geometry.rs @@ -170,29 +170,29 @@ impl<'a> From> for WKBLineString<'a> { } } -impl<'a> GeometryTrait<'a> for WKBGeometry<'a> { +impl<'a> GeometryTrait for WKBGeometry<'a> { type T = f64; - type Point = WKBPoint<'a>; - type LineString = WKBLineString<'a>; - type Polygon = WKBPolygon<'a>; - type MultiPoint = WKBMultiPoint<'a>; - type MultiLineString = WKBMultiLineString<'a>; - type MultiPolygon = WKBMultiPolygon<'a>; - type GeometryCollection = WKBGeometryCollection<'a>; - type Rect = WKBRect<'a>; + type Point<'b> = WKBPoint<'a> where Self: 'b; + type LineString<'b> = WKBLineString<'a> where Self: 'b; + type Polygon<'b> = WKBPolygon<'a> where Self: 'b; + type MultiPoint<'b> = WKBMultiPoint<'a> where Self: 'b; + type MultiLineString<'b> = WKBMultiLineString<'a> where Self: 'b; + type MultiPolygon<'b> = WKBMultiPolygon<'a> where Self: 'b; + type GeometryCollection<'b> = WKBGeometryCollection<'a> where Self: 'b; + type Rect<'b> = WKBRect<'a> where Self: 'b; fn as_type( - &'a self, + &self, ) -> crate::geo_traits::GeometryType< - 'a, - WKBPoint, - WKBLineString, - WKBPolygon, - WKBMultiPoint, - WKBMultiLineString, - WKBMultiPolygon, - WKBGeometryCollection, - WKBRect, + '_, + WKBPoint<'a>, + WKBLineString<'a>, + WKBPolygon<'a>, + WKBMultiPoint<'a>, + WKBMultiLineString<'a>, + WKBMultiPolygon<'a>, + WKBGeometryCollection<'a>, + WKBRect<'a>, > { use crate::geo_traits::GeometryType as B; use WKBGeometry as A; diff --git a/src/io/wkb/reader/geometry_collection.rs b/src/io/wkb/reader/geometry_collection.rs index 2b6be2c3..3f8e4bf4 100644 --- a/src/io/wkb/reader/geometry_collection.rs +++ b/src/io/wkb/reader/geometry_collection.rs @@ -17,20 +17,20 @@ impl<'a> WKBGeometryCollection<'a> { } } -impl<'a> GeometryCollectionTrait<'a> for WKBGeometryCollection<'a> { +impl<'a> GeometryCollectionTrait for WKBGeometryCollection<'a> { type T = f64; - type ItemType = WKBGeometry<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBGeometry<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_geometries(&self) -> usize { todo!() } - fn geometry(&self, _i: usize) -> Option { + fn geometry(&self, _i: usize) -> Option> { todo!() } - fn geometries(&'a self) -> Self::Iter { + fn geometries(&self) -> Self::Iter<'_> { todo!() } } diff --git a/src/io/wkb/reader/linearring.rs b/src/io/wkb/reader/linearring.rs index 4ef21562..d8f88b9c 100644 --- a/src/io/wkb/reader/linearring.rs +++ b/src/io/wkb/reader/linearring.rs @@ -67,16 +67,16 @@ impl<'a> WKBLinearRing<'a> { } } -impl<'a> LineStringTrait<'a> for WKBLinearRing<'a> { +impl<'a> LineStringTrait for WKBLinearRing<'a> { type T = f64; - type ItemType = WKBCoord<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBCoord<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_coords(&self) -> usize { self.num_points } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { if i > (self.num_points) { return None; } @@ -89,7 +89,7 @@ impl<'a> LineStringTrait<'a> for WKBLinearRing<'a> { Some(coord) } - fn coords(&'a self) -> Self::Iter { + fn coords(&self) -> Self::Iter<'_> { todo!() } } diff --git a/src/io/wkb/reader/linestring.rs b/src/io/wkb/reader/linestring.rs index b846707e..42a3d839 100644 --- a/src/io/wkb/reader/linestring.rs +++ b/src/io/wkb/reader/linestring.rs @@ -62,26 +62,26 @@ impl<'a> WKBLineString<'a> { } /// Check if this WKBLineString has equal coordinates as some other LineString object - pub fn equals_line_string(&self, other: impl LineStringTrait<'a, T = f64>) -> bool { + pub fn equals_line_string(&self, other: impl LineStringTrait) -> bool { line_string_eq(self, other) } /// Check if this WKBLineString has equal coordinates as some other MultiLineString object - pub fn equals_multi_line_string(&self, other: impl MultiLineStringTrait<'a, T = f64>) -> bool { + pub fn equals_multi_line_string(&self, other: impl MultiLineStringTrait) -> bool { multi_line_string_eq(self, other) } } -impl<'a> LineStringTrait<'a> for WKBLineString<'a> { +impl<'a> LineStringTrait for WKBLineString<'a> { type T = f64; - type ItemType = WKBCoord<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBCoord<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_coords(&self) -> usize { self.num_points } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { if i > (self.num_coords()) { return None; } @@ -94,21 +94,21 @@ impl<'a> LineStringTrait<'a> for WKBLineString<'a> { Some(coord) } - fn coords(&'a self) -> Self::Iter { + fn coords(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> LineStringTrait<'a> for &WKBLineString<'a> { +impl<'a> LineStringTrait for &'a WKBLineString<'a> { type T = f64; - type ItemType = WKBCoord<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBCoord<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_coords(&self) -> usize { self.num_points } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { if i > (self.num_coords()) { return None; } @@ -118,21 +118,21 @@ impl<'a> LineStringTrait<'a> for &WKBLineString<'a> { Some(coord) } - fn coords(&'a self) -> Self::Iter { + fn coords(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> MultiLineStringTrait<'a> for WKBLineString<'a> { +impl<'a> MultiLineStringTrait for WKBLineString<'a> { type T = f64; - type ItemType = WKBLineString<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBLineString<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_lines(&self) -> usize { 1 } - fn line(&self, i: usize) -> Option { + fn line(&self, i: usize) -> Option> { if i > self.num_lines() { return None; } @@ -140,21 +140,21 @@ impl<'a> MultiLineStringTrait<'a> for WKBLineString<'a> { Some(*self) } - fn lines(&'a self) -> Self::Iter { + fn lines(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> MultiLineStringTrait<'a> for &WKBLineString<'a> { +impl<'a> MultiLineStringTrait for &'a WKBLineString<'a> { type T = f64; - type ItemType = WKBLineString<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBLineString<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_lines(&self) -> usize { 1 } - fn line(&self, i: usize) -> Option { + fn line(&self, i: usize) -> Option> { if i > self.num_lines() { return None; } @@ -162,7 +162,7 @@ impl<'a> MultiLineStringTrait<'a> for &WKBLineString<'a> { Some(**self) } - fn lines(&'a self) -> Self::Iter { + fn lines(&self) -> Self::Iter<'_> { todo!() } } diff --git a/src/io/wkb/reader/maybe_multi_line_string.rs b/src/io/wkb/reader/maybe_multi_line_string.rs index 831781d6..f8feec61 100644 --- a/src/io/wkb/reader/maybe_multi_line_string.rs +++ b/src/io/wkb/reader/maybe_multi_line_string.rs @@ -16,15 +16,15 @@ pub enum WKBMaybeMultiLineString<'a> { impl<'a> WKBMaybeMultiLineString<'a> { /// Check if this has equal coordinates as some other MultiLineString object - pub fn equals_multi_line_string(&self, other: impl MultiLineStringTrait<'a, T = f64>) -> bool { + pub fn equals_multi_line_string(&self, other: impl MultiLineStringTrait) -> bool { multi_line_string_eq(self, other) } } -impl<'a> MultiLineStringTrait<'a> for WKBMaybeMultiLineString<'a> { +impl<'a> MultiLineStringTrait for WKBMaybeMultiLineString<'a> { type T = f64; - type ItemType = WKBLineString<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBLineString<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_lines(&self) -> usize { match self { @@ -33,14 +33,14 @@ impl<'a> MultiLineStringTrait<'a> for WKBMaybeMultiLineString<'a> { } } - fn line(&self, i: usize) -> Option { + fn line(&self, i: usize) -> Option> { match self { WKBMaybeMultiLineString::LineString(geom) => geom.line(i), WKBMaybeMultiLineString::MultiLineString(geom) => geom.line(i), } } - fn lines(&'a self) -> Self::Iter { + fn lines(&self) -> Self::Iter<'_> { match self { WKBMaybeMultiLineString::LineString(geom) => geom.lines(), WKBMaybeMultiLineString::MultiLineString(geom) => geom.lines(), @@ -48,10 +48,10 @@ impl<'a> MultiLineStringTrait<'a> for WKBMaybeMultiLineString<'a> { } } -impl<'a> MultiLineStringTrait<'a> for &WKBMaybeMultiLineString<'a> { +impl<'a> MultiLineStringTrait for &'a WKBMaybeMultiLineString<'a> { type T = f64; - type ItemType = WKBLineString<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBLineString<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_lines(&self) -> usize { match self { @@ -60,14 +60,14 @@ impl<'a> MultiLineStringTrait<'a> for &WKBMaybeMultiLineString<'a> { } } - fn line(&self, i: usize) -> Option { + fn line(&self, i: usize) -> Option> { match self { WKBMaybeMultiLineString::LineString(geom) => geom.line(i), WKBMaybeMultiLineString::MultiLineString(geom) => geom.line(i), } } - fn lines(&'a self) -> Self::Iter { + fn lines(&self) -> Self::Iter<'_> { match self { WKBMaybeMultiLineString::LineString(geom) => geom.lines(), WKBMaybeMultiLineString::MultiLineString(geom) => geom.lines(), diff --git a/src/io/wkb/reader/maybe_multi_point.rs b/src/io/wkb/reader/maybe_multi_point.rs index e352a6e8..3eae6e60 100644 --- a/src/io/wkb/reader/maybe_multi_point.rs +++ b/src/io/wkb/reader/maybe_multi_point.rs @@ -18,15 +18,15 @@ pub enum WKBMaybeMultiPoint<'a> { impl<'a> WKBMaybeMultiPoint<'a> { /// Check if this has equal coordinates as some other MultiPoint object - pub fn equals_multi_point(&self, other: impl MultiPointTrait<'a, T = f64>) -> bool { + pub fn equals_multi_point(&self, other: impl MultiPointTrait) -> bool { multi_point_eq(self, other) } } -impl<'a> MultiPointTrait<'a> for WKBMaybeMultiPoint<'a> { +impl<'a> MultiPointTrait for WKBMaybeMultiPoint<'a> { type T = f64; - type ItemType = WKBPoint<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPoint<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_points(&self) -> usize { match self { @@ -35,14 +35,14 @@ impl<'a> MultiPointTrait<'a> for WKBMaybeMultiPoint<'a> { } } - fn point(&self, i: usize) -> Option { + fn point(&self, i: usize) -> Option> { match self { WKBMaybeMultiPoint::Point(geom) => geom.point(i), WKBMaybeMultiPoint::MultiPoint(geom) => geom.point(i), } } - fn points(&'a self) -> Self::Iter { + fn points(&self) -> Self::Iter<'_> { match self { WKBMaybeMultiPoint::Point(geom) => geom.points(), WKBMaybeMultiPoint::MultiPoint(geom) => geom.points(), @@ -50,10 +50,10 @@ impl<'a> MultiPointTrait<'a> for WKBMaybeMultiPoint<'a> { } } -impl<'a> MultiPointTrait<'a> for &WKBMaybeMultiPoint<'a> { +impl<'a> MultiPointTrait for &'a WKBMaybeMultiPoint<'a> { type T = f64; - type ItemType = WKBPoint<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPoint<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_points(&self) -> usize { match self { @@ -62,14 +62,14 @@ impl<'a> MultiPointTrait<'a> for &WKBMaybeMultiPoint<'a> { } } - fn point(&self, i: usize) -> Option { + fn point(&self, i: usize) -> Option> { match self { WKBMaybeMultiPoint::Point(geom) => geom.point(i), WKBMaybeMultiPoint::MultiPoint(geom) => geom.point(i), } } - fn points(&'a self) -> Self::Iter { + fn points(&self) -> Self::Iter<'_> { match self { WKBMaybeMultiPoint::Point(geom) => geom.points(), WKBMaybeMultiPoint::MultiPoint(geom) => geom.points(), diff --git a/src/io/wkb/reader/maybe_multipolygon.rs b/src/io/wkb/reader/maybe_multipolygon.rs index c898a2af..829da60d 100644 --- a/src/io/wkb/reader/maybe_multipolygon.rs +++ b/src/io/wkb/reader/maybe_multipolygon.rs @@ -16,15 +16,15 @@ pub enum WKBMaybeMultiPolygon<'a> { impl<'a> WKBMaybeMultiPolygon<'a> { /// Check if this has equal coordinates as some other MultiPolygon object - pub fn equals_multi_polygon(&self, other: impl MultiPolygonTrait<'a, T = f64>) -> bool { + pub fn equals_multi_polygon(&self, other: impl MultiPolygonTrait) -> bool { multi_polygon_eq(self, other) } } -impl<'a> MultiPolygonTrait<'a> for WKBMaybeMultiPolygon<'a> { +impl<'a> MultiPolygonTrait for WKBMaybeMultiPolygon<'a> { type T = f64; - type ItemType = WKBPolygon<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPolygon<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_polygons(&self) -> usize { match self { @@ -33,14 +33,14 @@ impl<'a> MultiPolygonTrait<'a> for WKBMaybeMultiPolygon<'a> { } } - fn polygon(&self, i: usize) -> Option { + fn polygon(&self, i: usize) -> Option> { match self { WKBMaybeMultiPolygon::Polygon(geom) => geom.polygon(i), WKBMaybeMultiPolygon::MultiPolygon(geom) => geom.polygon(i), } } - fn polygons(&'a self) -> Self::Iter { + fn polygons(&self) -> Self::Iter<'_> { match self { WKBMaybeMultiPolygon::Polygon(geom) => geom.polygons(), WKBMaybeMultiPolygon::MultiPolygon(geom) => geom.polygons(), @@ -48,10 +48,10 @@ impl<'a> MultiPolygonTrait<'a> for WKBMaybeMultiPolygon<'a> { } } -impl<'a> MultiPolygonTrait<'a> for &WKBMaybeMultiPolygon<'a> { +impl<'a> MultiPolygonTrait for &'a WKBMaybeMultiPolygon<'a> { type T = f64; - type ItemType = WKBPolygon<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPolygon<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_polygons(&self) -> usize { match self { @@ -60,14 +60,14 @@ impl<'a> MultiPolygonTrait<'a> for &WKBMaybeMultiPolygon<'a> { } } - fn polygon(&self, i: usize) -> Option { + fn polygon(&self, i: usize) -> Option> { match self { WKBMaybeMultiPolygon::Polygon(geom) => geom.polygon(i), WKBMaybeMultiPolygon::MultiPolygon(geom) => geom.polygon(i), } } - fn polygons(&'a self) -> Self::Iter { + fn polygons(&self) -> Self::Iter<'_> { match self { WKBMaybeMultiPolygon::Polygon(geom) => geom.polygons(), WKBMaybeMultiPolygon::MultiPolygon(geom) => geom.polygons(), diff --git a/src/io/wkb/reader/multilinestring.rs b/src/io/wkb/reader/multilinestring.rs index 84134e12..78e3ec32 100644 --- a/src/io/wkb/reader/multilinestring.rs +++ b/src/io/wkb/reader/multilinestring.rs @@ -58,21 +58,21 @@ impl<'a> WKBMultiLineString<'a> { } /// Check if this WKBMultiLineString has equal coordinates as some other MultiLineString object - pub fn equals_multi_line_string(&self, other: impl MultiLineStringTrait<'a, T = f64>) -> bool { + pub fn equals_multi_line_string(&self, other: impl MultiLineStringTrait) -> bool { multi_line_string_eq(self, other) } } -impl<'a> MultiLineStringTrait<'a> for WKBMultiLineString<'a> { +impl<'a> MultiLineStringTrait for WKBMultiLineString<'a> { type T = f64; - type ItemType = WKBLineString<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBLineString<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_lines(&self) -> usize { self.wkb_line_strings.len() } - fn line(&self, i: usize) -> Option { + fn line(&self, i: usize) -> Option> { if i > self.num_lines() { return None; } @@ -80,21 +80,21 @@ impl<'a> MultiLineStringTrait<'a> for WKBMultiLineString<'a> { Some(self.wkb_line_strings[i]) } - fn lines(&'a self) -> Self::Iter { + fn lines(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> MultiLineStringTrait<'a> for &WKBMultiLineString<'a> { +impl<'a> MultiLineStringTrait for &'a WKBMultiLineString<'a> { type T = f64; - type ItemType = WKBLineString<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBLineString<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_lines(&self) -> usize { self.wkb_line_strings.len() } - fn line(&self, i: usize) -> Option { + fn line(&self, i: usize) -> Option> { if i > self.num_lines() { return None; } @@ -102,7 +102,7 @@ impl<'a> MultiLineStringTrait<'a> for &WKBMultiLineString<'a> { Some(self.wkb_line_strings[i]) } - fn lines(&'a self) -> Self::Iter { + fn lines(&self) -> Self::Iter<'_> { todo!() } } diff --git a/src/io/wkb/reader/multipoint.rs b/src/io/wkb/reader/multipoint.rs index 73f638fb..ff04f77e 100644 --- a/src/io/wkb/reader/multipoint.rs +++ b/src/io/wkb/reader/multipoint.rs @@ -57,21 +57,21 @@ impl<'a> WKBMultiPoint<'a> { } /// Check if this WKBMultiPoint has equal coordinates as some other MultiPoint object - pub fn equals_multi_point(&self, other: impl MultiPointTrait<'a, T = f64>) -> bool { + pub fn equals_multi_point(&self, other: impl MultiPointTrait) -> bool { multi_point_eq(self, other) } } -impl<'a> MultiPointTrait<'a> for WKBMultiPoint<'a> { +impl<'a> MultiPointTrait for WKBMultiPoint<'a> { type T = f64; - type ItemType = WKBPoint<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPoint<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_points(&self) -> usize { self.num_points } - fn point(&self, i: usize) -> Option { + fn point(&self, i: usize) -> Option> { if i > self.num_points() { return None; } @@ -83,21 +83,21 @@ impl<'a> MultiPointTrait<'a> for WKBMultiPoint<'a> { )) } - fn points(&'a self) -> Self::Iter { + fn points(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> MultiPointTrait<'a> for &WKBMultiPoint<'a> { +impl<'a> MultiPointTrait for &'a WKBMultiPoint<'a> { type T = f64; - type ItemType = WKBPoint<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPoint<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_points(&self) -> usize { self.num_points } - fn point(&self, i: usize) -> Option { + fn point(&self, i: usize) -> Option> { if i > self.num_points() { return None; } @@ -109,7 +109,7 @@ impl<'a> MultiPointTrait<'a> for &WKBMultiPoint<'a> { )) } - fn points(&'a self) -> Self::Iter { + fn points(&self) -> Self::Iter<'_> { todo!() } } diff --git a/src/io/wkb/reader/multipolygon.rs b/src/io/wkb/reader/multipolygon.rs index cc61da67..f7ca18c1 100644 --- a/src/io/wkb/reader/multipolygon.rs +++ b/src/io/wkb/reader/multipolygon.rs @@ -55,21 +55,21 @@ impl<'a> WKBMultiPolygon<'a> { } /// Check if this WKBMultiLineString has equal coordinates as some other MultiLineString object - pub fn equals_multi_polygon(&self, other: impl MultiPolygonTrait<'a, T = f64>) -> bool { + pub fn equals_multi_polygon(&self, other: impl MultiPolygonTrait) -> bool { multi_polygon_eq(self, other) } } -impl<'a> MultiPolygonTrait<'a> for WKBMultiPolygon<'a> { +impl<'a> MultiPolygonTrait for WKBMultiPolygon<'a> { type T = f64; - type ItemType = WKBPolygon<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPolygon<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_polygons(&self) -> usize { self.wkb_polygons.len() } - fn polygon(&self, i: usize) -> Option { + fn polygon(&self, i: usize) -> Option> { if i > self.num_polygons() { return None; } @@ -77,21 +77,21 @@ impl<'a> MultiPolygonTrait<'a> for WKBMultiPolygon<'a> { Some(self.wkb_polygons[i].clone()) } - fn polygons(&'a self) -> Self::Iter { + fn polygons(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> MultiPolygonTrait<'a> for &WKBMultiPolygon<'a> { +impl<'a> MultiPolygonTrait for &'a WKBMultiPolygon<'a> { type T = f64; - type ItemType = WKBPolygon<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPolygon<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_polygons(&self) -> usize { self.wkb_polygons.len() } - fn polygon(&self, i: usize) -> Option { + fn polygon(&self, i: usize) -> Option> { if i > self.num_polygons() { return None; } @@ -99,7 +99,7 @@ impl<'a> MultiPolygonTrait<'a> for &WKBMultiPolygon<'a> { Some(self.wkb_polygons[i].clone()) } - fn polygons(&'a self) -> Self::Iter { + fn polygons(&self) -> Self::Iter<'_> { todo!() } } diff --git a/src/io/wkb/reader/point.rs b/src/io/wkb/reader/point.rs index be4355c3..d0478cdd 100644 --- a/src/io/wkb/reader/point.rs +++ b/src/io/wkb/reader/point.rs @@ -64,16 +64,16 @@ impl<'a> PointTrait for &WKBPoint<'a> { } } -impl<'a> MultiPointTrait<'a> for WKBPoint<'a> { +impl<'a> MultiPointTrait for WKBPoint<'a> { type T = f64; - type ItemType = WKBPoint<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPoint<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_points(&self) -> usize { 1 } - fn point(&self, i: usize) -> Option { + fn point(&self, i: usize) -> Option> { if i > self.num_points() { return None; } @@ -81,21 +81,21 @@ impl<'a> MultiPointTrait<'a> for WKBPoint<'a> { Some(*self) } - fn points(&'a self) -> Self::Iter { + fn points(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> MultiPointTrait<'a> for &WKBPoint<'a> { +impl<'a> MultiPointTrait for &'a WKBPoint<'a> { type T = f64; - type ItemType = WKBPoint<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPoint<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_points(&self) -> usize { 1 } - fn point(&self, i: usize) -> Option { + fn point(&self, i: usize) -> Option> { if i > self.num_points() { return None; } @@ -103,7 +103,7 @@ impl<'a> MultiPointTrait<'a> for &WKBPoint<'a> { Some(**self) } - fn points(&'a self) -> Self::Iter { + fn points(&self) -> Self::Iter<'_> { todo!() } } diff --git a/src/io/wkb/reader/polygon.rs b/src/io/wkb/reader/polygon.rs index 72006799..3bf53732 100644 --- a/src/io/wkb/reader/polygon.rs +++ b/src/io/wkb/reader/polygon.rs @@ -72,15 +72,15 @@ impl<'a> WKBPolygon<'a> { } /// Check if this WKBPolygon has equal coordinates as some other Polygon object - pub fn equals_polygon(&self, other: impl PolygonTrait<'a, T = f64>) -> bool { + pub fn equals_polygon(&self, other: impl PolygonTrait) -> bool { polygon_eq(self, other) } } -impl<'a> PolygonTrait<'a> for WKBPolygon<'a> { +impl<'a> PolygonTrait for WKBPolygon<'a> { type T = f64; - type ItemType = WKBLinearRing<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBLinearRing<'a>where Self: 'b; + type Iter<'b> = Cloned>>where Self: 'b; fn num_interiors(&self) -> usize { // Support an empty polygon with no rings @@ -91,7 +91,7 @@ impl<'a> PolygonTrait<'a> for WKBPolygon<'a> { } } - fn exterior(&self) -> Option { + fn exterior(&self) -> Option> { if self.wkb_linear_rings.is_empty() { None } else { @@ -99,7 +99,7 @@ impl<'a> PolygonTrait<'a> for WKBPolygon<'a> { } } - fn interior(&self, i: usize) -> Option { + fn interior(&self, i: usize) -> Option> { if i > self.num_interiors() { return None; } @@ -107,15 +107,15 @@ impl<'a> PolygonTrait<'a> for WKBPolygon<'a> { Some(self.wkb_linear_rings[i + 1]) } - fn interiors(&'a self) -> Self::Iter { + fn interiors(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> PolygonTrait<'a> for &WKBPolygon<'a> { +impl<'a> PolygonTrait for &'a WKBPolygon<'a> { type T = f64; - type ItemType = WKBLinearRing<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBLinearRing<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_interiors(&self) -> usize { // Support an empty polygon with no rings @@ -126,7 +126,7 @@ impl<'a> PolygonTrait<'a> for &WKBPolygon<'a> { } } - fn exterior(&self) -> Option { + fn exterior(&self) -> Option> { if self.wkb_linear_rings.is_empty() { None } else { @@ -134,7 +134,7 @@ impl<'a> PolygonTrait<'a> for &WKBPolygon<'a> { } } - fn interior(&self, i: usize) -> Option { + fn interior(&self, i: usize) -> Option> { if i > self.num_interiors() { return None; } @@ -142,21 +142,21 @@ impl<'a> PolygonTrait<'a> for &WKBPolygon<'a> { Some(self.wkb_linear_rings[i + 1]) } - fn interiors(&'a self) -> Self::Iter { + fn interiors(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> MultiPolygonTrait<'a> for WKBPolygon<'a> { +impl<'a> MultiPolygonTrait for WKBPolygon<'a> { type T = f64; - type ItemType = WKBPolygon<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPolygon<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_polygons(&self) -> usize { 1 } - fn polygon(&self, i: usize) -> Option { + fn polygon(&self, i: usize) -> Option> { if i > self.num_polygons() { return None; } @@ -164,21 +164,21 @@ impl<'a> MultiPolygonTrait<'a> for WKBPolygon<'a> { Some(self.clone()) } - fn polygons(&'a self) -> Self::Iter { + fn polygons(&self) -> Self::Iter<'_> { todo!() } } -impl<'a> MultiPolygonTrait<'a> for &WKBPolygon<'a> { +impl<'a> MultiPolygonTrait for &'a WKBPolygon<'a> { type T = f64; - type ItemType = WKBPolygon<'a>; - type Iter = Cloned>; + type ItemType<'b> = WKBPolygon<'a> where Self: 'b; + type Iter<'b> = Cloned>> where Self: 'b; fn num_polygons(&self) -> usize { 1 } - fn polygon(&self, i: usize) -> Option { + fn polygon(&self, i: usize) -> Option> { if i > self.num_polygons() { return None; } @@ -188,7 +188,7 @@ impl<'a> MultiPolygonTrait<'a> for &WKBPolygon<'a> { Some(self.clone().clone()) } - fn polygons(&'a self) -> Self::Iter { + fn polygons(&self) -> Self::Iter<'_> { todo!() } } diff --git a/src/io/wkb/reader/rect.rs b/src/io/wkb/reader/rect.rs index 55977fe8..71b33f39 100644 --- a/src/io/wkb/reader/rect.rs +++ b/src/io/wkb/reader/rect.rs @@ -7,15 +7,15 @@ pub struct WKBRect<'a> { _buf: &'a [u8], } -impl<'a> RectTrait<'a> for WKBRect<'a> { +impl<'a> RectTrait for WKBRect<'a> { type T = f64; - type ItemType = WKBCoord<'a>; + type ItemType<'b> = WKBCoord<'a> where Self: 'b; - fn lower(&self) -> Self::ItemType { + fn lower(&self) -> Self::ItemType<'_> { todo!() } - fn upper(&self) -> Self::ItemType { + fn upper(&self) -> Self::ItemType<'_> { todo!() } } diff --git a/src/io/wkb/writer/geometry.rs b/src/io/wkb/writer/geometry.rs index 2f472e76..92236e32 100644 --- a/src/io/wkb/writer/geometry.rs +++ b/src/io/wkb/writer/geometry.rs @@ -11,7 +11,7 @@ use crate::io::wkb::writer::polygon::{polygon_wkb_size, write_polygon_as_wkb}; use std::io::Write; /// The byte length of a Geometry -pub fn geometry_wkb_size<'a>(geom: &'a impl GeometryTrait<'a>) -> usize { +pub fn geometry_wkb_size(geom: &impl GeometryTrait) -> usize { use GeometryType::*; match geom.as_type() { Point(_) => POINT_WKB_SIZE, @@ -25,9 +25,9 @@ pub fn geometry_wkb_size<'a>(geom: &'a impl GeometryTrait<'a>) -> usize { } /// Write a Geometry to a Writer encoded as WKB -pub fn write_geometry_as_wkb<'a, W: Write>( +pub fn write_geometry_as_wkb( writer: W, - geom: &'a impl GeometryTrait<'a, T = f64>, + geom: &impl GeometryTrait, ) -> Result<()> { use GeometryType::*; match geom.as_type() { diff --git a/src/io/wkb/writer/linestring.rs b/src/io/wkb/writer/linestring.rs index 968b7f79..766c82d4 100644 --- a/src/io/wkb/writer/linestring.rs +++ b/src/io/wkb/writer/linestring.rs @@ -9,14 +9,14 @@ use byteorder::{LittleEndian, WriteBytesExt}; use std::io::{Cursor, Write}; /// The byte length of a WKBLineString -pub fn line_string_wkb_size<'a>(geom: &impl LineStringTrait<'a>) -> usize { +pub fn line_string_wkb_size(geom: &impl LineStringTrait) -> usize { 1 + 4 + 4 + (geom.num_coords() * 16) } /// Write a LineString geometry to a Writer encoded as WKB -pub fn write_line_string_as_wkb<'a, W: Write>( +pub fn write_line_string_as_wkb( mut writer: W, - geom: &impl LineStringTrait<'a, T = f64>, + geom: &impl LineStringTrait, ) -> Result<()> { // Byte order writer.write_u8(Endianness::LittleEndian.into()).unwrap(); diff --git a/src/io/wkb/writer/multilinestring.rs b/src/io/wkb/writer/multilinestring.rs index 8638363f..2c5f9382 100644 --- a/src/io/wkb/writer/multilinestring.rs +++ b/src/io/wkb/writer/multilinestring.rs @@ -10,7 +10,7 @@ use byteorder::{LittleEndian, WriteBytesExt}; use std::io::{Cursor, Write}; /// The byte length of a WKBMultiLineString -pub fn multi_line_string_wkb_size<'a>(geom: &impl MultiLineStringTrait<'a>) -> usize { +pub fn multi_line_string_wkb_size(geom: &impl MultiLineStringTrait) -> usize { let mut sum = 1 + 4 + 4; for line_string_idx in 0..geom.num_lines() { let line_string = geom.line(line_string_idx).unwrap(); @@ -21,9 +21,9 @@ pub fn multi_line_string_wkb_size<'a>(geom: &impl MultiLineStringTrait<'a>) -> u } /// Write a MultiLineString geometry to a Writer encoded as WKB -pub fn write_multi_line_string_as_wkb<'a, W: Write>( +pub fn write_multi_line_string_as_wkb( mut writer: W, - geom: &impl MultiLineStringTrait<'a, T = f64>, + geom: &impl MultiLineStringTrait, ) -> Result<()> { // Byte order writer.write_u8(Endianness::LittleEndian.into()).unwrap(); diff --git a/src/io/wkb/writer/multipoint.rs b/src/io/wkb/writer/multipoint.rs index 585de6c9..a38d9ba9 100644 --- a/src/io/wkb/writer/multipoint.rs +++ b/src/io/wkb/writer/multipoint.rs @@ -10,14 +10,14 @@ use byteorder::{LittleEndian, WriteBytesExt}; use std::io::{Cursor, Write}; /// The byte length of a WKBMultiPoint -pub fn multi_point_wkb_size<'a>(geom: &impl MultiPointTrait<'a>) -> usize { +pub fn multi_point_wkb_size(geom: &impl MultiPointTrait) -> usize { 1 + 4 + 4 + (geom.num_points() * POINT_WKB_SIZE) } /// Write a MultiPoint geometry to a Writer encoded as WKB -pub fn write_multi_point_as_wkb<'a, W: Write>( +pub fn write_multi_point_as_wkb( mut writer: W, - geom: &impl MultiPointTrait<'a, T = f64>, + geom: &impl MultiPointTrait, ) -> Result<()> { // Byte order writer.write_u8(Endianness::LittleEndian.into()).unwrap(); diff --git a/src/io/wkb/writer/multipolygon.rs b/src/io/wkb/writer/multipolygon.rs index b4a16152..50af9c78 100644 --- a/src/io/wkb/writer/multipolygon.rs +++ b/src/io/wkb/writer/multipolygon.rs @@ -10,7 +10,7 @@ use byteorder::{LittleEndian, WriteBytesExt}; use std::io::{Cursor, Write}; /// The byte length of a WKBMultiPolygon -pub fn multi_polygon_wkb_size<'a>(geom: &impl MultiPolygonTrait<'a>) -> usize { +pub fn multi_polygon_wkb_size(geom: &impl MultiPolygonTrait) -> usize { let mut sum = 1 + 4 + 4; for polygon_idx in 0..geom.num_polygons() { let polygon = geom.polygon(polygon_idx).unwrap(); @@ -21,9 +21,9 @@ pub fn multi_polygon_wkb_size<'a>(geom: &impl MultiPolygonTrait<'a>) -> usize { } /// Write a MultiPolygon geometry to a Writer encoded as WKB -pub fn write_multi_polygon_as_wkb<'a, W: Write>( +pub fn write_multi_polygon_as_wkb( mut writer: W, - geom: &impl MultiPolygonTrait<'a, T = f64>, + geom: &impl MultiPolygonTrait, ) -> Result<()> { // Byte order writer.write_u8(Endianness::LittleEndian.into()).unwrap(); diff --git a/src/io/wkb/writer/polygon.rs b/src/io/wkb/writer/polygon.rs index fe3a0e3c..3efae513 100644 --- a/src/io/wkb/writer/polygon.rs +++ b/src/io/wkb/writer/polygon.rs @@ -9,7 +9,7 @@ use byteorder::{LittleEndian, WriteBytesExt}; use std::io::{Cursor, Write}; /// The byte length of a WKBPolygon -pub fn polygon_wkb_size<'a>(geom: &impl PolygonTrait<'a>) -> usize { +pub fn polygon_wkb_size(geom: &impl PolygonTrait) -> usize { let mut sum = 1 + 4 + 4; // TODO: support empty polygons where this will panic @@ -25,9 +25,9 @@ pub fn polygon_wkb_size<'a>(geom: &impl PolygonTrait<'a>) -> usize { } /// Write a Polygon geometry to a Writer encoded as WKB -pub fn write_polygon_as_wkb<'a, W: Write>( +pub fn write_polygon_as_wkb( mut writer: W, - geom: &impl PolygonTrait<'a, T = f64>, + geom: &impl PolygonTrait, ) -> Result<()> { // Byte order writer.write_u8(Endianness::LittleEndian.into()).unwrap(); diff --git a/src/scalar/geometry/scalar.rs b/src/scalar/geometry/scalar.rs index 84867d4c..f639589e 100644 --- a/src/scalar/geometry/scalar.rs +++ b/src/scalar/geometry/scalar.rs @@ -34,31 +34,71 @@ impl<'a, O: OffsetSizeTrait> GeometryScalarTrait<'a> for Geometry<'a, O> { } } -impl<'a, O: OffsetSizeTrait> GeometryTrait<'a> for Geometry<'a, O> { +impl<'a, O: OffsetSizeTrait> GeometryTrait for Geometry<'a, O> { type T = f64; - type Point = Point<'a>; - type LineString = LineString<'a, O>; - type Polygon = Polygon<'a, O>; - type MultiPoint = MultiPoint<'a, O>; - type MultiLineString = MultiLineString<'a, O>; - type MultiPolygon = MultiPolygon<'a, O>; - type GeometryCollection = GeometryCollection<'a, O>; - type Rect = Rect<'a>; + type Point<'b> = Point<'b> where Self: 'b; + type LineString<'b> = LineString<'b, O> where Self: 'b; + type Polygon<'b> = Polygon<'b, O> where Self: 'b; + type MultiPoint<'b> = MultiPoint<'b, O> where Self: 'b; + type MultiLineString<'b> = MultiLineString<'b, O> where Self: 'b; + type MultiPolygon<'b> = MultiPolygon<'b, O> where Self: 'b; + type GeometryCollection<'b> = GeometryCollection<'b, O> where Self: 'b; + type Rect<'b> = Rect<'b> where Self: 'b; // TODO: not 100% sure what this is #[allow(implied_bounds_entailment)] fn as_type( - &'a self, + &self, + ) -> crate::geo_traits::GeometryType< + '_, + Point<'_>, + LineString<'_, O>, + Polygon<'_, O>, + MultiPoint<'_, O>, + MultiLineString<'_, O>, + MultiPolygon<'_, O>, + GeometryCollection<'_, O>, + Rect<'_>, + > { + match self { + Geometry::Point(p) => GeometryType::Point(p), + Geometry::LineString(p) => GeometryType::LineString(p), + Geometry::Polygon(p) => GeometryType::Polygon(p), + Geometry::MultiPoint(p) => GeometryType::MultiPoint(p), + Geometry::MultiLineString(p) => GeometryType::MultiLineString(p), + Geometry::MultiPolygon(p) => GeometryType::MultiPolygon(p), + // Geometry::GeometryCollection(p) => GeometryType::GeometryCollection(p), + // Geometry::Rect(p) => GeometryType::Rect(p), + _ => todo!(), + } + } +} + +impl<'a, O: OffsetSizeTrait> GeometryTrait for &'a Geometry<'a, O> { + type T = f64; + type Point<'b> = Point<'a> where Self: 'b; + type LineString<'b> = LineString<'a, O> where Self: 'b; + type Polygon<'b> = Polygon<'a, O> where Self: 'b; + type MultiPoint<'b> = MultiPoint<'a, O> where Self: 'b; + type MultiLineString<'b> = MultiLineString<'a, O> where Self: 'b; + type MultiPolygon<'b> = MultiPolygon<'a, O> where Self: 'b; + type GeometryCollection<'b> = GeometryCollection<'a, O> where Self: 'b; + type Rect<'b> = Rect<'a> where Self: 'b; + + // TODO: not 100% sure what this is + #[allow(implied_bounds_entailment)] + fn as_type( + &self, ) -> crate::geo_traits::GeometryType< 'a, - Point, - LineString, - Polygon, - MultiPoint, - MultiLineString, - MultiPolygon, - GeometryCollection, - Rect, + Point<'a>, + LineString<'a, O>, + Polygon<'a, O>, + MultiPoint<'a, O>, + MultiLineString<'a, O>, + MultiPolygon<'a, O>, + GeometryCollection<'a, O>, + Rect<'a>, > { match self { Geometry::Point(p) => GeometryType::Point(p), diff --git a/src/scalar/geometrycollection/scalar.rs b/src/scalar/geometrycollection/scalar.rs index a7406577..1328dc22 100644 --- a/src/scalar/geometrycollection/scalar.rs +++ b/src/scalar/geometrycollection/scalar.rs @@ -28,12 +28,37 @@ impl<'a, O: OffsetSizeTrait> GeometryScalarTrait<'a> for GeometryCollection<'a, } } -impl<'a, O: OffsetSizeTrait> GeometryCollectionTrait<'a> for GeometryCollection<'a, O> { +impl<'a, O: OffsetSizeTrait> GeometryCollectionTrait for GeometryCollection<'a, O> { type T = f64; - type ItemType = Geometry<'a, O>; - type Iter = GeometryCollectionIterator<'a, O>; + type ItemType<'b> = Geometry<'a, O> where Self: 'b; + type Iter<'b> = GeometryCollectionIterator<'a, O> where Self: 'b; - fn geometries(&'a self) -> Self::Iter { + fn geometries(&self) -> Self::Iter<'_> { + todo!() + // GeometryCollectionIterator::new(self) + } + + fn num_geometries(&self) -> usize { + let (start, end) = self.geom_offsets.start_end(self.geom_index); + end - start + } + + fn geometry(&self, i: usize) -> Option> { + let (start, end) = self.geom_offsets.start_end(self.geom_index); + if i > (end - start) { + return None; + } + + Some(self.array.value(start + i)) + } +} + +impl<'a, O: OffsetSizeTrait> GeometryCollectionTrait for &'a GeometryCollection<'a, O> { + type T = f64; + type ItemType<'b> = Geometry<'a, O> where Self: 'b; + type Iter<'b> = GeometryCollectionIterator<'a, O> where Self: 'b; + + fn geometries(&self) -> Self::Iter<'_> { GeometryCollectionIterator::new(self) } @@ -42,7 +67,7 @@ impl<'a, O: OffsetSizeTrait> GeometryCollectionTrait<'a> for GeometryCollection< end - start } - fn geometry(&self, i: usize) -> Option { + fn geometry(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start) { return None; diff --git a/src/scalar/linestring/scalar.rs b/src/scalar/linestring/scalar.rs index b3ce418f..4c554bc5 100644 --- a/src/scalar/linestring/scalar.rs +++ b/src/scalar/linestring/scalar.rs @@ -92,13 +92,14 @@ impl<'a, O: OffsetSizeTrait> GeometryScalarTrait<'a> for LineString<'a, O> { } } -impl<'a, O: OffsetSizeTrait> LineStringTrait<'a> for LineString<'a, O> { +impl<'a, O: OffsetSizeTrait> LineStringTrait for LineString<'a, O> { type T = f64; - type ItemType = Point<'a>; - type Iter = LineStringIterator<'a, O>; + type ItemType<'b> = Point<'a> where Self: 'b; + type Iter<'b> = LineStringIterator<'a, O> where Self: 'b; - fn coords(&'a self) -> Self::Iter { - LineStringIterator::new(self) + fn coords(&self) -> Self::Iter<'_> { + todo!() + // LineStringIterator::new(self) } fn num_coords(&self) -> usize { @@ -106,7 +107,7 @@ impl<'a, O: OffsetSizeTrait> LineStringTrait<'a> for LineString<'a, O> { end - start } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start) { return None; @@ -116,12 +117,12 @@ impl<'a, O: OffsetSizeTrait> LineStringTrait<'a> for LineString<'a, O> { } } -impl<'a, O: OffsetSizeTrait> LineStringTrait<'a> for &LineString<'a, O> { +impl<'a, O: OffsetSizeTrait> LineStringTrait for &'a LineString<'a, O> { type T = f64; - type ItemType = Point<'a>; - type Iter = LineStringIterator<'a, O>; + type ItemType<'b> = Point<'a> where Self: 'b; + type Iter<'b> = LineStringIterator<'a, O> where Self: 'b; - fn coords(&'a self) -> Self::Iter { + fn coords(&self) -> Self::Iter<'_> { LineStringIterator::new(self) } @@ -130,7 +131,7 @@ impl<'a, O: OffsetSizeTrait> LineStringTrait<'a> for &LineString<'a, O> { end - start } - fn coord(&self, i: usize) -> Option { + fn coord(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start) { return None; diff --git a/src/scalar/multilinestring/scalar.rs b/src/scalar/multilinestring/scalar.rs index 615affbb..a73aa8df 100644 --- a/src/scalar/multilinestring/scalar.rs +++ b/src/scalar/multilinestring/scalar.rs @@ -108,13 +108,14 @@ impl<'a, O: OffsetSizeTrait> GeometryScalarTrait<'a> for MultiLineString<'a, O> } } -impl<'a, O: OffsetSizeTrait> MultiLineStringTrait<'a> for MultiLineString<'a, O> { +impl<'a, O: OffsetSizeTrait> MultiLineStringTrait for MultiLineString<'a, O> { type T = f64; - type ItemType = LineString<'a, O>; - type Iter = MultiLineStringIterator<'a, O>; + type ItemType<'b> = LineString<'a, O> where Self: 'b; + type Iter<'b> = MultiLineStringIterator<'a, O> where Self: 'b; - fn lines(&'a self) -> Self::Iter { - MultiLineStringIterator::new(self) + fn lines(&self) -> Self::Iter<'_> { + todo!() + // MultiLineStringIterator::new(self) } fn num_lines(&self) -> usize { @@ -122,7 +123,7 @@ impl<'a, O: OffsetSizeTrait> MultiLineStringTrait<'a> for MultiLineString<'a, O> end - start } - fn line(&self, i: usize) -> Option { + fn line(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start) { return None; @@ -136,12 +137,12 @@ impl<'a, O: OffsetSizeTrait> MultiLineStringTrait<'a> for MultiLineString<'a, O> } } -impl<'a, O: OffsetSizeTrait> MultiLineStringTrait<'a> for &MultiLineString<'a, O> { +impl<'a, O: OffsetSizeTrait> MultiLineStringTrait for &'a MultiLineString<'a, O> { type T = f64; - type ItemType = LineString<'a, O>; - type Iter = MultiLineStringIterator<'a, O>; + type ItemType<'b> = LineString<'a, O> where Self: 'b; + type Iter<'b> = MultiLineStringIterator<'a, O> where Self: 'b; - fn lines(&'a self) -> Self::Iter { + fn lines(&self) -> Self::Iter<'_> { MultiLineStringIterator::new(self) } @@ -150,7 +151,7 @@ impl<'a, O: OffsetSizeTrait> MultiLineStringTrait<'a> for &MultiLineString<'a, O end - start } - fn line(&self, i: usize) -> Option { + fn line(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start) { return None; diff --git a/src/scalar/multipoint/scalar.rs b/src/scalar/multipoint/scalar.rs index 21b8f4bd..4cf49d59 100644 --- a/src/scalar/multipoint/scalar.rs +++ b/src/scalar/multipoint/scalar.rs @@ -93,13 +93,14 @@ impl<'a, O: OffsetSizeTrait> GeometryScalarTrait<'a> for MultiPoint<'a, O> { } } -impl<'a, O: OffsetSizeTrait> MultiPointTrait<'a> for MultiPoint<'a, O> { +impl<'a, O: OffsetSizeTrait> MultiPointTrait for MultiPoint<'a, O> { type T = f64; - type ItemType = Point<'a>; - type Iter = MultiPointIterator<'a, O>; + type ItemType<'b> = Point<'a> where Self: 'b; + type Iter<'b> = MultiPointIterator<'a, O> where Self: 'b; - fn points(&'a self) -> Self::Iter { - MultiPointIterator::new(self) + fn points(&self) -> Self::Iter<'_> { + todo!() + // MultiPointIterator::new(self) } fn num_points(&self) -> usize { @@ -107,7 +108,7 @@ impl<'a, O: OffsetSizeTrait> MultiPointTrait<'a> for MultiPoint<'a, O> { end - start } - fn point(&self, i: usize) -> Option { + fn point(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start) { return None; @@ -117,12 +118,12 @@ impl<'a, O: OffsetSizeTrait> MultiPointTrait<'a> for MultiPoint<'a, O> { } } -impl<'a, O: OffsetSizeTrait> MultiPointTrait<'a> for &MultiPoint<'a, O> { +impl<'a, O: OffsetSizeTrait> MultiPointTrait for &'a MultiPoint<'a, O> { type T = f64; - type ItemType = Point<'a>; - type Iter = MultiPointIterator<'a, O>; + type ItemType<'b> = Point<'a> where Self: 'b; + type Iter<'b> = MultiPointIterator<'a, O> where Self: 'b; - fn points(&'a self) -> Self::Iter { + fn points(&self) -> Self::Iter<'_> { MultiPointIterator::new(self) } @@ -131,7 +132,7 @@ impl<'a, O: OffsetSizeTrait> MultiPointTrait<'a> for &MultiPoint<'a, O> { end - start } - fn point(&self, i: usize) -> Option { + fn point(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start) { return None; diff --git a/src/scalar/multipolygon/scalar.rs b/src/scalar/multipolygon/scalar.rs index 00a21c30..9ad7e9eb 100644 --- a/src/scalar/multipolygon/scalar.rs +++ b/src/scalar/multipolygon/scalar.rs @@ -127,13 +127,14 @@ impl<'a, O: OffsetSizeTrait> GeometryScalarTrait<'a> for MultiPolygon<'a, O> { } } -impl<'a, O: OffsetSizeTrait> MultiPolygonTrait<'a> for MultiPolygon<'a, O> { +impl<'a, O: OffsetSizeTrait> MultiPolygonTrait for MultiPolygon<'a, O> { type T = f64; - type ItemType = Polygon<'a, O>; - type Iter = MultiPolygonIterator<'a, O>; + type ItemType<'b> = Polygon<'a, O> where Self: 'b; + type Iter<'b> = MultiPolygonIterator<'a, O> where Self: 'b; - fn polygons(&'a self) -> Self::Iter { - MultiPolygonIterator::new(self) + fn polygons(&self) -> Self::Iter<'_> { + todo!() + // MultiPolygonIterator::new(self) } fn num_polygons(&self) -> usize { @@ -141,7 +142,7 @@ impl<'a, O: OffsetSizeTrait> MultiPolygonTrait<'a> for MultiPolygon<'a, O> { end - start } - fn polygon(&self, i: usize) -> Option { + fn polygon(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start) { return None; @@ -157,12 +158,12 @@ impl<'a, O: OffsetSizeTrait> MultiPolygonTrait<'a> for MultiPolygon<'a, O> { } } -impl<'a, O: OffsetSizeTrait> MultiPolygonTrait<'a> for &MultiPolygon<'a, O> { +impl<'a, O: OffsetSizeTrait> MultiPolygonTrait for &'a MultiPolygon<'a, O> { type T = f64; - type ItemType = Polygon<'a, O>; - type Iter = MultiPolygonIterator<'a, O>; + type ItemType<'b> = Polygon<'a, O> where Self: 'b; + type Iter<'b> = MultiPolygonIterator<'a, O> where Self: 'b; - fn polygons(&'a self) -> Self::Iter { + fn polygons(&self) -> Self::Iter<'_> { MultiPolygonIterator::new(self) } @@ -171,7 +172,7 @@ impl<'a, O: OffsetSizeTrait> MultiPolygonTrait<'a> for &MultiPolygon<'a, O> { end - start } - fn polygon(&self, i: usize) -> Option { + fn polygon(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start) { return None; diff --git a/src/scalar/polygon/scalar.rs b/src/scalar/polygon/scalar.rs index ce435e40..b544ec10 100644 --- a/src/scalar/polygon/scalar.rs +++ b/src/scalar/polygon/scalar.rs @@ -108,12 +108,12 @@ impl<'a, O: OffsetSizeTrait> GeometryScalarTrait<'a> for Polygon<'a, O> { } } -impl<'a, O: OffsetSizeTrait> PolygonTrait<'a> for Polygon<'a, O> { +impl<'a, O: OffsetSizeTrait> PolygonTrait for Polygon<'a, O> { type T = f64; - type ItemType = LineString<'a, O>; - type Iter = PolygonInteriorIterator<'a, O>; + type ItemType<'b> = LineString<'a, O> where Self: 'b; + type Iter<'b> = PolygonInteriorIterator<'a, O> where Self: 'b; - fn exterior(&self) -> Option { + fn exterior(&self) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if start == end { None @@ -126,8 +126,9 @@ impl<'a, O: OffsetSizeTrait> PolygonTrait<'a> for Polygon<'a, O> { } } - fn interiors(&'a self) -> Self::Iter { - PolygonInteriorIterator::new(self) + fn interiors(&self) -> Self::Iter<'_> { + todo!() + // PolygonInteriorIterator::new(self) } fn num_interiors(&self) -> usize { @@ -135,7 +136,7 @@ impl<'a, O: OffsetSizeTrait> PolygonTrait<'a> for Polygon<'a, O> { end - start - 1 } - fn interior(&self, i: usize) -> Option { + fn interior(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start - 1) { return None; @@ -149,12 +150,12 @@ impl<'a, O: OffsetSizeTrait> PolygonTrait<'a> for Polygon<'a, O> { } } -impl<'a, O: OffsetSizeTrait> PolygonTrait<'a> for &Polygon<'a, O> { +impl<'a, O: OffsetSizeTrait> PolygonTrait for &'a Polygon<'a, O> { type T = f64; - type ItemType = LineString<'a, O>; - type Iter = PolygonInteriorIterator<'a, O>; + type ItemType<'b> = LineString<'a, O> where Self: 'b; + type Iter<'b> = PolygonInteriorIterator<'a, O> where Self: 'b; - fn exterior(&self) -> Option { + fn exterior(&self) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if start == end { None @@ -167,7 +168,7 @@ impl<'a, O: OffsetSizeTrait> PolygonTrait<'a> for &Polygon<'a, O> { } } - fn interiors(&'a self) -> Self::Iter { + fn interiors(&self) -> Self::Iter<'_> { PolygonInteriorIterator::new(self) } @@ -176,7 +177,7 @@ impl<'a, O: OffsetSizeTrait> PolygonTrait<'a> for &Polygon<'a, O> { end - start - 1 } - fn interior(&self, i: usize) -> Option { + fn interior(&self, i: usize) -> Option> { let (start, end) = self.geom_offsets.start_end(self.geom_index); if i > (end - start - 1) { return None; diff --git a/src/scalar/rect/scalar.rs b/src/scalar/rect/scalar.rs index 2546fcd5..a764d735 100644 --- a/src/scalar/rect/scalar.rs +++ b/src/scalar/rect/scalar.rs @@ -39,17 +39,17 @@ impl<'a> GeometryScalarTrait<'a> for Rect<'a> { } } -impl<'a> RectTrait<'a> for Rect<'a> { +impl<'a> RectTrait for Rect<'a> { type T = f64; - type ItemType = (Self::T, Self::T); + type ItemType<'b> = (Self::T, Self::T) where Self: 'b; - fn lower(&self) -> Self::ItemType { + fn lower(&self) -> Self::ItemType<'_> { let minx = self.values[self.geom_index * 4]; let miny = self.values[self.geom_index * 4 + 1]; (minx, miny) } - fn upper(&self) -> Self::ItemType { + fn upper(&self) -> Self::ItemType<'_> { let maxx = self.values[self.geom_index * 4 + 2]; let maxy = self.values[self.geom_index * 4 + 3]; (maxx, maxy)