Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accept discouraged access tags for foot/bicycle routing #950

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

kaligrafy
Copy link
Collaborator

discouraged is used to say it is permitted, but could be dangerous, we should accept routing with this tag

discouraged is used to say it is permitted, but could be dangerous, we should accept routing with this tag
@greenscientist
Copy link
Collaborator

Is there a way to give a penalty when using this tag?

@greenscientist
Copy link
Collaborator

Can you add a link to the tag documentation in the commit message or in the file?

@kaligrafy
Copy link
Collaborator Author

With OSRM actual version: short answer: no

@kaligrafy
Copy link
Collaborator Author

Links added

Copy link
Collaborator

@tahini tahini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dommage qu'on ne puisse pas mettre de pénalité... Est-ce que ça ne risque pas de faussement donner des "points" au vélo ou à la marche dans nos calculs comparés par mode en faisant marcher/rouler les gens sur des boulevards urbains plein de camions, mais plus directs? Mais si ça encourage à y faire des REV, ce serait pas trop mal...

@kaligrafy
Copy link
Collaborator Author

Limite de OSRM... Il faut utiliser Valhalla pour de meilleurs résultats pondérés selon nos critères

@kaligrafy kaligrafy requested a review from tahini May 21, 2024 13:15
@davidmurray
Copy link
Collaborator

@kaligrafy il me semble que c'est possible d'ajuster le rate dans les profils Lua selon les tags OSM. Voir cet exemple: Project-OSRM/osrm-backend#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?

@kaligrafy
Copy link
Collaborator Author

kaligrafy commented May 21, 2024

@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

@davidmurray
Copy link
Collaborator

davidmurray commented May 21, 2024

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

@kaligrafy
Copy link
Collaborator Author

On peut créer un nouveau issue séparé pour ça?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants