-
Notifications
You must be signed in to change notification settings - Fork 14
feat: Add distance metric support for RTree neighbor queries #141
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
base: main
Are you sure you want to change the base?
feat: Add distance metric support for RTree neighbor queries #141
Conversation
Add pluggable distance metrics for RTree neighbor searches, enabling Euclidean, Haversine, and Spheroid distance calculations. This allows users to choose appropriate distance calculations for different coordinate systems (planar vs geographic).
kylebarron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR.
Here are some initial comments. I need to think more about the changes in trait.rs
| /// Calculate the distance between two geometries. | ||
| /// This method is used by geometry-based neighbor searches to compute the actual | ||
| /// distance between a query geometry and an item geometry. | ||
| fn distance_to_geometry(&self, geom1: &Geometry<f64>, geom2: &Geometry<f64>) -> N; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I'd prefer for these to take in &impl GeometryTrait<T = f64>, but I suppose that's a non-breaking change in the future.
…rkspace, eliminating geo, wkt and wkb forks (#203) This is the final step of the forked dependency elimination plan: https://github.com/apache/sedona-db/pull/165/files. sedona-geo-generic-alg will go live and replace the original wherobots/geo dependency. We also replace forked wkb and wkt dependencies with the latest release versions. This patch depends on wherobots/geo-index#7 to resolve a geo version conflict. Remaining tasks: * geo-index will be the only forked dependency, and we are [submitting patches](kylebarron/geo-index#141) to put the nearest neighbour search APIs needed by sedona-db to the upstream. * We need a released version of [georust/wkb](https://github.com/georust/wkb) before releasing 0.2.0.
- Feature Flag Implementation (geo-types pattern) - Removed top-level re-exports from rtree/mod.rs - Removed redundant geo-types dependency - Removed duplicate axis_dist function (now in trait.rs) - Made entire distance module conditional on use-geo_0_31 feature - Trait architecture change: created SimpleDistanceMetric (no geo dependency) - Tests run successfully with and without use-geo_0_31 feature flag
|
@kylebarron Thanks for the thorough review! I've addressed all the feedback:
All tests pass both with and without the feature flag enabled. Thanks for the review again and please let me know any further changes you'd like to have on this PR. |
…istance_metric_extension_upstream
|
@kylebarron Hi Kyle, can you take a look of this PR? |
This PR adds pluggable distance metrics for RTree neighbor searches, enabling Euclidean, Haversine, and Spheroid distance calculations. This allows users to choose appropriate distance calculations for different coordinate systems (planar vs geographic).
The distance metric system is designed to be extensible, allowing users to implement custom metrics (e.g., Manhattan distance, custom caching strategies, or WKB decoding).