Fix assertions in car profile, resolves #3629
restrict direction if access tag is missing and can not be derived from highway tag http://www.openstreetmap.org/way/4282676 http://www.openstreetmap.org/way/4621857 http://www.openstreetmap.org/way/4898368
This commit is contained in:
parent
eaed5c7a8e
commit
1628ebb871
@ -245,3 +245,14 @@ Feature: Car - Restricted access
|
|||||||
| gate | designated | x |
|
| gate | designated | x |
|
||||||
| gate | private | |
|
| gate | private | |
|
||||||
| gate | garbagetag | x |
|
| gate | garbagetag | x |
|
||||||
|
|
||||||
|
Scenario: Car - a way with conditional access
|
||||||
|
Then routability should be
|
||||||
|
| highway | vehicle:forward | vehicle:backward:conditional | forw | backw |
|
||||||
|
| pedestrian | yes | delivery @ (20:00-11:00) | x | |
|
||||||
|
|
||||||
|
Scenario: Car - a way with a list of tags
|
||||||
|
Then routability should be
|
||||||
|
| highway | motor_vehicle | motor_vehicle:forward | motor_vehicle:backward | forw | backw |
|
||||||
|
| footway | | | destination | | x |
|
||||||
|
| track | destination;agricultural | destination | | x | x |
|
||||||
|
@ -103,3 +103,8 @@ Feature: Foot - Access tags on ways
|
|||||||
| bridleway | | yes | | |
|
| bridleway | | yes | | |
|
||||||
| bridleway | designated | | | |
|
| bridleway | designated | | | |
|
||||||
| bridleway | | | | |
|
| bridleway | | | | |
|
||||||
|
|
||||||
|
Scenario: Foot - a way with missing :forward tag
|
||||||
|
Then routability should be
|
||||||
|
| highway | bicycle:backward | foot:backward | forw | backw |
|
||||||
|
| cycleway | designated | designated | | x |
|
||||||
|
@ -66,7 +66,7 @@ end
|
|||||||
-- determine if this way can be used as a start/end point for routing
|
-- determine if this way can be used as a start/end point for routing
|
||||||
function Handlers.handle_startpoint(way,result,data,profile)
|
function Handlers.handle_startpoint(way,result,data,profile)
|
||||||
-- only allow this road as start point if it not a ferry
|
-- only allow this road as start point if it not a ferry
|
||||||
result.is_startpoint = result.forward_mode == profile.default_mode or
|
result.is_startpoint = result.forward_mode == profile.default_mode or
|
||||||
result.backward_mode == profile.default_mode
|
result.backward_mode == profile.default_mode
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -210,23 +210,29 @@ function Handlers.handle_speed(way,result,data,profile)
|
|||||||
if result.forward_speed ~= -1 then
|
if result.forward_speed ~= -1 then
|
||||||
return -- abort if already set, eg. by a route
|
return -- abort if already set, eg. by a route
|
||||||
end
|
end
|
||||||
|
|
||||||
local key,value,speed = Tags.get_constant_by_key_value(way,profile.speeds)
|
local key,value,speed = Tags.get_constant_by_key_value(way,profile.speeds)
|
||||||
|
|
||||||
if speed then
|
if speed then
|
||||||
-- set speed by way type
|
-- set speed by way type
|
||||||
result.forward_speed = highway_speed
|
|
||||||
result.backward_speed = highway_speed
|
|
||||||
result.forward_speed = speed
|
result.forward_speed = speed
|
||||||
result.backward_speed = speed
|
result.backward_speed = speed
|
||||||
else
|
else
|
||||||
-- Set the avg speed on ways that are marked accessible
|
-- Set the avg speed on ways that are marked accessible
|
||||||
if profile.access_tag_whitelist[data.forward_access] then
|
if profile.access_tag_whitelist[data.forward_access] then
|
||||||
result.forward_speed = profile.default_speed
|
result.forward_speed = profile.default_speed
|
||||||
|
elseif data.forward_access and not profile.access_tag_blacklist[data.forward_access] then
|
||||||
|
result.forward_speed = profile.default_speed -- fallback to the avg speed if access tag is not blacklisted
|
||||||
|
elseif not data.forward_access and data.backward_access then
|
||||||
|
result.forward_mode = mode.inaccessible
|
||||||
end
|
end
|
||||||
|
|
||||||
if profile.access_tag_whitelist[data.backward_access] then
|
if profile.access_tag_whitelist[data.backward_access] then
|
||||||
result.backward_speed = profile.default_speed
|
result.backward_speed = profile.default_speed
|
||||||
|
elseif data.backward_access and not profile.access_tag_blacklist[data.backward_access] then
|
||||||
|
result.backward_speed = profile.default_speed -- fallback to the avg speed if access tag is not blacklisted
|
||||||
|
elseif not data.backward_access and data.forward_access then
|
||||||
|
result.backward_mode = mode.inaccessible
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -236,7 +242,7 @@ function Handlers.handle_speed(way,result,data,profile)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- reduce speed on special side roads
|
-- reduce speed on special side roads
|
||||||
function Handlers.handle_side_roads(way,result,data,profile)
|
function Handlers.handle_side_roads(way,result,data,profile)
|
||||||
local sideway = way:get_value_by_key("side_road")
|
local sideway = way:get_value_by_key("side_road")
|
||||||
if "yes" == sideway or
|
if "yes" == sideway or
|
||||||
"rotary" == sideway then
|
"rotary" == sideway then
|
||||||
@ -281,7 +287,7 @@ function Handlers.handle_speed_scaling(way,result,data,profile)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local is_bidirectional = result.forward_mode ~= mode.inaccessible and
|
local is_bidirectional = result.forward_mode ~= mode.inaccessible and
|
||||||
result.backward_mode ~= mode.inaccessible
|
result.backward_mode ~= mode.inaccessible
|
||||||
|
|
||||||
local service = way:get_value_by_key("service")
|
local service = way:get_value_by_key("service")
|
||||||
@ -367,7 +373,7 @@ function Handlers.handle_oneway(way,result,data,profile)
|
|||||||
if not profile.oneway_handling then
|
if not profile.oneway_handling then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local oneway
|
local oneway
|
||||||
if profile.oneway_handling == true then
|
if profile.oneway_handling == true then
|
||||||
oneway = Tags.get_value_by_prefixed_sequence(way,profile.restrictions,'oneway') or way:get_value_by_key("oneway")
|
oneway = Tags.get_value_by_prefixed_sequence(way,profile.restrictions,'oneway') or way:get_value_by_key("oneway")
|
||||||
@ -388,7 +394,7 @@ function Handlers.handle_oneway(way,result,data,profile)
|
|||||||
elseif profile.oneway_handling == true then
|
elseif profile.oneway_handling == true then
|
||||||
local junction = way:get_value_by_key("junction")
|
local junction = way:get_value_by_key("junction")
|
||||||
if data.highway == "motorway" or
|
if data.highway == "motorway" or
|
||||||
junction == "roundabout" or
|
junction == "roundabout" or
|
||||||
junction == "circular" then
|
junction == "circular" then
|
||||||
if oneway ~= "no" then
|
if oneway ~= "no" then
|
||||||
-- implied oneway
|
-- implied oneway
|
||||||
@ -402,12 +408,12 @@ end
|
|||||||
|
|
||||||
-- handle various that can block access
|
-- handle various that can block access
|
||||||
function Handlers.handle_blocked_ways(way,result,data,profile)
|
function Handlers.handle_blocked_ways(way,result,data,profile)
|
||||||
|
|
||||||
-- areas
|
-- areas
|
||||||
if profile.avoid.area and way:get_value_by_key("area") == "yes" then
|
if profile.avoid.area and way:get_value_by_key("area") == "yes" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- toll roads
|
-- toll roads
|
||||||
if profile.avoid.toll and way:get_value_by_key("toll") == "yes" then
|
if profile.avoid.toll and way:get_value_by_key("toll") == "yes" then
|
||||||
return false
|
return false
|
||||||
@ -419,7 +425,7 @@ function Handlers.handle_blocked_ways(way,result,data,profile)
|
|||||||
if profile.avoid.reversible and way:get_value_by_key("oneway") == "reversible" then
|
if profile.avoid.reversible and way:get_value_by_key("oneway") == "reversible" then
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
-- impassables
|
-- impassables
|
||||||
if profile.avoid.impassable then
|
if profile.avoid.impassable then
|
||||||
if way:get_value_by_key("impassable") == "yes" then
|
if way:get_value_by_key("impassable") == "yes" then
|
||||||
@ -458,4 +464,4 @@ function Handlers.run(handlers,way,result,data,profile)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return Handlers
|
return Handlers
|
||||||
|
@ -13,7 +13,7 @@ local Tags = {}
|
|||||||
function Tags.get_forward_backward_by_key(way,data,key)
|
function Tags.get_forward_backward_by_key(way,data,key)
|
||||||
local forward = way:get_value_by_key(key .. ':forward')
|
local forward = way:get_value_by_key(key .. ':forward')
|
||||||
local backward = way:get_value_by_key(key .. ':backward')
|
local backward = way:get_value_by_key(key .. ':backward')
|
||||||
|
|
||||||
if forward and backward then
|
if forward and backward then
|
||||||
return forward, backward
|
return forward, backward
|
||||||
end
|
end
|
||||||
@ -23,7 +23,7 @@ function Tags.get_forward_backward_by_key(way,data,key)
|
|||||||
backward or common
|
backward or common
|
||||||
end
|
end
|
||||||
|
|
||||||
-- return [forward,backward] values, searching a
|
-- return [forward,backward] values, searching a
|
||||||
-- prioritized sequence of tags
|
-- prioritized sequence of tags
|
||||||
-- e.g. for the sequence [maxspeed,advisory] search forward:
|
-- e.g. for the sequence [maxspeed,advisory] search forward:
|
||||||
-- maxspeed:forward
|
-- maxspeed:forward
|
||||||
@ -90,7 +90,7 @@ function Tags.get_value_by_postfixed_sequence(way,seq,postfix)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- check if key-value pairs are set in a way and return a
|
-- check if key-value pairs are set in a way and return a
|
||||||
-- corresponding constant if it is. e.g. for this input:
|
-- corresponding constant if it is. e.g. for this input:
|
||||||
--
|
--
|
||||||
-- local speeds = {
|
-- local speeds = {
|
||||||
@ -105,7 +105,7 @@ end
|
|||||||
--
|
--
|
||||||
-- we would check whether the following key-value combinations
|
-- we would check whether the following key-value combinations
|
||||||
-- are set, and return the corresponding constant:
|
-- are set, and return the corresponding constant:
|
||||||
--
|
--
|
||||||
-- highway = residential => 20
|
-- highway = residential => 20
|
||||||
-- highway = primary => 40
|
-- highway = primary => 40
|
||||||
-- amenity = parking => 10
|
-- amenity = parking => 10
|
||||||
@ -121,4 +121,4 @@ function Tags.get_constant_by_key_value(way,lookup)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return Tags
|
return Tags
|
||||||
|
Loading…
Reference in New Issue
Block a user