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

Daniel Kastl daniel at georepublic.de
Wed Apr 13 10:28:39 EDT 2011


2011/4/13 cathal coffey <coffey.cathal at gmail.com>

> 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
>


Hi Cathal,

thank you for sharing your nice demo application!

If you look at this demo (zoom in to see path details), you will see that it
also starts in the middle of an edge.
http://websi.openvrp.com/

It also adds a line from the to the start/end point to the closest point on
the nearest edge.
The wrapper used in this demo is written in plpgsql and the source is here:
https://github.com/pgRouting/pgrouting-contrib/blob/master/wrapper/routing_core_smart.sql

Maybe it gives you some hints how to write your own wrapper. It uses
Shooting Star though.

Daniel



>
>
> _______________________________________________
> pgrouting-dev mailing list
> pgrouting-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/pgrouting-dev
>
>


-- 
Georepublic UG & Georepublic Japan
eMail: daniel.kastl at georepublic.de
Web: http://georepublic.de
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/pgrouting-dev/attachments/20110413/5d8bc337/attachment.html


More information about the pgrouting-dev mailing list