Database Reference
In-Depth Information
SELECT pgr_createTopology('voronoi_intersect',
0.001, 'the_geom', 'gid', 'source', 'target',
'true');
CREATE INDEX source_idx ON
voronoi_intersect("source");
CREATE INDEX target_idx ON
voronoi_intersect("target");
ALTER TABLE voronoi_intersect ADD COLUMN length
double precision;
UPDATE voronoi_intersect SET length =
ST_Length(the_geom);
ALTER TABLE voronoi_intersect ADD COLUMN
reverse_cost double precision;
UPDATE voronoi_intersect SET reverse_cost =
length;
Now, we can route along the primary centerline of our polygon, using the following
commands:
CREATE TABLE voronoi_route AS
WITH dijkstra AS (
SELECT pgr_dijkstra('SELECT gid AS id, source,
target,
length AS cost FROM voronoi_intersect',
10851, 3,
false,
false)
)
SELECT gid, the_geom
FROM voronoi_intersect et, dijkstra d
WHERE et.gid = (d.pgr_dijkstra).id2;
Finally, we can compare the original polygon with the trace of its centerline: