chairemobilite / transition

Transition is a modern new approach to transit planning. It's a web application to model, simulate and plan public transit and alternative transportation.
http://transition.city
MIT License
20 stars 13 forks source link

accept discouraged access tags for foot/bicycle routing #950

Open kaligrafy opened 1 month ago

kaligrafy commented 1 month ago

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

greenscientist commented 1 month ago

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

greenscientist commented 1 month ago

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

kaligrafy commented 1 month ago

With OSRM actual version: short answer: no

kaligrafy commented 1 month ago

Links added

kaligrafy commented 1 month ago

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

davidmurray commented 1 month ago

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

kaligrafy commented 1 month ago

@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 commented 1 month ago

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 commented 1 month ago

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