Use lua 5.2+ without needing compatibility flags.
This commit is contained in:
parent
407036e215
commit
566ab993df
@ -1,5 +1,7 @@
|
|||||||
require("lib/access")
|
-- Bicycle profile
|
||||||
require("lib/maxspeed")
|
|
||||||
|
local find_access_tag = require("lib/access").find_access_tag
|
||||||
|
local limit = require("lib/maxspeed").limit
|
||||||
|
|
||||||
-- Begin of globals
|
-- Begin of globals
|
||||||
barrier_whitelist = { [""] = true, ["cycle_barrier"] = true, ["bollard"] = true, ["entrance"] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["no"] = true }
|
barrier_whitelist = { [""] = true, ["cycle_barrier"] = true, ["bollard"] = true, ["entrance"] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["no"] = true }
|
||||||
@ -122,7 +124,6 @@ local function parse_maxspeed(source)
|
|||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
function get_exceptions(vector)
|
function get_exceptions(vector)
|
||||||
for i,v in ipairs(restriction_exception_tags) do
|
for i,v in ipairs(restriction_exception_tags) do
|
||||||
vector:Add(v)
|
vector:Add(v)
|
||||||
@ -131,7 +132,7 @@ end
|
|||||||
|
|
||||||
function node_function (node, result)
|
function node_function (node, result)
|
||||||
local barrier = node:get_value_by_key("barrier")
|
local barrier = node:get_value_by_key("barrier")
|
||||||
local access = Access.find_access_tag(node, access_tags_hierachy)
|
local access = find_access_tag(node, access_tags_hierachy)
|
||||||
local traffic_signal = node:get_value_by_key("highway")
|
local traffic_signal = node:get_value_by_key("highway")
|
||||||
|
|
||||||
-- flag node if it carries a traffic light
|
-- flag node if it carries a traffic light
|
||||||
@ -181,7 +182,7 @@ function way_function (way, result)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- access
|
-- access
|
||||||
local access = Access.find_access_tag(way, access_tags_hierachy)
|
local access = find_access_tag(way, access_tags_hierachy)
|
||||||
if access and access_tag_blacklist[access] then
|
if access and access_tag_blacklist[access] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -391,7 +392,7 @@ function way_function (way, result)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- maxspeed
|
-- maxspeed
|
||||||
MaxSpeed.limit( result, maxspeed, maxspeed_forward, maxspeed_backward )
|
limit( result, maxspeed, maxspeed_forward, maxspeed_backward )
|
||||||
end
|
end
|
||||||
|
|
||||||
function turn_function (angle)
|
function turn_function (angle)
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
-- Begin of globals
|
-- Car profile
|
||||||
--require("lib/access") --function temporarily inlined
|
|
||||||
|
|
||||||
|
local find_access_tag = require("lib/access").find_access_tag
|
||||||
|
|
||||||
|
-- Begin of globals
|
||||||
barrier_whitelist = { ["cattle_grid"] = true, ["border_control"] = true, ["checkpoint"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["lift_gate"] = true, ["no"] = true, ["entrance"] = true }
|
barrier_whitelist = { ["cattle_grid"] = true, ["border_control"] = true, ["checkpoint"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["lift_gate"] = true, ["no"] = true, ["entrance"] = true }
|
||||||
access_tag_whitelist = { ["yes"] = true, ["motorcar"] = true, ["motor_vehicle"] = true, ["vehicle"] = true, ["permissive"] = true, ["designated"] = true }
|
access_tag_whitelist = { ["yes"] = true, ["motorcar"] = true, ["motor_vehicle"] = true, ["vehicle"] = true, ["permissive"] = true, ["designated"] = true }
|
||||||
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestry"] = true, ["emergency"] = true, ["psv"] = true }
|
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestry"] = true, ["emergency"] = true, ["psv"] = true }
|
||||||
@ -147,16 +149,6 @@ local mode_normal = 1
|
|||||||
local mode_ferry = 2
|
local mode_ferry = 2
|
||||||
local mode_movable_bridge = 3
|
local mode_movable_bridge = 3
|
||||||
|
|
||||||
local function find_access_tag(source, access_tags_hierachy)
|
|
||||||
for i,v in ipairs(access_tags_hierachy) do
|
|
||||||
local access_tag = source:get_value_by_key(v)
|
|
||||||
if access_tag and "" ~= access_tag then
|
|
||||||
return access_tag
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return ""
|
|
||||||
end
|
|
||||||
|
|
||||||
function get_exceptions(vector)
|
function get_exceptions(vector)
|
||||||
for i,v in ipairs(restriction_exception_tags) do
|
for i,v in ipairs(restriction_exception_tags) do
|
||||||
vector:Add(v)
|
vector:Add(v)
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
-- Foot profile
|
-- Foot profile
|
||||||
|
|
||||||
require("lib/access")
|
local find_access_tag = require("lib/access").find_access_tag
|
||||||
|
|
||||||
|
-- Begin of globals
|
||||||
barrier_whitelist = { [""] = true, ["cycle_barrier"] = true, ["bollard"] = true, ["entrance"] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["no"] = true}
|
barrier_whitelist = { [""] = true, ["cycle_barrier"] = true, ["bollard"] = true, ["entrance"] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["no"] = true}
|
||||||
access_tag_whitelist = { ["yes"] = true, ["foot"] = true, ["permissive"] = true, ["designated"] = true }
|
access_tag_whitelist = { ["yes"] = true, ["foot"] = true, ["permissive"] = true, ["designated"] = true }
|
||||||
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
|
access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
|
||||||
@ -75,7 +76,7 @@ end
|
|||||||
|
|
||||||
function node_function (node, result)
|
function node_function (node, result)
|
||||||
local barrier = node:get_value_by_key("barrier")
|
local barrier = node:get_value_by_key("barrier")
|
||||||
local access = Access.find_access_tag(node, access_tags_hierachy)
|
local access = find_access_tag(node, access_tags_hierachy)
|
||||||
local traffic_signal = node:get_value_by_key("highway")
|
local traffic_signal = node:get_value_by_key("highway")
|
||||||
|
|
||||||
-- flag node if it carries a traffic light
|
-- flag node if it carries a traffic light
|
||||||
@ -125,7 +126,7 @@ function way_function (way, result)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- access
|
-- access
|
||||||
local access = Access.find_access_tag(way, access_tags_hierachy)
|
local access = find_access_tag(way, access_tags_hierachy)
|
||||||
if access_tag_blacklist[access] then
|
if access_tag_blacklist[access] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -1,13 +1,15 @@
|
|||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
|
|
||||||
module "Access"
|
local Access = {}
|
||||||
|
|
||||||
function find_access_tag(source,access_tags_hierachy)
|
function Access.find_access_tag(source,access_tags_hierachy)
|
||||||
for i,v in ipairs(access_tags_hierachy) do
|
for i,v in ipairs(access_tags_hierachy) do
|
||||||
local tag = source:get_value_by_key(v)
|
local tag = source:get_value_by_key(v)
|
||||||
if tag and tag ~= '' then
|
if tag and tag ~= '' then
|
||||||
return tag
|
return tag
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return nil
|
return ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return Access
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
local math = math
|
local math = math
|
||||||
|
|
||||||
module "MaxSpeed"
|
local MaxSpeed = {}
|
||||||
|
|
||||||
function limit(way,max,maxf,maxb)
|
function MaxSpeed.limit(way,max,maxf,maxb)
|
||||||
if maxf and maxf>0 then
|
if maxf and maxf>0 then
|
||||||
way.forward_speed = math.min(way.forward_speed, maxf)
|
way.forward_speed = math.min(way.forward_speed, maxf)
|
||||||
elseif max and max>0 then
|
elseif max and max>0 then
|
||||||
@ -15,3 +15,5 @@ function limit(way,max,maxf,maxb)
|
|||||||
way.backward_speed = math.min(way.backward_speed, max)
|
way.backward_speed = math.min(way.backward_speed, max)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return MaxSpeed
|
||||||
|
Loading…
Reference in New Issue
Block a user