# [pgrouting-users] directions problem

Stephen Woodbridge woodbri at swoodbridge.com
Thu Feb 12 14:06:44 EST 2009

```Well, maybe I got the from-to sense backwards. Does it always route the
wrong-way down all one-way streets now? If so then, swap the 1 and -1 in
the update statements.

-Steve

Valeria Muñoz wrote:
> Stephen
>
> does not work, please see the attachment
> RG
>
> 2009/2/12 Stephen Woodbridge <woodbri at swoodbridge.com
> <mailto:woodbri at swoodbridge.com>>
>
>     So set reverse_cost when oneway=1 and cost when oneway=-1
>     Since you have already messed with the values I would do this now:
>
>     -- make sure everything is re-initiallized
>
>     UPDATE calle SET to_cost=length(the_geom),
>     reverse_cost=length(the_geom);
>
>     -- update the oneway costs
>     update calle set reverse_cost=reverse_cost + 1000000 WHERE oneway=1;
>     update calle set cost=cost + 1000000 WHERE oneway=-1;
>     vacuum analyze calle;
>
>     Now see how your test route looks.
>
>     -Steve
>
>     Valeria Muñoz wrote:
>
>         hi Stephen
>          i got
>          "oneway";"count"
>         -1;1451
>         0;21403
>         1;2640
>           0=both ways
>         -1=B->A
>         1= A->B
>          RG.
>
>         2009/2/12 Stephen Woodbridge <woodbri at swoodbridge.com
>         <mailto:woodbri at swoodbridge.com> <mailto:woodbri at swoodbridge.com
>         <mailto:woodbri at swoodbridge.com>>>
>
>
>            Valeria,
>
>            What do you get for this query:
>
>            select distinct oneway, count(*) as count from calle group by
>            oneway, order by oneway;
>
>            If you have a street A------->B then the oneway flag probable
>         needs
>            3 values. 0 for both ways, 1? for A to B, and maybe 2? for B
>         to A.
>            You need to figure out which values are which.
>
>            Then you need cost or reverse cost based on the value of oneway.
>
>            -Steve
>
>            Valeria Muñoz wrote:
>
>                hi Daniel, thanks for the link..
>                 I did the following:
>                 * UPDATE calle SET to_cost=length(the_geom),
>                reverse_cost=length(the_geom); *
>                * *
>                * UPDATE calle SET reverse_cost=reverse_cost + 1000000 WHERE
>                oneway!=0 ,  oneway!=0 are one way streets. *
>
>                my query:
>                        SELECT edge_id as gid,cost as length FROM
>                shortest_path_astar('SELECT gid AS id,source::int4,
>                target::int4, to_cost::double precision as cost,
>                reverse_cost::double precision, x1,y1,x2,y2 FROM
>                calle',3412,3411,false,true)**
>
>                 this do not works 100%, with some street works with
>         others no...
>                 I am missing something?
>                 RG
>
>                2009/2/11 Daniel Kastl <kastl at orkney.co.jp
>         <mailto:kastl at orkney.co.jp>
>                <mailto:kastl at orkney.co.jp <mailto:kastl at orkney.co.jp>>
>         <mailto:kastl at orkney.co.jp <mailto:kastl at orkney.co.jp>
>
>                <mailto:kastl at orkney.co.jp <mailto:kastl at orkney.co.jp>>>>
>
>
>                   So I guess pgRouting doesn't know that there is a one
>         way street.
>                   You might want to read this:
>                   http://pgrouting.postlbs.org/wiki/OneWayStreets
>
>                   Daniel
>
>
>                   Valeria Muñoz schrieb:
>                    > HI!!
>                    >
>                    >       I have a little problem with my routing, the best
>                path from
>                   A to
>                    > B do not respect the traffic direction.
>                    > attached image.
>                    >
>                    > please check in the example vicente perez rosales
>         street
>                    >
>                    > Query
>                    >
>                    > rt.gid,rt.the_geom AS tg, AsText(rt.the_geom) AS wkt,
>                    > length(rt.the_geom) AS length, calle.gid FROM calle,
>                (SELECT gid,
>                    > the_geom FROM dijkstra_sp_delta( 'calle', 3414, 3406,
>                3000) ) as rt
>                    > WHERE calle.gid=rt.gid;
>                    >
>                    >
>                    > RG
>                    >
>                    >
>
>         ------------------------------------------------------------------------
>                    >
>                    >
>
>         ------------------------------------------------------------------------
>                    >
>                    > _______________________________________________
>                    > Pgrouting-users mailing list
>                    > Pgrouting-users at lists.postlbs.org
>         <mailto:Pgrouting-users at lists.postlbs.org>
>                <mailto:Pgrouting-users at lists.postlbs.org
>         <mailto:Pgrouting-users at lists.postlbs.org>>
>                   <mailto:Pgrouting-users at lists.postlbs.org
>         <mailto:Pgrouting-users at lists.postlbs.org>
>                <mailto:Pgrouting-users at lists.postlbs.org
>         <mailto:Pgrouting-users at lists.postlbs.org>>>
>
>                    >
>         http://lists.postlbs.org/mailman/listinfo/pgrouting-users
>                    >
>
>
>
>
>          ------------------------------------------------------------------------
>
>                _______________________________________________
>                Pgrouting-users mailing list
>                Pgrouting-users at lists.postlbs.org
>         <mailto:Pgrouting-users at lists.postlbs.org>
>                <mailto:Pgrouting-users at lists.postlbs.org
>         <mailto:Pgrouting-users at lists.postlbs.org>>
>                http://lists.postlbs.org/mailman/listinfo/pgrouting-users
>
>
>
>
>
>
> ------------------------------------------------------------------------
>

```