Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Nov 15, 2024
1 parent e525deb commit cb227ca
Show file tree
Hide file tree
Showing 25 changed files with 295 additions and 352 deletions.
12 changes: 6 additions & 6 deletions python/geoarrow-core/src/constructors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn create_array_metadata(crs: Option<CRS>) -> Arc<ArrayMetadata> {
pub fn points(coords: PyCoordBuffer, crs: Option<CRS>) -> PyGeoArrowResult<PyNativeArray> {
let metadata = create_array_metadata(crs);
// TODO: remove const generic
let array = PointArray::<2>::new(coords.into_inner(), None, metadata);
let array = PointArray::new(coords.into_inner(), None, metadata);
Ok(PyNativeArray::new(NativeArrayDyn::new(Arc::new(array))))
}

Expand All @@ -35,7 +35,7 @@ pub fn linestrings(
) -> PyGeoArrowResult<PyNativeArray> {
let metadata = create_array_metadata(crs);
// TODO: remove const generic
let array = LineStringArray::<2>::new(
let array = LineStringArray::new(
coords.into_inner(),
geom_offsets.into_inner(),
None,
Expand All @@ -54,7 +54,7 @@ pub fn polygons(
) -> PyGeoArrowResult<PyNativeArray> {
let metadata = create_array_metadata(crs);
// TODO: remove const generic
let array = PolygonArray::<2>::new(
let array = PolygonArray::new(
coords.into_inner(),
geom_offsets.into_inner(),
ring_offsets.into_inner(),
Expand All @@ -72,7 +72,7 @@ pub fn multipoints(
crs: Option<CRS>,
) -> PyGeoArrowResult<PyNativeArray> {
let metadata = create_array_metadata(crs);
let array = MultiPointArray::<2>::new(
let array = MultiPointArray::new(
coords.into_inner(),
geom_offsets.into_inner(),
None,
Expand All @@ -90,7 +90,7 @@ pub fn multilinestrings(
crs: Option<CRS>,
) -> PyGeoArrowResult<PyNativeArray> {
let metadata = create_array_metadata(crs);
let array = MultiLineStringArray::<2>::new(
let array = MultiLineStringArray::new(
coords.into_inner(),
geom_offsets.into_inner(),
ring_offsets.into_inner(),
Expand All @@ -110,7 +110,7 @@ pub fn multipolygons(
crs: Option<CRS>,
) -> PyGeoArrowResult<PyNativeArray> {
let metadata = create_array_metadata(crs);
let array = MultiPolygonArray::<2>::new(
let array = MultiPolygonArray::new(
coords.into_inner(),
geom_offsets.into_inner(),
polygon_offsets.into_inner(),
Expand Down
56 changes: 24 additions & 32 deletions rust/geoarrow/src/algorithm/native/concatenate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub trait Concatenate: Sized {
fn concatenate(&self) -> Self::Output;
}

impl Concatenate for &[PointArray<2>] {
type Output = Result<PointArray<2>>;
impl Concatenate for &[PointArray] {
type Output = Result<PointArray>;

fn concatenate(&self) -> Self::Output {
let output_capacity = self.iter().fold(0, |sum, val| sum + val.buffer_lengths());
Expand Down Expand Up @@ -43,50 +43,45 @@ macro_rules! impl_concatenate {
}

impl_concatenate!(
LineStringArray<2>,
LineStringArray,
LineStringCapacity,
LineStringBuilder<2>,
LineStringBuilder,
push_line_string
);
impl_concatenate!(PolygonArray, PolygonCapacity, PolygonBuilder, push_polygon);
impl_concatenate!(
PolygonArray<2>,
PolygonCapacity,
PolygonBuilder<2>,
push_polygon
);
impl_concatenate!(
MultiPointArray<2>,
MultiPointArray,
MultiPointCapacity,
MultiPointBuilder<2>,
MultiPointBuilder,
push_multi_point
);
impl_concatenate!(
MultiLineStringArray<2>,
MultiLineStringArray,
MultiLineStringCapacity,
MultiLineStringBuilder<2>,
MultiLineStringBuilder,
push_multi_line_string
);
impl_concatenate!(
MultiPolygonArray<2>,
MultiPolygonArray,
MultiPolygonCapacity,
MultiPolygonBuilder<2>,
MultiPolygonBuilder,
push_multi_polygon
);
impl_concatenate!(
MixedGeometryArray<2>,
MixedGeometryArray,
MixedCapacity,
MixedGeometryBuilder<2>,
MixedGeometryBuilder,
push_geometry
);
impl_concatenate!(
GeometryCollectionArray<2>,
GeometryCollectionArray,
GeometryCollectionCapacity,
GeometryCollectionBuilder<2>,
GeometryCollectionBuilder,
push_geometry_collection
);

impl Concatenate for ChunkedPointArray<2> {
type Output = Result<PointArray<2>>;
impl Concatenate for ChunkedPointArray {
type Output = Result<PointArray>;

fn concatenate(&self) -> Self::Output {
self.chunks.as_slice().concatenate()
Expand All @@ -105,13 +100,10 @@ macro_rules! impl_chunked_concatenate {
};
}

impl_chunked_concatenate!(ChunkedLineStringArray<2>, LineStringArray<2>);
impl_chunked_concatenate!(ChunkedPolygonArray<2>, PolygonArray<2>);
impl_chunked_concatenate!(ChunkedMultiPointArray<2>, MultiPointArray<2>);
impl_chunked_concatenate!(ChunkedMultiLineStringArray<2>, MultiLineStringArray<2>);
impl_chunked_concatenate!(ChunkedMultiPolygonArray<2>, MultiPolygonArray<2>);
impl_chunked_concatenate!(ChunkedMixedGeometryArray<2>, MixedGeometryArray<2>);
impl_chunked_concatenate!(
ChunkedGeometryCollectionArray<2>,
GeometryCollectionArray<2>
);
impl_chunked_concatenate!(ChunkedLineStringArray, LineStringArray);
impl_chunked_concatenate!(ChunkedPolygonArray, PolygonArray);
impl_chunked_concatenate!(ChunkedMultiPointArray, MultiPointArray);
impl_chunked_concatenate!(ChunkedMultiLineStringArray, MultiLineStringArray);
impl_chunked_concatenate!(ChunkedMultiPolygonArray, MultiPolygonArray);
impl_chunked_concatenate!(ChunkedMixedGeometryArray, MixedGeometryArray);
impl_chunked_concatenate!(ChunkedGeometryCollectionArray, GeometryCollectionArray);
Loading

0 comments on commit cb227ca

Please sign in to comment.