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

Clipping ops #886

Merged
merged 8 commits into from Aug 14, 2022
Merged

Clipping ops #886

merged 8 commits into from Aug 14, 2022

Conversation

rmanoka
Copy link
Contributor

@rmanoka rmanoka commented Jul 30, 2022

  • I agree to follow the project's code of conduct.
  • I added an entry to CHANGES.md if knowledge of this change could be valuable to users.

I had a use-case for clipping a 1-d geom. by a 2-d goem. It's conceptually a bool ops, but needed some refactoring of the region construction implementation.

Copy link
Member

@michaelkirk michaelkirk left a comment

Choose a reason for hiding this comment

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

I had some clarifying questions and some typo fixes - I'd like to re-review the core of the algorithm once I understand better what is_simple is about.

@@ -37,6 +38,7 @@ pub trait BooleanOps: Sized {
fn difference(&self, other: &Self) -> MultiPolygon<Self::Scalar> {
self.boolean_op(other, OpType::Difference)
}
fn clip(&self, ls: &MultiLineString<Self::Scalar>) -> MultiLineString<Self::Scalar>;
Copy link
Member

Choose a reason for hiding this comment

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

The difference between intersection and clip is that the input/output of intersection are 2D, while the input/output of clip are 1D. Is that right?

I wonder if there's a way to reorganize this trait to handle that more uniformly - maybe related to #881.

I think that this is a good addition, and am happy to have it included in any form, I'm just "thinking out loud" about future directions that will make this more uniform.

geo/src/algorithm/bool_ops/op.rs Outdated Show resolved Hide resolved
geo/src/algorithm/bool_ops/op.rs Outdated Show resolved Hide resolved
geo/src/algorithm/bool_ops/spec.rs Outdated Show resolved Hide resolved
}
}
impl<T: GeoFloat> Spec<T> for BoolOp<T> {
type Region = Region;
Copy link
Member

Choose a reason for hiding this comment

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

Maybe I'm missing something, but it seems like we have two implementations of impl Spec, and both have type Region = Region. Rather than an associated type, could we then more simply refer to the concrete Region type? Or am I missing something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I set that up for flexibility but didn't end up using it. Looking ahead: the algo. can actually be generalized to handle "cascade union" / union of a vector of polygons. In those cases, the region would be different.

rfcs/2022-05-24-boolean-ops.md Outdated Show resolved Hide resolved
rfcs/2022-05-24-boolean-ops.md Outdated Show resolved Hide resolved
geo/src/algorithm/bool_ops/op.rs Outdated Show resolved Hide resolved
events: BinaryHeap<Event<C::Scalar, IMSegment<C>>>,
active_segments: BTreeSet<Active<IMSegment<C>>>,
}

impl<C: Cross + Clone> Sweep<C> {
pub(crate) fn new<I>(iter: I) -> Self
pub(crate) fn new<I>(iter: I, is_simple: bool) -> Self
Copy link
Member

Choose a reason for hiding this comment

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

Is there a definition of what is_simple means in this context?

geo-bool-ops-benches/benches/boolean_ops.rs Outdated Show resolved Hide resolved
rmanoka and others added 2 commits August 1, 2022 10:59
Thanks @michaelkirk

Co-authored-by: Michael Kirk <michael.code@endoftheworl.de>
Copy link
Member

@michaelkirk michaelkirk left a comment

Choose a reason for hiding this comment

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

Ok LGTM! Thanks for the code and thanks for helping me review!

@michaelkirk
Copy link
Member

(reminder that this still needs a changelog entry, but otherwise feel free to merge)

@michaelkirk michaelkirk added this to the 0.23.0 release milestone Aug 4, 2022
@michaelkirk
Copy link
Member

Are you waiting on anything else before merging this @rmanoka?

If it's helpful, I can provide the changelog entry if that's the only thing we're waiting on.

@rmanoka
Copy link
Contributor Author

rmanoka commented Aug 10, 2022

No major changes; didn't get to wrap it up due to travel. I should get to this by this weekend, but feel free to merge if pushing for a release before then.

@rmanoka
Copy link
Contributor Author

rmanoka commented Aug 14, 2022

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 14, 2022

Build succeeded:

@bors bors bot merged commit dcb0c87 into georust:main Aug 14, 2022
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.

None yet

2 participants