jiayuasu opened a new issue, #2722: URL: https://github.com/apache/sedona/issues/2722
### Description `ST_Equals` throws `IllegalArgumentException` when either argument is a non-empty `GeometryCollection`. PostGIS and shapely/geopandas handle `GeometryCollection` inputs without errors. ### Root cause In [`Predicates.java` line 58-60](https://github.com/apache/sedona/blob/master/common/src/main/java/org/apache/sedona/common/Predicates.java#L58-L60): ```java public static boolean equals(Geometry leftGeometry, Geometry rightGeometry) { return leftGeometry.symDifference(rightGeometry).isEmpty(); } ``` JTS's `symDifference` does not support `GeometryCollection` arguments, so this throws: ``` java.lang.IllegalArgumentException: Operation does not support GeometryCollection arguments at org.locationtech.jts.geom.Geometry.checkNotGeometryCollection(Geometry.java:1735) at org.locationtech.jts.geom.GeometryOverlay.symDifference(GeometryOverlay.java:135) at org.locationtech.jts.geom.Geometry.symDifference(Geometry.java:1382) at org.apache.sedona.common.Predicates.equals(Predicates.java:59) ``` ### Steps to reproduce ```sql SELECT ST_Equals( ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0, 1 1))'), ST_GeomFromText('GEOMETRYCOLLECTION(POINT(0 0), LINESTRING(0 0, 1 1))') ) -- Sedona: throws IllegalArgumentException -- PostGIS: returns true ``` ```python from shapely.geometry import GeometryCollection, Point, LineString gc = GeometryCollection([Point(0, 0), LineString([(0, 0), (1, 1)])]) gc.equals(gc) # True ``` ### Suggested fix Use `equalsTopo` instead of `symDifference().isEmpty()`, or add special handling for `GeometryCollection`: ```java public static boolean equals(Geometry leftGeometry, Geometry rightGeometry) { return leftGeometry.equalsTopo(rightGeometry); } ``` Note: `equalsTopo` is the JTS equivalent of the DE-9IM based topological equality check and handles `GeometryCollection` inputs correctly. -- 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]
