From 985270bb02743c36ba884b92230b00efd455e68c Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Wed, 5 Mar 2014 19:16:17 +0100 Subject: [PATCH] parse maxspeed in LUA --- profiles/bicycle.lua | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/profiles/bicycle.lua b/profiles/bicycle.lua index 08f78b8ce..b935bafbc 100644 --- a/profiles/bicycle.lua +++ b/profiles/bicycle.lua @@ -96,6 +96,22 @@ turn_penalty = 60 turn_bias = 1.4 -- End of globals + +local function parse_maxspeed(source) + if not source then + return 0 + end + local n = tonumber(source:match("%d*")) + if not n then + n = 0 + end + if string.match(source, "mph") or string.match(source, "mp/h") then + n = (n*1609)/1000; + end + return n +end + + function get_exceptions(vector) for i,v in ipairs(restriction_exception_tags) do vector:Add(v) @@ -107,6 +123,29 @@ function node_function (node) local access = Access.find_access_tag(node, access_tags_hierachy) local traffic_signal = node.tags:Find("highway") + -- flag node if it carries a traffic light + if traffic_signal == "traffic_signals" then + node.traffic_light = true + end + + -- parse access and barrier tags + if access and access ~= "" then + if access_tag_blacklist[access] then + node.bollard = true + else + node.bollard = false + end + elseif barrier and barrier ~= "" then + if barrier_whitelist[barrier] then + node.bollard = false + else + node.bollard = true + end + end + + -- return 1 +end + -- flag node if it carries a traffic light if traffic_signal == "traffic_signals" then node.traffic_light = true @@ -159,7 +198,6 @@ function way_function (way) return 0 end - -- other tags local name = way.tags:Find("name") local ref = way.tags:Find("ref")