jiayuasu opened a new issue, #2719: URL: https://github.com/apache/sedona/issues/2719
### Description `ST_FrechetDistance` returns `0.0` when either input geometry is empty. The correct behavior (matching PostGIS and shapely/geopandas) is to return `null`/`NaN`, since the distance between empty geometries is undefined. ### Root cause In [`GeomUtils.java` line 546](https://github.com/apache/sedona/blob/master/common/src/main/java/org/apache/sedona/common/utils/GeomUtils.java#L546): ```java public static double getFrechetDistance(Geometry g1, Geometry g2) { if (g1.isEmpty() || g2.isEmpty()) return 0.0; // should return null/NaN return DiscreteFrechetDistance.distance(g1, g2); } ``` ### Steps to reproduce ```sql SELECT ST_FrechetDistance(ST_GeomFromText('POINT EMPTY'), ST_GeomFromText('POINT EMPTY')) -- Sedona returns: 0.0 -- Expected (PostGIS / shapely): null / NaN ``` ```python import geopandas as gpd from shapely.geometry import Point gpd.GeoSeries([Point()]).frechet_distance(gpd.GeoSeries([Point()])) # 0 NaN ``` ### Suggested fix Change the return type to `Double` (boxed) and return `null` for empty geometries, or return `Double.NaN`: ```java public static Double getFrechetDistance(Geometry g1, Geometry g2) { if (g1.isEmpty() || g2.isEmpty()) return Double.NaN; return DiscreteFrechetDistance.distance(g1, g2); } ``` -- 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]
