Skip to content
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 distance traits for more geometries #113

Merged
merged 5 commits into from
Apr 2, 2017

Conversation

urschrei
Copy link
Member

@urschrei urschrei commented Apr 1, 2017

This PR adds distance traits for all geometries for which the trait was already implemented in one direction. E.g. if Point-to-Polygon distance existed, Polygon-to-Point distance now also exists. This adds a few boilerplate functions, but I can't think of a more ergonomic solution.

Still missing:

  • LineString-to-LineString minimum distance (is there a good algorithm for this?)
  • Polygon-to-Polygon minimum distance (I'm (slowly) working on a rotating calipers implementation)

@@ -10,10 +10,10 @@ use num_traits::pow::pow;
pub trait Distance<T, Rhs = Self> {
/// Returns the distance between two geometries
///
/// If a `Point` is contained by a `Polygon`, the distance is `0.0`
Copy link
Member

Choose a reason for hiding this comment

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

I think these spaces might have been intentional because markdown treats them as newlines:

http://spec.commonmark.org/0.26/#hard-line-breaks

I think with your changes, these sentences get put on the same line

Copy link
Member Author

Choose a reason for hiding this comment

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

Oops. Fixed.

@frewsxcv
Copy link
Member

frewsxcv commented Apr 2, 2017

Thanks for this! It's unfortunate that we can't do something like #73

bors r+

bors bot added a commit that referenced this pull request Apr 2, 2017
113: Implement distance traits for more geometries r=frewsxcv
This PR adds distance traits for all geometries for which the trait was already implemented in one direction. E.g. if `Point`-to-`Polygon` distance existed, `Polygon`-to-`Point` distance now also exists. This adds a few boilerplate functions, but I can't think of a more ergonomic solution.

Still missing:
- `LineString`-to-`LineString` minimum distance (is there a good algorithm for this?)
- `Polygon`-to-`Polygon` minimum distance (I'm (slowly) working on a [rotating calipers](http://web.archive.org/web/20150407022621/http://cgm.cs.mcgill.ca/~orm/mind2p.html) implementation)
@bors
Copy link
Contributor

bors bot commented Apr 2, 2017

Build succeeded

@bors bors bot merged commit 87863ec into georust:master Apr 2, 2017
@urschrei urschrei deleted the distance branch April 2, 2017 14:35
@urschrei
Copy link
Member Author

urschrei commented Apr 2, 2017

That would be great, and I did wonder whether something like that would be possible given the symmetry of From<T> for U and Into<U> for T impls, but I don't know nearly enough about how it would work under the hood. Maybe a post for Internals…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants