[Mobilitydb-dev] Problem with ST_FrechetDistance in PostGIS/GEOS

Esteban Zimanyi esteban.zimanyi at ulb.be
Sat Sep 11 01:34:47 PDT 2021


Dear Regina

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.

Indeed the matrix of Euclidean distances between a vertex of the first
linestring and a vertex of the second linestring is as follows

3.6 2.23 2.23
3.6 2.23 3
2.23 1 2.23
3 2.23 3.6

And the matrix of the computation of the Frechet distance (ca in the
algorithm) is as follows

3.6 3 3
3.6 3 3
3 3 3
3 3 3.6

Could you please have a look ? If you confirm that there is a problem I
will post a ticket in PostGIS and/or GEOS mailing lists.

Many thanks

Esteban
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mobilitydb-dev/attachments/20210911/ad1116fc/attachment.html>


More information about the Mobilitydb-dev mailing list