Skip to content
Moritz Kobitzsch edited this page Dec 22, 2015 · 29 revisions

Traffic updates

Biggest feature in OSRM 4.9.0 is experimental support of traffic data. This is achieved by providing osrm-prepare with an additional file that specifies edge weight updates. For convenience, updates can be specified in a csv file; each line has to follow the format from_osm_id;to_osm_id;edge_weight.

./osrm-extract data.osm.pbf -p profile.lua --generate-edge-lookup
./osrm-prepare data.osrm -p profile.lua --speed-segment-file updates.csv
# modify updates.csv
./osrm-prepare data.osrm -p profile.lua --speed-segment-file updates.csv
# Repeat in loop for desired update time

Since this is too slow for big datasets to get meaningful updates cycles, you can do a partial contraction using the --core-factor parameter.A core factor drastically increases query times. As a result, the alternative-route search is slowed down immensely. .

./osrm-extract data.osm.pbf -p profile.lua --generate-edge-lookup
# about x8 speedup wrt to --core-factor 1.0
./osrm-prepare data.osrm -p profile.lua --speed-segment-file updates.csv --core-factor 0.8
# modify updates.csv
./osrm-prepare data.osrm -p profile.lua --speed-segment-file updates.csv --core-factor 0.8
# Repeat in loop for desired update time

For even more speedups use the --level-cache option:

./osrm-extract data.osm.pbf -p profile.lua --generate-edge-lookup
# For the first run a core-factor of 1.0 is required
./osrm-prepare data.osrm -p profile.lua --speed-segment-file updates.csv --core-factor 1.0
# modify updates.csv
./osrm-prepare data.osrm -p profile.lua --speed-segment-file updates.csv --core-factor 0.8 --cache-level true`
# Repeat in loop for desired update time

A level cache should always be generated with a full hierarchy (core=1.0). After this initial generation, any core factor can be specified.