Skip to content

Commit

Permalink
fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron authored and nmandery committed Nov 26, 2024
1 parent 2c48d7e commit c2973cb
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 16 deletions.
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 @@ -38,12 +38,12 @@ macro_rules! impl_to_cells {
};
}

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

impl<O: OffsetSizeTrait> ToCellListArray<O> for WKBArray<O> {
fn to_celllistarray(
Expand Down
40 changes: 30 additions & 10 deletions crates/h3arrow/src/array/to_geoarrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ use arrow::array::{Array, OffsetSizeTrait};
use geo::point;
use geo_types::LineString;
use geoarrow::array::{
LineStringArray, PointArray, PolygonArray, WKBArray, WKBBuilder, WKBCapacity,
LineStringArray, LineStringBuilder, PointArray, PointBuilder, PolygonArray, PolygonBuilder,
WKBArray, WKBBuilder, WKBCapacity,
};
use geoarrow::datatypes::Dimension;

pub trait ToGeoArrowPolygons {
type Error;
fn to_geoarrow_polygons<O: OffsetSizeTrait>(
&self,
use_degrees: bool,
) -> Result<PolygonArray<2>, Self::Error>;
) -> Result<PolygonArray, Self::Error>;
}

impl<T> ToGeoArrowPolygons for T
Expand All @@ -26,23 +28,35 @@ where
fn to_geoarrow_polygons<O: OffsetSizeTrait>(
&self,
use_degrees: bool,
) -> Result<PolygonArray<2>, Self::Error> {
Ok(self.to_polygons(use_degrees)?.into())
) -> Result<PolygonArray, Self::Error> {
Ok(PolygonBuilder::from_nullable_polygons(
&self.to_polygons(use_degrees)?,
Dimension::XY,
Default::default(),
Default::default(),
)
.into())
}
}

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

impl<T> ToGeoArrowPoints for T
where
T: ToPoints,
{
type Error = T::Error;
fn to_geoarrow_points(&self, use_degrees: bool) -> Result<PointArray<2>, Self::Error> {
Ok(self.to_points(use_degrees)?.into())
fn to_geoarrow_points(&self, use_degrees: bool) -> Result<PointArray, Self::Error> {
Ok(PointBuilder::from_nullable_points(
self.to_points(use_degrees)?.iter().map(|x| x.as_ref()),
Dimension::XY,
Default::default(),
Default::default(),
)
.into())
}
}

Expand All @@ -51,7 +65,7 @@ pub trait ToGeoArrowLineStrings {
fn to_geoarrow_lines<O: OffsetSizeTrait>(
&self,
use_degrees: bool,
) -> Result<LineStringArray<2>, Self::Error>;
) -> Result<LineStringArray, Self::Error>;
}

impl<T> ToGeoArrowLineStrings for T
Expand All @@ -62,8 +76,14 @@ where
fn to_geoarrow_lines<O: OffsetSizeTrait>(
&self,
use_degrees: bool,
) -> Result<LineStringArray<2>, Self::Error> {
Ok(self.to_linestrings(use_degrees)?.into())
) -> Result<LineStringArray, Self::Error> {
Ok(LineStringBuilder::from_nullable_line_strings(
&self.to_linestrings(use_degrees)?,
Dimension::XY,
Default::default(),
Default::default(),
)
.into())
}
}

Expand Down

0 comments on commit c2973cb

Please sign in to comment.