Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

share|improve this question
add comment

2 Answers

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));
share|improve this answer
    
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 Feb 7 '13 at 18:06
add comment

or just

UPDATE <table> SET cost = km

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

share|improve this answer
    
If I set also the reverse_cost in this way I have no information if a street is one-way or not!! –  Robert Feb 8 '13 at 13:52
    
Ok. I solved it. I didn't know that I can used the if condition in sql. Thanks –  Robert Feb 8 '13 at 14:11
    
Why "if"? Just UPDATE <table> SET reverse_cost=km WHERE reverse_cost < 1000000 –  Carsten Feb 10 '13 at 8:31
    
oh, thanks. very good!! –  Robert Feb 10 '13 at 18:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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