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

Adds Within trait and fixes more Contains edge cases #884

Merged
merged 2 commits into from
Aug 13, 2022
Merged

Conversation

michaelkirk
Copy link
Member

@michaelkirk michaelkirk commented Jul 28, 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.

Based on #880, so review that first. Merged! This is ready for review!

The new Within trait is implemented in terms of Contains.

Running the "within" tests from the JTS suite exposed some further inconsistencies with how we're handling line string edge cases.

This fixes 24 failures of `Within` in the JTS "validation" suite.

The changes are in the `Contains` impl because `Within` is implemented
on top of the `Contains` trait.
Base automatically changed from mkirk/contains-all to main August 1, 2022 22:35
if self.is_closed() && coord == &self.0[0] {
return true;
if coord == &self.0[0] || coord == self.0.last().unwrap() {
return self.is_closed();
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Here's an example of the kind of test that was failing before this change:

<case>
<desc>P/nsL.1-5-1: a point on a non-simple LineString's start point with crossing line segments [dim(0){A.P.Int = B.nsL.Bdy.SPx}]</desc>
  <a>
    POINT(110 110)
  </a>
  <b>
    LINESTRING(110 110, 220 20, 20 20, 110 110, 220 220)
  </b>
  <test>
    <op name="relate" arg1="A" arg2="B" arg3="F0FFFF102">true</op>
  </test>
  <test><op name="contains"   arg1="A" arg2="B">false</op></test>
  <test><op name="coveredBy"  arg1="A" arg2="B">true</op></test>
  <test><op name="covers"     arg1="A" arg2="B">false</op></test>
  <test><op name="crosses"    arg1="A" arg2="B">false</op></test>
  <test><op name="disjoint"   arg1="A" arg2="B">false</op></test>
  <test><op name="equalsTopo" arg1="A" arg2="B">false</op></test>
  <test><op name="intersects" arg1="A" arg2="B">true</op></test>
  <test><op name="overlaps"   arg1="A" arg2="B">false</op></test>
  <test><op name="touches"    arg1="A" arg2="B">true</op></test>
  <test><op name="within"     arg1="A" arg2="B">false</op></test>
</case>

@michaelkirk
Copy link
Member Author

Now that #880 has been merged, this is ready for review!

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

bors r=frewsxcv

@bors
Copy link
Contributor

bors bot commented Aug 13, 2022

Build succeeded:

@bors bors bot merged commit 34fa01b into main Aug 13, 2022
@bors bors bot deleted the mkirk/within branch August 13, 2022 03:05
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