[pgrouting-users] Incorrect order of edges

Stephen Woodbridge woodbri at swoodbridge.com
Thu Apr 15 19:45:33 EDT 2010


The segments are in the right order, but the direction of the segment 
from A to B is the order that the segment was loaded and NOT the order 
of traversal. You can check and flip segments something like this:

1) check if the first segment needs to be reversed if (the A end match 
either the A or B end of the next segment flip segment one.
2) for the next segment, if the B end matches the B end of the current 
segment, then flip the next segment
3) make the next segment the current segment and loop to 2) until done

Now you segments should be in the correct order.

-Steve W
  http://imaptools.com/

Mehmet Sirin wrote:
> No one knows why I get an wrong order? For displaying the route it is 
> not important to have ordered edges. But for other issues like 
> implementing a route description ("in 200meters turn left") i need a 
> correct order..
> 
> Thank you for your help in advance
> 
> regards
> mehmet sirin
> 
> 2010/3/17 Mehmet Sirin <m.sirin07 at googlemail.com 
> <mailto:m.sirin07 at googlemail.com>>
> 
>     Hi,
>     I wonder why pgRouting is giving back a wrong order of edges in the
>     calculated shortest path?
>     e.g. shortest path order should be: 1,2,3,4,5 but a different one is
>     returned, e.g.: 1,3,5,2,4
> 
>     We use this code:
> 
>     SELECT * FROM shortest_path('SELECT gid AS id, source::int4,
>     target::int4,
>             to_cost_shortest::double precision AS
>     cost,reverse_cost_shortest::double
>         precision AS reverse_cost FROM ways', $startVertex, $endVertex,
>     true, true)
> 
>     Anyone got an idea?
> 
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.postlbs.org
> http://lists.postlbs.org/mailman/listinfo/pgrouting-users




More information about the Pgrouting-users mailing list