petern48 commented on code in PR #229:
URL: https://github.com/apache/sedona-db/pull/229#discussion_r2443374656
##########
python/sedonadb/tests/functions/test_functions.py:
##########
@@ -211,6 +211,63 @@ def test_st_centroid(eng, geom, expected):
eng.assert_query_result(f"SELECT ST_Centroid({geom_or_null(geom)})",
expected)
[email protected]("eng", [SedonaDB, PostGIS])
[email protected](
+ ("geom", "expected"),
+ [
+ (None, None),
+ ("POINT (0 0)", True),
+ ("POINT EMPTY", True),
+ ("LINESTRING (0 0, 1 1)", True),
+ ("LINESTRING (0 0, 1 1, 1 0, 0 1)", True),
+ (
+ "MULTILINESTRING ((0 0, 1 1), (0 0, 1 1, 1 0, 0 1))",
+ True,
+ ),
+ ("LINESTRING EMPTY", True),
+ # Invalid LineStrings
+ ("LINESTRING (0 0, 0 0)", False), # Degenerate - both points identical
+ ("LINESTRING (0 0, 0 0, 0 0)", False), # All points identical
+ # Invalid MultiLineStrings
+ ("MULTILINESTRING ((0 0, 0 0), (1 1, 2 2))", False), # Degenerate
component
+ (
+ "MULTILINESTRING ((0 0, 0 0), (1 1, 1 1))",
+ False,
+ ), # Multiple degenerate components
+ ("POLYGON ((0 0, 0 1, 1 1, 1 0, 0 0))", True),
+ ("POLYGON EMPTY", True),
+ ("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 1, 1 2, 2 2, 2 1, 1 1))",
True),
+ # Invalid Polygons
+ # Self-intersecting polygon (bowtie)
+ ("POLYGON ((0 0, 1 1, 0 1, 1 0, 0 0))", False),
+ # Inner ring shares an edge with the outer ring
+ ("POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (0 0, 0 1, 1 1, 1 0, 0 0))",
False),
+ # Self-intersecting polygon (figure-8)
+ ("Polygon((0 0, 2 0, 1 1, 2 2, 0 2, 1 1, 0 0))", False),
+ # Inner ring touches the outer ring at a point
+ (
+ "POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (1 10, 1 9, 2 9, 2 10, 1
10))",
+ False,
+ ),
+ # Overlapping polygons in a multipolygon
Review Comment:
Super helpful comments! I didn't know about these invalid geometry cases
until now.
--
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]