feat(c/sedona-geos): Add ST_HausdorffDistance#1039
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds the SQL scalar function ST_HausdorffDistance (with optional densifyFrac) backed by the GEOS kernel layer, and exposes it through docs and tests.
Changes:
- Introduces a new GEOS scalar kernel implementation for
ST_HausdorffDistance(geom1, geom2)andST_HausdorffDistance(geom1, geom2, densifyFrac). - Registers the new kernels in the GEOS extension and documents the SQL function.
- Adds Python-level cross-engine (SedonaDB/PostGIS) tests for NULL/EMPTY handling and representative geometry cases.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/sedonadb/tests/functions/test_distance.py | Adds Python tests for ST_HausdorffDistance (2-arg and densify variants). |
| docs/reference/sql/st_hausdorffdistance.qmd | Adds SQL reference documentation page for ST_HausdorffDistance. |
| c/sedona-geos/src/st_hausdorffdistance.rs | Implements GEOS-backed kernels and Rust unit tests for Hausdorff distance. |
| c/sedona-geos/src/register.rs | Registers the new scalar kernels under st_hausdorffdistance. |
| c/sedona-geos/src/lib.rs | Wires the new module into the GEOS crate. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+39
to
+41
| The Hausdorff distance is a measure of the similarity between two geometric shapes. This implementation returns the greatest of all distances from a point in one geometry to the closest point in the other geometry. | ||
|
|
||
| Returns `NULL` if either geometry is `NULL`. Returns 0 if either geometry is empty. |
Comment on lines
+284
to
+290
| // With densify fraction | ||
| let result = tester | ||
| .invoke_scalar_scalar_scalar("LINESTRING (0 0, 100 0)", "LINESTRING (0 1, 0 1)", 0.5) | ||
| .unwrap(); | ||
| // Without densification this would be 1.0, with densification it should be sqrt(100^2 + 1^2) ≈ 100.005 | ||
| let result_f64: f64 = result.try_into().unwrap(); | ||
| assert!(result_f64 > 1.0); |
jiayuasu
approved these changes
Jul 9, 2026
zhangfengcdt
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds ST_HausdorffDistance backed by GEOS