├── README.md ├── mtb-zossebart-hard.brf └── mtb-zossebart.brf /README.md: -------------------------------------------------------------------------------- 1 | # brouter-mtb 2 | a Brouter Mountainbike Profile 3 | 4 | This profile tries to find routes suitable for mountainbikes. It tries to avoid major roads and focuses on tracks for uphills and paths/tracks for downhills where possible. 5 | 6 | There are two major parameters to modify the behaviour: 7 | 8 | * is_wet 9 | * false: normal behaviour (default) 10 | * true: try to avoid ways which are potentially unpleasant to ride when they are wet (for example ways with grass/earth surface) 11 | * mtb_hard_factor (range 0 - 4) 12 | * 0: normal behaviour (default in mtb-zossebart.brf), generate routes for XC/AM 13 | * 2: generate harder routes (for example All Mountain, default in mtb-zossebart-hard.brf) 14 | * 4: highest setting (for example Enduro) 15 | 16 | Also, there are some additional switches for special features: 17 | * allow_ferries: switch on and off the usage of ferries (default off) 18 | * allow_steps: wether the route can go over steps (default on) 19 | * use_uncertain_gates: wether passing of gates with unknown access restrictions is allowed or not. The default behaviour is to do not pass such gates. However, in some poorly mapped areas, it might be beneficial to enable this switch to avoid lots of big detours in the routing. Be aware that you could end up at a closed or restricted gate then! 20 | 21 | **CAUTION:** Locus ignores the default settings of the parameters when the profile is first configured! This means the _avoid_unpaved_ parameter is set to _false_, which leads to the creation of harder routes in profile versions prior to v1.1.0! 22 | Please enable _avoid_unpaved_ at the first setup if you want the default behaviour! This setting is global for all profiles configured in Locus. 23 | This is not a problem with other apps or brouter-web, as they are not aware of these parameters and thus use the default settings. 24 | Beginning from v1.1.0, the profile is split into two separate variants (normal/hard), so this is not a problem any more. 25 | 26 | ## Changelog ## 27 | ### v1.0.0 ### 28 | * initial version 29 | 30 | ### v1.0.1 ### 31 | * refactor to syntax alternatives (should improve the readability) 32 | 33 | ### v1.0.2 ### 34 | * correction to make Locus parameter switches work again 35 | 36 | ### v1.1.0 ### 37 | * split into normal/hard versions of the profile, removed avoid_unpaved parameter 38 | 39 | ### v1.1.1 ### 40 | * fix for wrong turninstructions bug 41 | 42 | ### v1.1.2 ### 43 | * add profile parameter comments, fix ferry route avoidance 44 | 45 | ### v1.1.3 ### 46 | * add missing turninstructionmode parameters 47 | 48 | ### v1.1.4 ### 49 | * add oruxmaps turninstructionmode parameter 50 | 51 | ### v1.2.0 ### 52 | * avoid oneways on cycleways 53 | * kinematic model parameters for more precise ETA 54 | 55 | ### v1.2.1 ### 56 | * add parameter to switch access on uncertain gates (without access-tags) 57 | 58 | ### v1.2.2 ### 59 | * add parameter to allow ferries (default off) 60 | * add parameter to allow steps (default on) 61 | * adapt default kinematic parameters for more realistic ETA 62 | 63 | ### v1.2.3 ### 64 | * fix elevation filtering default settings 65 | * make ntb_hard_factor param an enum to restrict it to the designed range 66 | * rearrange paramters to a more sensible order 67 | -------------------------------------------------------------------------------- /mtb-zossebart-hard.brf: -------------------------------------------------------------------------------- 1 | # 2 | # mountainbike profile by zossebart 3 | # v1.2.3 4 | # see https://github.com/zossebart/brouter-mtb for information and releases 5 | # 6 | # CAUTION! always ride carefully, routing data and/or route calculation might not be accurate and safe at all times! 7 | # 8 | 9 | ---context:global # following code refers to global config 10 | 11 | # generate a bike route 12 | assign validForBikes = true 13 | assign validForCars = false 14 | assign validForFoot = false 15 | 16 | # Locus nav interface flags 17 | assign mtb_hard_factor = 2 # %mtb_hard_factor% | Difficulty of the route | [0=easy, 1=moderate, 2=demanding, 3=hard, 4=extreme/uncompromising] 18 | assign is_wet = false # %is_wet% | Choose a safer route in wet conditions | boolean 19 | assign allow_ferries = false # %allow_ferries% | Allow ferries | boolean 20 | assign allow_steps = true # %allow_steps% | Allow steps | boolean 21 | assign use_uncertain_gates = false # %use_uncertain_gates% | Route through gates with no access info (might be locked) | boolean 22 | 23 | # the global elevation parameters 24 | assign downhillcost = max 0 ( sub 30 ( multiply mtb_hard_factor 10 ) ) 25 | assign downhillcutoff = 4 26 | assign uphillcost = max 0 ( sub 40 ( multiply mtb_hard_factor 15 ) ) 27 | assign uphillcutoff = 1.5 28 | 29 | # elevation filtering parameters (tbd: optimized settings) 30 | assign elevationpenaltybuffer = 5 31 | assign elevationmaxbuffer = 10 32 | assign elevationbufferreduce = 0 33 | 34 | # +++ Kinematic model parameters (travel time computation) 35 | assign totalMass = 100 # %totalMass% | Mass (in kg) of the bike + biker, for travel time computation | number 36 | assign maxSpeed = 35 # %maxSpeed% | Absolute maximum speed (in km/h), for travel time computation | number 37 | assign S_C_x = 0.75 # %S_C_x% | Drag coefficient times the reference area (in m^2), for travel time computation | number 38 | assign C_r = 0.02 # %C_r% | Rolling resistance coefficient (dimensionless), for travel time computation | number 39 | assign bikerPower = 180 # %bikerPower% | Average power (in W) provided by the biker, for travel time computation | number 40 | 41 | assign turnInstructionMode = 1 # %turnInstructionMode% | Mode for the generated turn instructions | [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=oruxmaps-style] 42 | assign turnInstructionRoundabouts = true # %turnInstructionRoundabouts% | Set to "false" to avoid generating special turning instructions for roundabouts | boolean 43 | assign turnInstructionCatchingRange = 4 44 | 45 | # ++++++++++++++++++++++++++++++++++++++ some global defines for finetuning 46 | 47 | assign voiceprio = 2 # 1: all ways have the same prio (max instructions) 48 | # 2: mtb prio, more instructions on different small way types 49 | assign mj_rd_penalty = 0.5 # additional penalty for major roads for finetuning 50 | assign construction_penalty = 3 # penalty for roads in construction (oftentimes rideable by mtb) 51 | assign steps_penalty = max 0 ( sub 15 ( multiply mtb_hard_factor 5 ) ) 52 | # penalty for steps 53 | assign steps_ramp_uh_penalty = 5 # penalty for uphill steps with a ramp (might be smaller than default steps penalty) 54 | assign steps_ramp_dh_penalty = 2 # penalty for downhill steps with a ramp (even smaller than uphill ramp) 55 | assign ferry_penalty = if allow_ferries # penalty for ferries 56 | then 2000 57 | else 100000 58 | assign private_penalty = 6 # penalty for private ways and nodes 59 | assign bicycle_no_penalty = 5 # penalty for ways and nodes with bicycle=no 60 | assign slippery_muddy_penalty = if is_wet # penalty for unpaved roads and tracks, which are tricky to ride when wet 61 | then 2 62 | else 0 63 | assign ford_penalty = max 0 ( sub 15 ( multiply mtb_hard_factor 8 ) ) 64 | # penalty for fords (you might not want to get your feet wet ;-) ) 65 | 66 | assign isbike_reduce = 0.7 # penalty reduction for major roads with a cycleway 67 | assign isfoot_reduce = 0.9 # penalty reduction for major roads with a footway or sidewalk 68 | 69 | # +++ special downhill parameters 70 | assign considerdownhill = true # use special penalties for downhills? (enables/disables below parameters) 71 | assign dh_penalty = max 0 ( add 2.0 ( multiply mtb_hard_factor 0.5 ) ) 72 | # additional penalty for undesired downhills (e.g. major roads) 73 | assign dh_difficult_penalty = max 0 ( sub 10 ( multiply mtb_hard_factor 1 ) ) 74 | # additional downhill penalty for ways with high difficulty (mtb/sac_scale) 75 | assign dh_use_tracks = lesser mtb_hard_factor 0 76 | # use less penalty for downhill tracks than for other waytypes? (0/1) 77 | # enables/disables dh_track_penalty 78 | assign dh_track_penalty = multiply 0.75 dh_penalty 79 | # percentage of reduced downhill penalty for tracks 80 | 81 | # +++ special uphill parameters 82 | assign consideruphill = true # use special penalties for uphills? (enables/disables below parameters) 83 | assign uh_penalty = max 0 ( sub 2.5 ( multiply mtb_hard_factor 0.25 ) ) 84 | # additional penalty for undesired uphills (e.g. paths) 85 | assign uh_difficult_penalty = max 0 ( sub 10 ( multiply mtb_hard_factor 1 ) ) 86 | # additional uphill penalty for ways with high difficulty (mtb/sac_scale or mtb_scale_uphill) 87 | 88 | # ------------------------------------------- global defines end 89 | 90 | ---context:way # following code refers to way-tags 91 | 92 | # classifier constants 93 | assign classifier_none = 1 94 | assign classifier_ferry = 2 95 | 96 | # 97 | # pre-calculate some logical expressions 98 | # 99 | 100 | # 101 | # does the road have a footway or sidewalk? 102 | # 103 | assign has_sidewalk = not ( or sidewalk= sidewalk=no|none ) 104 | assign has_footway = not ( or footway= footway=no|none ) 105 | assign has_foot = or has_sidewalk has_footway 106 | 107 | # 108 | # does the road have a cycleway? 109 | # 110 | assign cycle = not ( or cycleway= cycleway=no|none|proposed ) 111 | assign l_cycle = not ( or cycleway:left= cycleway:left=no ) 112 | assign r_cycle = not ( or cycleway:right= cycleway:right=no ) 113 | assign has_cycleway = or cycle ( or l_cycle r_cycle ) 114 | 115 | # 116 | # is it a low-speed highway? 117 | # 118 | assign islowspeed = if maxspeed=10|20|30 119 | then true 120 | else false 121 | 122 | # 123 | # is it a high-speed highway? 124 | # 125 | assign ishighspeed = if maxspeed=60|70|80|90|100|110|120|130|rural 126 | then true 127 | else false 128 | 129 | # 130 | # are there multiple lanes on the highway? 131 | # 132 | assign ismultilane = if lanes= 133 | then false 134 | else if lanes=1|1.5|2 135 | then false 136 | else true 137 | 138 | # 139 | # assign the penalty reduction for roads with sidewalks or cycleways 140 | # 141 | assign penalty_reduce = if has_cycleway 142 | then isbike_reduce 143 | else if has_foot 144 | then isfoot_reduce 145 | else 1 146 | 147 | # 148 | # is the road paved or unpaved? 149 | # 150 | assign ispaved = surface=paved|asphalt|concrete|paving_stones|grass_paver|metal|wood|compacted 151 | assign isunpaved = not ( or surface= ispaved ) 152 | 153 | # 154 | # is the surface potentially slippery or muddy when it's wet? 155 | # 156 | assign surfacebadwhenwet = and isunpaved ( not surface=compacted|fine_gravel ) 157 | assign highwaybadwhenwet = or highway=path ( or tracktype=grade5|grade4 highway=bridleway ) 158 | assign isbadwhenwet = or surfacebadwhenwet highwaybadwhenwet 159 | 160 | assign any_cycleroute = or route_bicycle_icn=yes ( or route_bicycle_ncn=yes ( or route_bicycle_rcn=yes route_bicycle_lcn=yes ) ) 161 | 162 | # 163 | # get the inclination (up=1, down=-1, unknown=0) 164 | # 165 | assign inclination = 166 | if incline= 167 | then 0 168 | else if incline=yes|up|5%|8%|10%|15%|20%|25%|30% 169 | then if reversedirection=yes 170 | then -1 171 | else 1 172 | else if incline=down|-5%|-8%|-10%|-15%|-20%|-25%|-30% 173 | then if reversedirection=yes 174 | then 1 175 | else -1 176 | else 0 177 | 178 | 179 | # 180 | # precalculate steps penaltys 181 | # 182 | assign steps_uh_penalty = 183 | if not allow_steps 184 | then 99999 185 | else if or ramp:stroller=yes ramp:bicycle=yes 186 | then steps_ramp_uh_penalty 187 | else multiply 1.2 ( add uh_penalty steps_penalty ) # boost steps uphill penalty even more 188 | 189 | assign steps_dh_penalty = 190 | if not allow_steps 191 | then 99999 192 | else if or ramp:stroller=yes ramp:bicycle=yes 193 | then steps_ramp_dh_penalty 194 | else add dh_penalty steps_penalty 195 | 196 | 197 | # 198 | # base penalties for roadtypes 199 | # 200 | assign hw_penalty = 201 | if highway=motorway|motorway_link then 9999 202 | else if highway=proposed then 9999 203 | else if highway=construction then construction_penalty 204 | else 0 205 | 206 | assign hw_major_penalty = 207 | multiply if islowspeed # reduce the penalty if the speedlimit is low 208 | then 0.75 209 | else 1 210 | multiply max 1 ( multiply ishighspeed 1.2 ) # rise the penalty if the speedlimit is high 211 | multiply max 1 ( multiply ismultilane 1.2 ) # rise the penalty if there are more than 2 lanes 212 | if highway=trunk|trunk_link then add mj_rd_penalty 10 213 | else if highway=primary|primary_link then add mj_rd_penalty 6.0 214 | else if highway=secondary|secondary_link then add mj_rd_penalty 2.6 215 | else if highway=tertiary|tertiary_link then add mj_rd_penalty 2.3 216 | else if highway=unclassified then add mj_rd_penalty 2.2 217 | else 0 218 | 219 | assign hw_minor_penalty = 220 | multiply max 1 ( multiply ishighspeed 1.2 ) # rise the penalty if the speedlimit is high 221 | multiply max 1 ( multiply ismultilane 1.2 ) # rise the penalty if there are more than 2 lanes 222 | if highway=residential then 1.2 223 | else if highway=service then 1.1 224 | else if highway=living_street then 1.1 225 | else if highway=pedestrian then 1.1 226 | else if highway=footway then 1.1 227 | else 0 228 | 229 | # 230 | # additional penalties for other road attributes 231 | # 232 | assign mtb_sac_penalty = 233 | max 0 234 | multiply 235 | ( sub 1 ( multiply mtb_hard_factor 0.25 ) ) 236 | ( 237 | if ( or mtb:scale=3|2+ sac_scale=demanding_mountain_hiking ) then 2 238 | else if ( or mtb:scale=4 sac_scale=alpine_hiking ) then 4 239 | else if ( or mtb:scale=5 sac_scale=demanding_alpine_hiking ) then 50 240 | else if ( or mtb:scale=6 sac_scale=difficult_alpine_hiking ) then 100 241 | else 0 242 | ) 243 | 244 | assign mtb_uh_penalty = #(supported since 1.4.4) 245 | max 0 246 | multiply 247 | ( sub 1 ( multiply mtb_hard_factor 0.25 ) ) 248 | ( 249 | if mtb:scale:uphill=3 then 2 250 | else if mtb:scale:uphill=4 then 4 251 | else if mtb:scale:uphill=5 then 50 252 | else if mtb:scale=6 then 100 253 | else 0 254 | ) 255 | 256 | assign tracktype_penalty = 257 | max 0 258 | multiply 259 | ( sub 1 ( multiply mtb_hard_factor 0.5 ) ) 260 | ( 261 | if tracktype=grade5 then 0.2 262 | else 0 263 | ) 264 | 265 | assign traffic_penalty = 266 | multiply 267 | 0.3 268 | ( 269 | if estimated_traffic_class=2 then 1 270 | else if estimated_traffic_class=3 then 2 271 | else if estimated_traffic_class=4 then 3 272 | else if estimated_traffic_class=5 then 4 273 | else if estimated_traffic_class=6 then 5 274 | else if estimated_traffic_class=7 then 6 275 | else 0 276 | ) 277 | 278 | # 279 | # implicit access here just from the motorroad tag 280 | # (implicit access rules from highway tag handled elsewhere) 281 | # 282 | assign defaultaccess = 283 | if access= 284 | then ( not motorroad=yes ) 285 | else 286 | ( 287 | if access=no 288 | then false 289 | else 290 | ( 291 | if access=private 292 | then false 293 | else true 294 | ) 295 | ) 296 | 297 | # 298 | # calculate logical bike access 299 | # 300 | assign bikeaccess = 301 | or 302 | any_cycleroute 303 | ( 304 | if bicycle= 305 | then 306 | ( 307 | if vehicle= 308 | then defaultaccess 309 | else 310 | ( 311 | if vehicle=private|no 312 | then false 313 | else true 314 | ) 315 | ) 316 | else 317 | ( 318 | if not bicycle=private 319 | then true 320 | else false 321 | ) 322 | ) 323 | 324 | # 325 | # calculate logical foot access 326 | # 327 | assign footaccess = 328 | or bikeaccess 329 | or bicycle=dismount 330 | if foot= 331 | then defaultaccess 332 | else not foot=private|no 333 | 334 | # 335 | # combine to penalty for access 336 | # 337 | assign access_penalty = 338 | if bikeaccess 339 | then 340 | ( 341 | if bicycle=no # bike access granted from above, but check for bicycle=no 342 | then bicycle_no_penalty # access with penalty for bicycle=no 343 | else 344 | ( 345 | if bicycle=dismount # bike access granted from above, but check for bicycle=dismount 346 | then ( multiply 0.2 bicycle_no_penalty ) # access with penalty for bicycle=dismount 347 | else 0 348 | ) 349 | ) # full bike access 350 | else 351 | ( 352 | if ( or access=private or bicycle=private or vehicle=private foot=private ) 353 | then private_penalty # access with penalty for private 354 | else 100000 # absolutely no access 355 | ) 356 | 357 | assign badoneway = 358 | if reversedirection=yes then 359 | if oneway:bicycle=yes then true 360 | else if oneway= then junction=roundabout 361 | else oneway=yes|true|1 362 | else oneway=-1 363 | 364 | assign onewaypenalty = 365 | if ( badoneway ) then 366 | ( 367 | if oneway:bicycle=no 368 | then 0 369 | else if or highway=cycleway and highway=path bicycle=designated 370 | then 50 371 | else 0.0 372 | ) 373 | else 0.0 374 | 375 | # 376 | # combine additional penaltys which are common for flat, up and down ways 377 | # 378 | assign misc_penalty = 379 | add access_penalty 380 | add traffic_penalty 381 | add onewaypenalty 382 | add if ( not ford= ) then ford_penalty 383 | else 0 384 | add if trail_visibility=bad then 2 385 | else 386 | ( 387 | if trail_visibility=horrible then 5 388 | else 389 | ( 390 | if trail_visibility=no then 15 391 | else 0 392 | ) 393 | ) 394 | add if smoothness=impassable then 10 395 | else 0 396 | max 0 multiply ( sub 1 ( multiply mtb_hard_factor 0.3333 ) ) 397 | add if surfacebadwhenwet then slippery_muddy_penalty 398 | else 0 399 | add if highwaybadwhenwet then slippery_muddy_penalty 400 | else 0 401 | if surface=sand|mud then 3 402 | else 0 403 | 404 | 405 | # 406 | # now assign the parameters for the routing engine (initialcost, turncost and flat/up/down costfactors) 407 | # 408 | assign turncost = 409 | if highway=path|footway 410 | then 411 | ( 412 | if equal inclination -1 then 0 413 | else 10 414 | ) 415 | else 416 | ( 417 | if highway=track then 50 418 | else 150 419 | ) 420 | 421 | # 422 | # assign parameters for turn instruction generation 423 | # 424 | assign priorityclassifier = 425 | if equal voiceprio 1 then 1 426 | else if equal voiceprio 2 427 | then if ( highway=motorway ) then 101 428 | else if ( highway=motorway_link ) then 100 429 | else if ( highway=trunk ) then 91 430 | else if ( highway=trunk_link ) then 90 431 | else if ( highway=primary ) then 88 432 | else if ( highway=primary_link ) then 87 433 | else if ( highway=secondary ) then 86 434 | else if ( highway=secondary_link ) then 85 435 | else if ( highway=tertiary ) then 84 436 | else if ( highway=tertiary_link ) then 83 437 | else if ( highway=unclassified ) then 82 438 | else if ( highway=residential|living_street ) then 50 439 | else if ( highway=service ) then 40 440 | else if ( highway=road ) then 35 441 | else if ( highway=cycleway ) then 30 442 | else if ( highway=bridleway|track ) then 20 443 | else if ( highway=footway|pedestrian ) then 17 444 | else if ( highway=steps ) then 15 445 | else if ( highway=path ) then 10 446 | else 0 447 | else 0 448 | 449 | assign isroundabout = junction=roundabout 450 | assign islinktype = highway=motorway_link|trunk_link|primary_link|secondary_link|tertiary_link 451 | assign isgoodforcars = 452 | if ( greater priorityclassifier 30 ) 453 | then true 454 | else 455 | ( 456 | if highway=residential|living_street|service 457 | then true 458 | else 459 | ( 460 | if ( and highway=track tracktype=grade1 ) 461 | then true 462 | else false 463 | ) 464 | ) 465 | 466 | # ... encoded into a bitmask 467 | 468 | assign classifiermask = add multiply isroundabout 4 469 | add multiply islinktype 8 470 | multiply isgoodforcars 16 471 | 472 | # 473 | # for any change in initialclassifier, initialcost is added once 474 | # 475 | assign initialclassifier = 476 | if route=ferry then classifier_ferry 477 | else classifier_none 478 | 479 | assign initialcost = 480 | if ( equal initialclassifier classifier_ferry ) then ferry_penalty 481 | else 0 482 | 483 | # 484 | # costfactor for flat terrain 485 | # 486 | assign costfactor = 487 | if and highway= not route=ferry then 100000 488 | else 489 | min 9999 490 | add misc_penalty 491 | add if ( and ( equal inclination 1 ) mtb_uh_penalty ) 492 | then 493 | ( 494 | add 495 | mtb_uh_penalty 496 | ( 497 | if consideruphill then uh_difficult_penalty 498 | else 0 499 | ) 500 | ) 501 | else mtb_sac_penalty 502 | add tracktype_penalty 503 | max 1 504 | if hw_penalty then hw_penalty 505 | else if hw_major_penalty then hw_major_penalty 506 | else if hw_minor_penalty then hw_minor_penalty 507 | 508 | else if highway=path then 1 509 | else if highway=steps 510 | then 511 | ( 512 | if equal inclination 1 then steps_uh_penalty 513 | else 514 | ( 515 | if equal inclination -1 then steps_dh_penalty 516 | else 517 | ( 518 | if reversedirection=yes then steps_dh_penalty 519 | else steps_uh_penalty 520 | ) 521 | ) 522 | ) 523 | else if highway=track|bridleway then 1 524 | else if highway=cycleway then max 1 ( add 1.1 ( multiply mtb_hard_factor 0.1 ) ) 525 | else if route=ferry then 1 # ferries are handled through initialcost, so no need to add cosfactory here 526 | else 40 # default for any other highway type not handled above 527 | 528 | # 529 | # costfactor for uphills 530 | # 531 | assign uphillcostfactor = 532 | if consideruphill 533 | then 534 | ( 535 | if and highway= not route=ferry then 100000 536 | else 537 | min 9999 538 | add misc_penalty 539 | add if ( and ( equal inclination 1 ) mtb_uh_penalty ) 540 | then add uh_difficult_penalty mtb_uh_penalty 541 | else 542 | ( 543 | if mtb_sac_penalty then add uh_difficult_penalty mtb_sac_penalty 544 | else 0 545 | ) 546 | add if tracktype_penalty then add uh_difficult_penalty tracktype_penalty 547 | else 0 548 | max 1 549 | if hw_penalty then hw_penalty 550 | else if hw_major_penalty then multiply penalty_reduce hw_major_penalty 551 | else if hw_minor_penalty then hw_minor_penalty 552 | 553 | else if highway=path then uh_penalty 554 | else if highway=steps # first try to use incline 555 | then if equal inclination 1 then steps_uh_penalty 556 | else if equal inclination -1 then steps_dh_penalty 557 | else steps_uh_penalty # no incline tag, assume step is really uphill 558 | else if highway=track then 1 559 | else if highway=bridleway then 1.2 560 | else if highway=cycleway then 1 561 | else if route=ferry then 1 # ferries are handled through initialcost, so no need to add cosfactory here 562 | else 40 # default for any other highway type not handled above 563 | ) 564 | else 0 # no special handling for uphill selected, flat costfactor will be used instead 565 | 566 | # 567 | # costfactor for downhills 568 | # 569 | assign downhillcostfactor = 570 | if considerdownhill 571 | then 572 | ( 573 | if and highway= not route=ferry then 100000 574 | else 575 | min 9999 576 | add misc_penalty 577 | add if ( and ( equal inclination 1 ) mtb_uh_penalty ) 578 | then 579 | ( 580 | add if consideruphill then uh_difficult_penalty 581 | else 0 582 | mtb_uh_penalty 583 | ) 584 | else 585 | ( 586 | if mtb_sac_penalty then add dh_difficult_penalty mtb_sac_penalty 587 | else 0 588 | ) 589 | add if tracktype_penalty then add dh_difficult_penalty tracktype_penalty 590 | else 0 591 | max 1 592 | if hw_penalty then add dh_penalty hw_penalty 593 | else if hw_major_penalty then add dh_penalty hw_major_penalty 594 | else if hw_minor_penalty then add dh_penalty hw_minor_penalty 595 | 596 | else if highway=path then 1 597 | else if highway=steps # first try to use incline 598 | then if equal inclination 1 then steps_uh_penalty 599 | else if equal inclination -1 then steps_dh_penalty 600 | else steps_dh_penalty # no incline tag, assume step is really downhill 601 | else if highway=track|bridleway 602 | then if dh_use_tracks then dh_track_penalty 603 | else dh_penalty 604 | else if highway=cycleway then add dh_penalty 0.5 605 | else if route=ferry then 1 # ferries are handled through initialcost, so no need to add cosfactory here 606 | else 40 # default for any other highway type not handled above 607 | ) 608 | else 0 # no special handling for downhill selected, flat costfactor will be used instead 609 | 610 | ---context:node # following code refers to node tags 611 | 612 | assign defaultaccess = 613 | if access= 614 | then 615 | ( 616 | if and barrier=gate use_uncertain_gates then true 617 | else if barrier=gate|fence|door|wall then false 618 | else true 619 | ) 620 | else 621 | ( 622 | if access=private|no 623 | then false 624 | else true 625 | ) 626 | 627 | assign bikeaccess = 628 | or nodeaccessgranted=yes 629 | if bicycle= 630 | then 631 | ( 632 | if vehicle= then defaultaccess 633 | else 634 | ( 635 | if vehicle=private|no then false 636 | else true 637 | ) 638 | ) 639 | else 640 | ( 641 | if bicycle=private|no|dismount then false 642 | else true 643 | ) 644 | 645 | assign footaccess = 646 | or bicycle=dismount 647 | if foot= then defaultaccess 648 | else if foot=private|no then false 649 | else true 650 | 651 | assign initialcost = 652 | add if highway=traffic_signals then 100 653 | else 0 654 | if ( and ( or bikeaccess footaccess ) ( not highway=elevator ) ) 655 | then 656 | ( 657 | if ( or ( not ford= ) highway=ford ) then ( multiply 100 ford_penalty ) 658 | else 0 659 | ) 660 | # switch or access=private 661 | # or bicycle=private 662 | # or vehicle=private 663 | # foot=private 664 | # multiply 100 private_penalty # access with penalty 665 | else 1000000 666 | -------------------------------------------------------------------------------- /mtb-zossebart.brf: -------------------------------------------------------------------------------- 1 | # 2 | # mountainbike profile by zossebart 3 | # v1.2.3 4 | # see https://github.com/zossebart/brouter-mtb for information and releases 5 | # 6 | # CAUTION! always ride carefully, routing data and/or route calculation might not be accurate and safe at all times! 7 | # 8 | 9 | ---context:global # following code refers to global config 10 | 11 | # generate a bike route 12 | assign validForBikes = true 13 | assign validForCars = false 14 | assign validForFoot = false 15 | 16 | # Locus nav interface flags 17 | assign mtb_hard_factor = 0 # %mtb_hard_factor% | Difficulty of the route | [0=easy, 1=moderate, 2=demanding, 3=hard, 4=extreme/uncompromising] 18 | assign is_wet = false # %is_wet% | Choose a safer route in wet conditions | boolean 19 | assign allow_ferries = false # %allow_ferries% | Allow ferries | boolean 20 | assign allow_steps = true # %allow_steps% | Allow steps | boolean 21 | assign use_uncertain_gates = false # %use_uncertain_gates% | Route through gates with no access info (might be locked) | boolean 22 | 23 | # the global elevation parameters 24 | assign downhillcost = max 0 ( sub 30 ( multiply mtb_hard_factor 10 ) ) 25 | assign downhillcutoff = 4 26 | assign uphillcost = max 0 ( sub 40 ( multiply mtb_hard_factor 15 ) ) 27 | assign uphillcutoff = 1.5 28 | 29 | # elevation filtering parameters (tbd: optimized settings) 30 | assign elevationpenaltybuffer = 5 31 | assign elevationmaxbuffer = 10 32 | assign elevationbufferreduce = 0 33 | 34 | # +++ Kinematic model parameters (travel time computation) 35 | assign totalMass = 100 # %totalMass% | Mass (in kg) of the bike + biker, for travel time computation | number 36 | assign maxSpeed = 35 # %maxSpeed% | Absolute maximum speed (in km/h), for travel time computation | number 37 | assign S_C_x = 0.75 # %S_C_x% | Drag coefficient times the reference area (in m^2), for travel time computation | number 38 | assign C_r = 0.02 # %C_r% | Rolling resistance coefficient (dimensionless), for travel time computation | number 39 | assign bikerPower = 180 # %bikerPower% | Average power (in W) provided by the biker, for travel time computation | number 40 | 41 | assign turnInstructionMode = 1 # %turnInstructionMode% | Mode for the generated turn instructions | [0=none, 1=auto-choose, 2=locus-style, 3=osmand-style, 4=comment-style, 5=gpsies-style, 6=oruxmaps-style] 42 | assign turnInstructionRoundabouts = true # %turnInstructionRoundabouts% | Set to "false" to avoid generating special turning instructions for roundabouts | boolean 43 | assign turnInstructionCatchingRange = 4 44 | 45 | # ++++++++++++++++++++++++++++++++++++++ some global defines for finetuning 46 | 47 | assign voiceprio = 2 # 1: all ways have the same prio (max instructions) 48 | # 2: mtb prio, more instructions on different small way types 49 | assign mj_rd_penalty = 0.5 # additional penalty for major roads for finetuning 50 | assign construction_penalty = 3 # penalty for roads in construction (oftentimes rideable by mtb) 51 | assign steps_penalty = max 0 ( sub 15 ( multiply mtb_hard_factor 5 ) ) 52 | # penalty for steps 53 | assign steps_ramp_uh_penalty = 5 # penalty for uphill steps with a ramp (might be smaller than default steps penalty) 54 | assign steps_ramp_dh_penalty = 2 # penalty for downhill steps with a ramp (even smaller than uphill ramp) 55 | assign ferry_penalty = if allow_ferries # penalty for ferries 56 | then 2000 57 | else 100000 58 | assign private_penalty = 6 # penalty for private ways and nodes 59 | assign bicycle_no_penalty = 5 # penalty for ways and nodes with bicycle=no 60 | assign slippery_muddy_penalty = if is_wet # penalty for unpaved roads and tracks, which are tricky to ride when wet 61 | then 2 62 | else 0 63 | assign ford_penalty = max 0 ( sub 15 ( multiply mtb_hard_factor 8 ) ) 64 | # penalty for fords (you might not want to get your feet wet ;-) ) 65 | 66 | assign isbike_reduce = 0.7 # penalty reduction for major roads with a cycleway 67 | assign isfoot_reduce = 0.9 # penalty reduction for major roads with a footway or sidewalk 68 | 69 | # +++ special downhill parameters 70 | assign considerdownhill = true # use special penalties for downhills? (enables/disables below parameters) 71 | assign dh_penalty = max 0 ( add 2.0 ( multiply mtb_hard_factor 0.5 ) ) 72 | # additional penalty for undesired downhills (e.g. major roads) 73 | assign dh_difficult_penalty = max 0 ( sub 10 ( multiply mtb_hard_factor 1 ) ) 74 | # additional downhill penalty for ways with high difficulty (mtb/sac_scale) 75 | assign dh_use_tracks = lesser mtb_hard_factor 0 76 | # use less penalty for downhill tracks than for other waytypes? (0/1) 77 | # enables/disables dh_track_penalty 78 | assign dh_track_penalty = multiply 0.75 dh_penalty 79 | # percentage of reduced downhill penalty for tracks 80 | 81 | # +++ special uphill parameters 82 | assign consideruphill = true # use special penalties for uphills? (enables/disables below parameters) 83 | assign uh_penalty = max 0 ( sub 2.5 ( multiply mtb_hard_factor 0.25 ) ) 84 | # additional penalty for undesired uphills (e.g. paths) 85 | assign uh_difficult_penalty = max 0 ( sub 10 ( multiply mtb_hard_factor 1 ) ) 86 | # additional uphill penalty for ways with high difficulty (mtb/sac_scale or mtb_scale_uphill) 87 | 88 | # ------------------------------------------- global defines end 89 | 90 | ---context:way # following code refers to way-tags 91 | 92 | # classifier constants 93 | assign classifier_none = 1 94 | assign classifier_ferry = 2 95 | 96 | # 97 | # pre-calculate some logical expressions 98 | # 99 | 100 | # 101 | # does the road have a footway or sidewalk? 102 | # 103 | assign has_sidewalk = not ( or sidewalk= sidewalk=no|none ) 104 | assign has_footway = not ( or footway= footway=no|none ) 105 | assign has_foot = or has_sidewalk has_footway 106 | 107 | # 108 | # does the road have a cycleway? 109 | # 110 | assign cycle = not ( or cycleway= cycleway=no|none|proposed ) 111 | assign l_cycle = not ( or cycleway:left= cycleway:left=no ) 112 | assign r_cycle = not ( or cycleway:right= cycleway:right=no ) 113 | assign has_cycleway = or cycle ( or l_cycle r_cycle ) 114 | 115 | # 116 | # is it a low-speed highway? 117 | # 118 | assign islowspeed = if maxspeed=10|20|30 119 | then true 120 | else false 121 | 122 | # 123 | # is it a high-speed highway? 124 | # 125 | assign ishighspeed = if maxspeed=60|70|80|90|100|110|120|130|rural 126 | then true 127 | else false 128 | 129 | # 130 | # are there multiple lanes on the highway? 131 | # 132 | assign ismultilane = if lanes= 133 | then false 134 | else if lanes=1|1.5|2 135 | then false 136 | else true 137 | 138 | # 139 | # assign the penalty reduction for roads with sidewalks or cycleways 140 | # 141 | assign penalty_reduce = if has_cycleway 142 | then isbike_reduce 143 | else if has_foot 144 | then isfoot_reduce 145 | else 1 146 | 147 | # 148 | # is the road paved or unpaved? 149 | # 150 | assign ispaved = surface=paved|asphalt|concrete|paving_stones|grass_paver|metal|wood|compacted 151 | assign isunpaved = not ( or surface= ispaved ) 152 | 153 | # 154 | # is the surface potentially slippery or muddy when it's wet? 155 | # 156 | assign surfacebadwhenwet = and isunpaved ( not surface=compacted|fine_gravel ) 157 | assign highwaybadwhenwet = or highway=path ( or tracktype=grade5|grade4 highway=bridleway ) 158 | assign isbadwhenwet = or surfacebadwhenwet highwaybadwhenwet 159 | 160 | assign any_cycleroute = or route_bicycle_icn=yes ( or route_bicycle_ncn=yes ( or route_bicycle_rcn=yes route_bicycle_lcn=yes ) ) 161 | 162 | # 163 | # get the inclination (up=1, down=-1, unknown=0) 164 | # 165 | assign inclination = 166 | if incline= 167 | then 0 168 | else if incline=yes|up|5%|8%|10%|15%|20%|25%|30% 169 | then if reversedirection=yes 170 | then -1 171 | else 1 172 | else if incline=down|-5%|-8%|-10%|-15%|-20%|-25%|-30% 173 | then if reversedirection=yes 174 | then 1 175 | else -1 176 | else 0 177 | 178 | 179 | # 180 | # precalculate steps penaltys 181 | # 182 | assign steps_uh_penalty = 183 | if not allow_steps 184 | then 99999 185 | else if or ramp:stroller=yes ramp:bicycle=yes 186 | then steps_ramp_uh_penalty 187 | else multiply 1.2 ( add uh_penalty steps_penalty ) # boost steps uphill penalty even more 188 | 189 | assign steps_dh_penalty = 190 | if not allow_steps 191 | then 99999 192 | else if or ramp:stroller=yes ramp:bicycle=yes 193 | then steps_ramp_dh_penalty 194 | else add dh_penalty steps_penalty 195 | 196 | 197 | # 198 | # base penalties for roadtypes 199 | # 200 | assign hw_penalty = 201 | if highway=motorway|motorway_link then 9999 202 | else if highway=proposed then 9999 203 | else if highway=construction then construction_penalty 204 | else 0 205 | 206 | assign hw_major_penalty = 207 | multiply if islowspeed # reduce the penalty if the speedlimit is low 208 | then 0.75 209 | else 1 210 | multiply max 1 ( multiply ishighspeed 1.2 ) # rise the penalty if the speedlimit is high 211 | multiply max 1 ( multiply ismultilane 1.2 ) # rise the penalty if there are more than 2 lanes 212 | if highway=trunk|trunk_link then add mj_rd_penalty 10 213 | else if highway=primary|primary_link then add mj_rd_penalty 6.0 214 | else if highway=secondary|secondary_link then add mj_rd_penalty 2.6 215 | else if highway=tertiary|tertiary_link then add mj_rd_penalty 2.3 216 | else if highway=unclassified then add mj_rd_penalty 2.2 217 | else 0 218 | 219 | assign hw_minor_penalty = 220 | multiply max 1 ( multiply ishighspeed 1.2 ) # rise the penalty if the speedlimit is high 221 | multiply max 1 ( multiply ismultilane 1.2 ) # rise the penalty if there are more than 2 lanes 222 | if highway=residential then 1.2 223 | else if highway=service then 1.1 224 | else if highway=living_street then 1.1 225 | else if highway=pedestrian then 1.1 226 | else if highway=footway then 1.1 227 | else 0 228 | 229 | # 230 | # additional penalties for other road attributes 231 | # 232 | assign mtb_sac_penalty = 233 | max 0 234 | multiply 235 | ( sub 1 ( multiply mtb_hard_factor 0.25 ) ) 236 | ( 237 | if ( or mtb:scale=3|2+ sac_scale=demanding_mountain_hiking ) then 2 238 | else if ( or mtb:scale=4 sac_scale=alpine_hiking ) then 4 239 | else if ( or mtb:scale=5 sac_scale=demanding_alpine_hiking ) then 50 240 | else if ( or mtb:scale=6 sac_scale=difficult_alpine_hiking ) then 100 241 | else 0 242 | ) 243 | 244 | assign mtb_uh_penalty = #(supported since 1.4.4) 245 | max 0 246 | multiply 247 | ( sub 1 ( multiply mtb_hard_factor 0.25 ) ) 248 | ( 249 | if mtb:scale:uphill=3 then 2 250 | else if mtb:scale:uphill=4 then 4 251 | else if mtb:scale:uphill=5 then 50 252 | else if mtb:scale=6 then 100 253 | else 0 254 | ) 255 | 256 | assign tracktype_penalty = 257 | max 0 258 | multiply 259 | ( sub 1 ( multiply mtb_hard_factor 0.5 ) ) 260 | ( 261 | if tracktype=grade5 then 0.2 262 | else 0 263 | ) 264 | 265 | assign traffic_penalty = 266 | multiply 267 | 0.3 268 | ( 269 | if estimated_traffic_class=2 then 1 270 | else if estimated_traffic_class=3 then 2 271 | else if estimated_traffic_class=4 then 3 272 | else if estimated_traffic_class=5 then 4 273 | else if estimated_traffic_class=6 then 5 274 | else if estimated_traffic_class=7 then 6 275 | else 0 276 | ) 277 | 278 | # 279 | # implicit access here just from the motorroad tag 280 | # (implicit access rules from highway tag handled elsewhere) 281 | # 282 | assign defaultaccess = 283 | if access= 284 | then ( not motorroad=yes ) 285 | else 286 | ( 287 | if access=no 288 | then false 289 | else 290 | ( 291 | if access=private 292 | then false 293 | else true 294 | ) 295 | ) 296 | 297 | # 298 | # calculate logical bike access 299 | # 300 | assign bikeaccess = 301 | or 302 | any_cycleroute 303 | ( 304 | if bicycle= 305 | then 306 | ( 307 | if vehicle= 308 | then defaultaccess 309 | else 310 | ( 311 | if vehicle=private|no 312 | then false 313 | else true 314 | ) 315 | ) 316 | else 317 | ( 318 | if not bicycle=private 319 | then true 320 | else false 321 | ) 322 | ) 323 | 324 | # 325 | # calculate logical foot access 326 | # 327 | assign footaccess = 328 | or bikeaccess 329 | or bicycle=dismount 330 | if foot= 331 | then defaultaccess 332 | else not foot=private|no 333 | 334 | # 335 | # combine to penalty for access 336 | # 337 | assign access_penalty = 338 | if bikeaccess 339 | then 340 | ( 341 | if bicycle=no # bike access granted from above, but check for bicycle=no 342 | then bicycle_no_penalty # access with penalty for bicycle=no 343 | else 344 | ( 345 | if bicycle=dismount # bike access granted from above, but check for bicycle=dismount 346 | then ( multiply 0.2 bicycle_no_penalty ) # access with penalty for bicycle=dismount 347 | else 0 348 | ) 349 | ) # full bike access 350 | else 351 | ( 352 | if ( or access=private or bicycle=private or vehicle=private foot=private ) 353 | then private_penalty # access with penalty for private 354 | else 100000 # absolutely no access 355 | ) 356 | 357 | assign badoneway = 358 | if reversedirection=yes then 359 | if oneway:bicycle=yes then true 360 | else if oneway= then junction=roundabout 361 | else oneway=yes|true|1 362 | else oneway=-1 363 | 364 | assign onewaypenalty = 365 | if ( badoneway ) then 366 | ( 367 | if oneway:bicycle=no 368 | then 0 369 | else if or highway=cycleway and highway=path bicycle=designated 370 | then 50 371 | else 0.0 372 | ) 373 | else 0.0 374 | 375 | # 376 | # combine additional penaltys which are common for flat, up and down ways 377 | # 378 | assign misc_penalty = 379 | add access_penalty 380 | add traffic_penalty 381 | add onewaypenalty 382 | add if ( not ford= ) then ford_penalty 383 | else 0 384 | add if trail_visibility=bad then 2 385 | else 386 | ( 387 | if trail_visibility=horrible then 5 388 | else 389 | ( 390 | if trail_visibility=no then 15 391 | else 0 392 | ) 393 | ) 394 | add if smoothness=impassable then 10 395 | else 0 396 | max 0 multiply ( sub 1 ( multiply mtb_hard_factor 0.3333 ) ) 397 | add if surfacebadwhenwet then slippery_muddy_penalty 398 | else 0 399 | add if highwaybadwhenwet then slippery_muddy_penalty 400 | else 0 401 | if surface=sand|mud then 3 402 | else 0 403 | 404 | 405 | # 406 | # now assign the parameters for the routing engine (initialcost, turncost and flat/up/down costfactors) 407 | # 408 | assign turncost = 409 | if highway=path|footway 410 | then 411 | ( 412 | if equal inclination -1 then 0 413 | else 10 414 | ) 415 | else 416 | ( 417 | if highway=track then 50 418 | else 150 419 | ) 420 | 421 | # 422 | # assign parameters for turn instruction generation 423 | # 424 | assign priorityclassifier = 425 | if equal voiceprio 1 then 1 426 | else if equal voiceprio 2 427 | then if ( highway=motorway ) then 101 428 | else if ( highway=motorway_link ) then 100 429 | else if ( highway=trunk ) then 91 430 | else if ( highway=trunk_link ) then 90 431 | else if ( highway=primary ) then 88 432 | else if ( highway=primary_link ) then 87 433 | else if ( highway=secondary ) then 86 434 | else if ( highway=secondary_link ) then 85 435 | else if ( highway=tertiary ) then 84 436 | else if ( highway=tertiary_link ) then 83 437 | else if ( highway=unclassified ) then 82 438 | else if ( highway=residential|living_street ) then 50 439 | else if ( highway=service ) then 40 440 | else if ( highway=road ) then 35 441 | else if ( highway=cycleway ) then 30 442 | else if ( highway=bridleway|track ) then 20 443 | else if ( highway=footway|pedestrian ) then 17 444 | else if ( highway=steps ) then 15 445 | else if ( highway=path ) then 10 446 | else 0 447 | else 0 448 | 449 | assign isroundabout = junction=roundabout 450 | assign islinktype = highway=motorway_link|trunk_link|primary_link|secondary_link|tertiary_link 451 | assign isgoodforcars = 452 | if ( greater priorityclassifier 30 ) 453 | then true 454 | else 455 | ( 456 | if highway=residential|living_street|service 457 | then true 458 | else 459 | ( 460 | if ( and highway=track tracktype=grade1 ) 461 | then true 462 | else false 463 | ) 464 | ) 465 | 466 | # ... encoded into a bitmask 467 | 468 | assign classifiermask = add multiply isroundabout 4 469 | add multiply islinktype 8 470 | multiply isgoodforcars 16 471 | 472 | # 473 | # for any change in initialclassifier, initialcost is added once 474 | # 475 | assign initialclassifier = 476 | if route=ferry then classifier_ferry 477 | else classifier_none 478 | 479 | assign initialcost = 480 | if ( equal initialclassifier classifier_ferry ) then ferry_penalty 481 | else 0 482 | 483 | # 484 | # costfactor for flat terrain 485 | # 486 | assign costfactor = 487 | if and highway= not route=ferry then 100000 488 | else 489 | min 9999 490 | add misc_penalty 491 | add if ( and ( equal inclination 1 ) mtb_uh_penalty ) 492 | then 493 | ( 494 | add 495 | mtb_uh_penalty 496 | ( 497 | if consideruphill then uh_difficult_penalty 498 | else 0 499 | ) 500 | ) 501 | else mtb_sac_penalty 502 | add tracktype_penalty 503 | max 1 504 | if hw_penalty then hw_penalty 505 | else if hw_major_penalty then hw_major_penalty 506 | else if hw_minor_penalty then hw_minor_penalty 507 | 508 | else if highway=path then 1 509 | else if highway=steps 510 | then 511 | ( 512 | if equal inclination 1 then steps_uh_penalty 513 | else 514 | ( 515 | if equal inclination -1 then steps_dh_penalty 516 | else 517 | ( 518 | if reversedirection=yes then steps_dh_penalty 519 | else steps_uh_penalty 520 | ) 521 | ) 522 | ) 523 | else if highway=track|bridleway then 1 524 | else if highway=cycleway then max 1 ( add 1.1 ( multiply mtb_hard_factor 0.1 ) ) 525 | else if route=ferry then 1 # ferries are handled through initialcost, so no need to add cosfactory here 526 | else 40 # default for any other highway type not handled above 527 | 528 | # 529 | # costfactor for uphills 530 | # 531 | assign uphillcostfactor = 532 | if consideruphill 533 | then 534 | ( 535 | if and highway= not route=ferry then 100000 536 | else 537 | min 9999 538 | add misc_penalty 539 | add if ( and ( equal inclination 1 ) mtb_uh_penalty ) 540 | then add uh_difficult_penalty mtb_uh_penalty 541 | else 542 | ( 543 | if mtb_sac_penalty then add uh_difficult_penalty mtb_sac_penalty 544 | else 0 545 | ) 546 | add if tracktype_penalty then add uh_difficult_penalty tracktype_penalty 547 | else 0 548 | max 1 549 | if hw_penalty then hw_penalty 550 | else if hw_major_penalty then multiply penalty_reduce hw_major_penalty 551 | else if hw_minor_penalty then hw_minor_penalty 552 | 553 | else if highway=path then uh_penalty 554 | else if highway=steps # first try to use incline 555 | then if equal inclination 1 then steps_uh_penalty 556 | else if equal inclination -1 then steps_dh_penalty 557 | else steps_uh_penalty # no incline tag, assume step is really uphill 558 | else if highway=track then 1 559 | else if highway=bridleway then 1.2 560 | else if highway=cycleway then 1 561 | else if route=ferry then 1 # ferries are handled through initialcost, so no need to add cosfactory here 562 | else 40 # default for any other highway type not handled above 563 | ) 564 | else 0 # no special handling for uphill selected, flat costfactor will be used instead 565 | 566 | # 567 | # costfactor for downhills 568 | # 569 | assign downhillcostfactor = 570 | if considerdownhill 571 | then 572 | ( 573 | if and highway= not route=ferry then 100000 574 | else 575 | min 9999 576 | add misc_penalty 577 | add if ( and ( equal inclination 1 ) mtb_uh_penalty ) 578 | then 579 | ( 580 | add if consideruphill then uh_difficult_penalty 581 | else 0 582 | mtb_uh_penalty 583 | ) 584 | else 585 | ( 586 | if mtb_sac_penalty then add dh_difficult_penalty mtb_sac_penalty 587 | else 0 588 | ) 589 | add if tracktype_penalty then add dh_difficult_penalty tracktype_penalty 590 | else 0 591 | max 1 592 | if hw_penalty then add dh_penalty hw_penalty 593 | else if hw_major_penalty then add dh_penalty hw_major_penalty 594 | else if hw_minor_penalty then add dh_penalty hw_minor_penalty 595 | 596 | else if highway=path then 1 597 | else if highway=steps # first try to use incline 598 | then if equal inclination 1 then steps_uh_penalty 599 | else if equal inclination -1 then steps_dh_penalty 600 | else steps_dh_penalty # no incline tag, assume step is really downhill 601 | else if highway=track|bridleway 602 | then if dh_use_tracks then dh_track_penalty 603 | else dh_penalty 604 | else if highway=cycleway then add dh_penalty 0.5 605 | else if route=ferry then 1 # ferries are handled through initialcost, so no need to add cosfactory here 606 | else 40 # default for any other highway type not handled above 607 | ) 608 | else 0 # no special handling for downhill selected, flat costfactor will be used instead 609 | 610 | ---context:node # following code refers to node tags 611 | 612 | assign defaultaccess = 613 | if access= 614 | then 615 | ( 616 | if and barrier=gate use_uncertain_gates then true 617 | else if barrier=gate|fence|door|wall then false 618 | else true 619 | ) 620 | else 621 | ( 622 | if access=private|no 623 | then false 624 | else true 625 | ) 626 | 627 | assign bikeaccess = 628 | or nodeaccessgranted=yes 629 | if bicycle= 630 | then 631 | ( 632 | if vehicle= then defaultaccess 633 | else 634 | ( 635 | if vehicle=private|no then false 636 | else true 637 | ) 638 | ) 639 | else 640 | ( 641 | if bicycle=private|no|dismount then false 642 | else true 643 | ) 644 | 645 | assign footaccess = 646 | or bicycle=dismount 647 | if foot= then defaultaccess 648 | else if foot=private|no then false 649 | else true 650 | 651 | assign initialcost = 652 | add if highway=traffic_signals then 100 653 | else 0 654 | if ( and ( or bikeaccess footaccess ) ( not highway=elevator ) ) 655 | then 656 | ( 657 | if ( or ( not ford= ) highway=ford ) then ( multiply 100 ford_penalty ) 658 | else 0 659 | ) 660 | # switch or access=private 661 | # or bicycle=private 662 | # or vehicle=private 663 | # foot=private 664 | # multiply 100 private_penalty # access with penalty 665 | else 1000000 666 | --------------------------------------------------------------------------------