-
Notifications
You must be signed in to change notification settings - Fork 28
feat: Implement ST_Crosses and ST_Overlaps predicates #204
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
Changes from 4 commits
2ccf81e
632a2c0
a497152
b46130f
c926c2a
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 | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -357,3 +357,86 @@ def test_st_within_skipped(eng, geom1, geom2, expected): | |||||||
| f"SELECT ST_Within({geom_or_null(geom1)}, {geom_or_null(geom2)})", | ||||||||
| expected, | ||||||||
| ) | ||||||||
|
|
||||||||
|
|
||||||||
| @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) | ||||||||
| @pytest.mark.parametrize( | ||||||||
| ("geom1", "geom2", "expected"), | ||||||||
| [ | ||||||||
| (None, None, None), | ||||||||
| ("POINT (0 0)", None, None), | ||||||||
| (None, "POINT (0 0)", None), | ||||||||
| ("POINT (0 0)", "POINT (0 0)", False), | ||||||||
| ("POINT (0.5 0.5)", "LINESTRING (0 0, 1 1)", False), | ||||||||
| ("POINT (0 0)", "LINESTRING (0 0, 1 1)", False), | ||||||||
| ("POINT (0.5 0.5)", "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", False), | ||||||||
| ("POINT (0 0)", "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", False), | ||||||||
| ("LINESTRING (0 0, 1 1)", "LINESTRING (0 1, 1 0)", True), | ||||||||
| ("LINESTRING (0 0, 1 1)", "LINESTRING (1 1, 2 2)", False), | ||||||||
| ("LINESTRING (0 0, 2 2)", "LINESTRING (1 1, 3 3)", False), | ||||||||
| ("LINESTRING (-1 -1, 1 1)", "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", True), | ||||||||
| ("LINESTRING (-1 0, 0 0)", "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", False), | ||||||||
| ( | ||||||||
| "LINESTRING (0.1 0.1, 0.5 0.5)", | ||||||||
| "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", | ||||||||
| False, | ||||||||
| ), | ||||||||
| ( | ||||||||
| "POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))", | ||||||||
| "POLYGON ((1 1, 3 1, 3 3, 1 3, 1 1))", | ||||||||
| False, | ||||||||
| ), | ||||||||
| ], | ||||||||
| ) | ||||||||
| def test_st_crosses(eng, geom1, geom2, expected): | ||||||||
| eng = eng.create_or_skip() | ||||||||
| eng.assert_query_result( | ||||||||
| f"SELECT ST_Crosses({geom_or_null(geom1)}, {geom_or_null(geom2)})", | ||||||||
| expected, | ||||||||
| ) | ||||||||
|
|
||||||||
|
|
||||||||
| @pytest.mark.parametrize("eng", [SedonaDB, PostGIS]) | ||||||||
| @pytest.mark.parametrize( | ||||||||
| ("geom1", "geom2", "expected"), | ||||||||
| [ | ||||||||
| (None, None, None), | ||||||||
| ("POINT (0 0)", None, None), | ||||||||
| (None, "POINT (0 0)", None), | ||||||||
|
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
|
||||||||
| ("POINT (0 0)", "LINESTRING (0 0, 1 1)", False), | ||||||||
| ("LINESTRING (0 0, 2 2)", "POLYGON ((1 1, 3 1, 3 3, 1 3, 1 1))", False), | ||||||||
| ("MULTIPOINT ((0 0), (1 1))", "MULTIPOINT ((1 1), (2 2))", True), | ||||||||
| ("MULTIPOINT ((0 0), (1 1))", "MULTIPOINT ((0 0), (1 1))", False), | ||||||||
| ("POINT (0 0)", "POINT (0 0)", False), | ||||||||
| ("LINESTRING (0 0, 2 2)", "LINESTRING (1 1, 3 3)", True), | ||||||||
| ("LINESTRING (0 0, 1 1)", "LINESTRING (0 1, 1 0)", False), | ||||||||
| ("LINESTRING (0 0, 1 1)", "LINESTRING (1 1, 2 2)", False), | ||||||||
|
Comment on lines
+412
to
+415
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. I like that we have some good edge cases here like identical geometries ( |
||||||||
| ("LINESTRING (0 0, 1 1)", "LINESTRING (0 0, 1 1)", False), | ||||||||
| ( | ||||||||
| "POLYGON ((0 0, 2 0, 2 2, 0 2, 0 0))", | ||||||||
| "POLYGON ((1 1, 3 1, 3 3, 1 3, 1 1))", | ||||||||
| True, | ||||||||
| ), | ||||||||
| ( | ||||||||
| "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", | ||||||||
| "POLYGON ((1 0, 2 0, 2 1, 1 1, 1 0))", | ||||||||
| False, | ||||||||
| ), | ||||||||
| ( | ||||||||
| "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", | ||||||||
| "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))", | ||||||||
| False, | ||||||||
| ), | ||||||||
| ( | ||||||||
| "POLYGON ((0 0, 3 0, 3 3, 0 3, 0 0))", | ||||||||
| "POLYGON ((1 1, 2 1, 2 2, 1 2, 1 1))", | ||||||||
| False, | ||||||||
| ), | ||||||||
| ], | ||||||||
| ) | ||||||||
| def test_st_overlaps(eng, geom1, geom2, expected): | ||||||||
| eng = eng.create_or_skip() | ||||||||
| eng.assert_query_result( | ||||||||
| f"SELECT ST_Overlaps({geom_or_null(geom1)}, {geom_or_null(geom2)})", | ||||||||
| expected, | ||||||||
| ) | ||||||||
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.
How about we add one more case (empty geometries) while we're here. I checked out the branch and tested these locally, and saw that they already pass.