-
Notifications
You must be signed in to change notification settings - Fork 755
Closed
Labels
Description
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
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
SELECT ST_FrechetDistance(ST_GeomFromText('POINT EMPTY'), ST_GeomFromText('POINT EMPTY'))
-- Sedona returns: 0.0
-- Expected (PostGIS / shapely): null / NaNimport geopandas as gpd
from shapely.geometry import Point
gpd.GeoSeries([Point()]).frechet_distance(gpd.GeoSeries([Point()]))
# 0 NaNSuggested fix
Change the return type to Double (boxed) and return null for empty geometries, or return Double.NaN:
public static Double getFrechetDistance(Geometry g1, Geometry g2) {
if (g1.isEmpty() || g2.isEmpty()) return Double.NaN;
return DiscreteFrechetDistance.distance(g1, g2);
}Reactions are currently unavailable