/ gravel.brf
gravel.brf
1 # Modified version of gravel profile with heavier penalties for MTB trails. Not particularly fun during Finnish autumn. 2 # 3 # goal is a long-distance gravel profile to ride on unpaved surfaces; the cost factors are based on certain expectation of the surfaces; 4 # for example, "gravel" is much less preferred than "compacted" or "fine_gravel" since it often means large-sized, sharp edged gravel 5 # found on some forest roads that is hard to ride and may cause punctures. 6 # 7 # if no offread track is suitable it falls back to low traffic paved roads 8 # main adjustments are done via: 9 # - surfacepenalty 10 # - tracktypepenalty 11 # - smoothnesspenalty 12 # - costfactor for highway types 13 14 15 ---context:global # following code refers to global config 16 assign processUnusedTags 1 # set to true if you want to display all tags in the "data" 17 18 # to generate turn instructions, adapt the mode by need 19 20 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] 21 assign turnInstructionRoundabouts = true # %turnInstructionRoundabouts% | Set to "false" to avoid generating special turning instructions for roundabouts | boolean 22 assign turnInstructionCatchingRange = 4 23 assign considerTurnRestrictions true # turn restrictions are considered 24 25 assign validForBikes true 26 assign validForCars false 27 assign validForFoot false 28 29 assign is_wet false 30 31 # +++ Kinematic model parameters (travel time computation) 32 assign totalMass = 87 # %totalMass% | Mass (in kg) of the bike + biker, for travel time computation | number 33 assign maxSpeed = 40 # %maxSpeed% | Absolute maximum speed (in km/h), for travel time computation | number 34 assign S_C_x = 0.75 # %S_C_x% | Drag coefficient times the reference area (in m^2), for travel time computation | number 35 assign C_r = 0.02 # %C_r% | Rolling resistance coefficient (dimensionless), for travel time computation | number 36 assign bikerPower = 170 # %bikerPower% | Average power (in W) provided by the biker, for travel time computation | number 37 38 # Use the following switches to change behaviour 39 # (1=yes, 0=no): 40 41 assign consider_elevation true # %considerElevation% | Activate to apply a penalty for uphills | boolean 42 assign avoid_path false # %avoidPath% | Activate to avoid paths. Sometimes you just don't want to deal with it. | boolean 43 44 # Turn cost definition 45 assign turncostBase = 50 # %turncostBase% | Cost of turning. The larger the cost, the straighter the route, at the cost of other parameters like surface or traffic. 46 47 # the elevation parameters 48 49 assign downhillcost switch consider_elevation 30 0 50 assign downhillcutoff 1.5 51 assign uphillcost switch consider_elevation 100 0 52 assign uphillcutoff 1.5 53 54 assign uh_difficult_penalty 10 55 56 ---context:way # following code refers to way-tags 57 58 # when "cycleway" only on 1 side of the road, use it only if it is on the right side in the direction of travel! 59 assign cycleway_right if reversedirection=yes 60 then if cycleway:left=track|lane then 1 else 0 61 else if cycleway:right=track|lane then 1 else 0 62 63 assign any_cycleway or cycleway=track|lane cycleway_right 64 # as soon it is supported in lookup, add ==> bicycle_road=yes in any_cycleway 65 66 # in relation with "route=bicycle" ? 67 assign any_cycleroute or route_bicycle_icn=yes or route_bicycle_ncn=yes or route_bicycle_rcn=yes route_bicycle_lcn=yes 68 69 assign nodeaccessgranted or any_cycleroute lcn=yes 70 71 assign ispaved or surface=paved surface=asphalt 72 assign isunpaved surface=unpaved|gravel|dirt|earth|ground|sand 73 74 assign isfine_gravel surface=fine_gravel|cobblestone|compacted|paving_stones 75 assign isconcrete surface=concrete 76 77 assign turncost = if junction=roundabout then 0 78 else turncostBase 79 # 80 assign initialclassifier = 81 switch route=ferry 2 1 82 assign initialcost = 83 switch route=ferry 4999 0 84 85 # 86 # get the inclination (up=1, down=-1, unknown=0) 87 # 88 assign inclination = 89 if incline= 90 then 0 91 else if incline=yes|up|5%|8%|10%|15%|20%|25%|30% 92 then if reversedirection=yes 93 then -1 94 else 1 95 else if incline=down|-5%|-8%|-10%|-15%|-20%|-25%|-30% 96 then if reversedirection=yes 97 then 1 98 else -1 99 else 0 100 101 # 102 # implicit access here just from the motorroad tag 103 # (implicit access rules from highway tag handled elsewhere) 104 # 105 assign defaultaccess 106 switch access= 107 not motorroad=yes 108 switch or access=private access=no 109 0 110 1 111 # 112 # calculate logical bike access 113 # 114 assign bikeaccess 115 or any_cycleroute 116 switch bicycle= 117 switch vehicle= 118 defaultaccess 119 switch or vehicle=private vehicle=no 120 0 121 1 122 not or bicycle=private or bicycle=no bicycle=dismount 123 124 # 125 # calculate logical foot access 126 # 127 assign footaccess 128 or bikeaccess 129 or bicycle=dismount 130 switch foot= 131 defaultaccess 132 not or foot=private foot=no 133 134 # 135 # if not bike-, but foot-acess, just a moderate penalty, 136 # otherwise access is forbidden 137 # 138 assign accesspenalty 139 switch bikeaccess 140 0 141 switch footaccess 142 6 143 10000 144 145 # 146 # handle one-ways. On primary roads, wrong-oneways should 147 # be close to forbidden, while on other ways we just add 148 # 6 to the costfactor (making it at least 7 - you are allowed 149 # to push your bike) 150 # 151 assign badoneway = 152 if reversedirection=yes then 153 if oneway:bicycle=yes then true 154 else if oneway= then junction=roundabout 155 else oneway=yes|true|1 156 else oneway=-1 157 158 assign onewaypenalty = 159 if ( badoneway ) then 160 ( 161 if ( cycleway=opposite|opposite_lane|opposite_track ) then 0 162 else if ( oneway:bicycle=no ) then 0 163 else if ( highway=trunk|trunk_link ) then 100 164 else if ( highway=primary|primary_link ) then 80 165 else if ( highway=secondary|secondary_link ) then 50 166 else if ( highway=tertiary|tertiary_link ) then 40 167 else 30 168 ) 169 else 0.0 170 171 assign surfacepenalty 172 switch surface=asphalt|paved 1.5 173 switch concrete=plates 1.5 # Betonplattenwege 174 switch surface=concrete|paving_stones|wood|metal 0.5 # Beton, Pflastersteine (geschnitzt), Holz, Metall 175 switch surface=cobblestone|sett switch smoothness=good|excellent 1 2 # Kopfsteinpflaster 176 # switch surface=unhewn_cobblestone 3 # ungeschnitzter Pflasterstein 177 switch concrete=lanes 1.5 # Betonspurplatten 178 switch surface=fine_gravel|compacted 0 # Splitt,verdichtete Oberflaesche 179 switch surface=grass_paver 0.3 # Rasengittersteine 180 switch surface=pebblestone|unpaved 0.1 # Schotter, Sand, Kies, unbefestigt 181 switch surface=mud 5 182 switch surface=ground|grass|dirt|earth|clay # naturbelassene Oberfl sche, Gras, Schutz Schlamm... 183 switch smoothness=horrible|very_horrible 1.5 184 0.2 185 switch surface=gravel 186 switch smoothness=horrible|very_horrible 2.0 187 0.6 # naturbelassene Oberfl sche, Gras, Schutz Schlamm... 188 switch surface=sand 1.0 # naturbelassene Oberfl sche, Gras, Schutz Schlamm... 189 190 # if "surface" is not defined... 191 switch surface= 192 # then, for Primary, secondary and tertiary asphalt is very probable 193 switch highway=trunk|trunk_link|primary|primary_link|secondary|secondary_link|tertiary|tertiary_link 1.5 194 # then, for residential & Co. probably asphalt 195 switch highway=road|residential|unclassified 1.2 196 # then, for living_street something paved 197 switch highway=living_street 0.3 198 # in some cases only smoothness is tagged but surface not! 199 switch smoothness=intermediate|good|excellent 0.5 200 # else, check if tracktype=grade1, then it is "something" paved, so middle penalty 201 switch tracktype=grade1 0.7 202 switch tracktype=grade2 0.2 203 1.5 204 # surface not known and probably not paved / no asphalt... 205 1.5 206 207 assign excludepenalty 208 switch and railway=razed highway= 100 209 switch not railway= and highway= 20000 # Really. Don't use railways. 210 switch highway= 10 211 0 212 213 assign tracktypepenalty 214 switch tracktype=grade1 0.3 215 switch tracktype=grade2 0 216 switch tracktype=grade3 0.1 217 switch tracktype=grade4 0.1 218 switch tracktype=grade5 0.2 219 # assume unknown tracks are comparable to grade3 220 0.1 221 222 assign trafficpenalty = 223 # if any_cycleway then 0 224 # else 225 if highway=trunk|trunk_link|primary|primary_link then 226 ( 227 if estimated_traffic_class=1|2 then 0 228 else if estimated_traffic_class=3 then 0.4 229 else if estimated_traffic_class=4 then 0.8 230 else if estimated_traffic_class=5 then 1 231 else if estimated_traffic_class=6|7 then 2 232 else 0.6 233 ) 234 else if highway=secondary|secondary_link then 235 ( 236 if estimated_traffic_class=1|2 then 0.1 237 else if estimated_traffic_class=3 then 0.3 238 else if estimated_traffic_class=4 then 0.7 239 else if estimated_traffic_class=5 then 1 240 else if estimated_traffic_class=6|7 then 1.5 241 else 0.2 242 ) 243 else if highway=tertiary|tertiary_link then 244 ( 245 if estimated_traffic_class=1|2 then 0.1 246 else if estimated_traffic_class=3 then 0.2 247 else if estimated_traffic_class=4 then 0.5 248 else if estimated_traffic_class=5|6|7 then 1 249 else 0.1 250 ) 251 else 0 252 253 assign smoothnesspenalty = 254 switch smoothness=excellent 0.9 255 switch smoothness=good 0.8 256 switch smoothness=intermediate 0.0 257 switch smoothness=bad 0.1 258 switch smoothness=very_bad 0.8 259 switch smoothness=horrible 10 260 switch smoothness=impassable 50 261 0 262 263 264 # 265 # additional penalties for other road attributes 266 # 267 assign mtb_sac_penalty = 268 max 0 269 if mtb:scale=1|1+|1- then switch avoid_path 50 8 270 else if mtb:scale=2|2- then 50 271 else if ( or mtb:scale=3|2+ sac_scale=demanding_mountain_hiking ) then 100 272 else if ( or mtb:scale=4 sac_scale=alpine_hiking ) then 500 273 else if ( or mtb:scale=5 sac_scale=demanding_alpine_hiking ) then 1000 274 else if ( or mtb:scale=6 sac_scale=difficult_alpine_hiking ) then 5000 275 else 0 276 277 assign mtb_uh_penalty = 278 max 0 279 if mtb:scale:uphill=3 then 2 280 else if mtb:scale:uphill=4 then 4 281 else if mtb:scale:uphill=5 then 50 282 else if mtb:scale=6 then 100 283 else 0 284 285 assign maxspeedpenalty = 286 switch or highway=primary highway=primary_link 287 # as soon "name" is supported in lookup, replace with "switch maxspeed= switch name= 2.2 1 288 switch maxspeed=50 0.2 289 # switch any_cycleway 0.2 290 switch maxspeed=60 0.7 291 switch maxspeed=70 1.2 292 switch maxspeed=80 2.0 293 switch maxspeed=90 5.0 294 switch maxspeed=100 10 295 switch maxspeed=110 15 296 switch maxspeed=120 20 297 switch maxspeed=130 20 298 switch maxspeed= 2.2 0 299 switch or highway=secondary highway=secondary_link 300 # as soon "name" is supported in lookup, replace with "switch maxspeed= switch name= 0.9 0.2 301 switch maxspeed=50 0.1 302 # switch any_cycleway 0.1 303 switch maxspeed=60 0.2 304 switch maxspeed=70 0.9 305 switch maxspeed=80 1.5 306 switch maxspeed=90 2 307 switch maxspeed=100 10 308 switch maxspeed=110 15 309 switch maxspeed=120 20 310 switch maxspeed=130 20 311 switch maxspeed= 0.9 0 312 switch or highway=tertiary highway=tertiary_link 313 # as soon "name" is supported in lookup, replace with "switch maxspeed= switch name= 0.2 0.1 314 switch maxspeed=50 0 315 switch maxspeed=60 0.1 316 # switch any_cycleway 0.05 317 switch maxspeed=70 0.2 318 switch maxspeed=80 0.2 319 switch maxspeed=90 0.3 320 switch maxspeed=100 8 321 switch maxspeed=110 11 322 switch maxspeed=120 12 323 switch maxspeed=130 13 324 switch maxspeed= 0.2 0 325 0 326 327 # if bicycle=use_sidepath, then try to prefer the (hopefully!) existing sidepath with a penalty on this highway (only if avoid_path is not set) 328 assign usesidepathpenalty = 329 switch bicycle=use_sidepath 0.5 0 330 331 # give a light advantage to highways with a relation cycleroute 332 assign nocycleroute_penalty switch any_cycleroute 0 0.05 333 334 assign not_bicycle_designatedpenalty switch highway=cycleway 0 335 switch bicycle=designated 0 336 0.1 337 338 assign segregated_penalty 339 switch segregated=yes 0 0.1 340 341 assign sum_highwaypenalty 342 add surfacepenalty 343 add tracktypepenalty 344 add trafficpenalty 345 add smoothnesspenalty 346 add maxspeedpenalty 347 add usesidepathpenalty 348 add excludepenalty 349 add nocycleroute_penalty 350 not_bicycle_designatedpenalty 351 352 # penalties differ when a cycleway is associated to the highway with "cycleway=yes" 353 354 assign cycleway_surfacepenalty 355 switch cycleway:surface= surfacepenalty # if not specified, same as highway 356 switch cycleway:surface=asphalt 0 357 switch cycleway:surface=sett 0.3 # behauene Pflastersteine 358 switch cycleway:surface=paved 0.3 # befestigte(harte)Oberflaesche 359 switch cycleway:surface=concrete|paving_stones 0.8 # Beton, Pflastersteine (geschnitzt) 360 switch cycleway:surface=cobblestone|sett 5 # Kopfsteinpflaster 361 switch cycleway:surface=fine_gravel|compacted 2 # Splitt,verdichtete Oberflaesche 362 switch cycleway:surface=gravel 4 # Schotter 363 0 # unknown value... 364 # to be activated after implementation of #241 365 #assign cycleway_smoothnesspenalty 366 # switch cycleway:smoothness= smoothnesspenalty # if not specified, same as highway 367 # switch cycleway:smoothness=intermediate 0.3 368 # switch cycleway:smoothness=bad 1 369 # switch cycleway:smoothness=very_bad 2 370 # switch cycleway:smoothness=horrible 4.5 371 # 0 372 373 # temporary... 374 assign cycleway_smoothnesspenalty smoothnesspenalty # temporray same as highway 375 376 assign sum_cyclewaypenalty 377 add cycleway_surfacepenalty 378 add cycleway_smoothnesspenalty 379 # add usesidepathpenalty 380 add nocycleroute_penalty 381 add not_bicycle_designatedpenalty 382 switch any_cycleway 0 # 0 if cycleway exists 383 10000 # no cycleway 384 385 assign costfactor 386 add min sum_highwaypenalty sum_cyclewaypenalty 387 switch or highway=proposed highway=abandoned 10000 388 min 9999 389 add if ( and ( equal inclination 1 ) mtb_uh_penalty ) then add mtb_uh_penalty uh_difficult_penalty else mtb_sac_penalty 390 add max onewaypenalty accesspenalty 391 add segregated_penalty 392 switch or highway=motorway highway=motorway_link 10000 393 switch or highway=trunk highway=trunk_link 30 394 switch or highway=primary highway=primary_link 2.6 395 switch or highway=secondary highway=secondary_link 2.5 396 switch or highway=tertiary highway=tertiary_link 2.4 397 switch highway=unclassified 1.5 398 switch highway=pedestrian 1.0 399 switch highway=steps 400 switch ramp:stroller=yes 10 401 100 402 switch route=ferry 11 403 switch highway=bridleway 404 switch bicycle=yes|designated 0.6 405 100 406 switch highway=cycleway 0.5 407 switch highway=living_street 1.0 408 switch highway=residential 409 switch bicycle_road=yes 0.8 410 1.2 411 switch highway=service 412 switch bicycle=yes|designated 0.6 413 switch service=alley 1.1 414 switch service=driveway 30 415 3 416 switch highway=track|road 1.0 417 switch highway=path 418 switch bicycle=designated 0.5 # alternative way for combined pedestrian and cycleways 419 switch avoid_path 10 420 1 421 switch highway=footway 422 switch bicycle=yes 1.5 423 50 424 19.9 425 426 # way priorities used for voice hint generation 427 428 assign priorityclassifier = 429 if ( highway=motorway ) then 30 430 else if ( highway=motorway_link ) then 29 431 else if ( highway=trunk ) then 28 432 else if ( highway=trunk_link ) then 27 433 else if ( highway=primary ) then 23 434 else if ( highway=primary_link ) then 23 435 else if ( highway=secondary ) then 22 436 else if ( highway=secondary_link ) then 22 437 else if ( highway=tertiary ) then 21 438 else if ( highway=tertiary_link ) then 21 439 else if ( highway=residential|living_street ) then 15 440 else if ( highway=unclassified ) then 8 441 else if ( highway=service ) then 8 442 else if ( highway=cycleway ) then 8 443 else if ( bicycle=designated ) then 8 444 else if ( highway=track|road|path ) 445 then if or surface=asphalt|paved|concrete|wood|metal tracktype=grade1 then 8 else 6 446 else if ( highway=steps ) then 2 447 else if ( highway=pedestrian ) then 2 448 else 0 449 450 # some more classifying bits used for voice hint generation... 451 452 assign isbadoneway = not equal onewaypenalty 0 453 assign isgoodoneway = if reversedirection=yes then oneway=-1 454 else if oneway= then junction=roundabout else oneway=yes|true|1 455 assign isroundabout = junction=roundabout 456 assign islinktype = highway=motorway_link|trunk_link|primary_link|secondary_link|tertiary_link 457 assign isgoodforcars = if greater priorityclassifier 6 then true 458 else if highway=residential|living_street|service then true 459 else if ( and highway=track tracktype=grade1 ) then true 460 else false 461 462 # ... encoded into a bitmask 463 464 assign classifiermask 465 # add isbadoneway # no voice hint if 1 of the 2 possibilities is badoneway 466 add multiply isgoodoneway 2 467 add multiply isroundabout 4 468 add multiply islinktype 8 469 multiply isgoodforcars 16 470 471 472 ---context:node # following code refers to node tags 473 474 assign defaultaccess 475 switch access= 476 1 # add default barrier restrictions here! 477 switch or access=private access=no 478 0 479 1 480 481 assign bikeaccess 482 or nodeaccessgranted=yes 483 switch bicycle= 484 switch vehicle= 485 defaultaccess 486 switch or vehicle=private vehicle=no 487 0 488 1 489 switch or bicycle=private or bicycle=no bicycle=dismount 490 0 491 1 492 493 assign footaccess 494 or bicycle=dismount 495 switch foot= 496 defaultaccess 497 switch or foot=private foot=no 498 0 499 1 500 501 assign railwaypenalty 502 switch railway= 0 503 25 504 505 # assign signalpenalty switch highway=traffic_signals 99 506 # switch crossing=traffic_signals 49 0 507 # note: in case of a "left-turn" at the traffic-signal the penalty is counted twice... 508 509 assign barrierpenalty 510 switch barrier= 0 511 switch barrier=swing_gate 2 512 switch barrier=gate 50 513 switch barrier=block|bollard 0 514 139 515 516 assign initialcost 517 # add signalpenalty 518 add railwaypenalty 519 add barrierpenalty 520 switch bikeaccess 0 521 switch footaccess 300 522 1000000