You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
highway=residential without bicycle infrastructure preferred over one with infrastructure #3219
We currently have residential in preferHighwayTags, which we assign priority PREFER. But when adding the cycleway=lane it gets assigned with SLIGHT_PREFER only.
As a quickfix we could also reduce the preferHighwayTags. But what is the best fix for this problem?
changed the title [-]highway=residential without bicycle infrastructure preferred over on with infrastructure[/-][+]highway=residential without bicycle infrastructure preferred over one with infrastructure[/+]on Oct 24, 2025
Hm, tricky to say. This looks to be again due to the complexity of the priority parser, which I would prefer to reduce. We could use the same approach I took for #3226 and slightly move out a few things into the custom model. A cycleway encoded value (or just boolean bike_designated?) would be helpful anyway.
A new encoded value would be nice, yes. Although it might be a bit tricky, but haven't looked into it yet.
Generally I also agree that the priority parser is too complex.
A few steps are already done and future change I will try is inside #3227. Further steps will hopefully also fix a few of the open issues for bike and e.g. remove at least a few bike priority parsers so that maybe just one BikePriorityParser is left (currently we have 4)
Shoudn't we handle highway=residential more like we handle highway=tertiary? (see #3015)
The tag highway=residential often (not always!) means less traffic, but at least in Germany you often have lots of parked cars on the side which speaks more for UNCHANGED=1.0 than 1.2. For example I don't think that it is the same like highway=path, bicycle=designated and foot=yes where we currently use PREFER.
(And as we are at it we should also use UNCHANGED=1.0 for highway=unclassified, highway=service and highway=road. At least there should be no such difference with 1.2 for unclassified and 1.0 for tertiary. Changing highway=residential to UNCHANGED will also remove the difference to racingbike, which I'd prefer. All the mentioned highway values will be automatically "preferred" as the other highway values get a penalty and we could probably remove preferHighwayTags.)
This is hard to decide. I would like to keep the little different handling for racingbike.
An alternative would be that we reduce the priority for those highway types we have in the preferHighwayTags list from currently 1.2 (PREFER) to 1.1 and add 0.1 if such a segment is equipped with any kind of bicycle infrastructure. I think that this would solve the problem of this issue for the ordinary bicycle profile, MTB and should not have negative impacts on racingbike. Anyway, for the racingbike profile I would like to test a couple of real world scenarios before applying this change to master.
I thought that you wanted to apply it for racing bike as well because at another location you mentioned the goal to have a solution which works for all profiles, and this is what my proposal tries to achieve. The only difference for racingbike would be the different highway types assigned to preferHighwayTags.
Sorry, I didn't answer your question. For racingbike we don't have the problem for highway=residential, but for tertiary.
The following racingbike test currently passes:
I mean. If the idea is that bike infrastructure trumps the highway tag (which makes sense), and we think that no street gets worse by putting a bike lane on it (which we do), then no regular highway=* tag can be assigned a better rating than any cycleway=* can replace it with, right?
That seems to be almost logically necessary and independent of what we do afterwards. So either highway=residential and friends get downgraded from PREFER to SLIGHT_PREFER and/or cycleway=lane gets upgraded from SLIGHT_PREFER to PREFER?
And that's it?
And that consistency check goes in a test so that we don't forget about it when someone retunes the weights?
The only highway preference that's positive is PREFER (1.2). The only cycleway preference below that is the lane/shared_lane/etc group at SLIGHT_PREFER (1.1). So the fix is straightforward: bump that group from SLIGHT_PREFER to PREFER.
That would mean cycleway=lane and cycleway=track both get PREFER (1.2), losing the distinction between them. If we want to preserve that ranking, we'd bump both:
track → VERY_NICE (1.3)
lane etc → PREFER (1.2)
This has a nice side effect: cycleway=track on any road would then match a standalone highway=cycleway with mixed foot traffic (also VERY_NICE/PREFER), which is arguably more correct than the current gap.
Option 1: Only bump cycleway values (track → VERY_NICE 1.3, lane → PREFER 1.2)
Fixes the downgrade bug, but residential + cycleway=lane would score the same as plain residential (both PREFER 1.2). Adding a bike lane to a residential street would be invisible to the router.
This is what the simplify_tmp branch did. cycleway=lane (1.1) and cycleway=track (1.2) are both correctly above the base road (1.0). But the gap between cycleway=track (1.2) and standalone highway=cycleway (1.3) remains, penalizing identical infrastructure based on mapping style.
Option 3: Both
Scenario
Current
Option 3
residential alone
1.2
1.0
residential + cycleway=lane
1.1 (!)
1.2
residential + cycleway=track
1.2
1.3
secondary alone
0.8
0.8
secondary + cycleway=lane
1.1
1.2
secondary + cycleway=track
1.2
1.3
standalone highway=cycleway
1.3
1.3
Option 3 seems like the right answer:
The positive highway preference conflates "not dangerous" with "good for cycling". A residential street isn't good cycling infrastructure — it's just the absence of heavy traffic. The avoided highway tags (secondary, primary, trunk) already penalize dangerous roads. Making residential the baseline rather than a bonus is more honest.
The maxspeed ≤ 30 check already covers the "calm street" case. Residential streets in zone-30 areas still get PREFER from that rule regardless. Removing residential from preferHighwayTags only affects residential streets without a low speed limit — i.e. ones where traffic is potentially faster, and the preference was arguably undeserved anyway.
Sorry for the slop but I think he's right. Should we just do it?
I think this would amount to just owning up to the consequences of what we currently have, and show that we understand it. Then we can see about simplification or new features another time.
@ratrun What makes a racing_bike by the way? Does it mean "I don't get as much utility from dedicated bike lanes, perhaps because I'm not necessarily going to use them every time"?
Because the current (regular) bike model if I'm reading it correctly basically says "I'm definitely using the bike lane, so my experience depends almost entirely on the bike lane if one exists."
By means of that "weight" thing (not to be confused with priority, and also not with (routing-) weight).
Is that what you were saying even?
If so, then maybe racing_bike really wants to not have cycleway=* stuff dominatehighway=* stuff.
@ratrun What makes a racing_bike by the way? Does it mean "I don't get as much utility from dedicated bike lanes, perhaps because I'm not necessarily going to use them every time"?
The most important requirement for racebike is to never route over unpaved or segments with bad surface. And yes, one oftentimes does not use dedicated bike lanes as the road usually allows higher speeds, especially within urban area. It mostly depends on the amount of traffic and the speed difference compared to the traffic on the road. If the maxspeed is between 30-40 km/h I prefer the road, except for cases with heavy traffic. If the road is steep and you go up then the dedicated bike lanes should be used, if you go down usually the road is better. In rural areas dedicated bike lanes next to highways should only be used in case of highway=primary or highway=secondary, but in case that there is a longer alternative with a lower highway classification next to it then this longer alternative should be used.
Sounds great to me, by which I mean I think it would solve the issue at hand and it makes sense. Though I've not done a careful comparison, or indeed any comparison. ,-)
... if we also downgrade maxspeed=30 to 1.1 (same reason)
Yet another possibility (6): cycleway=lane doesn't buff, but only prevents debuff. Hmm, I kind of like that one:
Scenario
Current
Option 3
Option 4
Option 5
Option 6
residential alone
1.2
1.0
1.0
1.0
1.0
residential + cycleway=lane
1.1 (!)
1.2
1.1
1.0
1.0
residential + cycleway=track
1.2
1.3
1.2
1.2
1.2
secondary alone
0.8
0.8
0.8
0.8
0.8
secondary + cycleway=lane
1.1
1.2
1.1
0.8
1.0
secondary + cycleway=track
1.2
1.3
1.2
1.2
1.2
standalone highway=cycleway
1.3
1.3
1.2
1.2
1.2
maxspeed<=30 alone
1.2
1.2
1.1
1.2
1.2
I think that one (6) would make the math (much) nicer, because then we could write it (that part of the formula) like
rating = max(highway rating, cycleway rating) (which is not what we currently have)
with
cycleway
maxspeed <= 30
other residential
other secondary
highway rating
1.2
1.2
1.0
0.8
none
cycleway = lane
cycleway = track
cycleway rating
0.0
1.0
1.2
And then those values could be anything they want again and wouldn't make (this kind of) trouble. 0.8, 1.0, 1.1, 1.2, 1.3, doesn't matter.
Read as "this is how I like the highway part, this is how I like the cycleway part, I'll be using the one I like more". Perhaps not too bad for adapting to racing bike / mtb either.
Actually if we just use that new formula on the current parameters, no number from the "current" column would change except the one with the exclamation mark, and the immediate problem would be gone, too. (In case we want to make the numerical change as small as possible in this ticket).
Yet another possibility (6): cycleway=lane doesn't buff, but only prevents debuff.
This is really interesting option as I also thought how to avoid the IMO too strong boost of secondary+lane without introducing yet another code path. Do you have already some code where you implemented this?
I will try to implement something like this and try this out on a real world examples and compare this with the Option 4 (#3336).
Do you have already some code where you implemented this?
I think it doesn't require new code, just putting in the numbers in the column. "cycleway=lane doesn't buff, but only prevents debuff" is just interpretation, not a new mechanics.
Because with those parameters, we could then change the formula to them max construction and it would be the same result.
And from there we could then change the parameters any way we want and the bug wouldn't come back.
Activity
[-]highway=residential without bicycle infrastructure preferred over on with infrastructure[/-][+]highway=residential without bicycle infrastructure preferred over one with infrastructure[/+]ratrun commentedon Nov 5, 2025
@karussell: I would like to get started with this. Do we need to apply the quickfix or do you have a better idea?
karussell commentedon Nov 10, 2025
Hm, tricky to say. This looks to be again due to the complexity of the priority parser, which I would prefer to reduce. We could use the same approach I took for #3226 and slightly move out a few things into the custom model. A cycleway encoded value (or just
boolean bike_designated?) would be helpful anyway.wltrr commentedon Nov 28, 2025
I think having a separate encoded value + parser to parse cycleway would be a great addition. I can also work on it if desired.
Generally I also agree that the priority parser is too complex. Moving more logic to
bike.jsonwould be more transparent and accessible in my opinion.karussell commentedon Nov 28, 2025
A new encoded value would be nice, yes. Although it might be a bit tricky, but haven't looked into it yet.
A few steps are already done and future change I will try is inside #3227. Further steps will hopefully also fix a few of the open issues for bike and e.g. remove at least a few bike priority parsers so that maybe just one BikePriorityParser is left (currently we have 4)
karussell commentedon Dec 7, 2025
Shoudn't we handle
highway=residentialmore like we handlehighway=tertiary? (see #3015)The tag
highway=residentialoften (not always!) means less traffic, but at least in Germany you often have lots of parked cars on the side which speaks more for UNCHANGED=1.0 than 1.2. For example I don't think that it is the same likehighway=path,bicycle=designatedandfoot=yeswhere we currently use PREFER.(And as we are at it we should also use UNCHANGED=1.0 for
highway=unclassified,highway=serviceandhighway=road. At least there should be no such difference with 1.2 forunclassifiedand 1.0 fortertiary. Changing highway=residential to UNCHANGED will also remove the difference to racingbike, which I'd prefer. All the mentioned highway values will be automatically "preferred" as the other highway values get a penalty and we could probably removepreferHighwayTags.)ratrun commentedon Dec 8, 2025
This is hard to decide. I would like to keep the little different handling for
racingbike.An alternative would be that we reduce the priority for those highway types we have in the
preferHighwayTagslist from currently 1.2 (PREFER) to 1.1 and add 0.1 if such a segment is equipped with any kind of bicycle infrastructure. I think that this would solve the problem of this issue for the ordinary bicycle profile, MTB and should not have negative impacts on racingbike. Anyway, for the racingbike profile I would like to test a couple of real world scenarios before applying this change to master.karussell commentedon Dec 8, 2025
Is racingbike affected of this too? The change I meant I proposed only for mtb and bike.
ratrun commentedon Dec 8, 2025
I thought that you wanted to apply it for racing bike as well because at another location you mentioned the goal to have a solution which works for all profiles, and this is what my proposal tries to achieve. The only difference for racingbike would be the different highway types assigned to preferHighwayTags.
ratrun commentedon Dec 8, 2025
Sorry, I didn't answer your question. For racingbike we don't have the problem for highway=residential, but for tertiary.
The following racingbike test currently passes:
residential, unclassified and more are UNCHANGED (#3219, #3015)
michaz commentedon Mar 30, 2026
I mean. If the idea is that bike infrastructure trumps the
highwaytag (which makes sense), and we think that no street gets worse by putting a bike lane on it (which we do), then no regularhighway=*tag can be assigned a better rating than anycycleway=*can replace it with, right?That seems to be almost logically necessary and independent of what we do afterwards. So either
highway=residentialand friends get downgraded fromPREFERtoSLIGHT_PREFERand/orcycleway=lanegets upgraded fromSLIGHT_PREFERtoPREFER?And that's it?
And that consistency check goes in a test so that we don't forget about it when someone retunes the weights?
michaz commentedon Mar 30, 2026
(In Claude's voice:)
Looking at the current state of the code, here's the full picture of how highway and cycleway preferences interact:
Highway preferences (weight 40d/50d):
Cycleway preferences (weight 100d):
The only highway preference that's positive is PREFER (1.2). The only cycleway preference below that is the lane/shared_lane/etc group at SLIGHT_PREFER (1.1). So the fix is straightforward: bump that group from SLIGHT_PREFER to PREFER.
That would mean
cycleway=laneandcycleway=trackboth get PREFER (1.2), losing the distinction between them. If we want to preserve that ranking, we'd bump both:track→ VERY_NICE (1.3)laneetc → PREFER (1.2)This has a nice side effect:
cycleway=trackon any road would then match a standalonehighway=cyclewaywith mixed foot traffic (also VERY_NICE/PREFER), which is arguably more correct than the current gap.michaz commentedon Mar 30, 2026
There are three options for fixing this:
Option 1: Only bump cycleway values (track → VERY_NICE 1.3, lane → PREFER 1.2)
Fixes the downgrade bug, but residential +
cycleway=lanewould score the same as plain residential (both PREFER 1.2). Adding a bike lane to a residential street would be invisible to the router.Option 2: Only remove positive highway preferences (residential/unclassified/service → UNCHANGED 1.0)
This is what the
simplify_tmpbranch did.cycleway=lane(1.1) andcycleway=track(1.2) are both correctly above the base road (1.0). But the gap betweencycleway=track(1.2) and standalonehighway=cycleway(1.3) remains, penalizing identical infrastructure based on mapping style.Option 3: Both
cycleway=lanecycleway=trackcycleway=lanecycleway=trackhighway=cyclewayOption 3 seems like the right answer:
The positive highway preference conflates "not dangerous" with "good for cycling". A residential street isn't good cycling infrastructure — it's just the absence of heavy traffic. The avoided highway tags (secondary, primary, trunk) already penalize dangerous roads. Making residential the baseline rather than a bonus is more honest.
The maxspeed ≤ 30 check already covers the "calm street" case. Residential streets in zone-30 areas still get PREFER from that rule regardless. Removing residential from
preferHighwayTagsonly affects residential streets without a low speed limit — i.e. ones where traffic is potentially faster, and the preference was arguably undeserved anyway.michaz commentedon Mar 30, 2026
Sorry for the slop but I think he's right. Should we just do it?
I think this would amount to just owning up to the consequences of what we currently have, and show that we understand it. Then we can see about simplification or new features another time.
fix bike priority: cycleway tags no longer downgrade preferred highwa…
michaz commentedon Mar 30, 2026
@ratrun What makes a
racing_bikeby the way? Does it mean "I don't get as much utility from dedicated bike lanes, perhaps because I'm not necessarily going to use them every time"?Because the current (regular) bike model if I'm reading it correctly basically says "I'm definitely using the bike lane, so my experience depends almost entirely on the bike lane if one exists."
By means of that "weight" thing (not to be confused with priority, and also not with (routing-) weight).
Is that what you were saying even?
If so, then maybe
racing_bikereally wants to not havecycleway=*stuff dominatehighway=*stuff.ratrun commentedon Mar 31, 2026
The most important requirement for
racebikeis to never route over unpaved or segments with bad surface. And yes, one oftentimes does not use dedicated bike lanes as the road usually allows higher speeds, especially within urban area. It mostly depends on the amount of traffic and the speed difference compared to the traffic on the road. If themaxspeedis between 30-40 km/h I prefer the road, except for cases with heavy traffic. If the road is steep and you go up then the dedicated bike lanes should be used, if you go down usually the road is better. In rural areas dedicated bike lanes next to highways should only be used in case ofhighway=primaryorhighway=secondary, but in case that there is a longer alternative with a lower highway classification next to it then this longer alternative should be used.ratrun commentedon Apr 4, 2026
Let's first only focus on the bike profile, leaving MTB and racingbike aside until we found a consensus for bike.
I agree with the removal of
service,residential, andunclassifiedfrom thepreferHighwayTags.What about Option 4? It reduces the
cycleway=laneand the standalonehighway=cycleway:michaz commentedon Apr 4, 2026
Sounds great to me, by which I mean I think it would solve the issue at hand and it makes sense. Though I've not done a careful comparison, or indeed any comparison. ,-)
... if we also downgrade
maxspeed=30to 1.1 (same reason)michaz commentedon Apr 4, 2026
Yet another possibility (5): Drop
cycleway=laneentirely as a variable, because honestly who cares about those.michaz commentedon Apr 4, 2026
Yet another possibility (6):
cycleway=lanedoesn't buff, but only prevents debuff. Hmm, I kind of like that one:I think that one (6) would make the math (much) nicer, because then we could write it (that part of the formula) like
rating = max(highway rating, cycleway rating)(which is not what we currently have)with
And then those values could be anything they want again and wouldn't make (this kind of) trouble. 0.8, 1.0, 1.1, 1.2, 1.3, doesn't matter.
Read as "this is how I like the highway part, this is how I like the cycleway part, I'll be using the one I like more". Perhaps not too bad for adapting to racing bike / mtb either.
Actually if we just use that new formula on the current parameters, no number from the "current" column would change except the one with the exclamation mark, and the immediate problem would be gone, too. (In case we want to make the numerical change as small as possible in this ticket).
Fixing graphhopper#3219 for bike, mtb, and racingbike using Option 4 …
karussell commentedon Apr 17, 2026
This is really interesting option as I also thought how to avoid the IMO too strong boost of secondary+lane without introducing yet another code path. Do you have already some code where you implemented this?
I will try to implement something like this and try this out on a real world examples and compare this with the Option 4 (#3336).
michaz commentedon Apr 17, 2026
I think it doesn't require new code, just putting in the numbers in the column. "cycleway=lane doesn't buff, but only prevents debuff" is just interpretation, not a new mechanics.
Because with those parameters, we could then change the formula to them
maxconstruction and it would be the same result.And from there we could then change the parameters any way we want and the bug wouldn't come back.
But no I didn't try it.
Bike: priority "multiplier" instead of "set" for lane (graphhopper#3349)