This repository was archived by the owner on Jul 28, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 164
MultiGeometry binary predicate support. #1220
Draft
thomcom
wants to merge
16
commits into
rapidsai:branch-23.08
Choose a base branch
from
thomcom:feature/multigeometry-test-dispatch
base: branch-23.08
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
db747ac
Write first set of MultiPoint MultiPoint tests.
thomcom 375e352
Add all MultiPoint tests.
thomcom 7a4012d
Test Point-MultiLineString
thomcom 42467a4
Making progress on MultiLineString crosses, needed to update Overlaps.
thomcom b2fbb8b
_lines_to_boundary_multipoints builds from MultiLineString parts.
thomcom 6e61eb9
Start switching to MultiPoints and MultiLineStrings PRs.
thomcom 8edb189
Merge branch 'branch-23.08' into feature/multigeometry-test-dispatch
thomcom ce6ed25
Fix introduced issue in binpred tests.
thomcom 3296bad
Add an optimization comment.
thomcom 27f68fa
Improved comments etc.
thomcom a2e56ae
Drop special cases in multigeometry
thomcom b250209
Merge branch 'branch-23.08' into feature/multigeometry-test-dispatch
thomcom d30a517
Test with signing.
thomcom 197d7e1
Test with signing.
thomcom 1c8e980
Merge branch 'branch-23.08' into feature/multigeometry-test-dispatch
thomcom 743b195
Try running notebooks tests with full ipynb poath.
thomcom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,9 @@ | |||||
| Point, | ||||||
| Polygon, | ||||||
| _false_series, | ||||||
| _points_and_lines_to_multipoints, | ||||||
| _lines_to_boundary_multipoints, | ||||||
| _pli_lines_to_multipoints, | ||||||
| _pli_points_to_multipoints, | ||||||
| ) | ||||||
|
|
||||||
|
|
||||||
|
|
@@ -43,13 +45,23 @@ def _compute_predicate(self, lhs, rhs, preprocessor_result): | |||||
| # they intersect, and none of the points of the | ||||||
| # intersection are in the boundary of the other | ||||||
| pli = _basic_intersects_pli(rhs, lhs) | ||||||
| intersections = _points_and_lines_to_multipoints(pli[1], pli[0]) | ||||||
| equals_lhs_count = _basic_equals_count(intersections, lhs) | ||||||
| equals_rhs_count = _basic_equals_count(intersections, rhs) | ||||||
| equals_lhs = equals_lhs_count != intersections.sizes | ||||||
| equals_rhs = equals_rhs_count != intersections.sizes | ||||||
| equals = equals_lhs & equals_rhs | ||||||
| return equals | ||||||
| points = _pli_points_to_multipoints(pli) | ||||||
| lines = _pli_lines_to_multipoints(pli) | ||||||
| # Optimization: only compute the subsequent boundaries and equalities | ||||||
| # of indexes that contain point intersections and do not contain line | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| # intersections. | ||||||
| lhs_boundary = _lines_to_boundary_multipoints(lhs) | ||||||
| rhs_boundary = _lines_to_boundary_multipoints(rhs) | ||||||
| lhs_boundary_matches = _basic_equals_count(points, lhs_boundary) | ||||||
| rhs_boundary_matches = _basic_equals_count(points, rhs_boundary) | ||||||
| lhs_crosses = lhs_boundary_matches != points.sizes | ||||||
| rhs_crosses = rhs_boundary_matches != points.sizes | ||||||
|
Comment on lines
+57
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It says "none of the points of intersection is in the boundary of the geometry". AKA, there is 0 points in the intersection results that are in the boundary. Shouldn't this be ? |
||||||
| crosses = ( | ||||||
| (points.sizes > 0) | ||||||
| & (lhs_crosses & rhs_crosses) | ||||||
| & (lines.sizes == 0) | ||||||
| ) | ||||||
| return crosses | ||||||
|
|
||||||
|
|
||||||
| class LineStringPolygonCrosses(BinPred): | ||||||
|
|
||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -4,6 +4,8 @@ | |||||||||||
|
|
||||||||||||
| from cuspatial.core.binpreds.basic_predicates import ( | ||||||||||||
| _basic_contains_properly_any, | ||||||||||||
| _basic_equals_count, | ||||||||||||
| _basic_intersects_pli, | ||||||||||||
| ) | ||||||||||||
| from cuspatial.core.binpreds.binpred_interface import ( | ||||||||||||
| BinPred, | ||||||||||||
|
|
@@ -17,6 +19,7 @@ | |||||||||||
| Point, | ||||||||||||
| Polygon, | ||||||||||||
| _false_series, | ||||||||||||
| _pli_lines_to_multipoints, | ||||||||||||
| ) | ||||||||||||
| from cuspatial.utils.column_utils import has_same_geometry | ||||||||||||
|
|
||||||||||||
|
|
@@ -39,6 +42,15 @@ class OverlapsPredicateBase(EqualsPredicateBase): | |||||||||||
| pass | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| class LineStringLineStringOverlaps(BinPred): | ||||||||||||
| def _preprocess(self, lhs, rhs): | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A small docstring helps:
Suggested change
Sounds correct? |
||||||||||||
| pli = _basic_intersects_pli(lhs, rhs) | ||||||||||||
| lines = _pli_lines_to_multipoints(pli) | ||||||||||||
| lhs_not_equal = _basic_equals_count(lhs, lines) != lhs.sizes | ||||||||||||
| rhs_not_equal = _basic_equals_count(rhs, lines) != rhs.sizes | ||||||||||||
| return (lines.sizes > 0) & lhs_not_equal & rhs_not_equal | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| class PolygonPolygonOverlaps(BinPred): | ||||||||||||
| def _preprocess(self, lhs, rhs): | ||||||||||||
| contains_lhs = lhs.contains(rhs) | ||||||||||||
|
|
@@ -85,7 +97,7 @@ def _postprocess(self, lhs, rhs, op_result): | |||||||||||
| (MultiPoint, Polygon): ImpossiblePredicate, | ||||||||||||
| (LineString, Point): ImpossiblePredicate, | ||||||||||||
| (LineString, MultiPoint): ImpossiblePredicate, | ||||||||||||
| (LineString, LineString): ImpossiblePredicate, | ||||||||||||
| (LineString, LineString): LineStringLineStringOverlaps, | ||||||||||||
| (LineString, Polygon): ImpossiblePredicate, | ||||||||||||
| (Polygon, Point): OverlapsPredicateBase, | ||||||||||||
| (Polygon, MultiPoint): OverlapsPredicateBase, | ||||||||||||
|
|
||||||||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like you need a separate API that handles linestring merging. Something like:
Because calling the self intersection just to remove the additional points is too expensive.