Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move MixedGeometryStreamBuilder to GeometryStreamBuilder #898

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions python/pyo3-geoarrow/src/ffi/from_python/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use std::sync::Arc;

use crate::array::*;
use crate::scalar::*;
use geoarrow::array::MixedGeometryArray;
use geoarrow::datatypes::Dimension;
use geoarrow::io::geozero::ToMixedArray;
use geoarrow::io::geozero::ToGeometryArray;
use geoarrow::scalar::GeometryScalar;
use geozero::geojson::GeoJsonString;
use pyo3::exceptions::PyValueError;
Expand All @@ -26,8 +24,8 @@ impl<'a> FromPyObject<'a> for PyGeometry {
let reader = GeoJsonString(json_string);

// TODO: we need a dynamic dimensionality reader
let arr: MixedGeometryArray = reader
.to_mixed_geometry_array(Dimension::XY)
let arr = reader
.to_geometry_array()
.map_err(|err| PyValueError::new_err(err.to_string()))?;
Ok(Self(
GeometryScalar::try_new(Arc::new(arr))
Expand Down
30 changes: 15 additions & 15 deletions rust/geoarrow/src/array/geometry/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,21 @@ pub struct GeometryBuilder {
types: Vec<i8>,

// In the future we'll additionally have xym, xyzm array variants.
point_xy: PointBuilder,
line_string_xy: LineStringBuilder,
polygon_xy: PolygonBuilder,
mpoint_xy: MultiPointBuilder,
mline_string_xy: MultiLineStringBuilder,
mpolygon_xy: MultiPolygonBuilder,
gc_xy: GeometryCollectionBuilder,

point_xyz: PointBuilder,
line_string_xyz: LineStringBuilder,
polygon_xyz: PolygonBuilder,
mpoint_xyz: MultiPointBuilder,
mline_string_xyz: MultiLineStringBuilder,
mpolygon_xyz: MultiPolygonBuilder,
gc_xyz: GeometryCollectionBuilder,
pub(crate) point_xy: PointBuilder,
pub(crate) line_string_xy: LineStringBuilder,
pub(crate) polygon_xy: PolygonBuilder,
pub(crate) mpoint_xy: MultiPointBuilder,
pub(crate) mline_string_xy: MultiLineStringBuilder,
pub(crate) mpolygon_xy: MultiPolygonBuilder,
pub(crate) gc_xy: GeometryCollectionBuilder,

pub(crate) point_xyz: PointBuilder,
pub(crate) line_string_xyz: LineStringBuilder,
pub(crate) polygon_xyz: PolygonBuilder,
pub(crate) mpoint_xyz: MultiPointBuilder,
pub(crate) mline_string_xyz: MultiLineStringBuilder,
pub(crate) mpolygon_xyz: MultiPolygonBuilder,
pub(crate) gc_xyz: GeometryCollectionBuilder,

// Invariant: `offsets.len() == types.len()`
offsets: Vec<i32>,
Expand Down
5 changes: 3 additions & 2 deletions rust/geoarrow/src/io/csv/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::Read;
use crate::array::CoordType;
use crate::datatypes::Dimension;
use crate::error::Result;
use crate::io::geozero::array::MixedGeometryStreamBuilder;
use crate::io::geozero::array::GeometryStreamBuilder;
use crate::io::geozero::table::{GeoTableBuilder, GeoTableBuilderOptions};
use crate::table::Table;

Expand Down Expand Up @@ -48,7 +48,8 @@ pub fn read_csv<R: Read>(
None,
Default::default(),
);
let mut geo_table = GeoTableBuilder::<MixedGeometryStreamBuilder>::new_with_options(
let mut geo_table = GeoTableBuilder::<GeometryStreamBuilder>::new_with_options(
// Hack: this is unused
Dimension::XY,
table_builder_options,
);
Expand Down
8 changes: 5 additions & 3 deletions rust/geoarrow/src/io/flatgeobuf/reader/async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::datatypes::Dimension;
use crate::error::{GeoArrowError, Result};
use crate::io::flatgeobuf::reader::common::{infer_schema, FlatGeobufReaderOptions};
use crate::io::flatgeobuf::reader::object_store_reader::ObjectStoreWrapper;
use crate::io::geozero::array::MixedGeometryStreamBuilder;
use crate::io::geozero::array::GeometryStreamBuilder;
use crate::io::geozero::table::{GeoTableBuilder, GeoTableBuilderOptions};
use crate::table::Table;

Expand Down Expand Up @@ -93,7 +93,8 @@ pub async fn read_flatgeobuf_async(
(GeometryType::MultiLineString, false) => impl_read!(MultiLineStringBuilder, Dimension::XY),
(GeometryType::MultiPolygon, false) => impl_read!(MultiPolygonBuilder, Dimension::XY),
(GeometryType::Unknown, false) => {
let mut builder = GeoTableBuilder::<MixedGeometryStreamBuilder>::new_with_options(
let mut builder = GeoTableBuilder::<GeometryStreamBuilder>::new_with_options(
// Hack: this is unused
Dimension::XY,
options,
);
Expand All @@ -116,7 +117,8 @@ pub async fn read_flatgeobuf_async(
(GeometryType::MultiLineString, true) => impl_read!(MultiLineStringBuilder, Dimension::XYZ),
(GeometryType::MultiPolygon, true) => impl_read!(MultiPolygonBuilder, Dimension::XYZ),
(GeometryType::Unknown, true) => {
let mut builder = GeoTableBuilder::<MixedGeometryStreamBuilder>::new_with_options(
let mut builder = GeoTableBuilder::<GeometryStreamBuilder>::new_with_options(
// Hack: this is unused
Dimension::XYZ,
options,
);
Expand Down
8 changes: 5 additions & 3 deletions rust/geoarrow/src/io/flatgeobuf/reader/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use crate::array::*;
use crate::datatypes::Dimension;
use crate::error::{GeoArrowError, Result};
use crate::io::flatgeobuf::reader::common::{infer_schema, FlatGeobufReaderOptions};
use crate::io::geozero::array::MixedGeometryStreamBuilder;
use crate::io::geozero::array::GeometryStreamBuilder;
use crate::io::geozero::table::{GeoTableBuilder, GeoTableBuilderOptions};
use crate::table::Table;
use flatgeobuf::{FallibleStreamingIterator, FgbReader, GeometryType};
Expand Down Expand Up @@ -99,7 +99,8 @@ pub fn read_flatgeobuf<R: Read + Seek>(
(GeometryType::MultiLineString, false) => impl_read!(MultiLineStringBuilder, Dimension::XY),
(GeometryType::MultiPolygon, false) => impl_read!(MultiPolygonBuilder, Dimension::XY),
(GeometryType::Unknown, false) => {
let mut builder = GeoTableBuilder::<MixedGeometryStreamBuilder>::new_with_options(
let mut builder = GeoTableBuilder::<GeometryStreamBuilder>::new_with_options(
// Hack: this is unused
Dimension::XY,
options,
);
Expand All @@ -122,7 +123,8 @@ pub fn read_flatgeobuf<R: Read + Seek>(
(GeometryType::MultiLineString, true) => impl_read!(MultiLineStringBuilder, Dimension::XYZ),
(GeometryType::MultiPolygon, true) => impl_read!(MultiPolygonBuilder, Dimension::XYZ),
(GeometryType::Unknown, true) => {
let mut builder = GeoTableBuilder::<MixedGeometryStreamBuilder>::new_with_options(
let mut builder = GeoTableBuilder::<GeometryStreamBuilder>::new_with_options(
// Hack: this is unused
Dimension::XYZ,
options,
);
Expand Down
5 changes: 3 additions & 2 deletions rust/geoarrow/src/io/geojson/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::Read;
use crate::array::CoordType;
use crate::datatypes::Dimension;
use crate::error::Result;
use crate::io::geozero::array::MixedGeometryStreamBuilder;
use crate::io::geozero::array::GeometryStreamBuilder;
use crate::io::geozero::table::{GeoTableBuilder, GeoTableBuilderOptions};
use crate::table::Table;

Expand All @@ -21,8 +21,9 @@ pub fn read_geojson<R: Read>(reader: R, batch_size: Option<usize>) -> Result<Tab
None,
Default::default(),
);
// Hack: this dimension is unused
let mut geo_table =
GeoTableBuilder::<MixedGeometryStreamBuilder>::new_with_options(Dimension::XY, options);
GeoTableBuilder::<GeometryStreamBuilder>::new_with_options(Dimension::XY, options);
geojson.process(&mut geo_table)?;
geo_table.finish()
}
Expand Down
5 changes: 3 additions & 2 deletions rust/geoarrow/src/io/geojson_lines/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::io::BufRead;
use crate::array::CoordType;
use crate::datatypes::Dimension;
use crate::error::Result;
use crate::io::geozero::array::MixedGeometryStreamBuilder;
use crate::io::geozero::array::GeometryStreamBuilder;
use crate::io::geozero::table::{GeoTableBuilder, GeoTableBuilderOptions};
use crate::table::Table;

Expand All @@ -25,8 +25,9 @@ pub fn read_geojson_lines<R: BufRead>(reader: R, batch_size: Option<usize>) -> R
None,
Default::default(),
);
// hack: this dimension is unused
let mut geo_table =
GeoTableBuilder::<MixedGeometryStreamBuilder>::new_with_options(Dimension::XY, options);
GeoTableBuilder::<GeometryStreamBuilder>::new_with_options(Dimension::XY, options);
geojson_line_reader.process(&mut geo_table)?;
geo_table.finish()
}
Loading
Loading