jiayuasu opened a new pull request, #2730:
URL: https://github.com/apache/sedona/pull/2730

   ## Summary
   
   Fixes four geometry function bugs:
   
   ### [GH-2720] ST_FrechetDistance returns 0.0 instead of null for empty 
geometries
   
   Changed `getFrechetDistance` to return `Double.NaN` (instead of `0.0`) when 
either input geometry is empty, matching PostGIS and shapely/geopandas 
behavior. Updated return type from `double` to `Double` in `GeomUtils`, 
`Functions`, and Snowflake UDFs.
   
   ### [GH-2721] ST_HausdorffDistance returns 0.0 instead of null for empty 
geometries
   
   Changed `getHausdorffDistance` to return `Double.NaN` (instead of `0.0`) 
when either input geometry is empty, matching PostGIS and shapely/geopandas 
behavior.
   
   ### [GH-2722] ST_Equals throws IllegalArgumentException on 
GeometryCollection inputs
   
   Replaced `symDifference().isEmpty()` with `equalsTopo()` in 
`Predicates.equals()`. JTS's `symDifference` does not support 
`GeometryCollection` arguments; `equalsTopo` is the JTS equivalent of DE-9IM 
topological equality and handles `GeometryCollection` inputs correctly.
   
   ### [GH-2723] ST_VoronoiPolygons unnecessarily requires GeoTools on classpath
   
   Moved `voronoiPolygons` from `FunctionsGeoTools.java` to `Functions.java`. 
The method only uses JTS classes (`VoronoiDiagramBuilder`, `Geometry`, 
`Envelope`) -- no GeoTools APIs -- consistent with `ST_DelaunayTriangles` which 
is already in `Functions.java`. Updated all callers in Spark, Flink, and 
Snowflake modules. Removed unused imports.
   
   ## Changes
   
   | File | Change |
   |------|--------|
   | `common/.../utils/GeomUtils.java` | Return `Double.NaN` for empty geoms in 
`getFrechetDistance` and `getHausdorffDistance` |
   | `common/.../Functions.java` | Change `frechetDistance` return type to 
`Double`; add `voronoiPolygons` method |
   | `common/.../FunctionsGeoTools.java` | Remove `voronoiPolygons` method and 
unused imports |
   | `common/.../Predicates.java` | Use `equalsTopo()` instead of 
`symDifference().isEmpty()` |
   | `flink/.../expressions/Functions.java` | Update `ST_VoronoiPolygons` to 
call `Functions.voronoiPolygons` |
   | `snowflake/.../UDFs.java` | Update `ST_VoronoiPolygons` and 
`ST_FrechetDistance` callers |
   | `snowflake/.../UDFsV2.java` | Update `ST_VoronoiPolygons` and 
`ST_FrechetDistance` callers |
   | `spark/.../expressions/Functions.scala` | Update `ST_VoronoiPolygons` to 
reference `Functions.voronoiPolygons` |
   | `common/.../FunctionsTest.java` | Update tests to expect `NaN` for empty 
geoms; use `Functions.voronoiPolygons` |
   | `common/.../PredicatesTest.java` | Add test for `ST_Equals` with 
`GeometryCollection` inputs |
   
   Closes #2720
   Closes #2721
   Closes #2722
   Closes #2723
   


-- 
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]

Reply via email to