Project-OSRM / osrm-backend

Open Source Routing Machine - C++ backend
http://map.project-osrm.org
BSD 2-Clause "Simplified" License
6.25k stars 3.3k forks source link

Improving the `cyclability` weight in bike profiles II #5029

Closed chaupow closed 1 week ago

chaupow commented 6 years ago

Moving conversation from here

btw, profile I use is at https://github.com/FreemapSlovakia/freemap-routing/blob/master/oma-bicycle.lua

I check also for:

  • number of lanes (more lanes -> less safe)
  • whether buses pass that road -> less safe
  • wide segregated footways/paths/pedestrian -> safe and cyclable
  • (and elevation)

Copying the relevant part of code in here:

lanes and car speed

local lanes = way:get_value_by_key("lanes")
  if result.forward_speed > 0 then
    -- convert from km/h to m/s
    result.forward_rate = result.forward_speed / 3.6;
    if tonumber(maxspeed) >= 60 or tonumber(lanes) and tonumber(lanes) >= 2 or public_transport_ways[way:id()] then
      result.forward_rate = result.forward_rate * 0.5 end
    if profile.unsafe_highway[data.highway] then
      result.forward_rate = result.forward_rate * profile.unsafe_highway[data.highway]
    end
  end
  if result.backward_speed > 0 then
    -- convert from km/h to m/s
    result.backward_rate = result.backward_speed / 3.6;
    if tonumber(maxspeed) >= 60 or tonumber(lanes) and tonumber(lanes) >= 2 or public_transport_ways[way:id()] then
      result.backward_rate = result.backward_rate * 0.5; end
    if profile.unsafe_highway[data.highway] then
      result.backward_rate = result.backward_rate * profile.unsafe_highway[data.highway]
    end
  end

segregated

  if way:get_value_by_key("segregated") == "yes" and bicycle and profile.access_tag_whitelist[bicycle] then
    result.forward_speed = default_speed
    result.backward_speed = default_speed
    result.forward_mode = mode.cycling
    result.backward_mode = mode.cycling
  end
 if data.highway == 'cycleway' then 
    if way:get_value_by_key("segregated") == "no" then
     result.forward_rate = result.forward_rate*1.2
     result.backward_rate = result.backward_rate*1.2
    else
      result.forward_rate = result.forward_rate*1.4
      result.backward_rate = result.backward_rate*1.4
    end
  end
MichalPP commented 6 years ago

penalize ways with public transport (like buses) running on them (and really penalize highspeed or multilane roads)

if tonumber(maxspeed) >= 60
 or tonumber(lanes) and tonumber(lanes) >= 2 
 or public_transport_ways[way:id()] 
  then
    result.backward_rate = result.backward_rate * 0.5;
end

currently public_transport_ways is an array (produced from postgis in a very ugly way) but I will rewrite it to using function https://github.com/FreemapSlovakia/freemap-routing/blob/master/handlers.lua#L4 similarly to https://github.com/FreemapSlovakia/freemap-routing/blob/master/oma-bus.lua#L46

chaupow commented 6 years ago

oh I see thanks @MichalPP could we also use the cycleway tag share_busway or is that something different?

MichalPP commented 6 years ago

no, it's when a way is a part of public transport relation. General idea is that it is rather inconvenient/scary with a lot of huge buses around your bicycle.

I've created #5032 which solves a better purpose, but technically it is the same.

emiltin commented 6 years ago

I'm a bit worried that penalizing streets with busses will lead to strange detours. Ina city like Copenhagen, the main routes for busses and bike are typically on the same street. This is not considered unsafe.

chaupow commented 6 years ago

Interesting. In Berlin buses are scary because you'd have to overtake them from the left when they are stopping and sometimes they'd just start moving without checking for bikes. But your point sounds reasonable.

emiltin commented 6 years ago

Right. In Copenhagen there are bike lanes on all streets with significant bike traffic, so you pass on the right side of stopped busses. Example: https://www.google.dk/maps/@55.6626119,12.6023853,3a,75y,260.71h,79.51t/data=!3m6!1e1!3m4!1suiUvBO7RF-VjZkEczql9XQ!2e0!7i13312!8i6656.

chaupow commented 6 years ago

In Copenhagen there are bike lanes on all streets with significant bike traffic, so you pass on the right side of stopped busses.

This is awesome. One of the reasons why Copenhagen is just ❤️ ...

Ok. feels like penalizing shared_bus roads unconditionally doesn't make sense on a global scale 😞

github-actions[bot] commented 1 month ago

This issue seems to be stale. It will be closed in 30 days if no further activity occurs.