pgr_pointToEdgeNode¶
Name¶
pgr_pointToEdgeNode - Converts a point to a vertex_id based on closest edge.
Warning
This is a proposed function
- Is not officially in the release.
- Name could change.
- Signature could change.
- Needs testing.
- Functionality could change.
Synopsis¶
The function returns:
- integer that is the vertex id of the closest edge in the edges table within the tol tolerance of pnt. The vertex is selected by projection the pnt onto the edge and selecting which vertex is closer along the edge.
integer pgr_pointToEdgeNode(edges text, pnt geometry, tol float8)
Description¶
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
- Proposed in version 2.1.0
Examples¶
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.
See Also¶
- pgr_pointsToVids - convert an array of point geometries into vertex ids.
Indices and tables