Skip to content

highway=residential without bicycle infrastructure preferred over one with infrastructure #3219

Closed

Description

@ratrun

See bug description and discussion in forum.

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?

Activity

  1. 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
  2. ratrun commented on Nov 5, 2025

    @ratrun
    ContributorAuthor

    @karussell: I would like to get started with this. Do we need to apply the quickfix or do you have a better idea?

  3. karussell commented on Nov 10, 2025

    @karussell
    Member

    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.

  4. wltrr commented on Nov 28, 2025

    @wltrr
    Contributor

    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.json would be more transparent and accessible in my opinion.

  5. karussell commented on Nov 28, 2025

    @karussell
    Member

    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)

  6. karussell commented on Dec 7, 2025

    @karussell
    Member

    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.)

  7. ratrun commented on Dec 8, 2025

    @ratrun
    ContributorAuthor

    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.

  8. karussell commented on Dec 8, 2025

    @karussell
    Member

    Is racingbike affected of this too? The change I meant I proposed only for mtb and bike.

  9. ratrun commented on Dec 8, 2025

    @ratrun
    ContributorAuthor

    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.

  10. ratrun commented on Dec 8, 2025

    @ratrun
    ContributorAuthor

    Is racingbike affected of this too?

    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:

            osmWay.clearTags();
            osmWay.setTag("highway", "tertiary");
            assertPriority(PREFER, osmWay);
            osmWay.setTag("cycleway", "lane");
            assertPriority(SLIGHT_PREFER, osmWay);
    
  11. michaz commented on Mar 30, 2026

    @michaz
    Member

    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?

  12. michaz commented on Mar 30, 2026

    @michaz
    Member

    (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):

    Highway tag Priority Factor
    service, residential, unclassified PREFER 1.2
    (anything with maxspeed ≤ 30) PREFER 1.2
    secondary, secondary_link, bridleway AVOID 0.8
    primary, primary_link BAD 0.5
    trunk, trunk_link REACH_DESTINATION 0.3
    motorway, motorway_link REACH_DESTINATION 0.3

    Cycleway preferences (weight 100d):

    Cycleway tag Priority Factor
    track PREFER 1.2
    lane, opposite_track, shared_lane, share_busway, shoulder SLIGHT_PREFER 1.1

    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.

  13. michaz commented on Mar 30, 2026

    @michaz
    Member

    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=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.

    Option 2: Only remove positive highway preferences (residential/unclassified/service → UNCHANGED 1.0)

    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:

    1. 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.

    2. 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.

  14. michaz commented on Mar 30, 2026

    @michaz
    Member

    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.

  15. michaz commented on Mar 30, 2026

    @michaz
    Member

    @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 dominate highway=* stuff.

  16. ratrun commented on Mar 31, 2026

    @ratrun
    ContributorAuthor

    @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.

  17. ratrun commented on Apr 4, 2026

    @ratrun
    ContributorAuthor

    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, and unclassified from the preferHighwayTags.

    What about Option 4? It reduces the cycleway=lane and the standalone highway=cycleway:

    Scenario Current Option 3 Option 4
    residential alone 1.2 1.0 1.0
    residential + cycleway=lane 1.1 (!) 1.2 1.1
    residential + cycleway=track 1.2 1.3 1.2
    secondary alone 0.8 0.8 0.8
    secondary + cycleway=lane 1.1 1.2 1.1
    secondary + cycleway=track 1.2 1.3 1.2
    standalone highway=cycleway 1.3 1.3 1.2
  18. michaz commented on Apr 4, 2026

    @michaz
    Member

    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)

    Scenario Current Option 3 Option 4
    residential alone 1.2 1.0 1.0
    residential + cycleway=lane 1.1 (!) 1.2 1.1
    residential + cycleway=track 1.2 1.3 1.2
    secondary alone 0.8 0.8 0.8
    secondary + cycleway=lane 1.1 1.2 1.1
    secondary + cycleway=track 1.2 1.3 1.2
    standalone highway=cycleway 1.3 1.3 1.2
    maxspeed<=30 alone 1.2 1.2 1.1
  19. michaz commented on Apr 4, 2026

    @michaz
    Member

    Yet another possibility (5): Drop cycleway=lane entirely as a variable, because honestly who cares about those.

    Scenario Current Option 3 Option 4 Option 5
    residential alone 1.2 1.0 1.0 1.0
    residential + cycleway=lane 1.1 (!) 1.2 1.1 1.0
    residential + cycleway=track 1.2 1.3 1.2 1.2
    secondary alone 0.8 0.8 0.8 0.8
    secondary + cycleway=lane 1.1 1.2 1.1 0.8
    secondary + cycleway=track 1.2 1.3 1.2 1.2
    standalone highway=cycleway 1.3 1.3 1.2 1.2
    maxspeed<=30 alone 1.2 1.2 1.1 1.2
  20. michaz commented on Apr 4, 2026

    @michaz
    Member

    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).

    cycleway maxspeed <= 30 other residential other secondary
    highway rating 1.3 1.2 1.2 0.8
    none cycleway = lane cycleway = track
    cycleway rating 0.0 1.1 1.2
  21. added a commit that references this issue on Apr 5, 2026
  22. karussell commented on Apr 17, 2026

    @karussell
    Member

    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).

  23. michaz commented on Apr 17, 2026

    @michaz
    Member

    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.

    But no I didn't try it.

  24. added a commit that references this issue on May 12, 2026
    af47701
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions