I have set pgrouting and inserted my data with osm2pgrouting .

I would like to know how can I find out which way is one way. Also I read that if I assign the reverse_cost of an one way to -1 only the this road is considered as one way, is it true?

  • Interesting. I would like to know too.
    – Naresh
    Commented Jun 1, 2012 at 15:07

2 Answers 2


http://www.webrian.ch/2011/07/set-up-pgrouting-with-openstreetmap.html describes one possible solution. The challenge is that osm2pgrouting does not import one-way information. The author uses GRASS to find one-ways from the data. This solution sets reverse_cost to -1 to mark one-ways.

In pgRoutingDocs there is "How to handle one-way streets" The idea there is to set the cost against the one-way direction very high (instead of -1).

Note: Only if the reverse parameter is set to true, the algorithms will use the reverse_cost field.

Osm2po, another OSM import tool, handles one-way information better. reverse_cost fields are filled automatically (to a very high value).


Thank you for the answer, but I think that something might be wrong:

The osm2pgrouting code (Export2DB.cpp, called by osm2pgrouting.cpp) writes :

        row_data += TO_STR(way->length*1000000);
        row_data += TO_STR(way->length);

but after exporting france.osm I notice that

franceRouting=> select count (*) from ways where reverse_cost <> length;
count ------- 0 (1 row)

So I guess that the condition (way->oneway) is not precise enough... But "I might be wrong"!

=> Hell I did not send that answer?! In the meantime I forked and modified the osm2pgrouting git repo. for it to consider the "oneway" tag values "true", "1" and "yes"... Maybe some more modifications are to come : the osm wiki states something like 'some ways, like motorways, are automatically considered as oneway edges'. Still, this statement can be taken into account afterwards with a single sql command... HF!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.