abrensch / brouter

configurable OSM offline router with elevation awareness, Java + Android
MIT License
501 stars 119 forks source link

How to generate estimated_traffic_class data #496

Closed FFMbyBicycle closed 1 year ago

FFMbyBicycle commented 1 year ago

Together with @mjaschen I tried to find a way to generate the "estimated_traffic_class" data from scratch. The estimations are working fine for me and I'm missing them at bikerouter.de :wink: At the moment I have to decide if I use the traffic data at brouter.de or if I will be able to send a Link to someone with my profile.

So far we found out that there is a car-traffic_analysis.brf which seems to be used for this and calls a special case using "seed" keyword. This generates some data at a "traffic" subdirectory. This works for me but I have no idea what we have to do with the generated .trf files.

There seems to be a traffic_simulation.sh outside of this repository, maybe this does the magic? Or am I missing a step somewhere?

I can offer some Linux/scripting knowledge, time and will to write some documentation.

polyscias commented 1 year ago

The estimated_traffic_class is generated by the estimated_traffic_class function and underlying code.

It is not clear to me how this code is working but I think that with enough time you can find out what it is doing. Documenting that would be great.

quaelnix commented 1 year ago

@polyscias, Arndt once described it here (though in German): https://forum.openstreetmap.org/viewtopic.php?id=31044

The estimations are working fine for me

Yes, but you have to be careful when using it, because although it works quite well, there is still a considerable percentage of busy roads that are not classified correctly.

polyscias commented 1 year ago

Okay, I did put the text through deepl and the idea is clear to me.

I am not so sure it is a good way to get the "estimated traffic load" is there within a city more traffic on the roads getting to the highway entrance/exit? I think it is better to use the OSM highway qualification (primary/secondary/tertiary/unclassified/residential) and maybe the maxspeed to get a "estimated traffic load"

In Dutch context, a busy road (with >=50 km/h speed limits) is often chosen for bicycle routing because there will be cycle paths alone that road.

FFMbyBicycle commented 1 year ago

Thanks for your hints! The system is not perfect, but working quite good in my opinion.

I didn't want to start a discussion about other implementations, but get it working for bikerouter / other instances. Currently you get different results using the same profile depending on which brouter-web instance you're using and that's a little bit confusing. Sadly I'm not a software engineer and can't reverse-engineer the final segment data provided by Arndt.

quaelnix commented 1 year ago

This works for me but I have no idea what we have to do with the generated .trf files.

Looking at the code, I would say that these .trf files are ingested automatically by the addTrafficClass function:

https://github.com/abrensch/brouter/blob/a764c788ba17158c4e7d4decdeb2ecd2a659bd4d/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java#L156

https://github.com/abrensch/brouter/blob/a764c788ba17158c4e7d4decdeb2ecd2a659bd4d/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java#L217

https://github.com/abrensch/brouter/blob/a764c788ba17158c4e7d4decdeb2ecd2a659bd4d/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java#L268-L272

https://github.com/abrensch/brouter/blob/a764c788ba17158c4e7d4decdeb2ecd2a659bd4d/brouter-map-creator/src/main/java/btools/mapcreator/WayLinker.java#L487

https://github.com/abrensch/brouter/blob/9662e50a438b9aeb13a4dc9f4e890ddf48df949b/brouter-map-creator/src/main/java/btools/mapcreator/OsmNodeP.java#L94-L97

https://github.com/abrensch/brouter/blob/9662e50a438b9aeb13a4dc9f4e890ddf48df949b/brouter-map-creator/src/main/java/btools/mapcreator/OsmNodeP.java#L213-L217

EssBee59 commented 1 year ago

Hello,

Thank for the documentation above! I wasa interested to discover the jobs and could generate the RD5's with the "estimated_traffic_class" tag by following the steps decribed...but I think, there is an error somewhere...

Assuming the generation is done in the "root" directory mapcreation, then we have these commands: cd tmp mkdir traffic then start the seek jobs to generate the trf files in mapcreation/tmp/traffic

Anf then start the "waylinker" to add the tags: But on my local test system, waylinker is looking for trf files in mapcreation/traffic, NOT in mappcresation/tmp/traffic !

After moving the traffic directory to mapcreation, the tags were added properly

quaelnix commented 1 year ago

The estimated_traffic_class data is now generated as part of the new pseudo tag generation.

Preliminary documentation: https://github.com/abrensch/brouter/blob/master/misc/scripts/mapcreation/readme_database.md