Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
59 changes: 55 additions & 4 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ geodatafusion = { path = "rust/geodatafusion", version = "0.4.0" }
geohash = "0.13.1"
geojson = "0.24"
geoparquet = "0.8.0"
geos = { version = "11.1", default-features = false }
http-range-client = { version = "0.9", default-features = false }
object_store = "0.13.2"
serde_json = "1"
Expand Down
9 changes: 9 additions & 0 deletions DEVELOP.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This is a Rust workspace with multiple crates:
- Internally, each _provider_ of functions is organized in submodules:
- `native/` - Operations that are natively implemented, without the use of other dependencies like `geo`
- `geo/` - Operations implemented using the `geo` crate
- `geos/` - Operations implemented using the `geos` crate (bindings to the native GEOS library), gated behind the optional `geos` feature
- `geohash/` - GeoHash encoding/decoding, using the `geohash` crate
- `rust/geodatafusion-flatgeobuf` - FlatGeobuf format support
- `rust/geodatafusion-geoparquet` - GeoParquet format support
Expand Down Expand Up @@ -104,8 +105,16 @@ Functions are organized by category in `rust/geodatafusion/src/udf/`:
- `geo/processing/` - Processing functions (ST_Buffer, ST_Simplify)
- `geo/relationships/` - Spatial relationships (ST_Intersects, etc.)
- `geo/validation/` - Validation functions (ST_IsValid)
- `geos/processing/` - GEOS-backed processing functions (ST_LineMerge)
- `geohash/` - GeoHash functions

### GEOS-backed functions

Functions in the `geos/` provider link the [GEOS](https://libgeos.org/) library, and can be controlled via Cargo features:

- `geos` - enables the GEOS-backed UDFs, linking the **system** GEOS library (requires GEOS >= 3.11).
- `geos-static` - implies `geos` and builds a **bundled** GEOS from vendored source instead, so no system library is needed (requires a C++ compiler and CMake at build time).

### Code Style

- Use meaningful variable and function names
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ Functions are explicitly modeled after the [PostGIS API](https://postgis.net/doc
| ST_FilterByM | | Removes vertices based on their M value |
| ST_GeneratePoints | | Generates a multipoint of random points contained in a Polygon or MultiPolygon. |
| ST_GeometricMedian | | Returns the geometric median of a MultiPoint. |
| ST_LineMerge | | Return the lines formed by sewing together a MultiLineString. |
| ST_LineMerge | | Return the lines formed by sewing together a MultiLineString. |
| ST_MaximumInscribedCircle | | Computes the largest circle contained within a geometry. |
| ST_LargestEmptyCircle | | Computes the largest circle not overlapping a geometry. |
| ST_MinimumBoundingCircle | | Returns the smallest circle polygon that contains a geometry. |
Expand Down
8 changes: 8 additions & 0 deletions rust/geodatafusion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ categories = { workspace = true }
rust-version = { workspace = true }


[features]
# Enable GEOS-backed UDFs (e.g. ST_LineMerge).
# Requires GEOS >= 3.11 for directed merge (the feature flag here opts in to v3.11 features).
Comment thread
kylebarron marked this conversation as resolved.
Outdated
geos = ["dep:geos", "geos/v3_11_0"]
# Build a bundled GEOS from vendored source instead of linking the system library.
geos-static = ["geos", "geos/static"]
Comment thread
kylebarron marked this conversation as resolved.
Outdated

[dependencies]
arrow-arith = { workspace = true }
arrow-array = { workspace = true }
Expand All @@ -21,6 +28,7 @@ geoarrow-array = { workspace = true }
geoarrow-expr-geo = { workspace = true }
geoarrow-schema = { workspace = true }
geohash = { workspace = true }
geos = { workspace = true, optional = true }
thiserror = { workspace = true }
wkt = { workspace = true }

Expand Down
6 changes: 6 additions & 0 deletions rust/geodatafusion/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ pub(crate) enum GeoDataFusionError {
#[error(transparent)]
GeoArrow(#[from] GeoArrowError),

#[cfg(feature = "geos")]
#[error(transparent)]
Geos(#[from] geos::Error),

#[error(transparent)]
GeoHash(#[from] geohash::GeohashError),
}
Expand All @@ -32,6 +36,8 @@ impl From<GeoDataFusionError> for DataFusionError {
GeoDataFusionError::Arrow(err) => DataFusionError::ArrowError(Box::new(err), None),
GeoDataFusionError::DataFusion(err) => err,
GeoDataFusionError::GeoArrow(err) => DataFusionError::External(Box::new(err)),
#[cfg(feature = "geos")]
GeoDataFusionError::Geos(err) => DataFusionError::External(Box::new(err)),
GeoDataFusionError::GeoHash(err) => DataFusionError::External(Box::new(err)),
}
}
Expand Down
3 changes: 3 additions & 0 deletions rust/geodatafusion/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ pub fn register(session_context: &datafusion::prelude::SessionContext) {

crate::udf::geo::validation::register(session_context);

#[cfg(feature = "geos")]
crate::udf::geos::processing::register(session_context);

crate::udf::geohash::register(session_context);

crate::udf::native::accessors::register(session_context);
Expand Down
3 changes: 3 additions & 0 deletions rust/geodatafusion/src/udf/geos/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//! UDFs implemented via GEOS bindings.

pub mod processing;
Loading
Loading