-
Notifications
You must be signed in to change notification settings - Fork 154
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
MultiGeometry binary predicate support. #1220
base: branch-23.08
Are you sure you want to change the base?
Changes from all commits
db747ac
375e352
7a4012d
42467a4
b2fbb8b
6e61eb9
8edb189
ce6ed25
3296bad
27f68fa
a2e56ae
b250209
d30a517
197d7e1
1c8e980
743b195
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||||||
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
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): | ||||||
|
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): | ||||||||||||
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, | ||||||||||||
|
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.