GetEdgeByPoint — Find the edge-id of an edge that intersects a given point


integer GetEdgeByPoint(varchar atopology, geometry apoint, float8 tol);

Retrieve the id of an edge that intersects a Point

The function returns an integer (id-edge) given a topology, a POINT and a tolerance. If tolerance = 0 then the point has to intersect the edge.

If the point doesn't intersect an edge, returns 0 (zero).

If use tolerance > 0 and there is more than one edge near the point then an exception is thrown.


If tolerance = 0, the function use ST_Intersects otherwise uses ST_DWithin.

Availability: 2.0.0 - requires GEOS >= 3.3.0.


These examples use edges we created in AddEdge

SELECT topology.GetEdgeByPoint('ma_topo',geom, 1) As with1mtol, topology.GetEdgeByPoint('ma_topo',geom,0) As withnotol
FROM ST_GeomFromEWKT('SRID=26986;POINT(227622.6 893843)') As geom;
 with1mtol | withnotol
         2 |         0
SELECT topology.GetEdgeByPoint('ma_topo',geom, 1) As nearnode
FROM ST_GeomFromEWKT('SRID=26986;POINT(227591.9 893900.4)') As geom;

-- get error --
ERROR:  Two or more edges found

See Also

AddEdge, GetNodeByPoint, GetFaceByPoint