pgr_drivingDistance (V2.0)¶
Name¶
pgr_drivingDistance
- Returns the driving distance from a start node.
Synopsis¶
This function computes a Dijkstra shortest path solution them extracts the cost to get to each node in the network from the starting node. Using these nodes and costs it is possible to compute constant drive time polygons. Returns a set of pgr_costResult (seq, id1, id2, cost) rows, that make up a list of accessible points.
pgr_costResult[] pgr_drivingDistance(text sql, integer source, double precision distance,
boolean directed, boolean has_rcost);
Warning
This signature is being deprecated on version 2.1, Please use it
without the has_rcost
flag instead:
pgr_drivingDistance(sql, start_v, distance, directed)
Description¶
sql: | a SQL query, which should return a set of rows with the following columns: SELECT id, source, target, cost [,reverse_cost] FROM edge_table
|
||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
source: |
|
||||||||||
distance: |
|
||||||||||
directed: |
|
||||||||||
has_rcost: | if |
Returns set of pgr_costResult[]:
seq: | row sequence |
---|---|
id1: | node ID |
id2: | edge ID (this is probably not a useful item) |
cost: | cost to get to this node ID |
Warning
You must reconnect to the database after CREATE EXTENSION pgrouting
. Otherwise the function will return Error computing path: std::bad_alloc
.
History
- Renamed in version 2.0.0
Examples¶
- Without
reverse_cost
SELECT seq, id1 AS node, cost
FROM pgr_drivingDistance(
'SELECT id, source, target, cost FROM edge_table',
7, 1.5, false, false
);
seq | node | cost
-----+------+------
0 | 7 | 0
1 | 8 | 1
(2 rows)
- With
reverse_cost
SELECT seq, id1 AS node, cost
FROM pgr_drivingDistance(
'SELECT id, source, target, cost, reverse_cost FROM edge_table',
7, 1.5, true, true
);
seq | node | cost
-----+------+------
0 | 7 | 0
1 | 8 | 1
(5 rows)
The queries use the Sample Data network.
See Also¶
- pgr_alphaShape - Alpha shape computation
- pgr_pointsAsPolygon - Polygon around set of points