-
Notifications
You must be signed in to change notification settings - Fork 200
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
Implement Point to multipart geometry distance methods #104
Conversation
src/algorithm/distance.rs
Outdated
impl<T> Distance<T, MultiPolygon<T>> for Point<T> | ||
where T: Float | ||
{ | ||
fn distance(&self, mpolygon: &MultiPolygon<T>) -> T { |
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.
I think if you did:
/// Minimum distance from a Point to a MultiPolygon
fn distance(&self, mpolygon: &MultiPolygon<T>) -> T {
It would show up in documentation (via rustdoc), just to be explicit about the behavior here.
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.
Done!
src/algorithm/distance.rs
Outdated
@@ -167,7 +168,8 @@ impl<T> Distance<T, Polygon<T>> for Point<T> | |||
// Minimum distance from a Point to a MultiPolygon | |||
impl<T> Distance<T, MultiPolygon<T>> for Point<T> | |||
where T: Float | |||
{ | |||
{ |
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.
Nit: whitespace
src/algorithm/distance.rs
Outdated
@@ -180,7 +182,8 @@ impl<T> Distance<T, MultiPolygon<T>> for Point<T> | |||
// Minimum distance from a Point to a MultiLineString | |||
impl<T> Distance<T, MultiLineString<T>> for Point<T> | |||
where T: Float | |||
{ | |||
{ |
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.
Nit: whitespace
LGTM after whitespace is addressed |
bors r+ |
104: Implement Point to multipart geometry distance methods r=frewsxcv This adds distance methods and tests from Point to: - MultiPoint - MultiLineString - MultiPolygon For large MultiPolygons in particular, this could potentially be very slow. One approach would be the use of a spatial index storing the Polygon BoundingBoxes. Retrieving the closest one to the point, then calculating Point-to-Polygon distance would be much faster. There are a number of {quad-, r-, n-}tree implementations around in various states of maintenance, e.g. [acacia](https://github.com/aepsil0n/acacia), or (much heavier, extensively tested) [Spade](https://stoeoef.github.io/spade/spade/struct.RTree.html), so it'd be mostly a case of gluing things together. (It might also be good to have a spatial index crate backed by one of those implementations in geo-rust, but that's a separate issue)
Build succeeded |
This adds distance methods and tests from Point to:
For large MultiPolygons in particular, this could potentially be very slow. One approach would be the use of a spatial index storing the Polygon BoundingBoxes. Retrieving the closest one to the point, then calculating Point-to-Polygon distance would be much faster. There are a number of {quad-, r-, n-}tree implementations around in various states of maintenance, e.g. acacia, or (much heavier, extensively tested) Spade, so it'd be mostly a case of gluing things together.
(It might also be good to have a spatial index crate backed by one of those implementations in geo-rust, but that's a separate issue)