Skip to content

Commit

Permalink
GeometryStreamBuilder (#965)
Browse files Browse the repository at this point in the history
### Change list

- Instead of using really complex code to figure out which underlying
array to push each individual `xy` call to, we use an underlying
`GeoWriter` to collect each geometry into a scratch buffer, and then
push that geometry using our existing `push_geometry` APIs. This
simplifies the code a _lot_.
- It may have a negative performance impact because we're allocating
extra heap buffers for the small vecs. In the future, if we want to
optimize this, we may want to create a version of `geo-types` that uses
something like bumpalo

Closes #365
  • Loading branch information
kylebarron authored Dec 23, 2024
1 parent 676a09a commit 8af6586
Show file tree
Hide file tree
Showing 14 changed files with 328 additions and 434 deletions.
94 changes: 47 additions & 47 deletions python/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions python/pyo3-geoarrow/src/ffi/from_python/scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use std::sync::Arc;

use crate::array::*;
use crate::scalar::*;
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 @@ -24,9 +23,9 @@ impl<'a> FromPyObject<'a> for PyGeometry {
// Parse GeoJSON to geometry scalar
let reader = GeoJsonString(json_string);

// TODO: we need a dynamic dimensionality reader
// TODO: use ToGeometry directly in the future?
let arr = reader
.to_mixed_geometry_array(Dimension::XY)
.to_geometry_array()
.map_err(|err| PyValueError::new_err(err.to_string()))?;
Ok(Self(
GeometryScalar::try_new(Arc::new(arr))
Expand Down
Loading

0 comments on commit 8af6586

Please sign in to comment.