petern48 commented on code in PR #204:
URL: https://github.com/apache/sedona-db/pull/204#discussion_r2423244189
##########
python/sedonadb/tests/functions/test_predicates.py:
##########
@@ -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,
)
+
+
[email protected]("eng", [SedonaDB, PostGIS])
[email protected](
+ ("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,
+ )
+
+
[email protected]("eng", [SedonaDB, PostGIS])
[email protected](
+ ("geom1", "geom2", "expected"),
+ [
+ (None, None, None),
+ ("POINT (0 0)", None, None),
+ (None, "POINT (0 0)", None),
Review Comment:
```suggestion
(None, "POINT (0 0)", None),
("POINT (0 0)", "POINT EMPTY", False),
```
##########
python/sedonadb/tests/functions/test_predicates.py:
##########
@@ -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,
)
+
+
[email protected]("eng", [SedonaDB, PostGIS])
[email protected](
+ ("geom1", "geom2", "expected"),
+ [
+ (None, None, None),
+ ("POINT (0 0)", None, None),
+ (None, "POINT (0 0)", None),
Review Comment:
```suggestion
(None, "POINT (0 0)", None),
("POINT (0 0)", "POINT EMPTY", False),
```
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.
##########
python/sedonadb/tests/functions/test_predicates.py:
##########
@@ -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,
)
+
+
[email protected]("eng", [SedonaDB, PostGIS])
[email protected](
+ ("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,
+ )
+
+
[email protected]("eng", [SedonaDB, PostGIS])
[email protected](
+ ("geom1", "geom2", "expected"),
+ [
+ (None, None, None),
+ ("POINT (0 0)", None, None),
+ (None, "POINT (0 0)", None),
+ ("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),
Review Comment:
I like that we have some good edge cases here like identical geometries
(`"POINT (0 0)", "POINT (0 0)"`) and "touching geometries" (i.e. `"LINESTRING
(0 0, 1 1)", "LINESTRING (1 1, 2 2)"`)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]