-
Notifications
You must be signed in to change notification settings - Fork 157
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
Implement and Test All non-multi-Feature Spatial Predicate Combinations #1064
Merged
rapids-bot
merged 156 commits into
rapidsai:branch-23.06
from
thomcom:feature/binary-predicate-manual-test-dispatch
May 26, 2023
Merged
Changes from all commits
Commits
Show all changes
156 commits
Select commit
Hold shift + click to select a range
96b28a3
Work on the most obvious parts of allpairs_points_equals_count
thomcom b8785f7
Build system.
thomcom c6e3910
Try a hand at copying point_polygon_distance_test.cu
thomcom 45c128c
recording progress with Thomson
isVoid 0f0a0d4
fix 0 sized input error
isVoid d1fb60c
Pass all tests.
thomcom da247f8
Switch to atomicAdd
thomcom 2b7d7fa
Write one more test.
thomcom dd01d6c
using sort-then-search algorithm
isVoid b4ac329
Resolve merge
thomcom 3dc6195
passes compilation!
isVoid 9931ed1
Merge
thomcom dbd1bbf
Cleaning up for PR.
thomcom bd03668
Update docs, fix a typo.
thomcom 313c020
Rename cpp test.
thomcom 1c1e7ce
Strange test error.
thomcom 28d5c13
Write python bindings.
thomcom 6abb44e
Build python bindings and test.
thomcom c400646
Update cpp/include/cuspatial/experimental/detail/allpairs_multipoint_…
thomcom d2ac985
Update cpp/include/cuspatial/allpairs_multipoint_equals_count.hpp
thomcom 23f4363
Update cpp/tests/experimental/spatial/allpairs_multipoint_equals_coun…
thomcom 63eea9d
Add specific test.
thomcom 29050fc
Merge branch 'feature/allpairs_point_equals_count' of github.com:thom…
thomcom 30c9c86
refactors to multipoint-multipoint pairwise
isVoid 2d64f3b
add missing files
isVoid f99810f
Get all tests passing.
thomcom 7f606f9
Fix a bug in column wrapper.
thomcom c8ae2dd
Merge branch 'branch-23.04' into feature/allpairs_point_equals_count
thomcom ec24574
Make test untyped.:
thomcom b1f6207
Update docs
thomcom 0050be0
Transfer python updates from later branch.
thomcom c178414
Improve .cpp file testing based on length requirement.
thomcom 719d065
Tweak error message.
thomcom 05090bb
Update equals_count docs and tests.
thomcom ca1218d
Minor docs tweak.
thomcom 76c8aac
Remove repeat tests.
thomcom 5c78146
Fix docs
thomcom e3aeac7
Merge branch 'branch-23.06' into feature/allpairs_point_equals_count
thomcom e0bba71
Merge branch 'branch-23.06' into feature/allpairs_point_equals_count
thomcom 3d28ee9
Update cpp/include/cuspatial/experimental/detail/pairwise_multipoint_…
thomcom 32050f9
Doc tweak
thomcom 2420dfe
Merge branch 'feature/allpairs_point_equals_count' of github.com:thom…
thomcom ac9b755
Update cpp/include/cuspatial/pairwise_multipoint_equals_count.hpp
thomcom d904762
Update cpp/include/cuspatial/pairwise_multipoint_equals_count.hpp
thomcom 102915b
Update python/cuspatial/cuspatial/core/binops/equals_count.py
thomcom 72d6e97
Merge branch 'feature/allpairs_point_equals_count' of github.com:thom…
thomcom a806371
Merge branch 'branch-23.06' into feature/allpairs_point_equals_count
thomcom fbcd2bd
Update python/cuspatial/cuspatial/core/binops/equals_count.py
thomcom f7c2c98
Update cpp/include/cuspatial/experimental/pairwise_multipoint_equals_…
thomcom 89a54c5
Address comment about multipoint_range docs.
thomcom 37cba19
Merge branch 'feature/allpairs_point_equals_count' of github.com:thom…
thomcom e63c594
Tweaking because of format issue.
thomcom 66498cf
Tweaking problem with docs.
thomcom ce1df18
Repair docs?
thomcom 07401fe
CR at beginning of file typo
thomcom 86ad906
First commit of test dispatch branch.
thomcom 1a0072c
Enable xfail.
thomcom b2ea930
Binpred test dispatch documented and ready for review.
thomcom dfcd583
Fix bug in test list.
thomcom 1766437
Basic binpred first fork of big PR.
thomcom 1ff4589
Forgot geoseries.py
thomcom 367a420
Refactor contains and contains properly and pass all tests.
thomcom fbc1618
Remove unneeded predicate.
thomcom 873525a
Tweak docs.
thomcom 0d84603
Clean up docs in feature_contains.py
thomcom e4132b0
Clean up contains_properly docs.
thomcom 8dfca13
Clean up ContainsProperlyByIntersection.
thomcom a3d8b8a
Clean up WithinIntersectsPredicate.
thomcom 008631e
Write docs for geoseries.sizes
thomcom 550fa9b
Clean up docs and write docstrings for all _basic utility methods.
thomcom f45acda
Document and improve binpred_utils.py
thomcom 7198f40
Move files from master branch to new PR.
thomcom eaee84c
Updating
thomcom 9614dff
Merge
thomcom fc1ca25
Fix a bad test.
thomcom b651aaf
Merge
thomcom 8e83ec1
Merge binpred_test_dispatch
thomcom 6a931bb
Pass a couple of tests.
thomcom ae39c88
Back to 26 failed. Working on within, touches, and crosses only.
thomcom a48dbbf
Lots of changes trying to get contains working as expected.
thomcom c0dd549
Create arduous points_and_lines_to_multipoints function.
thomcom 753334c
Pass all contains tests.
thomcom a5ec83a
Resolve new indexing bug related to fixing a bug in geoseries.
thomcom 1a2456a
Remove breakpoints and pass a couple of old bug tests.
thomcom a394ea6
Pass all non-binpred-dispatch tests.
thomcom 410fd07
Pass all touches and more
thomcom bd5aebf
Five failing tests.
thomcom 1c98d6d
Working on the last few cases that depend on variations of .contains …
thomcom 57517cd
296/297 predicates.
thomcom 3fc9d44
Pass 100% of tests!
thomcom 32c9e0a
Merge branch 'branch-23.06' into feature/_basic_binpreds
thomcom 713a27a
Resolve merge
thomcom d0138c9
Resolve missed merge files.
thomcom e60af29
Return whitespace.
thomcom 85676d1
Still working on missed files.
thomcom f64b461
Rename CMakeFiles
thomcom ddda72c
One too many files.
thomcom 1c0a018
Merge branch 'branch-23.06' into feature/_basic_binpreds
thomcom 0d7ca82
Pull similar files from the master branch.
thomcom 12fa90f
Rename points back to final_rhs
thomcom b45a731
Update docs a bit.
thomcom d753bf0
Merge branch 'feature/_basic_binpreds' into feature/binary-predicate-…
thomcom fe978a3
Add mode argument docs.
thomcom 3b68ec2
Rename complex_geometry_predicate and cleaning up ContainsPredicates.
thomcom aae2f28
Updating contains and contains_properly to be neater.
thomcom 5924fd0
Merge branch 'feature/_basic_binpreds' into feature/binary-predicate-…
thomcom 96e442e
Cleaning up things throughout.
thomcom 37daece
Cleaning up intersects and within
thomcom 7b52117
Delete unused _basic functions.
thomcom d7fffac
Remove unsupported test.
thomcom 675f145
Reduce the number of basic predicates.
thomcom 2015405
Missed a couple of ContainsPredicateBases
thomcom 0698322
Updating comments for confusing sections.
thomcom 4fd668e
Begin cleaning up intersects.
thomcom 3de22b3
Theoretically well refactored intersects.
thomcom 195028d
Still pass all tests.
thomcom 6433096
Add another linestring example that proves touches.
thomcom 32a18de
Add complex polygons test to .contains test. It passes!
thomcom 9e65cb4
Update python/cuspatial/cuspatial/core/binpreds/feature_contains_prop…
thomcom 8a1d234
Handle review comments.
thomcom c433949
Drop one useless inheritance.
thomcom 24e4d9a
Update python/cuspatial/cuspatial/core/geoseries.py
thomcom a86fb2b
Change error type of mixed geometry geoseries.sizes call.
thomcom e9dd49e
Merge branch 'feature/_basic_binpreds' of github.com:thomcom/cuspatia…
thomcom c813ba7
Remove local imports from _basic_predicates.
thomcom c3d03cb
Get rid of intesrsects_through
thomcom 5814380
Merge branch 'feature/_basic_binpreds' into feature/binary-predicate-…
thomcom a2bf9d3
Get rid of through call
thomcom 92c918c
Move _basic_predicates into a dedicated file. Handle various review c…
thomcom 86dd5b3
Update python/cuspatial/cuspatial/core/geoseries.py
thomcom 4f6f8a8
Update python/cuspatial/cuspatial/core/geoseries.py
thomcom c14b4ca
Update python/cuspatial/cuspatial/core/geoseries.py
thomcom 6e8f6ee
Merge branch 'feature/_basic_binpreds' of github.com:thomcom/cuspatia…
thomcom 72ad8c9
Update contains predicate docs.
thomcom 6c6f097
Refactor use of quadtree and language.
thomcom c875787
Merge branch 'feature/_basic_binpreds' into feature/binary-predicate-…
thomcom 43c50ab
Refactor basic predicates.
thomcom d628a44
Update python/cuspatial/cuspatial/core/geoseries.py
thomcom 2eb4b32
Handle @isVoid's final comments.
thomcom 81d85f5
Merge branch 'feature/_basic_binpreds' of github.com:thomcom/cuspatia…
thomcom 14ec9d7
Merge branch 'branch-23.06' into feature/_basic_binpreds
thomcom 9855137
Style
thomcom ffa7141
Merge branch 'feature/_basic_binpreds' into feature/binary-predicate-…
thomcom 35d6bec
Merge branch 'branch-23.06' into feature/binary-predicate-manual-test…
thomcom f9b2df6
Disable logging without environment variable.
thomcom 961d199
Replace missing geoseries tests and clean up touches and binpreds test.
thomcom ebc33b8
Enable previosly unsupported tests.
thomcom 30eded7
Add deeper docs to _points_and_lines_to_multipoints
thomcom ded3d74
Resolve core issue with LineStringLineStringTouches and Crosses.
thomcom 55bac02
Improve PolygonPolygonTouches handling of edge overlapping cases.
thomcom ba4e5c6
Add a new test case that blew up linestringlinestring touches and cov…
thomcom 805d5f3
Improve PolygonLineStringCovers.
thomcom 9f27a62
Merge branch 'branch-23.06' into feature/binary-predicate-manual-test…
thomcom 69691d8
Final tweaks.
thomcom 227bd88
Merge branch 'branch-23.06' into feature/binary-predicate-manual-test…
thomcom a999014
Merge branch 'branch-23.06' into feature/binary-predicate-manual-test…
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 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 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
83 changes: 64 additions & 19 deletions
83
python/cuspatial/cuspatial/core/binpreds/feature_covers.py
This file contains 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 |
---|---|---|
@@ -1,56 +1,101 @@ | ||
# Copyright (c) 2023, NVIDIA CORPORATION. | ||
|
||
from cuspatial.core.binpreds.binpred_interface import NotImplementedPredicate | ||
from cuspatial.core.binpreds.basic_predicates import ( | ||
_basic_contains_any, | ||
_basic_contains_count, | ||
_basic_equals_count, | ||
_basic_intersects_pli, | ||
) | ||
from cuspatial.core.binpreds.binpred_interface import ( | ||
BinPred, | ||
ImpossiblePredicate, | ||
NotImplementedPredicate, | ||
) | ||
from cuspatial.core.binpreds.feature_equals import EqualsPredicateBase | ||
from cuspatial.core.binpreds.feature_intersects import ( | ||
LineStringPointIntersects, | ||
PointLineStringIntersects, | ||
) | ||
from cuspatial.utils.binpred_utils import ( | ||
LineString, | ||
MultiPoint, | ||
Point, | ||
Polygon, | ||
_points_and_lines_to_multipoints, | ||
_zero_series, | ||
) | ||
|
||
|
||
class CoversPredicateBase(EqualsPredicateBase): | ||
"""Implements the covers predicate across different combinations of | ||
geometry types. For example, a Point-Polygon covers predicate is | ||
defined in terms of a Point-Point equals predicate. The initial release | ||
implements covers predicates that depend only on the equals predicate, or | ||
depend on no predicate, such as impossible cases like | ||
`LineString.covers(Polygon)`. | ||
|
||
For this initial release, cover is supported for the following types: | ||
defined in terms of a Point-Polygon equals predicate. | ||
|
||
Point.covers(Point) | ||
Point.covers(Polygon) | ||
LineString.covers(Polygon) | ||
Polygon.covers(Point) | ||
Polygon.covers(MultiPoint) | ||
Polygon.covers(LineString) | ||
Polygon.covers(Polygon) | ||
""" | ||
|
||
pass | ||
|
||
|
||
class LineStringLineStringCovers(BinPred): | ||
def _preprocess(self, lhs, rhs): | ||
# A linestring A covers another linestring B iff | ||
# no point in B is outside of A. | ||
pli = _basic_intersects_pli(lhs, rhs) | ||
points = _points_and_lines_to_multipoints(pli[1], pli[0]) | ||
# Every point in B must be in the intersection | ||
equals = _basic_equals_count(rhs, points) == rhs.sizes | ||
return equals | ||
|
||
|
||
class PolygonPointCovers(BinPred): | ||
def _preprocess(self, lhs, rhs): | ||
return _basic_contains_any(lhs, rhs) | ||
isVoid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
class PolygonLineStringCovers(BinPred): | ||
def _preprocess(self, lhs, rhs): | ||
isVoid marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# A polygon covers a linestring if all of the points in the linestring | ||
# are in the interior or exterior of the polygon. This differs from | ||
# a polygon that contains a linestring in that some point of the | ||
# linestring must be in the interior of the polygon. | ||
# Count the number of points from rhs in the interior of lhs | ||
contains_count = _basic_contains_count(lhs, rhs) | ||
# Now count the number of points from rhs in the boundary of lhs | ||
pli = _basic_intersects_pli(lhs, rhs) | ||
intersections = pli[1] | ||
# There may be no intersection, so start with _zero_series | ||
equality = _zero_series(len(rhs)) | ||
if len(intersections) > 0: | ||
matching_length_multipoints = _points_and_lines_to_multipoints( | ||
intersections, pli[0] | ||
) | ||
equality = _basic_equals_count(matching_length_multipoints, rhs) | ||
covers = contains_count + equality >= rhs.sizes | ||
return covers | ||
|
||
|
||
class PolygonPolygonCovers(BinPred): | ||
def _preprocess(self, lhs, rhs): | ||
contains = lhs.contains(rhs) | ||
return contains | ||
|
||
|
||
DispatchDict = { | ||
(Point, Point): CoversPredicateBase, | ||
(Point, MultiPoint): NotImplementedPredicate, | ||
(Point, LineString): PointLineStringIntersects, | ||
(Point, Polygon): CoversPredicateBase, | ||
(Point, LineString): ImpossiblePredicate, | ||
(Point, Polygon): ImpossiblePredicate, | ||
(MultiPoint, Point): NotImplementedPredicate, | ||
(MultiPoint, MultiPoint): NotImplementedPredicate, | ||
(MultiPoint, LineString): NotImplementedPredicate, | ||
(MultiPoint, Polygon): NotImplementedPredicate, | ||
(LineString, Point): LineStringPointIntersects, | ||
(LineString, MultiPoint): NotImplementedPredicate, | ||
(LineString, LineString): NotImplementedPredicate, | ||
(LineString, LineString): LineStringLineStringCovers, | ||
(LineString, Polygon): CoversPredicateBase, | ||
(Polygon, Point): CoversPredicateBase, | ||
(Polygon, Point): PolygonPointCovers, | ||
(Polygon, MultiPoint): CoversPredicateBase, | ||
(Polygon, LineString): CoversPredicateBase, | ||
(Polygon, Polygon): CoversPredicateBase, | ||
(Polygon, LineString): PolygonLineStringCovers, | ||
(Polygon, Polygon): PolygonPolygonCovers, | ||
} |
This file contains 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 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 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.
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.
I can't comment on non-changed lines, but please don't add documentation that will go stale quickly, e.g. "in this initial release". Also, the fact that it is implemented using only the equals predicate is an implementation detail, not a feature of the API. Public documentation should cover features and usage of the API, not implementation details.
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.
Thanks for the clarification, those docs and others definitely needed a cleanup.