piyushka-ally opened a new pull request, #2772: URL: https://github.com/apache/sedona/pull/2772
# [GH-2230] Implement GeoSeries.is_ccw and GeoSeries.minimum_clearance ## Did you read the Contributor Guide? - Yes, I have read the [Contributor Rules](https://sedona.apache.org/latest/community/rule/) and [Contributor Development Guide](https://sedona.apache.org/latest/community/develop/) ## Is this PR related to a ticket? - Yes, and the PR name follows the format `[GH-XXX] my subject`. Closes #2230 ## What changes were proposed in this PR? Implements two missing `GeoSeries` methods from the [GH-2230 EPIC](https://github.com/apache/sedona/issues/2230) to expand Sedona's geopandas-compatible API: **`GeoSeries.is_ccw` (property)** - Returns `True` for `Polygon`/`MultiPolygon` geometries whose exterior ring is counter-clockwise oriented, `False` for all other geometry types. - Backed by `ST_IsPolygonCCW`. - Note: unlike geopandas (which works on `LinearRing`), this implementation operates on polygon geometry types. The behavioral difference is documented in the docstring. **`GeoSeries.minimum_clearance()` (method)** - Returns the minimum clearance distance of each geometry as a `float64` Series — the smallest distance by which any vertex could be moved to produce an invalid geometry. - Backed by `ST_MinimumClearance`. - Handles the JTS/GEOS representation difference: JTS returns `Double.MAX_VALUE` for degenerate geometries (e.g. `Point`, empty); this is converted to `float('inf')` to match geopandas/shapely behaviour. Both methods are implemented in `geoseries.py` (Spark SQL logic) and `base.py` (GeoDataFrame delegation + docstring with examples). ## How was this patch tested? - `tests/geopandas/test_geoseries.py` — hardcoded expected-value tests for both functions, including GeoDataFrame delegation: - `test_is_ccw`: CW polygon → `False`, CCW polygon → `True`, `Point` → `False` - `test_minimum_clearance`: unit square → `1.0`, half-unit square → `0.5` - `tests/geopandas/test_match_geopandas_series.py` — comparison against geopandas: - `test_is_ccw`: compares empty polygon (the only case where Sedona and geopandas semantics agree) - `test_minimum_clearance`: iterates all geometry fixture types (`self.geoms`) and compares against geopandas results All 4 tests pass locally. ## Did this PR include necessary documentation updates? - No, this PR does not affect any public API documentation — it implements existing stub methods that were already part of the planned API surface (tracked in #2230). Docstrings with examples are included inline. -- 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]
