Open kaligrafy opened 1 month ago
Is there a way to give a penalty when using this tag?
Can you add a link to the tag documentation in the commit message or in the file?
With OSRM actual version: short answer: no
Links added
Limite de OSRM... Il faut utiliser Valhalla pour de meilleurs résultats pondérés selon nos critères
@kaligrafy il me semble que c'est possible d'ajuster le rate dans les profils Lua selon les tags OSM. Voir cet exemple: https://github.com/Project-OSRM/osrm-backend/issues/4711 Dans ma maitrise j'avais fait une pondération différente selon la classification de tronçon (highway = residential, tertiary, secondary, primary, etc). Est-ce de cela dont on parle ici?
@davidmurray oui c'est exact, mais juste sur le tag highway... Là on est dans le tag foot ou bicycle, qui n'est pas accessible sauf pour les blacklists et whitelists (à ma connaissance), libre à vous de voir si on peut magouiller le profil pour avoir ça
Oui, c'est possible avec la fonction way:get_value_by_key("bicycle")
Voici un exemple (untested!)
function safety_handler(profile, way, result, data)
-- convert duration into cyclability
if profile.properties.weight_name == 'cyclability' then
local safety_penalty = profile.unsafe_highway_list[data.highway] or 1.
local is_unsafe = safety_penalty < 1
-- primaries that are one ways are probably huge primaries where the lanes need to be separated
if is_unsafe and data.highway == 'primary' and not data.is_twoway then
safety_penalty = safety_penalty * 0.5
end
if is_unsafe and data.highway == 'secondary' and not data.is_twoway then
safety_penalty = safety_penalty * 0.6
end
local forward_is_unsafe = is_unsafe and not data.has_cycleway_forward
local backward_is_unsafe = is_unsafe and not data.has_cycleway_backward
local is_undesireable = data.highway == "service" and profile.service_penalties[data.service]
local forward_penalty = 1.
local backward_penalty = 1.
if forward_is_unsafe then
forward_penalty = math.min(forward_penalty, safety_penalty)
end
if backward_is_unsafe then
backward_penalty = math.min(backward_penalty, safety_penalty)
end
if is_undesireable then
forward_penalty = math.min(forward_penalty, profile.service_penalties[data.service])
backward_penalty = math.min(backward_penalty, profile.service_penalties[data.service])
end
+ -- Add penalty for bicycle=discouraged tag
+ local bicycle_tag = way:get_value_by_key("bicycle")
+ if bicycle_tag == "discouraged" then
+ forward_penalty = forward_penalty * 0.5
+ backward_penalty = backward_penalty * 0.5
+ end
if result.forward_speed > 0 then
-- convert from km/h to m/s
result.forward_rate = result.forward_speed / 3.6 * forward_penalty
end
if result.backward_speed > 0 then
-- convert from km/h to m/s
result.backward_rate = result.backward_speed / 3.6 * backward_penalty
end
if result.duration > 0 then
result.weight = result.duration / forward_penalty
end
end
end
On peut créer un nouveau issue séparé pour ça?
discouraged is used to say it is permitted, but could be dangerous, we should accept routing with this tag