[Cartoweb-users] pgdijkstra : trap "no path found" ?
Arnaud Lesauvage
thewild at freesurf.fr
Tue Jan 31 07:49:37 EST 2006
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),
true,
true);
$$ 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,
thispoint);
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 !
--
Arnaud
More information about the Cartoweb-users
mailing list