[postgis-users] st_touches does not work with line/point real geometries

Sandro Santilli strk at kbt.io
Thu Mar 21 10:55:06 PDT 2019


On Thu, Mar 21, 2019 at 08:40:07PM +0300, Eugene Podshivalov wrote:

> But it won't work in the following case:
> =# select *st_touches(a.geom,st_endpoint(b.geom))* from
> st_geomfromewkt('SRID=4326;LINESTRING(28.9019278 53.8056134,28.901969
> 53.804671,28.90144 53.8017222)') as a (geom),
> st_geomfromewkt('SRID=4326;LINESTRING(28.896058 53.8047031,28.901969
> 53.804671)') as b (geom);
>  st_touches
> ------------
>  f

The endpoint of b.geom is POINT(28.901969  53.804671)
The a.geom boundary is    POINT(28.9019278 53.8056134)
             and          POINT(28.90144   53.8017222)

According to https://postgis.net/docs/ST_Touches.html ST_Touches...

  Returns TRUE if the only points in common between g1 and g2
  lie in the union of the boundaries of g1 and g2

The only common point in a point/line case can be the point,
but you can clearly see that the boundary of A does not
contain that B endpoint.


BTW, it looks like one of the pictures in the example is wrong
(the central line/line case). May be worth filing a ticket to
fix that (even better if you send a patch for it :)

--strk;


More information about the postgis-users mailing list