Skip to content

[GH-3171][GH-3172] Fix empty polygon orientation and GeoSeries skew flags - #3173

Merged
jiayuasu merged 4 commits into
apache:masterfrom
jiayuasu:fix/polygon-orientation-skew-flags
Jul 27, 2026
Merged

[GH-3171][GH-3172] Fix empty polygon orientation and GeoSeries skew flags#3173
jiayuasu merged 4 commits into
apache:masterfrom
jiayuasu:fix/polygon-orientation-skew-flags

Conversation

@jiayuasu

@jiayuasu jiayuasu commented Jul 26, 2026

Copy link
Copy Markdown
Member

Did you read the Contributor Guide?

Is this PR related to a ticket?

  • Yes, and the PR name follows the format [GH-XXX] my subject.

Closes #3171.
Closes #3172.

What changes were proposed in this PR?

  • Treat empty Polygon and MultiPolygon inputs as vacuously true in both ST_IsPolygonCW and ST_IsPolygonCCW.
  • Avoid accessing the first component of an empty MultiPolygon, and treat empty members of mixed multipolygons as neutral.
  • Add common, Spark, Flink, and Snowflake coverage and document the empty-geometry behavior across all three engines.
  • Accept Python and NumPy integer values for GeoSeries.skew(use_radians=...), matching GeoPandas truthiness behavior while retaining strict rejection of non-integral values.

The orientation predicates previously accessed getGeometryN(0) unconditionally for multipolygons and did not handle an empty polygon consistently. The GeoSeries method separately restricted use_radians to boolean scalar types even though GeoPandas also accepts integer boolean-like values.

Full PostGIS parity for non-polygonal inputs and geometry collections is deferred to #3174 because it changes existing predicate results and should be handled at a major-version boundary.

How was this patch tested?

  • mvn -pl common -Dtest=FunctionsTest test (302 tests)
  • Spark functionTestScala suite (235 tests)
  • Focused Flink empty-polygon orientation test
  • python -m pytest -q tests/geopandas/test_geoseries.py -k skew (20 tests)
  • mvn -Dsnowflake=true -pl snowflake-tester -am -DskipTests package
  • Repository pre-commit hooks

Did this PR include necessary documentation updates?

  • Yes, I have updated the documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes edge-case handling for polygon orientation predicates across Sedona engines and aligns Sedona’s GeoPandas-compatible GeoSeries.skew(use_radians=...) behavior with GeoPandas by accepting integer “boolean-like” flags.

Changes:

  • Make ST_IsPolygonCW / ST_IsPolygonCCW return true for empty POLYGON/MULTIPOLYGON inputs and avoid getGeometryN(0) on empty multipolygons.
  • Expand GeoSeries.skew(use_radians=...) to accept Python/NumPy integer scalars (while still rejecting non-integral values like floats).
  • Add/extend coverage (common, Spark, Flink, Snowflake, Python) and document empty-geometry semantics in SQL/Snowflake/Flink docs.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
common/src/main/java/org/apache/sedona/common/Functions.java Fixes orientation predicate logic for empty polygons/multipolygons and removes unsafe first-element access.
common/src/test/java/org/apache/sedona/common/FunctionsTest.java Adds unit tests covering empty polygon/multipolygon and mixed multipolygon cases.
spark/common/src/test/scala/org/apache/sedona/sql/functionTestScala.scala Adds Spark SQL test ensuring empty polygonal geometries return true for both predicates.
flink/src/test/java/org/apache/sedona/flink/FunctionTest.java Adds Flink SQL test for empty polygon/multipolygon orientation behavior.
snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestFunctions.java Adds Snowflake V1 function tests for empty polygon/multipolygon orientation behavior.
snowflake-tester/src/test/java/org/apache/sedona/snowflake/snowsql/TestFunctionsV2.java Adds Snowflake V2 function tests for empty polygon/multipolygon orientation behavior.
python/sedona/spark/sql/st_functions.py Updates Python SQL-function docstrings to document empty-geometry behavior consistently.
python/sedona/spark/geopandas/geoseries.py Allows integer/NumPy-integer use_radians values and normalizes via bool(use_radians).
python/tests/geopandas/test_geoseries.py Adds tests verifying integer use_radians parity with GeoPandas and adjusts invalid-case coverage to floats.
docs/api/sql/Geometry-Accessors/ST_IsPolygonCW.md Documents POLYGON EMPTY / MULTIPOLYGON EMPTY returning true.
docs/api/sql/Geometry-Accessors/ST_IsPolygonCCW.md Documents POLYGON EMPTY / MULTIPOLYGON EMPTY returning true.
docs/api/flink/Geometry-Accessors/ST_IsPolygonCW.md Documents empty-geometry semantics for Flink docs.
docs/api/flink/Geometry-Accessors/ST_IsPolygonCCW.md Documents empty-geometry semantics for Flink docs.
docs/api/snowflake/vector-data/Geometry-Accessors/ST_IsPolygonCW.md Documents empty-geometry semantics for Snowflake docs.
docs/api/snowflake/vector-data/Geometry-Accessors/ST_IsPolygonCCW.md Documents empty-geometry semantics for Snowflake docs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@jiayuasu jiayuasu changed the title [GH-3171][GH-3172] Fix empty polygon orientation and GeoSeries skew flags [GH-3171][GH-3172] Fix polygon orientation semantics and GeoSeries skew flags Jul 26, 2026
@jiayuasu jiayuasu changed the title [GH-3171][GH-3172] Fix polygon orientation semantics and GeoSeries skew flags [GH-3171][GH-3172] Fix empty polygon orientation and GeoSeries skew flags Jul 26, 2026
@jiayuasu jiayuasu added this to the sedona-1.9.1 milestone Jul 27, 2026
@jiayuasu
jiayuasu merged commit 525d994 into apache:master Jul 27, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GeoPandas: GeoSeries.skew rejects integer use_radians values ST_IsPolygonCW and ST_IsPolygonCCW mishandle empty polygonal geometries

2 participants