add movable bridge support to the car profile. Implements #1399
This commit is contained in:
parent
ab385f2bf5
commit
645e3ccbb3
47
features/car/bridge.feature
Normal file
47
features/car/bridge.feature
Normal file
@ -0,0 +1,47 @@
|
||||
@routing @car @bridge
|
||||
Feature: Car - Handle movable bridge
|
||||
|
||||
Background:
|
||||
Given the profile "car"
|
||||
|
||||
Scenario: Car - Use a ferry route
|
||||
Given the node map
|
||||
| a | b | c | | |
|
||||
| | | d | | |
|
||||
| | | e | f | g |
|
||||
|
||||
And the ways
|
||||
| nodes | highway | bridge | bicycle |
|
||||
| abc | primary | | |
|
||||
| cde | | movable | yes |
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes |
|
||||
| a | g | abc,cde,efg | 1,3,1 |
|
||||
| b | f | abc,cde,efg | 1,3,1 |
|
||||
| e | c | cde | 3 |
|
||||
| e | b | cde,abc | 3,1 |
|
||||
| e | a | cde,abc | 3,1 |
|
||||
| c | e | cde | 3 |
|
||||
| c | f | cde,efg | 3,1 |
|
||||
| c | g | cde,efg | 3,1 |
|
||||
|
||||
Scenario: Car - Properly handle durations
|
||||
Given the node map
|
||||
| a | b | c | | |
|
||||
| | | d | | |
|
||||
| | | e | f | g |
|
||||
|
||||
And the ways
|
||||
| nodes | highway | bridge | duration |
|
||||
| abc | primary | | |
|
||||
| cde | | movable | 00:05:00 |
|
||||
| efg | primary | | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes | speed |
|
||||
| a | g | abc,cde,efg | 1,3,1 | 6 km/h |
|
||||
| b | f | abc,cde,efg | 1,3,1 | 4 km/h |
|
||||
| c | e | cde | 3 | 2 km/h |
|
||||
| e | c | cde | 3 | 2 km/h |
|
@ -28,6 +28,7 @@ speed_profile = {
|
||||
["service"] = 15,
|
||||
-- ["track"] = 5,
|
||||
["ferry"] = 5,
|
||||
["movable"] = 5,
|
||||
["shuttle_train"] = 10,
|
||||
["default"] = 10
|
||||
}
|
||||
@ -144,6 +145,7 @@ local speed_reduction = 0.8
|
||||
--modes
|
||||
local mode_normal = 1
|
||||
local mode_ferry = 2
|
||||
local mode_movable_bridge = 3
|
||||
|
||||
local function find_access_tag(source, access_tags_hierachy)
|
||||
for i,v in ipairs(access_tags_hierachy) do
|
||||
@ -221,8 +223,9 @@ end
|
||||
function way_function (way, result)
|
||||
local highway = way:get_value_by_key("highway")
|
||||
local route = way:get_value_by_key("route")
|
||||
local bridge = way:get_value_by_key("bridge")
|
||||
|
||||
if not ((highway and highway ~= "") or (route and route ~= "")) then
|
||||
if not ((highway and highway ~= "") or (route and route ~= "") or (bridge and bridge ~= "")) then
|
||||
return
|
||||
end
|
||||
|
||||
@ -260,9 +263,9 @@ function way_function (way, result)
|
||||
return
|
||||
end
|
||||
|
||||
-- Handling ferries and piers
|
||||
-- handling ferries and piers
|
||||
local route_speed = speed_profile[route]
|
||||
if(route_speed and route_speed > 0) then
|
||||
if (route_speed and route_speed > 0) then
|
||||
highway = route;
|
||||
local duration = way:get_value_by_key("duration")
|
||||
if duration and durationIsValid(duration) then
|
||||
@ -274,6 +277,22 @@ function way_function (way, result)
|
||||
result.backward_speed = route_speed
|
||||
end
|
||||
|
||||
-- handling movable bridges
|
||||
local bridge_speed = speed_profile[bridge]
|
||||
if (bridge_speed and bridge_speed > 0) then
|
||||
io.write("-bridge: "..bridge.."\n")
|
||||
highway = bridge;
|
||||
io.write("-highway: "..highway.."\n")
|
||||
local duration = way:get_value_by_key("duration")
|
||||
if duration and durationIsValid(duration) then
|
||||
result.duration = max( parseDuration(duration), 1 );
|
||||
end
|
||||
result.forward_mode = mode_movable_bridge
|
||||
result.backward_mode = mode_movable_bridge
|
||||
result.forward_speed = bridge_speed
|
||||
result.backward_speed = bridge_speed
|
||||
end
|
||||
|
||||
-- leave early of this way is not accessible
|
||||
if "" == highway then
|
||||
return
|
||||
|
Loading…
Reference in New Issue
Block a user