# [pgrouting-users] directions problem

Stephen Woodbridge woodbri at swoodbridge.com
Thu Feb 12 10:39:11 EST 2009

```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>>
>
>     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>
>      > http://lists.postlbs.org/mailman/listinfo/pgrouting-users
>      >
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Pgrouting-users mailing list
> Pgrouting-users at lists.postlbs.org
> http://lists.postlbs.org/mailman/listinfo/pgrouting-users

```