1

As the column 'kmh' shows speed limits wrong for my city, and I didn't want to modify the configuration file of osm2po for each type of road, is there a way to change the cost function? I wish:

cost= length

and not

cost= length/kmh

2 Answers 2

1

As you tagged your question with pgrouting I assume you want to use osm2po to generate the PostgreSQL tables. So why don't you update your database table after import?

UPDATE <table> SET cost = ST_Length(geom_way);

And if you prefer the length in unit meter, then you can transform the geometry into some Mercator projection:

UPDATE <table> SET cost = ST_Length(ST_Transform(geom_way,3857));
1
  • No, it is not possible because the query to calculate the shortest path between two point (pg routing) uses cost and reverse_cost. If I modify only the cost column the query will not be correct. Also I can't change the column reverse_cost in the same way!
    – Robert
    Commented Feb 7, 2013 at 18:06
1

or just

UPDATE <table> SET cost = km

and don't forget to set the reverse_cost if needed.

3
  • If I set also the reverse_cost in this way I have no information if a street is one-way or not!!
    – Robert
    Commented Feb 8, 2013 at 13:52
  • Ok. I solved it. I didn't know that I can used the if condition in sql. Thanks
    – Robert
    Commented Feb 8, 2013 at 14:11
  • Why "if"? Just UPDATE <table> SET reverse_cost=km WHERE reverse_cost < 1000000
    – Carsten
    Commented Feb 10, 2013 at 8:31

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.