pgr_pointToEdgeNode - Proposed

Name

pgr_pointToEdgeNode - Converts a point to a vertex_id based on closest edge.

Warning

These are proposed functions

  • They are not officially of the current release.
  • They likely will not be officially be part of the next release:
    • The functions might not make use of ANY-INTEGER and ANY-NUMERICAL
    • Name might change.
    • Signature might change.
    • Functionality might change.
    • pgTap tests might be missing.
    • Might need c/c++ coding.
    • May lack documentation.
    • Documentation if any might need to be rewritten.
    • Documentation examples might need to be automatically generated.
    • Might need a lot of feedback from the comunity.
    • Might depend on a proposed function of pgRouting
    • Might depend on a deprecated function of pgRouting

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

Indices and tables