diff --git a/features/car/physical_limitation.feature b/features/car/physical_limitation.feature index d65f40a19f0..43eef90f8e0 100644 --- a/features/car/physical_limitation.feature +++ b/features/car/physical_limitation.feature @@ -48,3 +48,22 @@ Feature: Car - Handle physical limitation | primary | | none | x | | primary | | no-sign | x | | primary | | unsigned | x | + + Scenario: Car - Limited by length + Then routability should be + | highway | maxlength | bothw | + | primary | | x | + | primary | 1 | | + | primary | 5 | x | + | primary | unsigned | x | + + Scenario: Car - Limited by weight + Then routability should be + | highway | maxweight | bothw | + | primary | | x | + | primary | 1 | | + | primary | 3.5 | x | + | primary | 35000 kg | x | + | primary | 8.9t | x | + | primary | 0.1 lbs | | + | primary | unsigned | x | diff --git a/profiles/car.lua b/profiles/car.lua index 161a6466bae..ab4561afcf7 100644 --- a/profiles/car.lua +++ b/profiles/car.lua @@ -42,6 +42,10 @@ function setup() vehicle_height = 2.5, -- in meters, 2.5m is the height of van vehicle_width = 1.9, -- in meters, ways with narrow tag are considered narrower than 2.2m + -- Size of the vehicle, to be limited mostly by legal restriction of the way + vehicle_length = 4.8, -- in meters, 4.8m is the length of large or familly car + vehicle_weight = 3.5, -- in kilograms + -- a list of suffixes to suppress in name change instructions. The suffixes also include common substrings of each other suffix_list = { 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W', 'NW', 'North', 'South', 'West', 'East', 'Nor', 'Sou', 'We', 'Ea' @@ -387,6 +391,8 @@ function process_way(profile, way, result, relations) WayHandlers.avoid_ways, WayHandlers.handle_height, WayHandlers.handle_width, + WayHandlers.handle_length, + WayHandlers.handle_weight, -- determine access status by checking our hierarchy of -- access tags, e.g: motorcar, motor_vehicle, vehicle diff --git a/profiles/lib/way_handlers.lua b/profiles/lib/way_handlers.lua index ef9fa88e8c0..265929d733c 100644 --- a/profiles/lib/way_handlers.lua +++ b/profiles/lib/way_handlers.lua @@ -511,6 +511,38 @@ function WayHandlers.handle_width(profile,way,result,data) end end +-- handle maxweight tags +function WayHandlers.handle_weight(profile,way,result,data) + local keys = Sequence { 'maxweight' } + local forward, backward = Tags.get_forward_backward_by_set(way,data,keys) + forward = Measure.get_max_weight(forward) + backward = Measure.get_max_weight(backward) + + if forward and forward < profile.vehicle_weight then + result.forward_mode = mode.inaccessible + end + + if backward and backward < profile.vehicle_weight then + result.backward_mode = mode.inaccessible + end +end + +-- handle maxlength tags +function WayHandlers.handle_length(profile,way,result,data) + local keys = Sequence { 'maxlength' } + local forward, backward = Tags.get_forward_backward_by_set(way,data,keys) + forward = Measure.get_max_length(forward) + backward = Measure.get_max_length(backward) + + if forward and forward < profile.vehicle_length then + result.forward_mode = mode.inaccessible + end + + if backward and backward < profile.vehicle_length then + result.backward_mode = mode.inaccessible + end +end + -- handle oneways tags function WayHandlers.oneway(profile,way,result,data) if not profile.oneway_handling then