Pgrouting- A Practical Guide -

We handle this by manipulating the cost values.

Now you have a result set containing the actual geometry of the road segments that make up the shortest path.

SELECT * FROM pgr_dijkstra( 'SELECT id, source, target, cost, reverse_cost FROM edges_table', 10, -- Start Node ID 50, -- End Node ID directed := true ); Use code with caution. Understanding Costs : The simplest cost. Use ST_Length(geom) . PgRouting- A Practical Guide

To follow this practical guide, you need a running PostgreSQL instance.

SELECT pgr_version();

Verify the installation:

: Some versions may pre-date the most recent software updates. We handle this by manipulating the cost values

-- Imagine a start at lon/lat (-122.4194, 37.7749) and end at (-122.4090, 37.7845) SELECT * FROM pgr_withPoints( 'SELECT id, source, target, cost_s AS cost FROM roads', 'SELECT pid, edge_id, fraction FROM point_table', -- Your points -1, -- Start point ID (negative IDs are your custom points) -2, -- End point ID directed := true );