[postgis-users] Inconsistent results on ST_Intersects and ST_Distance
Palmetzhofer Dietmar
Dietmar.Palmetzhofer at vorarlberg.at
Wed Feb 26 02:02:59 PST 2020
I have a simple LINE-Geometry and a POINT, that I want to query, if it intersects the line.
The result ist, that ST_Intersects gives "FALSE", and ST_Distance gives "0". So, this is contradictory. An analysis with JTS shows, that there is a distance of 6.611191059663252E-13.
Should ST_Distance not also return this result?
Here are the SQL-Statements:
WITH point1 as
(Select ST_GeomFromWKB('\x0101000020167A0000B0A13497E151E5C0E386CC0EACF50D41', 31254) as geom),
line1 as
(select ST_GeomFromWKB('\x0102000020167A000002000000000000003952E5C00000005012F60D4100000000AF51E5C0000000E070F50D41', 31254) as geom)
select ST_Intersects(line1.geom, point1.geom), ST_Distance(line1.geom, point1.geom),
ST_AsText(ST_Intersection(line1.geom, point1.geom)),
ST_AsText(ST_ShortestLine(line1.geom, point1.geom))
from
line1, point1;
Even when I try to Snap the point to the line-geometry, it does not work:
WITH point1 as
(Select ST_GeomFromWKB('\x0101000020167A0000B0A13497E151E5C0E386CC0EACF50D41', 31254) as geom),
line1 as
(select ST_GeomFromWKB('\x0102000020167A000002000000000000003952E5C00000005012F60D4100000000AF51E5C0000000E070F50D41', 31254) as geom)
select ST_Intersects(line1.geom, ST_ClosestPoint(line1.geom, point1.geom)), ST_Distance(line1.geom, ST_ClosestPoint(line1.geom, point1.geom)),
ST_AsText(ST_Intersection(line1.geom, ST_ClosestPoint(line1.geom, point1.geom))),
ST_AsText(ST_ShortestLine(line1.geom, ST_ClosestPoint(line1.geom, point1.geom)))
from
line1, point1;
I know about the limitations of floating-point-operations (see discussion here: https://stackoverflow.com/questions/60298412/wrong-result-using-st-intersection-with-postgis/), but ST_Distance should give a result different than 0, right?
Is this a bug in the ST_Distance-function (and probalby in the ST_ClosestPoint-function)?
I tested this with postgres 9.6.15 and postgis 2.4
and also with
postgres 12.1 and postgis 3.0, same results.
Regards,
Didi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20200226/f7dc6868/attachment.html>
More information about the postgis-users
mailing list