osrm-backend icon indicating copy to clipboard operation
osrm-backend copied to clipboard

Weighted conditions for profiles

Open karlis-i opened this issue 3 years ago • 0 comments

Hey,

I'm trying to create a profile for emergency vehicles, that would allow driving the wrong way on one-way roads, make restricted turns etc. I have problems making these conditions weighted: going the wrong way or making a restricted turn should be possible, but carry more weight. I'm trying to do this by adding tags to OSM data and then processing these tags in my emergency.lua profile file.

For example, I'd add a tag <tag k="oneway" v="yes"/> to known one way roads in OSM file. In my lib/way_handlers.lua file, function WayHandlers.weights() I'd try adding weight to all roads with this tag:

local is_oneway = way:get_value_by_key('oneway')
if is_oneway == 'yes' then
    result.forward_rate = 1
    result.backward_rate = 5
end

I have tried changing various attributes of result object, like result.backward_speed, result.backward_restricted, also just returning false, but nothing works, Lua seems to completely miss the tags I've added, or make no change on the weights.

I have managed to turn off one way and restricted turn processing for this profile by setting oneway_handling = false and use_turn_restrictions = false in emergency.lua profile, but in this case driving the wrong way and making restricted turns does not have any additional weight compared to regular roads and turns.

What am I doing wrong and/or how should I go about enabling one way roads and restricted turns, but increasing their weight for an emergency profile?

My OSRM version: v5.25.0

karlis-i avatar Jan 26 '22 13:01 karlis-i