User:ManuelB701/Data consuming/Speed limits
Some possible ways how I would calculate maxspeed=* when one isn't provided.
Over the years of OSM history, multiple speed limit tags have been developed. maxspeed=* is the most simple one but has the downside that you're missing the cause of the speed limit which not only has advantages in quality assurance so tags like source:maxspeed and zone:traffic have been developed. Furthermore, these tags can also be used by data consumers to know further restrictions but also has the advantage of flexibility should the legislation change.
General calculation
Tags to always look out for:
maxspeed- Speed limits on a givenhighway=*, should be used as the first source.zone:traffic- The traffic zones which primarily (but not only) affects speed limits. A general example is urban and rural roads.zone:maxspeed- Speed limit zones. This affects speed limits.source:maxspeed- How the speed limit was calculated e.g. is it explicitly given by a sign or implicitly by thehighway=*restriction?maxspeed:type- The type of the speed limit. Largely overlaps withsource:maxspeed=*in usage.highway- Certainhighway=*impose their own speed limits, either by imposing a certain traffic zone or a speed limit zone.oneway- In certain legislations, there is a difference between driving on a single and dual carriageway.urban- In general, urban roads have slower speed limits than rural roads. Generally implied byzone:traffic=*motorway- In most countries, motorways. Usually implied byhighway=motorwaybut can be overwritten in few exceptions (mostly onhighway=motorway_link).living_street- In cases wherehighway=living_streetcan't be used (usually because the givenhighwaytype doesn't fit into the definition ofhighway=residential)
The values for zone:traffic also apply to source:maxspeed / maxspeed:type. Therefore, if only zone:traffic is given, it implies e.g. maxspeed:type with the same value .
Germany

On its own, the German speed limit is simple:
- Urban roads - tagged as
zone:traffic=DE:urban- are generally limited to 50 km/h. Therefore, when not otherwise overwrittenzone:traffic=DE:urbanimpliesmaxspeed=50 - Rural roads - tagged as
zone:traffic=DE:rural- are generally limited to 100 km/h. Therefore, when not otherwise overwrittenzone:traffic=DE:ruralimpliesmaxspeed=100 - Motorways - tagged as
zone:traffic=DE:motorway- have no implicit speed limit i.e. one is able to drive as fast as one can. Therefore, when not otherwise overwrittenzone:traffic=DE:motorwayimpliesmaxspeed=nonewithmaxspeed:advisory=130.
There is one notable exception: zone:traffic=DE:rural. Although common knowledge tells you that rural roads limit you to 100 km/h, this only applies under the following definitions:
- The road is a single carriageway and
- At least one direction has only one lane
On any other road (either any dual carriageway or a single carriageway with at least two lanes per-direction), the speed limit is lifted much like on motorways (which are dual carriageways by default)
A general flowchart looks like this (note that source:maxspeed can substitute in for maxspeed:type):
highway- Pedestrian right of way (i.e.highway=footway,living_streetandpedestrian) always impose a walking speed limit (a vague term). Any explicit value inmaxspeed=*must be tossed out, either because it's a residue when it was mapped as a normal street or because of some mapper's interpretation on what walking speed is. Beyond that,highway=motorwayandmotorway_linkimplymotorway=yesresp.zone:traffic=DE:motorway, although these values can get overwritten .living_street- Similar to above, walking speed is implied and overwritesmaxspeed=*.maxspeed- Always take the explicit speed limits over implicit speed limitsmotorway- Denotes if a road is a legal motorwayurban- Denotes whether a road is a built-up area or not when not on motorways (note that motorways can be urban but are still part of the motorway zone)zone:traffic- The first general speed limit when no speed limit has been givenzone:maxspeed- Overrides the speed limit ofzone:traffic=*maxspeed:type- Overrideszone:trafficandzone:maxspeed(useful when the value issign).
You can calculate zone:traffic using a combination of motorway and urban: motorway=yes implied zone:traffic=DE:motorway, otherwise if urban=yes then zone:traffic=DE:urban, else zone:traffic=DE:rural.
You can calculate maxspeed:type using a combination of zone:traffic and zone:maxspeed: maxspeed:type inherits the value from zone:traffic but if zone:maxspeed is given, take the latter's number and attach it at the end of DE:zone (e.g. if zone:maxspeed=DE:30 then maxspeed:type=DE:zone30)
Using this, you can use maxspeed:type=* to calculate the maxspeed=* with the following values:
- If
sign-> The speed limit is explicit and internal only, you should never reach this place ifmaxspeed=*is missing - If
DE:zone20->maxspeed=20 - If
DE:zone30->maxspeed=30 - If
DE:urban->maxspeed=50 - If
DE:motorway->maxspeed=none - If
DE:rural->- If
oneway=yes->maxspeed=none - If
lanes:forwardandlanes:backward->maxspeed=none - Otherwise ->
maxspeed=100
- If
Other vehicles have a hard limit so when maxspeed=* ends up being higher, use the lower limit. Note the following special cases:
- For HGVs with at least 7.5t gross vehicle weight rating, whether you're on a motorroad (which includes motorways because of same restrictions): In general, they're limited to 60 km/h if a higher speed were possible but motorroads raise that limit to 80 km/h.
- Bicycle have no
zone:trafficspeed limit so to accurately depictmaxspeed=*, you must look atmaxspeed:typeand if it isn't azone:trafficvalue.