# Version 2023-07-30-1 # This bike profile will avoid # - car traffic # - turns # - elevation # - steps # - traffic lights/stop signs # - bad surfaces # by default. The route may NOT be the shortest, but the most relaxed and should be ridable with all kind of bikes at an steady speed. It is designed to work on long distance tracks, but also generates good routes in cities. # # Please note that this complex profile needs more time to calculate than a lot of the others around, especially in larger cities - but it is worth it ;-) # ---context:global # following code refers to global config # Bike profile assign validForBikes = true # Use the following switches to change behaviour assign allow_steps = false # %allow_steps% | Set to true to allow steps | boolean assign allow_ferries = false # %allow_ferries% | set to true to allow ferries | boolean assign fuck_cars = false # %fuck_cars% | Set to true to avoid ALL car traffic / roads without cycleways wherever possible (TEST). Use this only if you know what you're doing, may result in crazy routing | boolean assign fuck_traffic_lights = false # %fuck_traffic_lights% | Set to true to avoid ALL traffic lights, except when they're required to reach destination (TEST). Use this only if you know what you're doing, may result in crazy routing | boolean assign considerTurnRestrictions = true # %considerTurnRestrictions% | Set to true to take turn restrictions into account | boolean assign processUnusedTags = false # %processUnusedTags% | Set to true to output unused tags in data tab | boolean assign consider_traffic = false # %consider_traffic% | Set to true to avoid heavy car traffic, not supported on every brouter-web instance | boolean assign avoid_unknown_surface = true # %avoid_unknown_surface% | Set to false to allow paths with unknown surface | boolean assign penalty_stop_sign = 50 # %penalty_stop_sign% | Penalty for stop signs | number assign penalty_traffic_light = 120 # %penalty_traffic_light% | Penalty for traffic lights, will be ignored if fuck_traffic_lights is set to true | number assign penalty_cycle_barrier = 20 # %penalty_cycle_barrier% | Penalty for cycle barrier of all kind | number assign penalty_elevator = 120 # %penalty_elevator% | Penalty for elevator usage | number assign penalty_compacted = 5 # %penalty_compacted% | Penalty for ways with "compacted" surface (Germany: "wassergebundene Decke") | number assign penalty_ferry_initial = 8000 # %penalty_ferry_initial% | Initial penalty if switching from a highway to ferry, only used if allow_ferries is true | number # Change elevation parameters assign consider_elevation = true # %consider_elevation% | Set to false to ignore elevation in routing | boolean assign downhillcost = 80 # %downhillcost% | Cost for going downhill | number assign downhillcutoff = 1.5 # %downhillcutoff% | Gradients below this value in percents are not counted. | number assign uphillcost = 50 # %uphillcost% | Cost for going uphill | number assign uphillcutoff = 1.5 # %uphillcutoff% | Gradients below this value in percents are not counted. | number assign downhillcost = if consider_elevation then downhillcost else 0 assign uphillcost = if consider_elevation then uphillcost else 0 # Kinematic model parameters (tr avel time computation) assign totalMass = 110 # %totalMass% | Mass (in kg) of the bike + biker, for travel time computation | number assign maxSpeed = 40 # %maxSpeed% | Absolute maximum speed (in km/h), for travel time computation | number assign S_C_x = 0.225 # %S_C_x% | Drag coefficient times the reference area (in m^2), for travel time computation | number assign C_r = 0.01 # %C_r% | Rolling resistance coefficient (dimensionless), for travel time computation | number assign bikerPower = 110 # %bikerPower% | Average power (in W) provided by the biker, for travel time computation | number # Turn instructions settings assign turnInstructionMode = 1 # %turnInstructionMode% | Mode for the generated turn instructions | [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style] assign turnInstructionCatchingRange = 50 # %turnInstructionCatchingRange% | Within this distance (in m) several turning instructions are combined into one and the turning angles are better approximated to the general direction | number assign turnInstructionRoundabouts = true # %turnInstructionRoundabouts% | Set to "false" to avoid generating special turning instructions for roundabouts | boolean ---context:way # following code refers to way-tags # Hack to make direction of way avaiable at node section for calculating stop sign direction # See also https://github.com/poutnikl/Brouter-profiles/issues/25#issuecomment-864365688 assign isreversed = reversedirection=yes # classifier constants assign classifier_none = 1 assign classifier_ferry = 2 # # pre-calculate some logical expressions # assign any_cycleroute = if route_bicycle_icn=yes then true else if route_bicycle_ncn=yes then true else if route_bicycle_rcn=yes then true else if route_bicycle_lcn=yes then true else if lcn=yes then true else false assign nodeaccessgranted = if any_cycleroute then true else lcn=yes assign hascycleway = if ( and ( or cycleway= cycleway=no|none ) and ( or cycleway:left= cycleway:left=no ) ( or cycleway:right= cycleway:right=no ) ) then 0 else 1 assign isbike = or bicycle=yes or bicycle=permissive or bicycle=designated or lcn=yes hascycleway assign ispaved = or surface=paved|asphalt|concrete|wood|paving_stones|metal|sett or cycleway:surface=paved|asphalt|concrete|paving_stones|sett ( and surface=concrete concrete=plates|lanes ) # surface=concrete concrete=plates|lanes is an alias for surface=concrete:plates / surface=concrete:lanes, see also https://github.com/abrensch/brouter/issues/61 assign isunpaved = or surface=unpaved|compacted|gravel|pebblestone|ground|dirt|grass|mud|sand|cobblestone|fine_gravel|earth|grass_paver cycleway:surface=unpaved|compacted|gravel|cobblestone|fine_gravel assign probablyGood = or ispaved and ( or isbike highway=footway ) ( or not isunpaved surface=compacted ) assign ishighspeed = or maxspeed=70|80|90|100|110|120|130 maxspeed= # Avoid streets with high speed car traffic and no cycling infrastructure # # this is the cost (in Meter) for a 90-degree turn # The actual cost is calculated as turncost*cos(angle) # assign turncost = if junction=roundabout then 0 else if isbike then 110 else if or bridge=yes tunnel=yes then 40 # there are a lot of nice bridge/tunnel shortcuts with tight corners, which will save energy and time else 180 # This is quite high but will allow a more straight route at the cost of a longer route. Still saves time and energy because of missing slowdowns at turns # # for any change in initialclassifier, initialcost is added once # assign initialclassifier = if route=ferry then classifier_ferry else classifier_none # # calculate the initial cost # this is added to the total cost each time the costfactor # changed # assign initialcost = if ( equal initialclassifier classifier_ferry ) then penalty_ferry_initial else 0 # # implicit access here just from the motorroad tag # (implicit access rules from highway tag handled elsewhere) # assign defaultaccess = if access= then not motorroad=yes else if access=private|no then false else true # # calculate logical bike access # assign bikeaccess = # Only allow footways with "Radverkehr frei" (Germany) when it is a bridge (good shortcut). Those ways in most cases are quite narrow and not eligible for riding your normal speed. if and highway=footway ( or bicycle=yes bicycle=designated ) then true else if highway=footway then false else if any_cycleroute then true else if bicycle= then ( if bicycle_road=yes then true else if vehicle= then ( if highway=footway then false else defaultaccess ) else not vehicle=private|no ) else not bicycle=private|no|dismount # # calculate logical foot access # assign footaccess = if bikeaccess then true else if bicycle=dismount then true else if foot= then defaultaccess else not foot=private|no # # if not bike-, but foot-acess, add a high penalty to avoid them (9000 to still be able to access if there is no other choice!), otherwise access is forbidden # assign accesspenalty = if bikeaccess then 0 else if footaccess then 9000 else 10000 # # Nearly forbid usage of oneway ways in the wrong direction, except for two-way cycleways # assign badoneway = if reversedirection=yes then # regular one-way streets with "Radverkehr frei" if and oneway=yes ( or cycleway=opposite|opposite_lane|opposite_track oneway:bicycle=no ) then false # respect one-way cycle ways else if or oneway:bicycle=yes oneway=yes then true # don't use roundabouts in the wrong direction else if oneway= then junction=roundabout else oneway=yes|true|1 else oneway=-1 assign onewaypenalty = if badoneway then 300 else 0.0 # # calculate the cost-factor, which is the factor # by which the distance of a way-segment is multiplied # to calculate the cost of that segment. The costfactor # must be >=1 and it's supposed to be close to 1 for # the type of way the routing profile is searching for # assign smoothness_penalty = if smoothness=excellent|very_good|good then -0.2 else if smoothness=intermediate then 0.5 else if smoothness= then 0 else 50.0 # This will handle smoothness=bad|robust_wheels|very_bad|high_clearance|horrible|off_road_wheels|very_horrible|impassable etc. # We allow some surfaces, but want to avoid them if easily possible assign surface_penalty = if or surface=sett cycleway:surface=sett then 0.5 else if or surface=compacted cycleway:surface=compacted then penalty_compacted else if isunpaved then 200 else if and and and avoid_unknown_surface highway=path surface= cycleway:surface= then 200 else 0.0 assign costfactor # # exclude rivers, rails etc. # if ( and highway= not route=ferry ) then 10000 # # exclude some highway types # else if ( highway=motorway|motorway_link|proposed|abandoned ) then 10000 else if highway=steps then if ( or ramp:wheelchair=yes allow_steps ) then 40 else 9999 # # all other exclusions below (access, steps, ferries,..) # should not be deleted by the decoder, to be available # in voice-hint-processing # else min 9999 # # apply oneway-and access-penalties # add max onewaypenalty accesspenalty add smoothness_penalty add surface_penalty if ( route=ferry ) then ( if allow_ferries then 5.67 else 9999 ) else if ford=yes then 10000 # # some other highway types # else if ( highway=pedestrian ) then 5 # Only allow footways with "Radverkehr frei" (Germany) at high costs when it is not a bridge/tunnel (good shortcut). Those ways in most cases are quite narrow and not eligible for riding your normal speed. else if ( and ( or ( and highway=footway ( or bicycle=yes bicycle=designated ) ) ( and highway=path and foot=designated bicycle=yes ) ) ( or bridge=yes tunnel=yes ) ) then 1.0 else if highway=path then ( if bicycle=designated then 1.0 else if bicycle=yes then 4 else 10 ) else if ( highway=footway ) then 10 else if ( highway=bridleway ) then 10 else if ( highway=cycleway ) then ( if probablyGood then 1.0 else 1.1 ) else if ( highway=residential ) then 1.1 else if ( highway=service ) then 1.0 else if ( or highway=living_street living_street=yes ) then 2.5 else if ( highway=unclassified ) then ( if isbike then 1.0 else if ishighspeed then 3 else 1.1 ) else if ( highway=construction ) then 200 # # tracks and track-like ways are rated mainly be tracktype/grade # But note that if no tracktype is given it can be o.k. # else if ( highway=track ) then ( if ( tracktype=grade1 ) then ( if probablyGood then 1.0 else 1.3 ) else if ( tracktype=grade2 ) then ( if probablyGood then 1.1 else 2.5 ) else if ( tracktype=grade3 ) then ( if ispaved then 10.0 else 9999 ) else if ( tracktype=grade4 ) then ( if ispaved then 15.0 else 9999 ) else if ( tracktype=grade5 ) then ( if ispaved then 20.0 else 9999 ) else ( if probablyGood then 1.1 else if avoid_unknown_surface then 200 else 3.0 ) ) # # actuals roads are o.k. if we have a bike hint and if there is no highspeed car traffic # We use traffic penalty for ways with high car traffic # See https://forum.openstreetmap.org/viewtopic.php?id=31044 for more information # else if ( highway=trunk|trunk_link ) then ( if isbike then 1.5 else if ishighspeed then 20 else 5 ) else if highway=primary|primary_link then ( if and not hascycleway fuck_cars then 500 else if consider_traffic then ( if or estimated_traffic_class=1|2 estimated_traffic_class= then ( if isbike then 1.6 else if ishighspeed then 3 else 1.8 ) else if estimated_traffic_class=3 then ( if isbike then 2 else if ishighspeed then 8 else 3 ) else if estimated_traffic_class=4 then ( if isbike then 2 else if ishighspeed then 9 else 3 ) else if estimated_traffic_class=5 then ( if isbike then 2 else if ishighspeed then 10 else 5 ) else if estimated_traffic_class=6|7 then ( if isbike then 2 else if ishighspeed then 15 else 5 ) else 4 ) else ( if isbike then 1.6 else if ishighspeed then 7 else 4 ) ) else if highway=secondary|secondary_link then ( if and not hascycleway fuck_cars then 500 else if consider_traffic then ( if or estimated_traffic_class=1|2 estimated_traffic_class= then ( if isbike then 1.3 else if ishighspeed then 2.5 else 1.5 ) else if estimated_traffic_class=3 then ( if isbike then 1.3 else if ishighspeed then 5 else 1.4 ) else if estimated_traffic_class=4 then ( if isbike then 1.3 else if ishighspeed then 6 else 1.4 ) else if estimated_traffic_class=5 then ( if isbike then 1.3 else if ishighspeed then 7 else 1.4 ) else if estimated_traffic_class=6|7 then ( if isbike then 1.3 else if ishighspeed then 10 else 1.4 ) else 3 ) else ( if isbike then 1.5 else if ishighspeed then 5 else 3 ) ) else if highway=tertiary|tertiary_link then ( if and not hascycleway fuck_cars then 500 else if consider_traffic then ( if or estimated_traffic_class=1|2 estimated_traffic_class= then ( if isbike then 1.1 else if ishighspeed then 1.5 else 1.3 ) else if estimated_traffic_class=3 then ( if isbike then 1.1 else if ishighspeed then 2 else 1.3 ) else if estimated_traffic_class=4 then ( if isbike then 1.1 else if ishighspeed then 2 else 1.3 ) else if estimated_traffic_class=5 then ( if isbike then 1.1 else if ishighspeed then 4 else 1.3 ) else if estimated_traffic_class=6|7 then ( if isbike then 1.1 else if ishighspeed then 10 else 1.4 ) else 2 ) else ( if isbike then 1.4 else if ishighspeed then 1.5 else 1.8 ) ) # # default for any other highway type not handled above # else 2.0 # way priorities used for voice hint generation assign priorityclassifier = if ( highway=motorway ) then 30 else if ( highway=motorway_link ) then 29 else if ( highway=trunk ) then 28 else if ( highway=trunk_link ) then 27 else if ( highway=primary ) then 26 else if ( highway=primary_link ) then 25 else if ( highway=secondary ) then 24 else if ( highway=secondary_link ) then 23 else if ( highway=tertiary ) then 22 else if ( highway=tertiary_link ) then 21 else if ( highway=unclassified ) then 20 else if ( or highway=living_street living_street=yes ) then 6 else if ( highway=service ) then 6 else if ( highway=cycleway ) then 6 else if ( or bicycle=designated bicycle_road=yes ) then 6 else if ( highway=track ) then if tracktype=grade1 then 6 else 4 else if ( highway=bridleway|road|path|footway ) then 4 else if ( highway=steps ) then 2 else if ( highway=pedestrian ) then 2 else 0 # some more classifying bits used for voice hint generation... assign isbadoneway = not equal onewaypenalty 0 assign isgoodoneway = if reversedirection=yes then oneway=-1 else if oneway= then junction=roundabout else oneway=yes|true|1 assign isroundabout = junction=roundabout assign islinktype = highway=motorway_link|trunk_link|primary_link|secondary_link|tertiary_link assign isgoodforcars = if greater priorityclassifier 6 then true else if ( or or highway=living_street living_street=yes highway=service ) then true else if ( and highway=track tracktype=grade1 ) then true else false # ... encoded into a bitmask assign classifiermask add isbadoneway add multiply isgoodoneway 2 add multiply isroundabout 4 add multiply islinktype 8 multiply isgoodforcars 16 # include `smoothness=` tags in the response's WayTags for track analysis assign dummyUsage = smoothness= ---context:node # following code refers to node tags assign initial_cost_node 0 assign defaultaccess = if ( access= ) then true # add default barrier restrictions here! else if ( access=private|no ) then false else true assign bikeaccess = if nodeaccessgranted=yes then true else if bicycle= then ( if vehicle= then defaultaccess else not vehicle=private|no ) else not bicycle=private|no|dismount assign footaccess = if bicycle=dismount then true else if foot= then defaultaccess else not foot=private|no # # Avoid traffic signals and stop signs # assign initialcost = add ( if highway=traffic_signals then ( if fuck_traffic_lights then 9999 else penalty_traffic_light ) else if highway=elevator then penalty_elevator # Only add penalty if stop sign is in direction of travel # see also https://github.com/poutnikl/Brouter-profiles/issues/25#issuecomment-864365688 else if highway=stop then ( if or or ( and not way:isreversed direction=forward|both ) ( and way:isreversed direction=backward|both ) ( direction= ) then penalty_stop_sign else 0 ) else if barrier=cycle_barrier then penalty_cycle_barrier else if ford=yes then 9999 else if and highway=crossing bicycle=no then 60 else if and highway=crossing crossing=no then 300 # workaround affecting road routing else initial_cost_node ) if bikeaccess then 0 else ( if footaccess then 9999 else 10000 )