Skip to content

Commit

Permalink
Remove generics
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Dec 16, 2024
1 parent 13c1d9f commit b6b5ed0
Show file tree
Hide file tree
Showing 78 changed files with 672 additions and 1,471 deletions.
74 changes: 37 additions & 37 deletions rust/geoarrow/src/algorithm/geo/euclidean_distance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ iter_geo_impl!(MultiPolygonArray, PointArray);
// └─────────────────────────────────┘

// Note: this implementation is outside the macro because it is not generic over O
impl<'a> EuclideanDistance<Point<'a>> for PointArray {
impl<'a> EuclideanDistance<Point> for PointArray {
/// Minimum distance between two Points
fn euclidean_distance(&self, other: &Point<'a>) -> Float64Array {
fn euclidean_distance(&self, other: &Point) -> Float64Array {
let mut output_array = Float64Builder::with_capacity(self.len());

self.iter_geo().for_each(|maybe_point| {
Expand Down Expand Up @@ -220,48 +220,48 @@ macro_rules! iter_geo_impl_scalar {
}

// Implementations on PointArray
iter_geo_impl_scalar!(PointArray, LineString<'a>);
iter_geo_impl_scalar!(PointArray, Polygon<'a>);
iter_geo_impl_scalar!(PointArray, MultiPoint<'a>);
iter_geo_impl_scalar!(PointArray, MultiLineString<'a>);
iter_geo_impl_scalar!(PointArray, MultiPolygon<'a>);
iter_geo_impl_scalar!(PointArray, LineString);
iter_geo_impl_scalar!(PointArray, Polygon);
iter_geo_impl_scalar!(PointArray, MultiPoint);
iter_geo_impl_scalar!(PointArray, MultiLineString);
iter_geo_impl_scalar!(PointArray, MultiPolygon);

// Implementations on LineStringArray
iter_geo_impl_scalar!(LineStringArray, Point<'a>);
iter_geo_impl_scalar!(LineStringArray, LineString<'a>);
iter_geo_impl_scalar!(LineStringArray, Polygon<'a>);
// iter_geo_impl_scalar!(LineStringArray, MultiPoint<'a>);
// iter_geo_impl_scalar!(LineStringArray, MultiLineString<'a>);
// iter_geo_impl_scalar!(LineStringArray, MultiPolygon<'a>);
iter_geo_impl_scalar!(LineStringArray, Point);
iter_geo_impl_scalar!(LineStringArray, LineString);
iter_geo_impl_scalar!(LineStringArray, Polygon);
// iter_geo_impl_scalar!(LineStringArray, MultiPoint);
// iter_geo_impl_scalar!(LineStringArray, MultiLineString);
// iter_geo_impl_scalar!(LineStringArray, MultiPolygon);

// Implementations on PolygonArray
iter_geo_impl_scalar!(PolygonArray, Point<'a>);
iter_geo_impl_scalar!(PolygonArray, LineString<'a>);
iter_geo_impl_scalar!(PolygonArray, Polygon<'a>);
// iter_geo_impl_scalar!(PolygonArray, MultiPoint<'a>);
// iter_geo_impl_scalar!(PolygonArray, MultiLineString<'a>);
// iter_geo_impl_scalar!(PolygonArray, MultiPolygon<'a>);
iter_geo_impl_scalar!(PolygonArray, Point);
iter_geo_impl_scalar!(PolygonArray, LineString);
iter_geo_impl_scalar!(PolygonArray, Polygon);
// iter_geo_impl_scalar!(PolygonArray, MultiPoint);
// iter_geo_impl_scalar!(PolygonArray, MultiLineString);
// iter_geo_impl_scalar!(PolygonArray, MultiPolygon);

// Implementations on MultiPointArray
iter_geo_impl_scalar!(MultiPointArray, Point<'a>);
// iter_geo_impl_scalar!(MultiPointArray, LineString<'a>);
// iter_geo_impl_scalar!(MultiPointArray, Polygon<'a>);
// iter_geo_impl_scalar!(MultiPointArray, MultiPoint<'a>);
// iter_geo_impl_scalar!(MultiPointArray, MultiLineString<'a>);
// iter_geo_impl_scalar!(MultiPointArray, MultiPolygon<'a>);
iter_geo_impl_scalar!(MultiPointArray, Point);
// iter_geo_impl_scalar!(MultiPointArray, LineString);
// iter_geo_impl_scalar!(MultiPointArray, Polygon);
// iter_geo_impl_scalar!(MultiPointArray, MultiPoint);
// iter_geo_impl_scalar!(MultiPointArray, MultiLineString);
// iter_geo_impl_scalar!(MultiPointArray, MultiPolygon);

// Implementations on MultiLineStringArray
iter_geo_impl_scalar!(MultiLineStringArray, Point<'a>);
// iter_geo_impl_scalar!(MultiLineStringArray, LineString<'a>);
// iter_geo_impl_scalar!(MultiLineStringArray, Polygon<'a>);
// iter_geo_impl_scalar!(MultiLineStringArray, MultiPoint<'a>);
// iter_geo_impl_scalar!(MultiLineStringArray, MultiLineString<'a>);
// iter_geo_impl_scalar!(MultiLineStringArray, MultiPolygon<'a>);
iter_geo_impl_scalar!(MultiLineStringArray, Point);
// iter_geo_impl_scalar!(MultiLineStringArray, LineString);
// iter_geo_impl_scalar!(MultiLineStringArray, Polygon);
// iter_geo_impl_scalar!(MultiLineStringArray, MultiPoint);
// iter_geo_impl_scalar!(MultiLineStringArray, MultiLineString);
// iter_geo_impl_scalar!(MultiLineStringArray, MultiPolygon);

// Implementations on MultiPolygonArray
iter_geo_impl_scalar!(MultiPolygonArray, Point<'a>);
// iter_geo_impl_scalar!(MultiPolygonArray, LineString<'a>);
// iter_geo_impl_scalar!(MultiPolygonArray, Polygon<'a>);
// iter_geo_impl_scalar!(MultiPolygonArray, MultiPoint<'a>);
// iter_geo_impl_scalar!(MultiPolygonArray, MultiLineString<'a>);
// iter_geo_impl_scalar!(MultiPolygonArray, MultiPolygon<'a>);
iter_geo_impl_scalar!(MultiPolygonArray, Point);
// iter_geo_impl_scalar!(MultiPolygonArray, LineString);
// iter_geo_impl_scalar!(MultiPolygonArray, Polygon);
// iter_geo_impl_scalar!(MultiPolygonArray, MultiPoint);
// iter_geo_impl_scalar!(MultiPolygonArray, MultiLineString);
// iter_geo_impl_scalar!(MultiPolygonArray, MultiPolygon);
74 changes: 37 additions & 37 deletions rust/geoarrow/src/algorithm/geo/within.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ iter_geo_impl!(MultiPolygonArray, MultiPolygonArray);
// └──────────────────────────────────────────┘

// Note: this implementation is outside the macro because it is not generic over O
impl<'a> Within<Point<'a>> for PointArray {
fn is_within(&self, rhs: &Point<'a>) -> BooleanArray {
impl<'a> Within<Point> for PointArray {
fn is_within(&self, rhs: &Point) -> BooleanArray {
let mut output_array = BooleanBuilder::with_capacity(self.len());

self.iter_geo().for_each(|maybe_point| {
Expand Down Expand Up @@ -175,51 +175,51 @@ macro_rules! iter_geo_impl_geoarrow_scalar {
}

// Implementations on PointArray
iter_geo_impl_geoarrow_scalar!(PointArray, LineString<'a>);
iter_geo_impl_geoarrow_scalar!(PointArray, Polygon<'a>);
iter_geo_impl_geoarrow_scalar!(PointArray, MultiPoint<'a>);
iter_geo_impl_geoarrow_scalar!(PointArray, MultiLineString<'a>);
iter_geo_impl_geoarrow_scalar!(PointArray, MultiPolygon<'a>);
iter_geo_impl_geoarrow_scalar!(PointArray, LineString);
iter_geo_impl_geoarrow_scalar!(PointArray, Polygon);
iter_geo_impl_geoarrow_scalar!(PointArray, MultiPoint);
iter_geo_impl_geoarrow_scalar!(PointArray, MultiLineString);
iter_geo_impl_geoarrow_scalar!(PointArray, MultiPolygon);

// Implementations on LineStringArray
iter_geo_impl_geoarrow_scalar!(LineStringArray, Point<'a>);
iter_geo_impl_geoarrow_scalar!(LineStringArray, LineString<'a>);
iter_geo_impl_geoarrow_scalar!(LineStringArray, Polygon<'a>);
iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiPoint<'a>);
iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiLineString<'a>);
iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiPolygon<'a>);
iter_geo_impl_geoarrow_scalar!(LineStringArray, Point);
iter_geo_impl_geoarrow_scalar!(LineStringArray, LineString);
iter_geo_impl_geoarrow_scalar!(LineStringArray, Polygon);
iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiPoint);
iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiLineString);
iter_geo_impl_geoarrow_scalar!(LineStringArray, MultiPolygon);

// Implementations on PolygonArray
iter_geo_impl_geoarrow_scalar!(PolygonArray, Point<'a>);
iter_geo_impl_geoarrow_scalar!(PolygonArray, LineString<'a>);
iter_geo_impl_geoarrow_scalar!(PolygonArray, Polygon<'a>);
iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiPoint<'a>);
iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiLineString<'a>);
iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiPolygon<'a>);
iter_geo_impl_geoarrow_scalar!(PolygonArray, Point);
iter_geo_impl_geoarrow_scalar!(PolygonArray, LineString);
iter_geo_impl_geoarrow_scalar!(PolygonArray, Polygon);
iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiPoint);
iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiLineString);
iter_geo_impl_geoarrow_scalar!(PolygonArray, MultiPolygon);

// Implementations on MultiPointArray
iter_geo_impl_geoarrow_scalar!(MultiPointArray, Point<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, LineString<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, Polygon<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiPoint<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiLineString<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiPolygon<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, Point);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, LineString);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, Polygon);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiPoint);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiLineString);
iter_geo_impl_geoarrow_scalar!(MultiPointArray, MultiPolygon);

// Implementations on MultiLineStringArray
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, Point<'a>);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, LineString<'a>);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, Polygon<'a>);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiPoint<'a>);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiLineString<'a>);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiPolygon<'a>);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, Point);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, LineString);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, Polygon);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiPoint);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiLineString);
iter_geo_impl_geoarrow_scalar!(MultiLineStringArray, MultiPolygon);

// Implementations on MultiPolygonArray
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, Point<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, LineString<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, Polygon<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiPoint<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiLineString<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiPolygon<'a>);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, Point);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, LineString);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, Polygon);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiPoint);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiLineString);
iter_geo_impl_geoarrow_scalar!(MultiPolygonArray, MultiPolygon);

// ┌─────────────────────────────────────┐
// │ Implementations for RHS geo scalars │
Expand Down
20 changes: 10 additions & 10 deletions rust/geoarrow/src/algorithm/native/map_coords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub trait MapCoords {

// Scalar impls

impl MapCoords for Coord<'_> {
impl MapCoords for Coord {
type Output = geo::Coord;

fn try_map_coords<F, E>(&self, map_op: F) -> Result<Self::Output>
Expand All @@ -44,7 +44,7 @@ impl MapCoords for Coord<'_> {
}
}

impl MapCoords for Point<'_> {
impl MapCoords for Point {
type Output = geo::Point;

fn try_map_coords<F, E>(&self, map_op: F) -> Result<Self::Output>
Expand All @@ -56,7 +56,7 @@ impl MapCoords for Point<'_> {
}
}

impl MapCoords for LineString<'_> {
impl MapCoords for LineString {
type Output = geo::LineString;

fn try_map_coords<F, E>(&self, map_op: F) -> Result<Self::Output>
Expand All @@ -72,7 +72,7 @@ impl MapCoords for LineString<'_> {
}
}

impl MapCoords for Polygon<'_> {
impl MapCoords for Polygon {
type Output = geo::Polygon;

fn try_map_coords<F, E>(&self, map_op: F) -> Result<Self::Output>
Expand All @@ -94,7 +94,7 @@ impl MapCoords for Polygon<'_> {
}
}

impl MapCoords for MultiPoint<'_> {
impl MapCoords for MultiPoint {
type Output = geo::MultiPoint;

fn try_map_coords<F, E>(&self, map_op: F) -> Result<Self::Output>
Expand All @@ -110,7 +110,7 @@ impl MapCoords for MultiPoint<'_> {
}
}

impl MapCoords for MultiLineString<'_> {
impl MapCoords for MultiLineString {
type Output = geo::MultiLineString;

fn try_map_coords<F, E>(&self, map_op: F) -> Result<Self::Output>
Expand All @@ -126,7 +126,7 @@ impl MapCoords for MultiLineString<'_> {
}
}

impl MapCoords for MultiPolygon<'_> {
impl MapCoords for MultiPolygon {
// TODO: support empty polygons within a multi polygon
type Output = geo::MultiPolygon;

Expand All @@ -143,7 +143,7 @@ impl MapCoords for MultiPolygon<'_> {
}
}

impl MapCoords for Geometry<'_> {
impl MapCoords for Geometry {
type Output = geo::Geometry;

fn try_map_coords<F, E>(&self, map_op: F) -> Result<Self::Output>
Expand Down Expand Up @@ -171,7 +171,7 @@ impl MapCoords for Geometry<'_> {
}
}

impl MapCoords for GeometryCollection<'_> {
impl MapCoords for GeometryCollection {
type Output = geo::GeometryCollection;

fn try_map_coords<F, E>(&self, map_op: F) -> Result<Self::Output>
Expand All @@ -187,7 +187,7 @@ impl MapCoords for GeometryCollection<'_> {
}
}

impl MapCoords for Rect<'_> {
impl MapCoords for Rect {
type Output = geo::Rect;

fn try_map_coords<F, E>(&self, map_op: F) -> Result<Self::Output>
Expand Down
21 changes: 9 additions & 12 deletions rust/geoarrow/src/algorithm/rstar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub trait RTree<'a> {
}

impl<'a> RTree<'a> for PointArray {
type RTreeObject = crate::scalar::Point<'a>;
type RTreeObject = crate::scalar::Point;

fn rstar_tree(&'a self) -> rstar::RTree<Self::RTreeObject> {
// Note: for points we don't memoize with CachedEnvelope
Expand All @@ -23,7 +23,7 @@ impl<'a> RTree<'a> for PointArray {
}

impl<'a> RTree<'a> for RectArray {
type RTreeObject = crate::scalar::Rect<'a>;
type RTreeObject = crate::scalar::Rect;

fn rstar_tree(&'a self) -> rstar::RTree<Self::RTreeObject> {
// Note: for rects we don't memoize with CachedEnvelope
Expand All @@ -43,13 +43,10 @@ macro_rules! iter_cached_impl {
};
}

iter_cached_impl!(LineStringArray, crate::scalar::LineString<'a>);
iter_cached_impl!(PolygonArray, crate::scalar::Polygon<'a>);
iter_cached_impl!(MultiPointArray, crate::scalar::MultiPoint<'a>);
iter_cached_impl!(MultiLineStringArray, crate::scalar::MultiLineString<'a>);
iter_cached_impl!(MultiPolygonArray, crate::scalar::MultiPolygon<'a>);
iter_cached_impl!(MixedGeometryArray, crate::scalar::Geometry<'a>);
iter_cached_impl!(
GeometryCollectionArray,
crate::scalar::GeometryCollection<'a>
);
iter_cached_impl!(LineStringArray, crate::scalar::LineString);
iter_cached_impl!(PolygonArray, crate::scalar::Polygon);
iter_cached_impl!(MultiPointArray, crate::scalar::MultiPoint);
iter_cached_impl!(MultiLineStringArray, crate::scalar::MultiLineString);
iter_cached_impl!(MultiPolygonArray, crate::scalar::MultiPolygon);
iter_cached_impl!(MixedGeometryArray, crate::scalar::Geometry);
iter_cached_impl!(GeometryCollectionArray, crate::scalar::GeometryCollection);
8 changes: 6 additions & 2 deletions rust/geoarrow/src/array/binary/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ impl<O: OffsetSizeTrait> WKBArray<O> {
arr.metadata = metadata;
arr
}

fn value(&self, index: usize) -> WKB<O> {
WKB::new(self.slice(index, 1))
}
}

impl<O: OffsetSizeTrait> ArrayBase for WKBArray<O> {
Expand Down Expand Up @@ -159,11 +163,11 @@ impl<O: OffsetSizeTrait> SerializedArray for WKBArray<O> {
}

impl<'a, O: OffsetSizeTrait> ArrayAccessor<'a> for WKBArray<O> {
type Item = WKB<'a, O>;
type Item = WKB<O>;
type ItemGeo = geo::Geometry;

unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item {
WKB::new(&self.array, index)
self.value(index)
}
}

Expand Down
2 changes: 1 addition & 1 deletion rust/geoarrow/src/array/coord/combined/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl CoordBuffer {
self.len() == 0
}

pub fn value(&self, index: usize) -> Coord<'_> {
pub fn value(&self, index: usize) -> Coord {
match self {
CoordBuffer::Interleaved(c) => Coord::Interleaved(c.value(index)),
CoordBuffer::Separated(c) => Coord::Separated(c.value(index)),
Expand Down
2 changes: 1 addition & 1 deletion rust/geoarrow/src/array/geometry/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,7 @@ impl<'a> crate::trait_::NativeGEOSGeometryAccessor<'a> for GeometryArray {
}

impl<'a> ArrayAccessor<'a> for GeometryArray {
type Item = Geometry<'a>;
type Item = Geometry;
type ItemGeo = geo::Geometry;

unsafe fn value_unchecked(&'a self, index: usize) -> Self::Item {
Expand Down
4 changes: 2 additions & 2 deletions rust/geoarrow/src/array/geometry/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ impl<'a> GeometryBuilder {
}

pub(crate) fn from_wkb<W: OffsetSizeTrait>(
wkb_objects: &[Option<WKB<'_, W>>],
wkb_objects: &[Option<WKB<W>>],
coord_type: CoordType,
metadata: Arc<ArrayMetadata>,
prefer_multi: bool,
Expand Down Expand Up @@ -989,7 +989,7 @@ impl<O: OffsetSizeTrait> TryFrom<WKBArray<O>> for GeometryBuilder {
);

let metadata = value.metadata.clone();
let wkb_objects: Vec<Option<WKB<'_, O>>> = value.iter().collect();
let wkb_objects: Vec<Option<WKB<O>>> = value.iter().collect();
Self::from_wkb(&wkb_objects, Default::default(), metadata, true)
}
}
Expand Down
Loading

0 comments on commit b6b5ed0

Please sign in to comment.