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
|
||||
| from | to | route | time |
|
||||
| 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
|
||||
|
||||
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)
|
||||
local barrier = node.tags:Find ("barrier")
|
||||
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 junction = way.tags:Find("junction")
|
||||
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 oneway = way.tags:Find("oneway")
|
||||
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
|
||||
if (speed_profile[highway] ~= nil and way.speed == -1 ) then
|
||||
if maxspeed > speed_profile[highway] then
|
||||
way.speed = maxspeed
|
||||
else
|
||||
if 0 == maxspeed then
|
||||
maxspeed = math.huge
|
||||
end
|
||||
way.speed = math.min(speed_profile[highway], maxspeed)
|
||||
end
|
||||
end
|
||||
|
||||
-- Set the avg speed on ways that are marked accessible
|
||||
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 );
|
||||
end
|
||||
|
||||
|
||||
-- Set access restriction flag if access is allowed under certain restrictions only
|
||||
if access ~= "" and access_tag_restricted[access] then
|
||||
way.is_access_restricted = true
|
||||
@ -196,18 +185,16 @@ function way_function (way, numberOfNodesInWay)
|
||||
end
|
||||
|
||||
-- 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
|
||||
way.ignore_in_grid = true
|
||||
end
|
||||
way.type = 1
|
||||
return 1
|
||||
return 1
|
||||
end
|
||||
|
||||
-- These are wrappers to parse vectors of nodes and ways and thus to speed up any tracing JIT
|
||||
|
||||
function node_vector_function(vector)
|
||||
for v in vector.nodes do
|
||||
for v in vector.nodes do
|
||||
node_function(v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user