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

Add "Orient" trait for Polygon #108

Merged
merged 3 commits into from
Apr 10, 2017
Merged

Conversation

urschrei
Copy link
Member

This returns a correctly-oriented copy of the polygon; Default returns counter-clockwise exterior rings and clockwise interior rings. Reversed returns rings with the opposite orientation.

@urschrei
Copy link
Member Author

urschrei commented Apr 9, 2017

Could I get a review of this, if someone's got time?
Landing this would enable the Rotation trait to merge, but more interestingly, I've got a working implementation of the Rotating Calipers algorithm for finding the minimum distance between two Polygons – It requires both the Orient trait and an Extremes trait for finding minimum and maximum vertices of a convex polygon, which also depends on Orient.

/// and its inner ring(s) oriented clockwise. Selecting `Reversed` will result in a Polygon
/// with a clockwise-oriented exterior ring, and counter-clockwise interior ring(s)
#[derive(Debug)]
pub enum Direction {
Copy link
Member

Choose a reason for hiding this comment

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

If you added #[derive(Copy, Clone, Debug)] here, you wouldn't need to pass &Direction references everywhere since it's just as cheap to pass the enum value than it is to pass a reference to the enum value.

pub enum Direction {
Default,
Reversed,
}
Copy link
Member

Choose a reason for hiding this comment

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

Might be good to explicitly mention:

enum Direction {
    /// exterior ring is oriented counter-clockwise, interior rings are oriented clockwise
    Default,
    /// exterior ring is oriented clockwise, interior rings are oriented counter-clockwise
    Reversed,
}

@frewsxcv
Copy link
Member

Could I get a review of this, if someone's got time?

Sorry about that, this PR slipped by me. Feel free to ping me directly if you need a review for GeoRust things. I also just realized you aren't part of the GeoRust GitHub organization, sorry about that! Just added you.

r=me after my couple minor comments (you should be able to add a comment bors r=frewsxcv to trigger the mergebot I have enabled for this repo0

@frewsxcv
Copy link
Member

bors r-

no bors, stop, not yet

@bors
Copy link
Contributor

bors bot commented Apr 10, 2017

Canceled

@frewsxcv
Copy link
Member

Unrelated to this PR, I've been working on a geospatial data viewer. My next steps are to add a basic UI and add in some of the operations/algorithms you've implemented in this repository, so thanks for all your work here :)

@urschrei
Copy link
Member Author

bors r=frewsxcv

bors bot added a commit that referenced this pull request Apr 10, 2017
108: Add "Orient" trait for Polygon r=frewsxcv
This returns a correctly-oriented copy of the polygon; `Default` returns counter-clockwise exterior rings and clockwise interior rings. `Reversed` returns rings with the opposite orientation.
@bors
Copy link
Contributor

bors bot commented Apr 10, 2017

Build succeeded

@bors bors bot merged commit 826fd8d into georust:master Apr 10, 2017
@urschrei urschrei deleted the orient_polygon branch April 10, 2017 13:42
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