Opened 3 years ago
Closed 5 months ago
#4992 closed defect (fixed)
Problem with ST_FrechetDistance in PostGIS/GEOS ?
Reported by: | ezimanyi | Owned by: | pramsey |
---|---|---|---|
Priority: | medium | Milestone: | PostGIS GEOS |
Component: | postgis | Version: | 2.5.x -- EOL |
Keywords: | Cc: |
Description
We started the implementation of the discrete Frechet distance in MobilityDB and found out that we obtain a different result than PostGIS/GEOS.
test=# select frechetDistance(tgeompoint '[Point(1 1)@2000-01-01, Point(2 2)@2000-01-02, Point(3 1)@2000-01-03]', tgeompoint '[Point(1 4)@2000-01-01, Point(2 3)@2000-01-02, Point(3 4)@2000-01-03, Point(4 3)@2000-01-04]'); frechetdistance ----------------- 3 (1 row) test=# select ST_FrechetDistance(geometry 'Linestring(1 1,2 2,3 1)', test(# geometry 'Linestring(1 4,2 3,3 4,4 3)'); st_frechetdistance -------------------- 2.23606797749979 (1 row)
We used the simple algorithm referenced in the PostGIS manual https://postgis.net/docs/ST_FrechetDistance.html and according to our understanding the correct result is 3.
Intuitively, thinking of the Frechet distance as a man walking a dog on a leash, if the distance between the first two points is 3, the result cannot be less than 3.
Change History (5)
comment:1 by , 3 years ago
comment:4 by , 3 years ago
Milestone: | PostGIS 3.1.5 → PostGIS GEOS |
---|
comment:5 by , 5 months ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Perhaps you have a more "batteries include" implementation of Frechet Distance.
The PostGIS algorithm (coming from GEOS) is a Discrete Frechet Distance implementation. It works better if the geometry is densified via the optional third argument: