U-turn Occurring despite No U-turn

Hi

Looking for advice, I am adding custom no u-turn restrictions to my mapping data and it seems they are not always honoured, would anyone know what could be the issue.

In the below Image it is allowing a u-turn from the red segment to the purple segment via the pink segment.

I have added the following restriction into my OSM data

<relation>
    <tag k="type" v="restriction"></tag>
    <tag k="restriction" v="no_u_turn"></tag>
    <member type="way" ref="740787" role="from"></member> // Red
    <member type="way" ref="721561" role="via"></member> // Pink
    <member type="way" ref="48042" role="to"></member> // Purple
  </relation>

However it does not seem to honour this even when I have the following routing config

    var truckProfile = Profile("truck").setCustomModel(model)
    truckProfile.turnCostsConfig = TurnCostsConfig().apply {
        uTurnCosts = TurnCostsConfig.INFINITE_U_TURN_COSTS
        vehicleTypes = listOf("hgv", "motorcar", "motor_vehicle")
    }

Any advice would be much appreciated,

Does it need a vehicle type on the OSM restriction

Regards

Try restriction=no_right_turn.

The uTurnCosts in the configuration are applied to ‘direct’ u-turns: When the “from” and “to” edges are identical.

No, unless you want to limit the types of vehicles the restriction should be applied to.

Hi @easbar

Thank you so much for the quick response, would I need to update anything in my profile for the no-right-turn to be enforced?

May I ask the difference between what I am doing here and what you advised me over here: Turn cost on via road - #4 by easbar ?

Also on this subject, does graphopper respect multiple via ways?

i.e. no u-turn (or I guess right turn) from A → D via C and B?

Kind Regards

Sorry, restriction=no_u_turn should work just as well, I was mistaken. Did you make sure to run the import again after you added the restriction? What you described should work actually. You have to make sure that the member ways like 740787, 721561 and 48042 are split at the junctions though. You can also check the GraphHopper logs, they will tell if some of your restrictions get ignored and for what reason. They should be in logs/osm_warnings.log

I think you are doing what I advised. My best guess why it does not work yet is that you did not split the ways at the junctions (see above).

Yes, but only since last year, so you need a recent version: Handle turn restrictions with multiple via ways and overlapping restrictions by easbar · Pull Request #3030 · graphhopper/graphhopper · GitHub

Thank you @easbar

I have managed to get the logs and there does not seem to be anything jumping out, what do you mean by split them at the junctions?

Regards

Hi @easbar

It seems there is a bug when there are multiple overlapping restrictions on one set of ways, as far as I can tell in these cases it will often just ignore all the restrictions.

For instance in the below image there are two restrictions
No U-turn from Orange onto blue via pink
No right Turn from Red onto green via orange

    <relation id="100011060">
    <tag k="type" v="restriction"></tag>
    <tag k="restriction" v="no_u_turn"></tag>
    <member type="way" ref="1147" role="from"></member> // Orange
    <member type="way" ref="5047" role="via"></member> // Pink
    <member type="way" ref="5050" role="to"></member> // Blue
  </relation>
  
    <relation id="100011843">
    <tag k="type" v="restriction"></tag>
    <tag k="restriction" v="no_right_turn"></tag>
    <member type="way" ref="5065" role="from"></member> // Red
    <member type="way" ref="1147" role="via"></member> // Orange
    <member type="way" ref="1145" role="to"></member> // Green
  </relation>

With those restrictions there it does not respect the no you turn restriction, if I remove the no right turn restriction then it adheres to the no u-turn restriction.

I assume this is not the expected behavior, would you like me to open up a ticket with code an the data to duplicate this behavior?

The member ways of the turn restrictions have to end at the nodes where they meet.

Handling such overlapping restrictions has been a challenge. But as far as I know GraphHopper handles them well. If you found a case where it does not that would be interesting indeed. So yes, a reproducible example would be helpful. Maybe you can create a unit test like this one: graphhopper/core/src/test/java/com/graphhopper/routing/util/parsers/RestrictionSetterTest.java at 58648102f7a572074e206667f2e59dd5321f64c7 · graphhopper/graphhopper · GitHub that shows the problem. But also an (ideally very small) OSM file would be helpful, of course.

Update: A similar problem was encountered recently. This might be the same issue: Overlapping turn restriction is ignored · Issue #3153 · graphhopper/graphhopper · GitHub

Thank you for all the help, I have updated the issue with a failing unit test

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.