Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update geos to 9.0 #626

Merged
merged 4 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ gdal = { version = "0.16", optional = true }
geo = "0.28"
geo-index = "0.1.1"
geodesy = { version = "0.12", optional = true }
geos = { version = "8.3", features = ["v3_10_0", "geo"], optional = true }
geos = { version = "9.0", features = ["v3_11_0", "geo"], optional = true }
geozero = { version = "0.12", features = ["with-wkb"], optional = true }
http-range-client = { version = "0.7.2", optional = true }
indexmap = "2"
Expand Down
3 changes: 3 additions & 0 deletions js/src/io/parquet/async_file_reader/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ use reqwest::Client;

use async_trait::async_trait;

// This was used until we switched to object store for making requests. When we're happy with the
// object store implementation and believe it's stable, we can remove this.
#[allow(dead_code)]
#[async_trait(?Send)]
trait SharedIO<T: AsyncFileReader + Unpin + Clone + 'static> {
fn generate_builder(
Expand Down
4 changes: 2 additions & 2 deletions src/algorithm/geos/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub trait Buffer<O: OffsetSizeTrait> {

fn buffer(&self, width: f64, quadsegs: i32) -> Self::Output;

fn buffer_with_params(&self, width: f64, buffer_params: &BufferParams<'_>) -> Self::Output;
fn buffer_with_params(&self, width: f64, buffer_params: &BufferParams) -> Self::Output;
}

impl<O: OffsetSizeTrait> Buffer<O> for PointArray {
Expand All @@ -32,7 +32,7 @@ impl<O: OffsetSizeTrait> Buffer<O> for PointArray {
Ok(builder.finish())
}

fn buffer_with_params(&self, width: f64, buffer_params: &BufferParams<'_>) -> Self::Output {
fn buffer_with_params(&self, width: f64, buffer_params: &BufferParams) -> Self::Output {
let mut builder = PolygonBuilder::new();

for maybe_g in self.iter() {
Expand Down
1 change: 1 addition & 0 deletions src/algorithm/native/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ pub use map_coords::MapCoords;
pub use rechunk::Rechunk;
pub use take::Take;
pub use total_bounds::TotalBounds;
pub use type_id::TypeIds;
pub use unary::Unary;
4 changes: 2 additions & 2 deletions src/array/point/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl PointBuilder {
}

pub fn from_points<'a>(
geoms: impl ExactSizeIterator + Iterator<Item = &'a (impl PointTrait<T = f64> + 'a)>,
geoms: impl ExactSizeIterator<Item = &'a (impl PointTrait<T = f64> + 'a)>,
coord_type: Option<CoordType>,
metadata: Arc<ArrayMetadata>,
) -> Self {
Expand All @@ -182,7 +182,7 @@ impl PointBuilder {
}

pub fn from_nullable_points<'a>(
geoms: impl ExactSizeIterator + Iterator<Item = Option<&'a (impl PointTrait<T = f64> + 'a)>>,
geoms: impl ExactSizeIterator<Item = Option<&'a (impl PointTrait<T = f64> + 'a)>>,
coord_type: Option<CoordType>,
metadata: Arc<ArrayMetadata>,
) -> Self {
Expand Down
4 changes: 2 additions & 2 deletions src/array/rect/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl RectBuilder {

/// Create this builder from a iterator of Rects.
pub fn from_rects<'a>(
geoms: impl ExactSizeIterator + Iterator<Item = &'a (impl RectTrait<T = f64> + 'a)>,
geoms: impl ExactSizeIterator<Item = &'a (impl RectTrait<T = f64> + 'a)>,
metadata: Arc<ArrayMetadata>,
) -> Self {
let mut mutable_array = Self::with_capacity(geoms.len(), metadata);
Expand All @@ -139,7 +139,7 @@ impl RectBuilder {

/// Create this builder from a iterator of nullable Rects.
pub fn from_nullable_rects<'a>(
geoms: impl ExactSizeIterator + Iterator<Item = Option<&'a (impl RectTrait<T = f64> + 'a)>>,
geoms: impl ExactSizeIterator<Item = Option<&'a (impl RectTrait<T = f64> + 'a)>>,
metadata: Arc<ArrayMetadata>,
) -> Self {
let mut mutable_array = Self::with_capacity(geoms.len(), metadata);
Expand Down
8 changes: 4 additions & 4 deletions src/io/geos/array/linestring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::array::{LineStringArray, LineStringBuilder};
use crate::error::{GeoArrowError, Result};
use crate::io::geos::scalar::GEOSLineString;

impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for LineStringBuilder<O> {
impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry>>> for LineStringBuilder<O> {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'_>>>) -> Result<Self> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> Result<Self> {
// TODO: don't use new_unchecked
let geos_objects: Vec<Option<GEOSLineString>> = value
.into_iter()
Expand All @@ -17,10 +17,10 @@ impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for LineString
}
}

impl<'a, O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'a>>>> for LineStringArray<O> {
impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry>>> for LineStringArray<O> {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'a>>>) -> std::result::Result<Self, Self::Error> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> std::result::Result<Self, Self::Error> {
let mutable_arr: LineStringBuilder<O> = value.try_into()?;
Ok(mutable_arr.into())
}
Expand Down
8 changes: 4 additions & 4 deletions src/io/geos/array/multilinestring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::array::{MultiLineStringArray, MultiLineStringBuilder};
use crate::error::{GeoArrowError, Result};
use crate::io::geos::scalar::GEOSMultiLineString;

impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for MultiLineStringBuilder<O> {
impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry>>> for MultiLineStringBuilder<O> {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'_>>>) -> Result<Self> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> Result<Self> {
// TODO: don't use new_unchecked
let geos_objects: Vec<Option<GEOSMultiLineString>> = value
.into_iter()
Expand All @@ -17,10 +17,10 @@ impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for MultiLineS
}
}

impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for MultiLineStringArray<O> {
impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry>>> for MultiLineStringArray<O> {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'_>>>) -> Result<Self> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> Result<Self> {
let mutable_arr: MultiLineStringBuilder<O> = value.try_into()?;
Ok(mutable_arr.into())
}
Expand Down
8 changes: 4 additions & 4 deletions src/io/geos/array/multipoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::array::{MultiPointArray, MultiPointBuilder};
use crate::error::GeoArrowError;
use crate::io::geos::scalar::GEOSMultiPoint;

impl<'a, O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'a>>>> for MultiPointBuilder<O> {
impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry>>> for MultiPointBuilder<O> {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'a>>>) -> std::result::Result<Self, Self::Error> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> std::result::Result<Self, Self::Error> {
// TODO: don't use new_unchecked
let geos_objects: Vec<Option<GEOSMultiPoint>> = value
.into_iter()
Expand All @@ -17,10 +17,10 @@ impl<'a, O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'a>>>> for MultiP
}
}

impl<'a, O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'a>>>> for MultiPointArray<O> {
impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry>>> for MultiPointArray<O> {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'a>>>) -> std::result::Result<Self, Self::Error> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> std::result::Result<Self, Self::Error> {
let mutable_arr: MultiPointBuilder<O> = value.try_into()?;
Ok(mutable_arr.into())
}
Expand Down
8 changes: 4 additions & 4 deletions src/io/geos/array/multipolygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use crate::array::{MultiPolygonArray, MultiPolygonBuilder};
use crate::error::{GeoArrowError, Result};
use crate::io::geos::scalar::GEOSMultiPolygon;

impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for MultiPolygonBuilder<O> {
impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry>>> for MultiPolygonBuilder<O> {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'_>>>) -> Result<Self> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> Result<Self> {
// TODO: don't use new_unchecked
let geos_objects: Vec<Option<GEOSMultiPolygon>> = value
.into_iter()
Expand All @@ -17,10 +17,10 @@ impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for MultiPolyg
}
}

impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for MultiPolygonArray<O> {
impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry>>> for MultiPolygonArray<O> {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'_>>>) -> Result<Self> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> Result<Self> {
let mutable_arr: MultiPolygonBuilder<O> = value.try_into()?;
Ok(mutable_arr.into())
}
Expand Down
26 changes: 11 additions & 15 deletions src/io/geos/array/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ use crate::array::{PointArray, PointBuilder};
use crate::error::GeoArrowError;
use crate::io::geos::scalar::GEOSPoint;

impl<'a> TryFrom<Vec<Option<geos::Geometry<'a>>>> for PointBuilder {
impl TryFrom<Vec<Option<geos::Geometry>>> for PointBuilder {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'a>>>) -> std::result::Result<Self, Self::Error> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> std::result::Result<Self, Self::Error> {
// TODO: don't use new_unchecked
let geos_linestring_objects: Vec<Option<GEOSPoint>> = value
.into_iter()
Expand All @@ -15,33 +15,29 @@ impl<'a> TryFrom<Vec<Option<geos::Geometry<'a>>>> for PointBuilder {
}
}

impl<'a> TryFrom<Vec<Option<geos::Geometry<'a>>>> for PointArray {
impl TryFrom<Vec<Option<geos::Geometry>>> for PointArray {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'a>>>) -> std::result::Result<Self, Self::Error> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> std::result::Result<Self, Self::Error> {
let mutable_arr: PointBuilder = value.try_into()?;
Ok(mutable_arr.into())
}
}

#[allow(unused_imports)]
#[cfg(test)]
mod test {
use super::*;
use crate::test::point::point_array;
use crate::trait_::{GeometryArrayAccessor, GeometryScalarTrait};

#[ignore = "geos lifetime error"]
#[test]
fn geos_round_trip() {
let _arr = point_array();
todo!()

// let geos_geoms: Vec<Option<geos::Geometry>> = arr
// .iter()
// .map(|opt_x| opt_x.map(|x| x.to_geos().unwrap()))
// .collect();
// let round_trip: PointArray = geos_geoms.try_into().unwrap();
// assert_eq!(arr, round_trip);
let arr = point_array();
let geos_geoms: Vec<Option<geos::Geometry>> = arr
.iter()
.map(|opt_x| opt_x.map(|x| x.to_geos().unwrap()))
.collect();
let round_trip: PointArray = geos_geoms.try_into().unwrap();
assert_eq!(arr, round_trip);
}
}
16 changes: 8 additions & 8 deletions src/io/geos/array/polygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ use crate::array::{PolygonArray, PolygonBuilder};
use crate::error::{GeoArrowError, Result};
use crate::io::geos::scalar::GEOSPolygon;

impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for PolygonBuilder<O> {
impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry>>> for PolygonBuilder<O> {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'_>>>) -> Result<Self> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> Result<Self> {
// TODO: don't use new_unchecked
let geos_objects: Vec<Option<GEOSPolygon>> = value
.into_iter()
Expand All @@ -19,21 +19,21 @@ impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for PolygonBui
}
}

impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry<'_>>>> for PolygonArray<O> {
impl<O: OffsetSizeTrait> TryFrom<Vec<Option<geos::Geometry>>> for PolygonArray<O> {
type Error = GeoArrowError;

fn try_from(value: Vec<Option<geos::Geometry<'_>>>) -> Result<Self> {
fn try_from(value: Vec<Option<geos::Geometry>>) -> Result<Self> {
let mutable_arr: PolygonBuilder<O> = value.try_into()?;
Ok(mutable_arr.into())
}
}

impl<'a, O: OffsetSizeTrait> TryFrom<bumpalo::collections::Vec<'a, Option<geos::Geometry<'_>>>>
impl<'a, O: OffsetSizeTrait> TryFrom<bumpalo::collections::Vec<'a, Option<geos::Geometry>>>
for PolygonBuilder<O>
{
type Error = GeoArrowError;

fn try_from(value: bumpalo::collections::Vec<'a, Option<geos::Geometry<'_>>>) -> Result<Self> {
fn try_from(value: bumpalo::collections::Vec<'a, Option<geos::Geometry>>) -> Result<Self> {
let bump = bumpalo::Bump::new();

// TODO: avoid creating GEOSPolygon objects at all?
Expand All @@ -47,12 +47,12 @@ impl<'a, O: OffsetSizeTrait> TryFrom<bumpalo::collections::Vec<'a, Option<geos::
}
}

impl<'a, O: OffsetSizeTrait> TryFrom<bumpalo::collections::Vec<'a, Option<geos::Geometry<'_>>>>
impl<'a, O: OffsetSizeTrait> TryFrom<bumpalo::collections::Vec<'a, Option<geos::Geometry>>>
for PolygonArray<O>
{
type Error = GeoArrowError;

fn try_from(value: bumpalo::collections::Vec<'a, Option<geos::Geometry<'_>>>) -> Result<Self> {
fn try_from(value: bumpalo::collections::Vec<'a, Option<geos::Geometry>>) -> Result<Self> {
let mutable_arr: PolygonBuilder<O> = value.try_into()?;
Ok(mutable_arr.into())
}
Expand Down
8 changes: 4 additions & 4 deletions src/io/geos/scalar/binary.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use crate::scalar::WKB;
use arrow_array::OffsetSizeTrait;

impl<'b, O: OffsetSizeTrait> TryFrom<WKB<'_, O>> for geos::Geometry<'b> {
impl<O: OffsetSizeTrait> TryFrom<WKB<'_, O>> for geos::Geometry {
type Error = geos::Error;

fn try_from(value: WKB<'_, O>) -> std::result::Result<geos::Geometry<'b>, geos::Error> {
fn try_from(value: WKB<'_, O>) -> std::result::Result<geos::Geometry, geos::Error> {
geos::Geometry::try_from(&value)
}
}

impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a WKB<'_, O>> for geos::Geometry<'b> {
impl<'a, O: OffsetSizeTrait> TryFrom<&'a WKB<'_, O>> for geos::Geometry {
type Error = geos::Error;

fn try_from(value: &'a WKB<'_, O>) -> std::result::Result<geos::Geometry<'b>, geos::Error> {
fn try_from(value: &'a WKB<'_, O>) -> std::result::Result<geos::Geometry, geos::Error> {
geos::Geometry::new_from_wkb(value.arr.value(value.geom_index))
}
}
2 changes: 1 addition & 1 deletion src/io/geos/scalar/coord/combined.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::array::CoordBuffer;
use geos::CoordSeq;

impl TryFrom<CoordBuffer> for CoordSeq<'_> {
impl TryFrom<CoordBuffer> for CoordSeq {
type Error = geos::Error;

fn try_from(value: CoordBuffer) -> std::result::Result<Self, geos::Error> {
Expand Down
2 changes: 1 addition & 1 deletion src/io/geos/scalar/coord/interleaved.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::array::InterleavedCoordBuffer;
use crate::GeometryArrayTrait;
use geos::CoordSeq;

impl TryFrom<InterleavedCoordBuffer> for CoordSeq<'_> {
impl TryFrom<InterleavedCoordBuffer> for CoordSeq {
type Error = geos::Error;

fn try_from(value: InterleavedCoordBuffer) -> std::result::Result<Self, geos::Error> {
Expand Down
6 changes: 3 additions & 3 deletions src/io/geos/scalar/coord/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ mod interleaved;
mod separated;

#[derive(Clone)]
pub struct GEOSConstCoord<'a> {
pub(crate) coords: geos::CoordSeq<'a>,
pub struct GEOSConstCoord {
pub(crate) coords: geos::CoordSeq,
pub(crate) geom_index: usize,
}

impl<'a> CoordTrait for GEOSConstCoord<'a> {
impl CoordTrait for GEOSConstCoord {
type T = f64;

fn x(&self) -> Self::T {
Expand Down
2 changes: 1 addition & 1 deletion src/io/geos/scalar/coord/separated.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::array::SeparatedCoordBuffer;
use geos::CoordSeq;

impl TryFrom<SeparatedCoordBuffer> for CoordSeq<'_> {
impl TryFrom<SeparatedCoordBuffer> for CoordSeq {
type Error = geos::Error;

fn try_from(value: SeparatedCoordBuffer) -> std::result::Result<Self, geos::Error> {
Expand Down
10 changes: 4 additions & 6 deletions src/io/geos/scalar/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
use crate::scalar::Geometry;
use arrow_array::OffsetSizeTrait;

impl<'b, O: OffsetSizeTrait> TryFrom<Geometry<'_, O>> for geos::Geometry<'b> {
impl<O: OffsetSizeTrait> TryFrom<Geometry<'_, O>> for geos::Geometry {
type Error = geos::Error;

fn try_from(value: Geometry<'_, O>) -> std::result::Result<geos::Geometry<'b>, geos::Error> {
fn try_from(value: Geometry<'_, O>) -> std::result::Result<geos::Geometry, geos::Error> {
geos::Geometry::try_from(&value)
}
}

impl<'a, 'b, O: OffsetSizeTrait> TryFrom<&'a Geometry<'_, O>> for geos::Geometry<'b> {
impl<'a, O: OffsetSizeTrait> TryFrom<&'a Geometry<'_, O>> for geos::Geometry {
type Error = geos::Error;

fn try_from(
value: &'a Geometry<'_, O>,
) -> std::result::Result<geos::Geometry<'b>, geos::Error> {
fn try_from(value: &'a Geometry<'_, O>) -> std::result::Result<geos::Geometry, geos::Error> {
match value {
Geometry::Point(g) => g.try_into(),
Geometry::LineString(g) => g.try_into(),
Expand Down
Loading
Loading