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

Fix a bug in point-in-polygon kernel: if the point is collinear with an edge, result is asserted false #1108

Merged
merged 7 commits into from
May 2, 2023

Conversation

isVoid
Copy link
Contributor

@isVoid isVoid commented Apr 29, 2023

Description

Fixes #1103, current algorithm tests if the test point is collinear with an edge of the polygon, the point is asserted to be on the edge. This is not true, because for a point to be on the edge, the point also needs to be within the range where the edge covers. Collinearity test only test if the point is covered by the line that the edge coincides.

This PR fixes this bug by adding additional tests to guarantee that the point is on an edge iff the point is collinear with the line where the edge coincides as well as the x coordinate of the point is within the closed range of the edge's x coordinates.

This PR also fixes an additional bug where the col-linearity flag is not reset after each iteration of a ring.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@isVoid isVoid requested a review from a team as a code owner April 29, 2023 00:12
@isVoid isVoid requested review from trxcllnt and harrism April 29, 2023 00:12
@isVoid isVoid self-assigned this Apr 29, 2023
@github-actions github-actions bot added the libcuspatial Relates to the cuSpatial C++ library label Apr 29, 2023
@isVoid isVoid added bug Something isn't working non-breaking Non-breaking change labels Apr 29, 2023
@isVoid isVoid changed the title Fix a bug in point-in-polygon test where if the point is collinear with the edge and result is asserted false Fix a bug in point-in-polygon kernel: if the point is collinear with an edge, result is asserted false Apr 29, 2023
Copy link
Member

@harrism harrism left a comment

Choose a reason for hiding this comment

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

Thanks for the quick fix!

@isVoid
Copy link
Contributor Author

isVoid commented May 2, 2023

/merge

@rapids-bot rapids-bot bot merged commit 8c66988 into rapidsai:branch-23.06 May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working libcuspatial Relates to the cuSpatial C++ library non-breaking Non-breaking change
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

[BUG]: wrong result for point_in_polygon
2 participants