Car Profile. Route by supporting physical limitation of height and weight
This commit is contained in:
parent
ddf11cc2cc
commit
5af776d963
45
features/car/physical_limitation.feature
Normal file
45
features/car/physical_limitation.feature
Normal file
@ -0,0 +1,45 @@
|
||||
@routing @car
|
||||
Feature: Car - Handle physical limitation
|
||||
|
||||
Background:
|
||||
Given the profile "car"
|
||||
|
||||
Scenario: Car - Use a narrow way
|
||||
Then routability should be
|
||||
| highway | width | narrow | bothw |
|
||||
| primary | | | x |
|
||||
| primary | narrow | | x |
|
||||
| primary | | yes | x |
|
||||
| primary | 1.8 | | |
|
||||
| primary | 1.9 | | |
|
||||
| primary | 2.0 | | x |
|
||||
| primary | 2.1 | | x |
|
||||
| primary | 1m | | |
|
||||
| primary | 1 m | | |
|
||||
| primary | 3 m | | x |
|
||||
| primary | 6' | | |
|
||||
| primary | 6'0" | | |
|
||||
| primary | 6'2" | | |
|
||||
| primary | 6'3" | | x |
|
||||
| primary | 7' | | x |
|
||||
| primary | 7'0" | | x |
|
||||
|
||||
Scenario: Car - Limited by width
|
||||
Then routability should be
|
||||
| highway | maxwidth:physical | maxwidth | width | est_width | bothw |
|
||||
| primary | 1 | | | | |
|
||||
| primary | 3 | | | | x |
|
||||
| primary | | 1 | | | |
|
||||
| primary | | 3 | | | x |
|
||||
| primary | | | 1 | | |
|
||||
| primary | | | 3 | | x |
|
||||
| primary | | | | 1 | |
|
||||
| primary | | | | 3 | x |
|
||||
|
||||
Scenario: Car - Limited by height
|
||||
Then routability should be
|
||||
| highway | maxheight:physical | maxheight | bothw |
|
||||
| primary | 1 | | |
|
||||
| primary | 3 | | x |
|
||||
| primary | | 1 | |
|
||||
| primary | | 3 | x |
|
@ -37,6 +37,10 @@ function setup()
|
||||
turn_bias = 1.075,
|
||||
cardinal_directions = false,
|
||||
|
||||
-- Size of the vehicle, to be limited by physical restriction of the way
|
||||
vehicle_height = 2.5, -- in metters, 2.5m is the height of van
|
||||
vehicle_width = 1.9, -- in metters, ways with narrow tag are considered narrower than 2.2m
|
||||
|
||||
-- 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'
|
||||
@ -357,6 +361,8 @@ function process_way(profile, way, result, relations)
|
||||
-- toll=yes and oneway=reversible
|
||||
WayHandlers.blocked_ways,
|
||||
WayHandlers.avoid_ways,
|
||||
WayHandlers.handle_height,
|
||||
WayHandlers.handle_width,
|
||||
|
||||
-- determine access status by checking our hierarchy of
|
||||
-- access tags, e.g: motorcar, motor_vehicle, vehicle
|
||||
|
@ -8,6 +8,7 @@ local get_turn_lanes = require("lib/guidance").get_turn_lanes
|
||||
local set_classification = require("lib/guidance").set_classification
|
||||
local get_destination = require("lib/destination").get_destination
|
||||
local Tags = require('lib/tags')
|
||||
local Measure = require("lib/measure")
|
||||
|
||||
WayHandlers = {}
|
||||
|
||||
@ -429,6 +430,47 @@ function WayHandlers.parse_maxspeed(source,profile)
|
||||
return n
|
||||
end
|
||||
|
||||
-- handle maxheight tags
|
||||
function WayHandlers.handle_height(profile,way,result,data)
|
||||
local keys = Sequence { 'maxheight:physical', 'maxheight' }
|
||||
local forward, backward = Tags.get_forward_backward_by_set(way,data,keys)
|
||||
forward = Measure.get_max_height(forward)
|
||||
backward = Measure.get_max_height(backward)
|
||||
|
||||
if forward and forward < profile.vehicle_height then
|
||||
result.forward_mode = mode.inaccessible
|
||||
end
|
||||
|
||||
if backward and backward < profile.vehicle_height then
|
||||
result.backward_mode = mode.inaccessible
|
||||
end
|
||||
end
|
||||
|
||||
-- handle maxwidth tags
|
||||
function WayHandlers.handle_width(profile,way,result,data)
|
||||
local keys = Sequence { 'maxwidth:physical', 'maxwidth', 'width', 'est_width' }
|
||||
local forward, backward = Tags.get_forward_backward_by_set(way,data,keys)
|
||||
local narrow = way:get_value_by_key('narrow')
|
||||
|
||||
if ((forward and forward == 'narrow') or (narrow and narrow == 'yes')) and profile.vehicle_width > 2.2 then
|
||||
result.forward_mode = mode.inaccessible
|
||||
elseif forward then
|
||||
forward = Measure.get_max_width(forward)
|
||||
if forward and forward <= profile.vehicle_width then
|
||||
result.forward_mode = mode.inaccessible
|
||||
end
|
||||
end
|
||||
|
||||
if ((backward and backward == 'narrow') or (narrow and narrow == 'yes')) and profile.vehicle_width > 2.2 then
|
||||
result.backward_mode = mode.inaccessible
|
||||
elseif backward then
|
||||
backward = Measure.get_max_width(backward)
|
||||
if backward and backward <= profile.vehicle_width then
|
||||
result.backward_mode = mode.inaccessible
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- handle oneways tags
|
||||
function WayHandlers.oneway(profile,way,result,data)
|
||||
if not profile.oneway_handling then
|
||||
|
Loading…
Reference in New Issue
Block a user