Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How is the column "cost" and similars calculated? #281

Open
Doev opened this issue Jul 7, 2020 · 5 comments
Open

How is the column "cost" and similars calculated? #281

Doev opened this issue Jul 7, 2020 · 5 comments

Comments

@Doev
Copy link

Doev commented Jul 7, 2020

Hello,

first: I do not feel well with starting this question as an issue. Is there any forum, that I can use for asking common questions?

How are the columns "cost" and "cost_s" calculated? I don't see any hint in the "mapconfig.xml".

@dkastl
Copy link
Member

dkastl commented Jul 7, 2020

The following "channels" are available to ask questions: http://pgrouting.org/support.html
The Gitter channel is in general a good place: https://gitter.im/pgRouting/pgrouting

@dkastl
Copy link
Member

dkastl commented Jul 7, 2020

I agree that a bit more documentation might be good to have.
However, the formula is available in this SQL:

" UPDATE " + table +
" SET length_m = ST_length(geography(ST_Transform(the_geom, 4326))),"
" cost_s = CASE "
" WHEN one_way = -1 THEN -ST_length(geography(ST_Transform(the_geom, 4326))) / (maxspeed_forward::float * 5.0 / 18.0)"
" ELSE ST_length(geography(ST_Transform(the_geom, 4326))) / (maxspeed_backward::float * 5.0 / 18.0)"
" END, "
" reverse_cost_s = CASE "
" WHEN one_way = 1 THEN -ST_length(geography(ST_Transform(the_geom, 4326))) / (maxspeed_backward::float * 5.0 / 18.0)"
" ELSE ST_length(geography(ST_Transform(the_geom, 4326))) / (maxspeed_backward::float * 5.0 / 18.0)"
" END "
" WHERE length_m IS NULL AND maxspeed_backward !=0 AND maxspeed_forward != 0;");

Maybe it would be better to leave the cost computation to the user, as also discussed recently here: #275 (comment)

@Doev
Copy link
Author

Doev commented Jul 8, 2020

Good morning Daniel,

thank you for your info. I didn't see that osm2pgrouting is an official pgrouting project and the theire channels can be used. Next time I will use it.

@bawidyantoro
Copy link

Dear dkastl

what the meaning og (maxspeed_backward::float * 5.0 / 18.0)? can I modify it as neede in osm2pgrouting?

@Doev
Copy link
Author

Doev commented Oct 13, 2020

bawidyantoro, it's just sql-code. You can execute it later in your database. But you have to modify the WHERE part, cause it only updates the fields that contains NULL.

In your case, I would take a look to the file that Daniel pointed to: osm2pgrouting/src/database/Export2DB.cpp

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants