Speed values in Valhalla APIs¶
To calculate speed and related factors when routing, such as travel times, Valhalla APIs consider speed limits in the OpenStreetMap source data, defaults for a particular category of road, or a measure of whether the road is in an urban or rural environment.
Real-time or historical traffic information is not currently included in speed calculations. Valhalla is working towards these capabilities, and the tiled data structures of Valhalla and dynamic costing approach can readily support traffic information when available.
Assignment of speeds to roadways¶
Routing data contains two attributes to denote speed:
The most important for routing determination is
speed, given in units of kilometers per hour. The
speed value, along with the length of the roadway edge, determine the travel time along a road section.
speed_limit contains the posted speed limit, if available, and can be used by mobile navigation applications to display the speed limit and possibly alert the driver when it is exceeded.
speed is assigned based on tags within the OpenStreetMap data as follows:
max_speed: If a
maxspeedtag is available from OSM, that speed is used as the routing speed and the
speed_limitis set to that value. Note that
maxspeed=noneis valid and means the speed limit is unlimited (as on the German Autobahn); in this case we do not set a speed based on
maxspeedbut rely on the default speeds based on the
highwaytag (see next bullet point).
highway: If there is no
speedis based on the OSM
highwaytag. There are a default set of speeds for each
highwaytag. Note that future work involves implementing country-specific default speeds for highway tags.
- road density: The road density (the length of drivable roads in kilometers per square kilometer) at each node in the routing graph is estimated during Valhalla data import. The road density is used to determine if a road is in a rural or urban area. Roads in urban areas have their speed reduced if there is no
maxspeedtag. In the future, this method may be replaced with a more accurate measure of rural versus urban regions, but density produces adequate results for now.
speed_type attribute defines whether the assigned routing speed is from a speed limit or based on the highway tag.