Skip to content

car profile use lane_markings=no as indicator for narrow street #6712

@flohoff

Description

@flohoff

Hi,
i use OSRM for Routing quality assurance in a part of Germany since 2013. I typically find unwanted Rat Race roads and changes in routing over time done by accident e.g. broken turn restrictions, deleted segments etc.

I typically tune the relative weight between roads by tagging maxspeed and lanes. E.g. the smaller rural roads get lane count 1 if they are to narrow for overtaking.

In the end this is not a 100% correct as most of the time there are no lane markings so noone could actualy count the lanes. Still they are narrow.

The OSRM car profile uses the lane count to reduce the assumed speed by half based on maxspeed or road type.

I would suggest doing something similiar when looking at the tag/value lane_markings=no

I'd like to reduce the speed not to 0.5 but something like 0.75 - just a smaller penalty.

Something like this. Just tested on real live data with ~50k routes and compared them with their originals and this looks pretty promising. Of 50K routes ~400 have changed. Most of them to the better e.g. avoiding small narrow roads for through traffic.

diff --git a/profiles/lib/way_handlers.lua b/profiles/lib/way_handlers.lua
index b13410235..5c3528d5d 100644
--- a/profiles/lib/way_handlers.lua
+++ b/profiles/lib/way_handlers.lua
@@ -397,6 +397,11 @@ function WayHandlers.penalties(profile,way,result,data)
   local is_bidirectional = result.forward_mode ~= mode.inaccessible and
                            result.backward_mode ~= mode.inaccessible
 
+  local lanemarkings = way:get_value_by_key("lane_markings")
+  if (lanemarkings and lanemarkings == 'no' and is_bidirectional) then
+    width_penalty = 0.75
+  end
+
   if width <= 3 or (lanes <= 1 and is_bidirectional) then
     width_penalty = 0.5
   end

Flo

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions