Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ jobs:
with:
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgeos-dev

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is failing because your indentation is wrong

Image

- name: Clippy
run: cargo clippy --all-features --tests -- -D warnings
- name: Check
Expand Down
30 changes: 26 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
24 changes: 24 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,31 @@ 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.

The version of GEOS required varies by UDF,
so we expose cargo features with explicit minimum version numbers,
like `geos-3_11` (GEOS >=3.11).

#### GEOS linking

This crate will try to link the system-provided GEOS library by default.
If you want to statically link GEOS from a source build,
add a direct dependency on the `geos` crate to your project,
and enable the `static` feature like so:

```toml
geos = { version = "11.1.1", features = ["static"] }
```

If you're using cargo workspaces, make sure that
the crates using geodatafusion directly reference `geos`.

### 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
9 changes: 9 additions & 0 deletions rust/geodatafusion/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ categories = { workspace = true }
rust-version = { workspace = true }


[features]
# Enables GEOS-backed UDFs.
# We only use explicitly versioned flags,
# and the structure should be recursive
# (with higher version targets implying lower version ones
# in a chain.)
geos-3_11 = ["geos/v3_11_0"]

[dependencies]
arrow-arith = { workspace = true }
arrow-array = { workspace = true }
Expand All @@ -21,6 +29,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-3_11")]
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