jiayuasu opened a new issue, #3171: URL: https://github.com/apache/sedona/issues/3171
## Expected behavior `ST_IsPolygonCW` and `ST_IsPolygonCCW` should handle empty polygonal geometries without throwing. Both predicates should return `true` when the input has no rings to violate the requested orientation, consistent with the documented PostGIS semantics: - https://postgis.net/docs/ST_IsPolygonCW.html - https://postgis.net/docs/ST_IsPolygonCCW.html ## Actual behavior - `POLYGON EMPTY` returns `true` from `ST_IsPolygonCW` but `false` from `ST_IsPolygonCCW`. - `MULTIPOLYGON EMPTY` throws `ArrayIndexOutOfBoundsException` from both predicates. The common implementations unconditionally call `getGeometryN(0)` for every `MultiPolygon`, including an empty one. ## Steps to reproduce the problem ```sql SELECT ST_IsPolygonCW(ST_GeomFromWKT('POLYGON EMPTY')), ST_IsPolygonCCW(ST_GeomFromWKT('POLYGON EMPTY')); SELECT ST_IsPolygonCW(ST_GeomFromWKT('MULTIPOLYGON EMPTY')), ST_IsPolygonCCW(ST_GeomFromWKT('MULTIPOLYGON EMPTY')); ``` The first query returns `(true, false)`. The second query fails with an error whose cause is: ```text java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0 at org.locationtech.jts.geom.GeometryCollection.getGeometryN(...) at org.apache.sedona.common.Functions.isPolygonCW(...) ``` The same unconditional first-element access exists in `isPolygonCCW`. ## Settings Sedona version = 1.9.1-SNAPSHOT Apache Spark version = 3.4 Apache Flink version = The affected implementation is shared by all engines API type = Spark SQL / common Java functions Scala version = 2.12 JRE version = 17 Python version = 3.12 Environment = Standalone -- 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]
