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

wip: Remove lifetime from scalars #949

Closed
wants to merge 7 commits into from
Closed
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
2 changes: 1 addition & 1 deletion js/Cargo.lock

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

17 changes: 5 additions & 12 deletions js/src/scalar/linestring.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
use geoarrow::scalar::OwnedLineString;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct LineString(pub(crate) OwnedLineString);
pub struct LineString(pub(crate) geoarrow::scalar::LineString);

impl<'a> From<&'a LineString> for geoarrow::scalar::LineString<'a> {
fn from(value: &'a LineString) -> Self {
(&value.0).into()
}
}

impl From<LineString> for geoarrow::scalar::OwnedLineString {
impl From<LineString> for geoarrow::scalar::LineString {
fn from(value: LineString) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::LineString<'a>> for LineString {
fn from(value: geoarrow::scalar::LineString<'a>) -> Self {
LineString(value.into())
impl From<geoarrow::scalar::LineString> for LineString {
fn from(value: geoarrow::scalar::LineString) -> Self {
LineString(value)
}
}
17 changes: 5 additions & 12 deletions js/src/scalar/multilinestring.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
use geoarrow::scalar::OwnedMultiLineString;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct MultiLineString(pub(crate) OwnedMultiLineString);
pub struct MultiLineString(pub(crate) geoarrow::scalar::MultiLineString);

impl<'a> From<&'a MultiLineString> for geoarrow::scalar::MultiLineString<'a> {
fn from(value: &'a MultiLineString) -> Self {
(&value.0).into()
}
}

impl From<MultiLineString> for geoarrow::scalar::OwnedMultiLineString {
impl From<MultiLineString> for geoarrow::scalar::MultiLineString {
fn from(value: MultiLineString) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::MultiLineString<'a>> for MultiLineString {
fn from(value: geoarrow::scalar::MultiLineString<'a>) -> Self {
MultiLineString(value.into())
impl From<geoarrow::scalar::MultiLineString> for MultiLineString {
fn from(value: geoarrow::scalar::MultiLineString) -> Self {
MultiLineString(value)
}
}
17 changes: 5 additions & 12 deletions js/src/scalar/multipoint.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
use geoarrow::scalar::OwnedMultiPoint;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct MultiPoint(pub(crate) OwnedMultiPoint);
pub struct MultiPoint(pub(crate) geoarrow::scalar::MultiPoint);

impl<'a> From<&'a MultiPoint> for geoarrow::scalar::MultiPoint<'a> {
fn from(value: &'a MultiPoint) -> Self {
(&value.0).into()
}
}

impl From<MultiPoint> for geoarrow::scalar::OwnedMultiPoint {
impl From<MultiPoint> for geoarrow::scalar::MultiPoint {
fn from(value: MultiPoint) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::MultiPoint<'a>> for MultiPoint {
fn from(value: geoarrow::scalar::MultiPoint<'a>) -> Self {
MultiPoint(value.into())
impl From<geoarrow::scalar::MultiPoint> for MultiPoint {
fn from(value: geoarrow::scalar::MultiPoint) -> Self {
MultiPoint(value)
}
}
17 changes: 5 additions & 12 deletions js/src/scalar/multipolygon.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
use geoarrow::scalar::OwnedMultiPolygon;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct MultiPolygon(pub(crate) OwnedMultiPolygon);
pub struct MultiPolygon(pub(crate) geoarrow::scalar::MultiPolygon);

impl<'a> From<&'a MultiPolygon> for geoarrow::scalar::MultiPolygon<'a> {
fn from(value: &'a MultiPolygon) -> Self {
(&value.0).into()
}
}

impl From<MultiPolygon> for geoarrow::scalar::OwnedMultiPolygon {
impl From<MultiPolygon> for geoarrow::scalar::MultiPolygon {
fn from(value: MultiPolygon) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::MultiPolygon<'a>> for MultiPolygon {
fn from(value: geoarrow::scalar::MultiPolygon<'a>) -> Self {
MultiPolygon(value.into())
impl From<geoarrow::scalar::MultiPolygon> for MultiPolygon {
fn from(value: geoarrow::scalar::MultiPolygon) -> Self {
MultiPolygon(value)
}
}
17 changes: 5 additions & 12 deletions js/src/scalar/point.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
use geoarrow::scalar::OwnedPoint;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct Point(pub(crate) OwnedPoint);
pub struct Point(pub(crate) geoarrow::scalar::Point);

impl<'a> From<&'a Point> for geoarrow::scalar::Point<'a> {
fn from(value: &'a Point) -> Self {
(&value.0).into()
}
}

impl From<Point> for geoarrow::scalar::OwnedPoint {
impl From<Point> for geoarrow::scalar::Point {
fn from(value: Point) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::Point<'a>> for Point {
fn from(value: geoarrow::scalar::Point<'a>) -> Self {
Point(value.into())
impl From<geoarrow::scalar::Point> for Point {
fn from(value: geoarrow::scalar::Point) -> Self {
Point(value)
}
}
17 changes: 5 additions & 12 deletions js/src/scalar/polygon.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
use geoarrow::scalar::OwnedPolygon;
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub struct Polygon(pub(crate) OwnedPolygon);
pub struct Polygon(pub(crate) geoarrow::scalar::Polygon);

impl<'a> From<&'a Polygon> for geoarrow::scalar::Polygon<'a> {
fn from(value: &'a Polygon) -> Self {
(&value.0).into()
}
}

impl From<Polygon> for geoarrow::scalar::OwnedPolygon {
impl From<Polygon> for geoarrow::scalar::Polygon {
fn from(value: Polygon) -> Self {
value.0
}
}

impl<'a> From<geoarrow::scalar::Polygon<'a>> for Polygon {
fn from(value: geoarrow::scalar::Polygon<'a>) -> Self {
Polygon(value.into())
impl From<geoarrow::scalar::Polygon> for Polygon {
fn from(value: geoarrow::scalar::Polygon) -> Self {
Polygon(value)
}
}
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 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 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
2 changes: 1 addition & 1 deletion rust/geoarrow/src/algorithm/native/binary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::array::*;
use crate::error::{GeoArrowError, Result};
use crate::trait_::ArrayAccessor;

pub trait Binary<'a, Rhs: ArrayAccessor<'a> = Self>: ArrayAccessor<'a> + NativeArray {
pub trait Binary<'a, Rhs: ArrayAccessor = Self>: ArrayAccessor + NativeArray {
fn binary_boolean<F>(&'a self, rhs: &'a Rhs, op: F) -> Result<BooleanArray>
where
F: Fn(Self::Item, Rhs::Item) -> bool,
Expand Down
Loading
Loading