Database Reference
In-Depth Information
pgr_dijkstra
--------------
(0,16,6,1)
(1,17,7,1)
(2,5,8,1)
(3,6,9,1)
(4,11,15,1)
(5,9,-1,0)
(6 rows)
Fornewusers,thisisasurprisingresult—weaskforaroute,weexpectalittlemore
thansomegenerictuplesinreturn.Whatreturnsincludesalistofsegmentsourroute
traverses.ForDijkstraandotherroutingalgorithms,thisoftencomesinthefollowing
form:
seq :Thisreturnsthesequencenumbersothatwecanmaintaintheorderof
the output
id1 : This is the node ID
id2 : This is the edge ID
cost : This is the cost for the route traversal (often, the distance)
Forexample,togetthegeometryback,weneedtorejointheedgeIDswiththeori-
ginaltable.Tomakethisapproachworktransparently,wewillusethe WITH common
table expression to create a temporary table to which we will join our geometry:
WITH dijkstra AS (
SELECT pgr_dijkstra('SELECT id, source, target,
cost, x1, x2, y1, y2 FROM edge_table',
16,
9,
false,
false)
)
SELECT id, ST_AsText(the_geom)
FROM edge_table et, dijkstra d
WHERE et.id = (d.pgr_dijkstra).id2;
Search WWH ::




Custom Search