From 0c31ce7c203f538c24115fd517ec72b9d01e0c79 Mon Sep 17 00:00:00 2001 From: Kyle Barron Date: Mon, 8 Jan 2024 10:23:07 -0500 Subject: [PATCH] python: bump to 0.1.0 (#403) --- python/.gitignore | 3 +++ python/core/Cargo.lock | 2 +- python/core/Cargo.toml | 2 +- .../core/src/algorithm/geo/geodesic_length.rs | 27 ++++++++++++++++++- 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/python/.gitignore b/python/.gitignore index b4d9ec6b8..010c17bc9 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -1,3 +1,6 @@ +tmp*.py +tmp*.ts +tmp*.js *.zip site /target diff --git a/python/core/Cargo.lock b/python/core/Cargo.lock index ce91edfbc..e01cd8c19 100644 --- a/python/core/Cargo.lock +++ b/python/core/Cargo.lock @@ -630,7 +630,7 @@ dependencies = [ [[package]] name = "geoarrow-rust" -version = "0.1.0-beta.4" +version = "0.1.0" dependencies = [ "arrow", "arrow-array", diff --git a/python/core/Cargo.toml b/python/core/Cargo.toml index 472dba23b..2fd1f55fe 100644 --- a/python/core/Cargo.toml +++ b/python/core/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "geoarrow-rust" -version = "0.1.0-beta.4" +version = "0.1.0" authors = ["Kyle Barron "] edition = "2021" description = "Efficient, vectorized geospatial operations in Python." diff --git a/python/core/src/algorithm/geo/geodesic_length.rs b/python/core/src/algorithm/geo/geodesic_length.rs index 48d6c7d2e..ac71112e6 100644 --- a/python/core/src/algorithm/geo/geodesic_length.rs +++ b/python/core/src/algorithm/geo/geodesic_length.rs @@ -1,4 +1,7 @@ use crate::array::*; +use crate::chunked_array::*; +use crate::error::PyGeoArrowResult; +use geoarrow::algorithm::geo::GeodesicLength; use pyo3::prelude::*; macro_rules! impl_geodesic_length { @@ -13,7 +16,6 @@ macro_rules! impl_geodesic_length { /// /// [Karney (2013)]: https://arxiv.org/pdf/1109.4448.pdf pub fn geodesic_length(&self) -> Float64Array { - use geoarrow::algorithm::geo::GeodesicLength; GeodesicLength::geodesic_length(&self.0).into() } } @@ -24,3 +26,26 @@ impl_geodesic_length!(PointArray); impl_geodesic_length!(MultiPointArray); impl_geodesic_length!(LineStringArray); impl_geodesic_length!(MultiLineStringArray); + +macro_rules! impl_chunked { + ($struct_name:ident) => { + #[pymethods] + impl $struct_name { + /// Determine the length of a geometry on an ellipsoidal model of the earth. + /// + /// This uses the geodesic measurement methods given by [Karney (2013)]. As opposed to + /// older methods like Vincenty, this method is accurate to a few nanometers and always + /// converges. + /// + /// [Karney (2013)]: https://arxiv.org/pdf/1109.4448.pdf + pub fn geodesic_length(&self) -> PyGeoArrowResult { + Ok(GeodesicLength::geodesic_length(&self.0)?.into()) + } + } + }; +} + +impl_chunked!(ChunkedPointArray); +impl_chunked!(ChunkedMultiPointArray); +impl_chunked!(ChunkedLineStringArray); +impl_chunked!(ChunkedMultiLineStringArray);