Skip to content

Commit

Permalink
Bump geo-traits to 0.2 (#874)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron authored Nov 25, 2024
1 parent e38f0d9 commit 3ecf7df
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 39 deletions.
8 changes: 4 additions & 4 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 js/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bytes = { version = "1", optional = true }
console_error_panic_hook = { version = "0.1.6", optional = true }
futures = { version = "0.3.30", optional = true }
geo = "0.28"
geo-traits = "0.1.1"
geo-traits = "0.2"
geoarrow = { path = "../rust/geoarrow" }
geodesy = { version = "0.12", optional = true, features = ["js"] }
object_store = { version = "0.11", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion python/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ arrow = "53"
arrow-array = "53"
arrow-buffer = "53"
arrow-schema = "53"
geo-traits = "0.1.1"
geo-traits = "0.2"
geoarrow = { path = "../rust/geoarrow" }
# Uncomment when publishing
# geoarrow = { version = "0.4.0-beta.1" }
Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ futures = { version = "0.3", optional = true }
gdal = { version = "0.17", optional = true }
geo = "0.28"
geo-index = "0.1.1"
geo-traits = "0.1.1"
geo-traits = "0.2"
geos = { version = "9.0", features = ["v3_10_0", "geo"], optional = true }
geozero = { version = "0.14", features = ["with-wkb"] }
half = { version = "2.4.1" }
Expand Down Expand Up @@ -96,8 +96,8 @@ sqlx = { version = "0.7", optional = true, default-features = false, features =
thiserror = "1"
tokio = { version = "1", default-features = false, optional = true }
# wkt = "0.11"
wkt = { git = "https://github.com/georust/wkt", branch = "kyle/geo-traits-writer" }
wkb = { git = "https://github.com/kylebarron/wkb", rev = "7d58a2327fe21cf250dab5ac6860b6cf0fddb838" }
wkt = { git = "https://github.com/georust/wkt", rev = "447be533e0a76188ca499eb8a0c74fc4e8a0f823" }
wkb = { git = "https://github.com/kylebarron/wkb", rev = "e0f29b4a24104356464cc123925b459d81c40e52" }


[dev-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion rust/geoarrow/src/algorithm/native/eq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn coord_eq<T: CoordFloat>(
}

for i in 0..left_dim.size() {
if left.nth_unchecked(i) != right.nth_unchecked(i) {
if left.nth_or_panic(i) != right.nth_or_panic(i) {
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust/geoarrow/src/io/flatgeobuf/reader/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ impl<'a> CoordTrait for Coord<'a> {
self.dim.into()
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
match n {
0 => self.geom.xy().unwrap().get(self.coord_offset * 2),
1 => self.geom.xy().unwrap().get((self.coord_offset * 2) + 1),
Expand Down
2 changes: 1 addition & 1 deletion rust/geoarrow/src/io/geos/scalar/coord/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl CoordTrait for GEOSConstCoord {
self.dim
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
match n {
0 => self.coords.get_x(self.geom_index).unwrap(),
1 => self.coords.get_y(self.geom_index).unwrap(),
Expand Down
8 changes: 4 additions & 4 deletions rust/geoarrow/src/io/geozero/scalar/coord.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) fn process_coord<P: GeomProcessor>(
Dimensions::Xyz | Dimensions::Unknown(3) => processor.coordinate(
coord.x(),
coord.y(),
Some(coord.nth_unchecked(2)),
Some(unsafe { coord.nth_unchecked(2) }),
None,
None,
None,
Expand All @@ -23,16 +23,16 @@ pub(crate) fn process_coord<P: GeomProcessor>(
coord.x(),
coord.y(),
None,
Some(coord.nth_unchecked(2)),
Some(unsafe { coord.nth_unchecked(2) }),
None,
None,
coord_idx,
)?,
Dimensions::Xyzm | Dimensions::Unknown(4) => processor.coordinate(
coord.x(),
coord.y(),
Some(coord.nth_unchecked(2)),
Some(coord.nth_unchecked(3)),
Some(unsafe { coord.nth_unchecked(2) }),
Some(unsafe { coord.nth_unchecked(3) }),
None,
None,
coord_idx,
Expand Down
8 changes: 4 additions & 4 deletions rust/geoarrow/src/io/geozero/scalar/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub(crate) fn process_point_as_coord<P: GeomProcessor>(
Dimensions::Xyz | Dimensions::Unknown(3) => processor.coordinate(
coord.x(),
coord.y(),
Some(coord.nth_unchecked(2)),
Some(unsafe { coord.nth_unchecked(2) }),
None,
None,
None,
Expand All @@ -43,16 +43,16 @@ pub(crate) fn process_point_as_coord<P: GeomProcessor>(
coord.x(),
coord.y(),
None,
Some(coord.nth_unchecked(2)),
Some(unsafe { coord.nth_unchecked(2) }),
None,
None,
coord_idx,
)?,
Dimensions::Xyzm | Dimensions::Unknown(4) => processor.coordinate(
coord.x(),
coord.y(),
Some(coord.nth_unchecked(2)),
Some(coord.nth_unchecked(3)),
Some(unsafe { coord.nth_unchecked(2) }),
Some(unsafe { coord.nth_unchecked(3) }),
None,
None,
coord_idx,
Expand Down
4 changes: 2 additions & 2 deletions rust/geoarrow/src/io/shapefile/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl<'a> CoordTrait for Point<'a> {
geo_traits::Dimensions::Xy
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
match n {
0 => self.0.x,
1 => self.0.y,
Expand Down Expand Up @@ -71,7 +71,7 @@ impl<'a> CoordTrait for PointZ<'a> {
}
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
match n {
0 => self.0.x,
1 => self.0.y,
Expand Down
8 changes: 4 additions & 4 deletions rust/geoarrow/src/io/wkt/writer/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ pub(super) fn coord_to_wkt<T: CoordFloat>(coord: &impl CoordTrait<T = T>) -> wkt
match coord.dim() {
Dimensions::Xy | Dimensions::Unknown(2) => {}
Dimensions::Xyz | Dimensions::Unknown(3) => {
out.z = Some(coord.nth_unchecked(2));
out.z = Some(unsafe { coord.nth_unchecked(2) });
}
Dimensions::Xym => {
out.m = Some(coord.nth_unchecked(2));
out.m = Some(unsafe { coord.nth_unchecked(2) });
}
Dimensions::Xyzm | Dimensions::Unknown(4) => {
out.z = Some(coord.nth_unchecked(2));
out.m = Some(coord.nth_unchecked(3));
out.z = Some(unsafe { coord.nth_unchecked(2) });
out.m = Some(unsafe { coord.nth_unchecked(3) });
}
_ => panic!(),
}
Expand Down
12 changes: 6 additions & 6 deletions rust/geoarrow/src/scalar/coord/combined/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ impl CoordTrait for Coord<'_> {
}
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
match self {
Coord::Interleaved(c) => c.nth_unchecked(n),
Coord::Separated(c) => c.nth_unchecked(n),
Coord::Interleaved(c) => c.nth_or_panic(n),
Coord::Separated(c) => c.nth_or_panic(n),
}
}

Expand Down Expand Up @@ -137,10 +137,10 @@ impl CoordTrait for &Coord<'_> {
}
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
match self {
Coord::Interleaved(c) => c.nth_unchecked(n),
Coord::Separated(c) => c.nth_unchecked(n),
Coord::Interleaved(c) => c.nth_or_panic(n),
Coord::Separated(c) => c.nth_or_panic(n),
}
}

Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/scalar/coord/interleaved/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct InterleavedCoord<'a> {
impl<'a> InterleavedCoord<'a> {
/// Return `true` if all values in the coordinate are f64::NAN
pub(crate) fn is_nan(&self) -> bool {
(0..self.dim.size()).all(|coord_dim| self.nth_unchecked(coord_dim).is_nan())
(0..self.dim.size()).all(|coord_dim| self.nth_or_panic(coord_dim).is_nan())
}
}

Expand Down Expand Up @@ -92,7 +92,7 @@ impl CoordTrait for InterleavedCoord<'_> {
self.dim.into()
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
debug_assert!(n < self.dim.size());
*self.coords.get(self.i * self.dim.size() + n).unwrap()
}
Expand All @@ -113,7 +113,7 @@ impl CoordTrait for &InterleavedCoord<'_> {
self.dim.into()
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
debug_assert!(n < self.dim.size());
*self.coords.get(self.i * self.dim.size() + n).unwrap()
}
Expand Down
6 changes: 3 additions & 3 deletions rust/geoarrow/src/scalar/coord/separated/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub struct SeparatedCoord<'a> {
impl<'a> SeparatedCoord<'a> {
/// Return `true` if all values in the coordinate are f64::NAN
pub(crate) fn is_nan(&self) -> bool {
(0..self.dim.size()).all(|coord_dim| self.nth_unchecked(coord_dim).is_nan())
(0..self.dim.size()).all(|coord_dim| self.nth_or_panic(coord_dim).is_nan())
}
}

Expand Down Expand Up @@ -90,7 +90,7 @@ impl CoordTrait for SeparatedCoord<'_> {
self.dim.into()
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
self.buffers[n][self.i]
}

Expand All @@ -110,7 +110,7 @@ impl CoordTrait for &SeparatedCoord<'_> {
self.dim.into()
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
self.buffers[n][self.i]
}

Expand Down
2 changes: 1 addition & 1 deletion rust/geoarrow/src/test/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl CoordTrait for CoordZ {
geo_traits::Dimensions::Xyz
}

fn nth_unchecked(&self, n: usize) -> Self::T {
fn nth_or_panic(&self, n: usize) -> Self::T {
match n {
0 => self.x,
1 => self.y,
Expand Down

0 comments on commit 3ecf7df

Please sign in to comment.