[Cartoweb-users] pgdijkstra : trap "no path found" ?
sylvain.pasche at camptocamp.com
Tue Jan 31 09:08:17 EST 2006
Have a look at the "Trapping Errors" section in the postgresql manual:
Le mardi 31 janvier 2006 à 13:49 +0100, Arnaud Lesauvage a écrit :
> Hi all !
> I hope this is the right place to post this. Excuse me if it is not !
> I just successfully installed pgdijkstra on my PostGIS server, abd
> it works great !
> I have just a little problem though.
> I would like to calculate all travel times from one given point to
> a set of points.
> I created a simple function that returns the shortest time to
> travel from one point to another (my costs are minutes actually) :
> CREATE FUNCTION shortest_path_total_cost(int8, int8) RETURNS
> float8 AS $$
> SELECT sum(cost)
> FROM shortest_path('SELECT id, source, target, cost, reverse_cost
> FROM graph_edges',
> (SELECT id FROM graph_vertices WHERE geom_id=$1),
> (SELECT id FROM graph_vertices WHERE geom_id=$2),
> $$ LANGUAGE SQL;
> It works also very fine, but I can't use it on a whole table
> because it breaks whenever no path is found.
> I would like to be able to write a simle query like :
> UPDATE sometable
> SET time_to_reach_point1 = shortest_path_total_cost(point1,
> But this query never runs because there are always points that
> cannot be reached. (ERROR: Error computing path: No path found)
> Does someone have a simple solution to this problem ?
> I am not very familiar with plpgsql or even with function
> creation, so maybe there a simple way to handle this ?
> Thanks a lot !
> Cartoweb-users mailing list
> Cartoweb-users at lists.maptools.org
More information about the Cartoweb-users