[pgrouting-dev] Converting Python algorithm into pgRouting wrapper function

cathal coffey coffey.cathal at gmail.com
Wed Apr 13 10:20:00 EDT 2011


Hi Devs,

I built the following web application using pg_routing.
http://ncg.nuim.ie/i2maps/projects/sp/index.html

This application lets you calculate shortest paths from any two points (*not
any two nodes, which seems to be the standard*) on the OSM network.
You add points by left clicking on the map, red points are your clicks, blue
points are the closest points on the OSM network to your clicks.
I wrote this function because I need to take n GPS points and return a
single path which visits each point in turn.

Currently this is half written in Python using the Django Geos API and it
works perfectly.
I would however like to convert this into a pgRouting wrapper function but I
am struggling to convert my Python into plpgsql.

Can you help?
I am stuck at one particular part, after I have calculated the shortest path
I need to do some tests on the first and last ways.
What I want to do is the below but this is not valid plpgsql, can you teach
me how to write this correctly?

DECLARE
sp record[];
record first;
 record last;
BEGIN
sp := dijkstra_sp_directed('ways', 100, 1000, true, true);
 first := sp[0]
last  := sp[-1]
END;

Kind regards,
Cathal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/pgrouting-dev/attachments/20110413/48b67cdc/attachment.html


More information about the pgrouting-dev mailing list