Fixes issue #579
This commit is contained in:
parent
bb1064ac42
commit
572b176401
@ -31,4 +31,4 @@ Feature: Car - Max speed restrictions
|
|||||||
When I route I should get
|
When I route I should get
|
||||||
| from | to | route | time |
|
| from | to | route | time |
|
||||||
| a | b | ab | 144s ~10% |
|
| a | b | ab | 144s ~10% |
|
||||||
| b | c | bc | 144s ~10% |
|
| b | c | bc | 63s ~10% |
|
||||||
|
@ -48,20 +48,6 @@ function get_exceptions(vector)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function parse_maxspeed(source)
|
|
||||||
if source == nil then
|
|
||||||
return 0
|
|
||||||
end
|
|
||||||
local n = tonumber(source:match("%d*"))
|
|
||||||
if n == nil then
|
|
||||||
n = 0
|
|
||||||
end
|
|
||||||
if string.match(source, "mph") or string.match(source, "mp/h") then
|
|
||||||
n = (n*1609)/1000;
|
|
||||||
end
|
|
||||||
return math.abs(n)
|
|
||||||
end
|
|
||||||
|
|
||||||
function node_function (node)
|
function node_function (node)
|
||||||
local barrier = node.tags:Find ("barrier")
|
local barrier = node.tags:Find ("barrier")
|
||||||
local access = Access.find_access_tag(node, access_tags_hierachy)
|
local access = Access.find_access_tag(node, access_tags_hierachy)
|
||||||
@ -102,7 +88,7 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
local ref = way.tags:Find("ref")
|
local ref = way.tags:Find("ref")
|
||||||
local junction = way.tags:Find("junction")
|
local junction = way.tags:Find("junction")
|
||||||
local route = way.tags:Find("route")
|
local route = way.tags:Find("route")
|
||||||
local maxspeed = parse_maxspeed(way.tags:Find ( "maxspeed") )
|
local maxspeed = parseMaxspeed(way.tags:Find ( "maxspeed") )
|
||||||
local barrier = way.tags:Find("barrier")
|
local barrier = way.tags:Find("barrier")
|
||||||
local oneway = way.tags:Find("oneway")
|
local oneway = way.tags:Find("oneway")
|
||||||
local cycleway = way.tags:Find("cycleway")
|
local cycleway = way.tags:Find("cycleway")
|
||||||
@ -151,11 +137,15 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
|
|
||||||
-- Set the avg speed on the way if it is accessible by road class
|
-- Set the avg speed on the way if it is accessible by road class
|
||||||
if (speed_profile[highway] ~= nil and way.speed == -1 ) then
|
if (speed_profile[highway] ~= nil and way.speed == -1 ) then
|
||||||
|
if maxspeed > speed_profile[highway] then
|
||||||
|
way.speed = maxspeed
|
||||||
|
else
|
||||||
if 0 == maxspeed then
|
if 0 == maxspeed then
|
||||||
maxspeed = math.huge
|
maxspeed = math.huge
|
||||||
end
|
end
|
||||||
way.speed = math.min(speed_profile[highway], maxspeed)
|
way.speed = math.min(speed_profile[highway], maxspeed)
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Set the avg speed on ways that are marked accessible
|
-- Set the avg speed on ways that are marked accessible
|
||||||
if "" ~= highway and access_tag_whitelist[access] and way.speed == -1 then
|
if "" ~= highway and access_tag_whitelist[access] and way.speed == -1 then
|
||||||
@ -169,7 +159,6 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
way.duration = math.max( parseDuration(duration), 1 );
|
way.duration = math.max( parseDuration(duration), 1 );
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Set access restriction flag if access is allowed under certain restrictions only
|
-- Set access restriction flag if access is allowed under certain restrictions only
|
||||||
if access ~= "" and access_tag_restricted[access] then
|
if access ~= "" and access_tag_restricted[access] then
|
||||||
way.is_access_restricted = true
|
way.is_access_restricted = true
|
||||||
@ -196,7 +185,6 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Override general direction settings of there is a specific one for our mode of travel
|
-- Override general direction settings of there is a specific one for our mode of travel
|
||||||
|
|
||||||
if ignore_in_grid[highway] ~= nil and ignore_in_grid[highway] then
|
if ignore_in_grid[highway] ~= nil and ignore_in_grid[highway] then
|
||||||
way.ignore_in_grid = true
|
way.ignore_in_grid = true
|
||||||
end
|
end
|
||||||
@ -205,7 +193,6 @@ function way_function (way, numberOfNodesInWay)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- These are wrappers to parse vectors of nodes and ways and thus to speed up any tracing JIT
|
-- These are wrappers to parse vectors of nodes and ways and thus to speed up any tracing JIT
|
||||||
|
|
||||||
function node_vector_function(vector)
|
function node_vector_function(vector)
|
||||||
for v in vector.nodes do
|
for v in vector.nodes do
|
||||||
node_function(v)
|
node_function(v)
|
||||||
|
Loading…
Reference in New Issue
Block a user