Skip to content

Commit

Permalink
update to geoarrow 0.3. fixes #56
Browse files Browse the repository at this point in the history
  • Loading branch information
nmandery committed Oct 6, 2024
1 parent 6f5981b commit 2e13b37
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
3 changes: 1 addition & 2 deletions crates/h3arrow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ spatial_index = ["dep:rstar"]
[dependencies]
ahash = "0.8"
arrow = { workspace = true }
# geoarrow = { package = "geoarrow", version = "0.1.0", optional = true, features = ["geozero"] }
geoarrow = { package = "geoarrow", git = "https://github.com/geoarrow/geoarrow-rs.git", rev = "30c18f7c07432dfb92f9612efa54aec1d9392daf", optional = true, features = ["geozero"] }
geoarrow = { version = "0.3", optional = true, features = ["geozero"] }
geo-types = { workspace = true }
geo = { workspace = true }
geozero = { version = "^0.13", default-features = false, features = ["with-geo", "with-wkb"], optional = true }
Expand Down
12 changes: 6 additions & 6 deletions crates/h3arrow/src/array/from_geoarrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ macro_rules! impl_to_cells {
};
}

impl_to_cells!(geoarrow::array::LineStringArray<O>, O);
impl_to_cells!(geoarrow::array::MultiLineStringArray<O>, O);
impl_to_cells!(geoarrow::array::MultiPointArray<O>, O);
impl_to_cells!(geoarrow::array::MultiPolygonArray<O>, O);
impl_to_cells!(geoarrow::array::PointArray);
impl_to_cells!(geoarrow::array::PolygonArray<O>, O);
impl_to_cells!(geoarrow::array::LineStringArray<O, 2>, O);
impl_to_cells!(geoarrow::array::MultiLineStringArray<O, 2>, O);
impl_to_cells!(geoarrow::array::MultiPointArray<O, 2>, O);
impl_to_cells!(geoarrow::array::MultiPolygonArray<O, 2>, O);
impl_to_cells!(geoarrow::array::PointArray<2>);
impl_to_cells!(geoarrow::array::PolygonArray<O, 2>, O);

impl<O: OffsetSizeTrait> ToCellListArray<O> for WKBArray<O> {
fn to_celllistarray(
Expand Down
16 changes: 9 additions & 7 deletions crates/h3arrow/src/array/to_geoarrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::array::to_geo::{
};
use crate::array::{H3Array, H3IndexArrayValue};
use arrow::array::{Array, OffsetSizeTrait};
use geo::point;
use geo_types::LineString;
use geoarrow::array::{
LineStringArray, PointArray, PolygonArray, WKBArray, WKBBuilder, WKBCapacity,
Expand All @@ -13,7 +14,7 @@ pub trait ToGeoArrowPolygons {
fn to_geoarrow_polygons<O: OffsetSizeTrait>(
&self,
use_degrees: bool,
) -> Result<PolygonArray<O>, Self::Error>;
) -> Result<PolygonArray<O, 2>, Self::Error>;
}

impl<T> ToGeoArrowPolygons for T
Expand All @@ -25,22 +26,22 @@ where
fn to_geoarrow_polygons<O: OffsetSizeTrait>(
&self,
use_degrees: bool,
) -> Result<PolygonArray<O>, Self::Error> {
) -> Result<PolygonArray<O, 2>, Self::Error> {
Ok(self.to_polygons(use_degrees)?.into())
}
}

pub trait ToGeoArrowPoints {
type Error;
fn to_geoarrow_points(&self, use_degrees: bool) -> Result<PointArray, Self::Error>;
fn to_geoarrow_points(&self, use_degrees: bool) -> Result<PointArray<2>, Self::Error>;
}

impl<T> ToGeoArrowPoints for T
where
T: ToPoints,
{
type Error = T::Error;
fn to_geoarrow_points(&self, use_degrees: bool) -> Result<PointArray, Self::Error> {
fn to_geoarrow_points(&self, use_degrees: bool) -> Result<PointArray<2>, Self::Error> {
Ok(self.to_points(use_degrees)?.into())
}
}
Expand All @@ -50,7 +51,7 @@ pub trait ToGeoArrowLineStrings {
fn to_geoarrow_lines<O: OffsetSizeTrait>(
&self,
use_degrees: bool,
) -> Result<LineStringArray<O>, Self::Error>;
) -> Result<LineStringArray<O, 2>, Self::Error>;
}

impl<T> ToGeoArrowLineStrings for T
Expand All @@ -61,7 +62,7 @@ where
fn to_geoarrow_lines<O: OffsetSizeTrait>(
&self,
use_degrees: bool,
) -> Result<LineStringArray<O>, Self::Error> {
) -> Result<LineStringArray<O, 2>, Self::Error> {
Ok(self.to_linestrings(use_degrees)?.into())
}
}
Expand Down Expand Up @@ -197,7 +198,8 @@ where
.is_some()
{
let mut cap = WKBCapacity::new_empty();
cap.add_point(true);
let point = point! {x:0.0f64, y:0.0f64};
cap.add_point(Some(&point));
cap.buffer_capacity()
} else {
0
Expand Down
2 changes: 1 addition & 1 deletion h3ronpy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ ndarray = { version = "0.15", features = ["rayon"] }
numpy = "0.21"
ordered-float = ">=2.0.1"
py_geo_interface = { version = "0.8", features = ["f64", "wkb"] }
pyo3 = { version = "0.21", features = ["extension-module", "abi3", "abi3-py39"] }
pyo3 = { version = "^0.21", features = ["extension-module", "abi3", "abi3-py39"] }
rasterh3 = { version = "^0.8", features = ["rayon"] }
rayon = { workspace = true }

0 comments on commit 2e13b37

Please sign in to comment.