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

Remove infallible accessor for Point::coord #880

Merged
merged 2 commits into from
Nov 27, 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
6 changes: 3 additions & 3 deletions rust/geoarrow/src/algorithm/native/map_coords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::trait_::ArrayAccessor;
use crate::NativeArray;
use geo_traits::{
CoordTrait, GeometryCollectionTrait, GeometryTrait, GeometryType, LineStringTrait,
MultiLineStringTrait, MultiPointTrait, MultiPolygonTrait, PolygonTrait, RectTrait,
MultiLineStringTrait, MultiPointTrait, MultiPolygonTrait, PointTrait, PolygonTrait, RectTrait,
};

/// Note: this will currently always create a _two-dimensional_ output array because it returns a [`geo::Coord`].
Expand Down Expand Up @@ -52,7 +52,7 @@ impl MapCoords for Point<'_> {
F: Fn(&crate::scalar::Coord) -> std::result::Result<geo::Coord, E> + Sync,
GeoArrowError: From<E>,
{
Ok(geo::Point(map_op(&self.coord())?))
Ok(geo::Point(map_op(&self.coord().unwrap())?))
}
}

Expand Down Expand Up @@ -229,7 +229,7 @@ impl MapCoords for PointArray {
);
for maybe_geom in self.iter() {
if let Some(geom) = maybe_geom {
let result = geom.coord().try_map_coords(&map_op)?;
let result = geom.coord().unwrap().try_map_coords(&map_op)?;
builder.push_coord(Some(&result));
} else {
builder.push_null()
Expand Down
4 changes: 0 additions & 4 deletions rust/geoarrow/src/scalar/point/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ impl<'a> Point<'a> {
Point { coords, geom_index }
}

pub fn coord(&self) -> Coord {
self.coords.value(self.geom_index)
}

pub fn into_owned_inner(self) -> (CoordBuffer, usize) {
let coords = self.coords.owned_slice(self.geom_index, 1);
(coords, self.geom_index)
Expand Down
4 changes: 2 additions & 2 deletions rust/geoarrow/src/trait_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,8 +540,8 @@ pub trait ArrayAccessor<'a>: ArrayBase {
/// let point = geo::point!(x: 1., y: 2.);
/// let array: PointArray = (vec![point].as_slice(), Dimension::XY).into();
/// let value = array.value(0); // geoarrow::scalar::Point
/// assert_eq!(value.coord().x(), 1.);
/// assert_eq!(value.coord().y(), 2.);
/// assert_eq!(value.coord().unwrap().x(), 1.);
/// assert_eq!(value.coord().unwrap().y(), 2.);
/// ```
///
/// # Panics
Expand Down
Loading