pgr_pointToEdgeNode
- Converts a point to a vertex_id
based on closest edge.
Warning
These are proposed functions
The function returns:
integer
that is the vertex id of the closest edge in theedges
table within thetol
tolerance ofpnt
. The vertex is selected by projection thepnt
onto the edge and selecting which vertex is closer along the edge.
integer pgr_pointToEdgeNode(edges text, pnt geometry, tol float8)
Given an table edges
with a spatial index on the_geom
and a point geometry search for the closest edge within tol
distance to the edges then compute the projection of the point onto the line segment and select source or target based on whether the projected point is closer to the respective end and return the source or target value.
Parameters
The function accepts the following parameters:
edges: | text The name of the edge table or view. (may contain the schema name AS well). |
---|---|
pnt: | geometry A point geometry object in the same SRID as edges . |
tol: | float8 The maximum search distance for an edge. |
Warning
If no edge is within tol distance then return -1
The edges
table must have the following columns:
source
target
the_geom
History
SELECT * FROM pgr_pointtoedgenode('edge_table', 'POINT(2 0)'::geometry, 0.02);
pgr_pointtoedgenode
---------------------
1
(1 row)
SELECT * FROM pgr_pointtoedgenode('edge_table', 'POINT(3 2)'::geometry, 0.02);
pgr_pointtoedgenode
---------------------
6
(1 row)
The example uses the Sample Data network.