[Cartoweb-users] Pgdijkstra Directed Map

Sylvain Pasche sylvain.pasche at camptocamp.com
Fri Aug 18 06:21:36 EDT 2006


Le vendredi 18 août 2006 à 09:01 +0800, Aileen Baylon a écrit :
> Thanks Sylvain for yor quick reply.
> 
> 1. What I meant by the directed route is the roads being one-way or two way
> or the roads being major roads or minor roads. How do return a postgis path?
> Currently I'm using the shortest_path_as_geometry() function but I read in 
> the readme
> that I can pass to the shortest_path function if the road is directed or not 
> (true/false)

The current implementation of  shortest_path_as_geometry makes the
assumption the graph is not directed and is not using reverse cost.

Modifying the pgdijkstra shortest_path_as_geometry to take into account
if the graph is directed should not be a great development. Feel free to
open a enhancement request on the bugzilla about it.

> 2. How do I tell my query that I already have a "distance" column in my 
> table?
> How does pgDijkstra compute the shortest path using the distance?

Here also, the shortest_path_as_geometry function is hard-coded to using
the cost column from the edges table. What you can do in your situation,
is to rename your "distance" column to "cost" in the yourtable_edges
table. If your distance column is elesewhere, you'll need to make a join
to update your _edges table.

> 3. So if I have existing source_id & target_id in my table, I do not need to 
> call the
> assign_vertex_id function right? But I should still call the 
> create_graph_tables? This is
> what I did but if I don't use the assign_vertex_id function before the 
> create_graph_tables function I
> get an error. :(

That's right, you don't need to call assign_vertex_id before calling
create_graph_tables.

Be sure that you have columns source_id and target_id in your table
before calling create_graph_tables, and also that you don't have
duplicate source->target nodes (that's an issue of pgdijkstra, see bug
http://bugzilla.maptools.org/show_bug.cgi?id=1205 )

Regards,

Sylvain



More information about the Cartoweb-users mailing list