# Cycling\_road with preference=shortest is routing through walking paths

**URL:** https://ask.openrouteservice.org/t/cycling-road-with-preference-shortest-is-routing-through-walking-paths/3044
**Category:** directions
**Created:** [August 5, 2021, 1:30pm UTC](https://ask.openrouteservice.org/t/cycling-road-with-preference-shortest-is-routing-through-walking-paths/3044 "2021-08-05T13:30:02Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![abhiank](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@abhiank](https://ask.openrouteservice.org/u/abhiank)
#### Post date: [August 5, 2021, 1:30pm UTC](https://ask.openrouteservice.org/t/cycling-road-with-preference-shortest-is-routing-through-walking-paths/3044/1 "2021-08-05T13:30:02Z")

</div>

Hi,

After some users of my app reported, I looked into it and realised that routes for road bikes are being created though walking/hiking paths. Here is one example which I created on ORS maps -

[https://maps.openrouteservice.org/#/directions/Can%20Gusi,Ribas,CT,Spain/Rue%20Sanilles,Saillagouse,France/data/55,130,32,198,15,97,4,224,38,9,96,59,2,24,5,192,166,6,113,0,184,64,38,0,232,4,96,13,148,129,216,4,224,21,130,129,152,0,97,170,198,0,231,221,128,104,1,98,41,226,197,27,214,47,137,149,122,108,3,113,20,111,148,149,10,20,107,213,106,95,13,70,140,122,242,35,211,126,98,138,122,53,31,191,15,16,92,64,64,0,234,158,4,68,216,114,128,5,229,0,45,174,98,109,174,222,128,128,3,55,128,1,183,69,199,0,4,243,5,10,64,7,48,5,164,14,69,130,177,0,15,66,15,70,135,68,67,0,139,196,192,0,177,128,196,197,65,0,5,242,170,0](https://maps.openrouteservice.org/#/directions/Can%20Gusi,Ribas,CT,Spain/Rue%20Sanilles,Saillagouse,France/data/55,130,32,198,15,97,4,224,38,9,96,59,2,24,5,192,166,6,113,0,184,64,38,0,232,4,96,13,148,129,216,4,224,21,130,129,152,0,97,170,198,0,231,221,128,104,1,98,41,226,197,27,214,47,137,149,122,108,3,113,20,111,148,149,10,20,107,213,106,95,13,70,140,122,242,35,211,126,98,138,122,53,31,191,15,16,92,64,64,0,234,158,4,68,216,114,128,5,229,0,45,174,98,109,174,222,128,128,3,55,128,1,183,69,199,0,4,243,5,10,64,7,48,5,164,14,69,130,177,0,15,66,15,70,135,68,67,0,139,196,192,0,177,128,196,197,65,0,5,242,170,0)

The problem also seems to be happening with (mode=cycling-regular, preference=recommended). However, for (mode=cycling\_road, preference=recommended), this is not happening as far as I’m seeing.

Is this a bug in the routing engine or in the passed parameters?

Thanks.

---

<div class="post-metadata">

### Author: ![amandus](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/amandus/32/669_2.png) [@amandus](https://ask.openrouteservice.org/u/amandus)
#### Post date: [August 5, 2021, 8:39pm UTC](https://ask.openrouteservice.org/t/cycling-road-with-preference-shortest-is-routing-through-walking-paths/3044/2 "2021-08-05T20:39:57Z")

</div>

Hi @abhiank,

[the footway](https://www.openstreetmap.org/way/306570990) is tagged with `bicycle:yes` which indicates, that bicycle usage is allowed. `cycling_road` has higher priority for smooth surfaces and normal roads, which is why it will prefer them over the `footway` with `surface:earth`

Best regards

---

<div class="post-metadata">

### Author: ![abhiank](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@abhiank](https://ask.openrouteservice.org/u/abhiank)
#### Post date: [August 18, 2021, 5:28am UTC](https://ask.openrouteservice.org/t/cycling-road-with-preference-shortest-is-routing-through-walking-paths/3044/3 "2021-08-18T05:28:57Z")

</div>

Hi @amandus ,

Apologies for the late reply. Regarding the issue, shouldn’t `footways` with `surface:earth` be completely avoided for road bikes? Unless a road bike is fitted for gravel riding, such a pathway seems completely unsuitable for road bike riding with thin tyres and low traction.

Also, on the same route, should’t [this path](https://www.openstreetmap.org/way/516999311#map=16/42.3193/2.1528) be avoided since the surface value is unknown? I had assumed that for road bikes only paved surfaces are used - is that not true?

Best Regards,  
Abhimanyu

---

<div class="post-metadata">

### Author: ![amandus](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/amandus/32/669_2.png) [@amandus](https://ask.openrouteservice.org/u/amandus)
#### Post date: [August 18, 2021, 1:21pm UTC](https://ask.openrouteservice.org/t/cycling-road-with-preference-shortest-is-routing-through-walking-paths/3044/4 "2021-08-18T13:21:14Z")

</div>

@abhiank

take a look at the [road bike flagencoder](https://github.com/GIScience/openrouteservice/blob/104371bb60298f90641908a1d11e3e6a6325eace/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/RoadBikeFlagEncoder.java#L105)

`surface:earth` will receive a really low speed (2km/h) and is therefor usually avoided except a detour would go a really long way around.

For the path you mentioned it seems the value for `highway: path` is used which is 10 km/h.  
If you have improvement suggestions, please also open an issue in the backend repo.

Best regards

---

<div class="post-metadata">

### Author: ![abhiank](https://ask.openrouteservice.org/letter_avatar_proxy/v4/letter/a/a587f6/32.png) [@abhiank](https://ask.openrouteservice.org/u/abhiank)
#### Post date: [August 21, 2021, 5:43pm UTC](https://ask.openrouteservice.org/t/cycling-road-with-preference-shortest-is-routing-through-walking-paths/3044/5 "2021-08-21T17:43:19Z")

</div>

Hi @amandus

I went through the RoadBikeFlagEncoder and tried to understand what the code was trying to do but I didn’t understand much. I also went though this documentation - [Travel Speeds - openrouteservice documentation](https://giscience.github.io/openrouteservice/documentation/travel-speeds/Travel-Speeds.html)

Can you tell me how the speed of different waytypes factor into the algorithm to choose a certain route? I tried to look for more info on how ORS worked internally but couldn’t find much.

Also, is there a way I can set such that paths with surface earth be avoided for road bikes in the current API?

Thanks,  
Abhimanyu

---

<div class="post-metadata">

### Author: ![amandus](https://ask.openrouteservice.org/user_avatar/ask.openrouteservice.org/amandus/32/669_2.png) [@amandus](https://ask.openrouteservice.org/u/amandus)
#### Post date: [August 23, 2021, 12:05pm UTC](https://ask.openrouteservice.org/t/cycling-road-with-preference-shortest-is-routing-through-walking-paths/3044/6 "2021-08-23T12:05:53Z")

</div>

Hi @abhiank,

> [@abhiank](#):
>
> Also, is there a way I can set such that paths with surface earth be avoided for road bikes in the current API?

This is not possible with the current API.

> [@abhiank](#):
>
> Can you tell me how the speed of different waytypes factor into the algorithm to choose a certain route?

The speeds set in the flagencoders transfer rather directly into weightings on the graph. There are however some further priority settings in the collect function of both the [RoadBikeFlagEncoder](https://github.com/GIScience/openrouteservice/blob/104371bb60298f90641908a1d11e3e6a6325eace/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/RoadBikeFlagEncoder.java#L217) and the [CommonBikeFlagEncoder](https://github.com/GIScience/openrouteservice/blob/master/openrouteservice/src/main/java/org/heigit/ors/routing/graphhopper/extensions/flagencoders/bike/CommonBikeFlagEncoder.java#L664), which can in- or decrease the used weighting.

Best regards
