[osrm] 09/13: Update config files

Christopher Baines cbaines-guest at moszumanska.debian.org
Sat Apr 4 16:04:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

cbaines-guest pushed a commit to branch master
in repository osrm.

commit 034fcb1a1749c47e5b42d9d2679567edee13dac9
Author: Christopher Baines <mail at cbaines.net>
Date:   Sat Apr 4 14:43:07 2015 +0100

    Update config files
    
    Copy the files from patches/
---
 debian/conffiles/access.lua   |   6 +-
 debian/conffiles/bicycle.lua  | 612 ++++++++++++++++++++++--------------------
 debian/conffiles/car.lua      | 461 +++++++++++++++++++++----------
 debian/conffiles/foot.lua     | 332 ++++++++++++-----------
 debian/conffiles/maxspeed.lua |  17 ++
 debian/conffiles/testbot.lua  | 195 +++++++-------
 6 files changed, 946 insertions(+), 677 deletions(-)

diff --git a/debian/conffiles/access.lua b/debian/conffiles/access.lua
index 094db62..76d2e2c 100644
--- a/debian/conffiles/access.lua
+++ b/debian/conffiles/access.lua
@@ -4,10 +4,10 @@ module "Access"
 
 function find_access_tag(source,access_tags_hierachy)
     for i,v in ipairs(access_tags_hierachy) do
-        local tag = source.tags:Find(v)
-        if tag ~= '' then
+        local tag = source:get_value_by_key(v)
+        if tag and tag ~= '' then
             return tag
         end
     end
     return nil
-end
\ No newline at end of file
+end
diff --git a/debian/conffiles/bicycle.lua b/debian/conffiles/bicycle.lua
index 98d03c8..713c6b7 100644
--- a/debian/conffiles/bicycle.lua
+++ b/debian/conffiles/bicycle.lua
@@ -1,8 +1,9 @@
 require("lib/access")
+require("lib/maxspeed")
 
 -- 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}
-access_tag_whitelist = { ["yes"] = true, ["permissive"] = true, ["designated"] = 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, ["permissive"] = true, ["designated"] = true }
 access_tag_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
 access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
 access_tags_hierachy = { "bicycle", "vehicle", "access" }
@@ -14,340 +15,375 @@ default_speed = 15
 
 walking_speed = 6
 
-bicycle_speeds = { 
-	["cycleway"] = default_speed,
-	["primary"] = default_speed,
-	["primary_link"] = default_speed,
-	["secondary"] = default_speed,
-	["secondary_link"] = default_speed,
-	["tertiary"] = default_speed,
-	["tertiary_link"] = default_speed,
-	["residential"] = default_speed,
-	["unclassified"] = default_speed,
-	["living_street"] = default_speed,
-	["road"] = default_speed,
-	["service"] = default_speed,
-	["track"] = 12,
-	["path"] = 12
-	--["footway"] = 12,
-	--["pedestrian"] = 12,
+bicycle_speeds = {
+  ["cycleway"] = default_speed,
+  ["primary"] = default_speed,
+  ["primary_link"] = default_speed,
+  ["secondary"] = default_speed,
+  ["secondary_link"] = default_speed,
+  ["tertiary"] = default_speed,
+  ["tertiary_link"] = default_speed,
+  ["residential"] = default_speed,
+  ["unclassified"] = default_speed,
+  ["living_street"] = default_speed,
+  ["road"] = default_speed,
+  ["service"] = default_speed,
+  ["track"] = 12,
+  ["path"] = 12
+  --["footway"] = 12,
+  --["pedestrian"] = 12,
 }
 
-pedestrian_speeds = { 
-	["footway"] = walking_speed,
-	["pedestrian"] = walking_speed,
-	["steps"] = 2
+pedestrian_speeds = {
+  ["footway"] = walking_speed,
+  ["pedestrian"] = walking_speed,
+  ["steps"] = 2
 }
 
-railway_speeds = { 
-	["train"] = 10,
-	["railway"] = 10,
-	["subway"] = 10,
-	["light_rail"] = 10,
-	["monorail"] = 10,
-	["tram"] = 10
+railway_speeds = {
+  ["train"] = 10,
+  ["railway"] = 10,
+  ["subway"] = 10,
+  ["light_rail"] = 10,
+  ["monorail"] = 10,
+  ["tram"] = 10
 }
 
-platform_speeds = { 
-	["platform"] = walking_speed
+platform_speeds = {
+  ["platform"] = walking_speed
 }
 
-amenity_speeds = { 
-	["parking"] = 10,
-	["parking_entrance"] = 10
+amenity_speeds = {
+  ["parking"] = 10,
+  ["parking_entrance"] = 10
 }
 
-man_made_speeds = { 
-	["pier"] = walking_speed
+man_made_speeds = {
+  ["pier"] = walking_speed
 }
 
-route_speeds = { 
-	["ferry"] = 5
+route_speeds = {
+  ["ferry"] = 5
 }
 
-surface_speeds = { 
-	["cobblestone:flattened"] = 10,
-	["paving_stones"] = 10,
-	["compacted"] = 10,
-	["cobblestone"] = 6,
-	["unpaved"] = 6,
-	["fine_gravel"] = 6,
-	["gravel"] = 6,
-	["fine_gravel"] = 6,
-	["pebbelstone"] = 6,
-	["ground"] = 6,
-	["dirt"] = 6,
-	["earth"] = 6,
-	["grass"] = 6,
-	["mud"] = 3,
-	["sand"] = 3	
+surface_speeds = {
+  ["asphalt"] = default_speed,
+  ["cobblestone:flattened"] = 10,
+  ["paving_stones"] = 10,
+  ["compacted"] = 10,
+  ["cobblestone"] = 6,
+  ["unpaved"] = 6,
+  ["fine_gravel"] = 6,
+  ["gravel"] = 6,
+  ["fine_gravel"] = 6,
+  ["pebbelstone"] = 6,
+  ["ground"] = 6,
+  ["dirt"] = 6,
+  ["earth"] = 6,
+  ["grass"] = 6,
+  ["mud"] = 3,
+  ["sand"] = 3
 }
 
-take_minimum_of_speeds 	= true
-obey_oneway 			= true
-obey_bollards 			= false
-use_restrictions 		= true
-ignore_areas 			= true -- future feature
-traffic_signal_penalty 	= 5
-u_turn_penalty 			= 20
+take_minimum_of_speeds  = true
+obey_oneway       = true
+obey_bollards       = false
+use_restrictions    = true
+ignore_areas      = true    -- future feature
+traffic_signal_penalty  = 5
+u_turn_penalty      = 20
 use_turn_restrictions   = false
-turn_penalty 			= 60
-turn_bias               = 1.4
--- End of globals
+turn_penalty      = 60
+turn_bias         = 1.4
+
+
+--modes
+mode_normal = 1
+mode_pushing = 2
+mode_ferry = 3
+mode_train = 4
+
+
+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)
-	end
+  for i,v in ipairs(restriction_exception_tags) do
+    vector:Add(v)
+  end
 end
 
-function node_function (node)
-	local barrier = node.tags:Find ("barrier")
-	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
+function node_function (node, result)
+  local barrier = node:get_value_by_key("barrier")
+  local access = Access.find_access_tag(node, access_tags_hierachy)
+  local traffic_signal = node:get_value_by_key("highway")
+
+	-- flag node if it carries a traffic light
+	if traffic_signal and traffic_signal == "traffic_signals" then
+		result.traffic_lights = true
 	end
-	
+
 	-- parse access and barrier tags
 	if access and access ~= "" then
 		if access_tag_blacklist[access] then
-			node.bollard = true
+			result.barrier = true
 		else
-			node.bollard = false
+			result.barrier = false
 		end
 	elseif barrier and barrier ~= "" then
 		if barrier_whitelist[barrier] then
-			node.bollard = false
+			result.barrier = false
 		else
-			node.bollard = true
+			result.barrier = true
 		end
 	end
-	
-	return 1
 end
 
-function way_function (way)
-	-- initial routability check, filters out buildings, boundaries, etc
-	local highway = way.tags:Find("highway")
-	local route = way.tags:Find("route")
-	local man_made = way.tags:Find("man_made")
-	local railway = way.tags:Find("railway")
-	local amenity = way.tags:Find("amenity")
-	local public_transport = way.tags:Find("public_transport")
-    if (not highway or highway == '') and 
-		(not route or route == '') and 
-		(not railway or railway=='') and 
-		(not amenity or amenity=='') and
-		(not man_made or man_made=='') and
-    	(not public_transport or public_transport=='')
-    	then
-    	return 0
+function way_function (way, result)
+  -- initial routability check, filters out buildings, boundaries, etc
+  local highway = way:get_value_by_key("highway")
+  local route = way:get_value_by_key("route")
+  local man_made = way:get_value_by_key("man_made")
+  local railway = way:get_value_by_key("railway")
+  local amenity = way:get_value_by_key("amenity")
+  local public_transport = way:get_value_by_key("public_transport")
+  if (not highway or highway == '') and
+  (not route or route == '') and
+  (not railway or railway=='') and
+  (not amenity or amenity=='') and
+  (not man_made or man_made=='') and
+  (not public_transport or public_transport=='')
+  then
+    return
+  end
+
+  -- don't route on ways or railways that are still under construction
+  if highway=='construction' or railway=='construction' then
+    return
+  end
+
+  -- access
+  local access = Access.find_access_tag(way, access_tags_hierachy)
+  if access and access_tag_blacklist[access] then
+    return
+  end
+
+  -- other tags
+  local name = way:get_value_by_key("name")
+  local ref = way:get_value_by_key("ref")
+  local junction = way:get_value_by_key("junction")
+  local maxspeed = parse_maxspeed(way:get_value_by_key ( "maxspeed") )
+  local maxspeed_forward = parse_maxspeed(way:get_value_by_key( "maxspeed:forward"))
+  local maxspeed_backward = parse_maxspeed(way:get_value_by_key( "maxspeed:backward"))
+  local barrier = way:get_value_by_key("barrier")
+  local oneway = way:get_value_by_key("oneway")
+  local onewayClass = way:get_value_by_key("oneway:bicycle")
+  local cycleway = way:get_value_by_key("cycleway")
+  local cycleway_left = way:get_value_by_key("cycleway:left")
+  local cycleway_right = way:get_value_by_key("cycleway:right")
+  local duration = way:get_value_by_key("duration")
+  local service = way:get_value_by_key("service")
+  local area = way:get_value_by_key("area")
+  local foot = way:get_value_by_key("foot")
+  local surface = way:get_value_by_key("surface")
+  local bicycle = way:get_value_by_key("bicycle")
+
+  -- name
+  if ref and "" ~= ref and name and "" ~= name then
+    result.name = name .. ' / ' .. ref
+  elseif ref and "" ~= ref then
+    result.name = ref
+  elseif name and "" ~= name then
+    result.name = name
+  elseif highway then
+    -- if no name exists, use way type
+    -- this encoding scheme is excepted to be a temporary solution
+    result.name = "{highway:"..highway.."}"
+  end
+
+  -- roundabout handling
+  if junction and "roundabout" == junction then
+    result.roundabout = true;
+  end
+
+  -- speed
+  if route_speeds[route] then
+    -- ferries (doesn't cover routes tagged using relations)
+    result.forward_mode = mode_ferry
+    result.backward_mode = mode_ferry
+    result.ignore_in_grid = true
+    if duration and durationIsValid(duration) then
+      result.duration = math.max( 1, parseDuration(duration) )
+    else
+       result.forward_speed = route_speeds[route]
+       result.backward_speed = route_speeds[route]
     end
-    
-    -- don't route on ways or railways that are still under construction
-    if highway=='construction' or railway=='construction' then
-        return 0
+  elseif railway and platform_speeds[railway] then
+    -- railway platforms (old tagging scheme)
+    result.forward_speed = platform_speeds[railway]
+    result.backward_speed = platform_speeds[railway]
+  elseif platform_speeds[public_transport] then
+    -- public_transport platforms (new tagging platform)
+    result.forward_speed = platform_speeds[public_transport]
+    result.backward_speed = platform_speeds[public_transport]
+    elseif railway and railway_speeds[railway] then
+      result.forward_mode = mode_train
+      result.backward_mode = mode_train
+     -- railways
+    if access and access_tag_whitelist[access] then
+      result.forward_speed = railway_speeds[railway]
+      result.backward_speed = railway_speeds[railway]
     end
-    
-	-- access
- 	local access = Access.find_access_tag(way, access_tags_hierachy)
-    if access_tag_blacklist[access] then
-		return 0
+  elseif amenity and amenity_speeds[amenity] then
+    -- parking areas
+    result.forward_speed = amenity_speeds[amenity]
+    result.backward_speed = amenity_speeds[amenity]
+  elseif bicycle_speeds[highway] then
+    -- regular ways
+    result.forward_speed = bicycle_speeds[highway]
+    result.backward_speed = bicycle_speeds[highway]
+  elseif access and access_tag_whitelist[access] then
+    -- unknown way, but valid access tag
+    result.forward_speed = default_speed
+    result.backward_speed = default_speed
+  else
+    -- biking not allowed, maybe we can push our bike?
+    -- essentially requires pedestrian profiling, for example foot=no mean we can't push a bike
+    if foot ~= 'no' and junction ~= "roundabout" then
+      if pedestrian_speeds[highway] then
+        -- pedestrian-only ways and areas
+        result.forward_speed = pedestrian_speeds[highway]
+        result.backward_speed = pedestrian_speeds[highway]
+        result.forward_mode = mode_pushing
+        result.backward_mode = mode_pushing
+      elseif man_made and man_made_speeds[man_made] then
+        -- man made structures
+        result.forward_speed = man_made_speeds[man_made]
+        result.backward_speed = man_made_speeds[man_made]
+        result.forward_mode = mode_pushing
+        result.backward_mode = mode_pushing
+      elseif foot == 'yes' then
+        result.forward_speed = walking_speed
+        result.backward_speed = walking_speed
+        result.forward_mode = mode_pushing
+        result.backward_mode = mode_pushing
+      elseif foot_forward == 'yes' then
+        result.forward_speed = walking_speed
+        result.forward_mode = mode_pushing
+        result.backward_mode = 0
+      elseif foot_backward == 'yes' then
+        result.forward_speed = walking_speed
+        result.forward_mode = 0
+        result.backward_mode = mode_pushing
+      end
     end
+  end
 
+  -- direction
+  local impliedOneway = false
+  if junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then
+    impliedOneway = true
+  end
 
-	-- other tags
-	local name = way.tags:Find("name")
-	local ref = way.tags:Find("ref")
-	local junction = way.tags:Find("junction")
-	local maxspeed = parseMaxspeed(way.tags:Find ( "maxspeed") )
-	local maxspeed_forward = parseMaxspeed(way.tags:Find( "maxspeed:forward"))
-	local maxspeed_backward = parseMaxspeed(way.tags:Find( "maxspeed:backward"))
-	local barrier = way.tags:Find("barrier")
-	local oneway = way.tags:Find("oneway")
-	local onewayClass = way.tags:Find("oneway:bicycle")
-	local cycleway = way.tags:Find("cycleway")
-	local cycleway_left = way.tags:Find("cycleway:left")
-	local cycleway_right = way.tags:Find("cycleway:right")
-	local duration	= way.tags:Find("duration")
-	local service	= way.tags:Find("service")
-	local area = way.tags:Find("area")
-	local foot = way.tags:Find("foot")
-	local surface = way.tags:Find("surface")
-
-	-- name	
-	if "" ~= ref and "" ~= name then
-		way.name = name .. ' / ' .. ref
-    elseif "" ~= ref then
-    	way.name = ref
-	elseif "" ~= name then
-		way.name = name
-	else
-		way.name = "{highway:"..highway.."}"	-- if no name exists, use way type
-		                                        -- this encoding scheme is excepted to be a temporary solution
-	end
-		
-	-- speed
-    if route_speeds[route] then
-		-- ferries (doesn't cover routes tagged using relations)
-		way.direction = Way.bidirectional
-		way.ignore_in_grid = true
-		if durationIsValid(duration) then
-			way.duration = math.max( 1, parseDuration(duration) )
-		else
-		 	way.speed = route_speeds[route]
-		end
-	elseif railway and platform_speeds[railway] then
-		-- railway platforms (old tagging scheme)
-		way.speed = platform_speeds[railway]
-	elseif platform_speeds[public_transport] then
-		-- public_transport platforms (new tagging platform)
-		way.speed = platform_speeds[public_transport]
-    elseif railway and railway_speeds[railway] then
-	 	-- railways
-		if access and access_tag_whitelist[access] then
-			way.speed = railway_speeds[railway]		
-			way.direction = Way.bidirectional
-		end
-	elseif amenity and amenity_speeds[amenity] then
-		-- parking areas
-		way.speed = amenity_speeds[amenity]
-	elseif bicycle_speeds[highway] then
-		-- regular ways
-      	way.speed = bicycle_speeds[highway]
-	elseif access and access_tag_whitelist[access] then
-	    -- unknown way, but valid access tag
-		way.speed = default_speed
-	else
-	    -- biking not allowed, maybe we can push our bike?
-	    -- essentially requires pedestrian profiling, for example foot=no mean we can't push a bike
-        -- TODO: if we can push, the way should be marked as pedestrion mode, but there's no way to do it yet from lua..
-        if foot ~= 'no' then
-	        if pedestrian_speeds[highway] then
-	            -- pedestrian-only ways and areas
-        		way.speed = pedestrian_speeds[highway]
-        	elseif man_made and man_made_speeds[man_made] then
-            	-- man made structures
-            	way.speed = man_made_speeds[man_made]
-            elseif foot == 'yes' then
-                way.speed = walking_speed
-            end
-        end
+  if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
+    result.backward_mode = 0
+  elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
+    -- prevent implied oneway
+  elseif onewayClass == "-1" then
+    result.forward_mode = 0
+  elseif oneway == "no" or oneway == "0" or oneway == "false" then
+    -- prevent implied oneway
+  elseif cycleway and string.find(cycleway, "opposite") == 1 then
+    if impliedOneway then
+      result.forward_mode = 0
+      result.backward_mode = mode_normal
+      result.backward_speed = bicycle_speeds["cycleway"]
     end
-		
-	-- direction
-	way.direction = Way.bidirectional
-	local impliedOneway = false
-	if junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then
-		way.direction = Way.oneway
-		impliedOneway = true
-	end
-	
-	if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
-		way.direction = Way.oneway
-	elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
-		way.direction = Way.bidirectional
-	elseif onewayClass == "-1" then
-		way.direction = Way.opposite
-	elseif oneway == "no" or oneway == "0" or oneway == "false" then
-		way.direction = Way.bidirectional
-	elseif cycleway and string.find(cycleway, "opposite") == 1 then
-		if impliedOneway then
-			way.direction = Way.opposite
-		else
-			way.direction = Way.bidirectional
-		end
-	elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then
-		way.direction = Way.bidirectional
-	elseif cycleway_left and cycleway_tags[cycleway_left] then
-		if impliedOneway then
-			way.direction = Way.opposite
-		else
-			way.direction = Way.bidirectional
-		end
-	elseif cycleway_right and cycleway_tags[cycleway_right] then
-		if impliedOneway then
-			way.direction = Way.oneway
-		else
-			way.direction = Way.bidirectional
-		end
-	elseif oneway == "-1" then
-		way.direction = Way.opposite
-	elseif oneway == "yes" or oneway == "1" or oneway == "true" then
-		way.direction = Way.oneway
-	end
-	
-	-- pushing bikes
-	if bicycle_speeds[highway] or pedestrian_speeds[highway] then
-	    if foot ~= 'no' then
-	        if junction ~= "roundabout" then
-            	if way.direction == Way.oneway then
-            	    way.backward_speed = walking_speed
-                elseif way.direction == Way.opposite then
-                    way.backward_speed = walking_speed
-                    way.speed = way.speed
-            	end
-            end
-        end
-        if way.backward_speed == way.speed then
-            -- TODO: no way yet to mark a way as pedestrian mode if forward/backward speeds are equal
-            way.direction = Way.bidirectional
-        end
+  elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then
+    -- prevent implied
+  elseif cycleway_left and cycleway_tags[cycleway_left] then
+    if impliedOneway then
+      result.forward_mode = 0
+      result.backward_mode = mode_normal
+      result.backward_speed = bicycle_speeds["cycleway"]
+    end
+  elseif cycleway_right and cycleway_tags[cycleway_right] then
+    if impliedOneway then
+      result.forward_mode = mode_normal
+      result.backward_speed = bicycle_speeds["cycleway"]
+      result.backward_mode = 0
     end
+  elseif oneway == "-1" then
+    result.forward_mode = 0
+  elseif oneway == "yes" or oneway == "1" or oneway == "true" or impliedOneway then
+    result.backward_mode = 0
+  end
 
-	
-	-- cycleways
-	if cycleway and cycleway_tags[cycleway] then
-		way.speed = bicycle_speeds["cycleway"]
-	elseif cycleway_left and cycleway_tags[cycleway_left] then
-		way.speed = bicycle_speeds["cycleway"]
-	elseif cycleway_right and cycleway_tags[cycleway_right] then
-		way.speed = bicycle_speeds["cycleway"]
-	end
-    
-    -- surfaces
-    if surface then
-        surface_speed = surface_speeds[surface]
-        if surface_speed then
-            way.speed = math.min(way.speed, surface_speed)
-            way.backward_speed  = math.min(way.backward_speed, surface_speed)
-        end
+  -- pushing bikes
+  if bicycle_speeds[highway] or pedestrian_speeds[highway] then
+    if foot ~= "no" and junction ~= "roundabout" then
+      if result.backward_mode == 0 then
+        result.backward_speed = walking_speed
+        result.backward_mode = mode_pushing
+      elseif result.forward_mode == 0 then
+        result.forward_speed = walking_speed
+        result.forward_mode = mode_pushing
+      end
     end
+  end
 
-	-- maxspeed
-	-- TODO: maxspeed of backward direction
-	if take_minimum_of_speeds then
-		if maxspeed and maxspeed>0 then
-			way.speed = math.min(way.speed, maxspeed)
-		end
-	end
+  -- cycleways
+  if cycleway and cycleway_tags[cycleway] then
+    result.forward_speed = bicycle_speeds["cycleway"]
+  elseif cycleway_left and cycleway_tags[cycleway_left] then
+    result.forward_speed = bicycle_speeds["cycleway"]
+  elseif cycleway_right and cycleway_tags[cycleway_right] then
+    result.forward_speed = bicycle_speeds["cycleway"]
+  end
 
-  -- Override speed settings if explicit forward/backward maxspeeds are given
-    if maxspeed_forward ~= nil and maxspeed_forward > 0 then
-	if Way.bidirectional == way.direction then
-          way.backward_speed = way.speed
-        end
-        way.speed = maxspeed_forward
-    end
-    if maxspeed_backward ~= nil and maxspeed_backward > 0 then
-      way.backward_speed = maxspeed_backward
-    end
+  -- dismount
+  if bicycle == "dismount" then
+    result.forward_mode = mode_pushing
+    result.backward_mode = mode_pushing
+    result.forward_speed = walking_speed
+    result.backward_speed = walking_speed
+  end
 
+  -- surfaces
+  if surface then
+    surface_speed = surface_speeds[surface]
+    if surface_speed then
+      if result.forward_speed > 0 then
+        result.forward_speed = surface_speed
+      end
+      if result.backward_speed > 0 then
+        result.backward_speed  = surface_speed
+      end
+    end
+  end
 
-	
-	way.type = 1
-	return 1
+  -- maxspeed
+  MaxSpeed.limit( result, maxspeed, maxspeed_forward, maxspeed_backward )
 end
 
 function turn_function (angle)
-    -- compute turn penalty as angle^2, with a left/right bias
-    k = turn_penalty/(90.0*90.0)
-	if angle>=0 then
-	    return angle*angle*k/turn_bias
-	else
-	    return angle*angle*k*turn_bias
-    end
+  -- compute turn penalty as angle^2, with a left/right bias
+  k = turn_penalty/(90.0*90.0)
+  if angle>=0 then
+    return angle*angle*k/turn_bias
+  else
+    return angle*angle*k*turn_bias
+  end
 end
diff --git a/debian/conffiles/car.lua b/debian/conffiles/car.lua
index ff7c379..cd1f06b 100644
--- a/debian/conffiles/car.lua
+++ b/debian/conffiles/car.lua
@@ -1,9 +1,9 @@
 -- Begin of globals
-require("lib/access")
+--require("lib/access") --function temporarily inlined
 
-barrier_whitelist = { ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["no"] = 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 }
+barrier_whitelist = { ["cattle_grid"] = true, ["border_control"] = true, ["checkpoint"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = true, ["no"] = true, ["entrance"] = 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 }
 access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
 access_tags = { "motorcar", "motor_vehicle", "vehicle" }
 access_tags_hierachy = { "motorcar", "motor_vehicle", "vehicle", "access" }
@@ -13,15 +13,15 @@ restriction_exception_tags = { "motorcar", "motor_vehicle", "vehicle" }
 
 speed_profile = {
   ["motorway"] = 90,
-  ["motorway_link"] = 75,
+  ["motorway_link"] = 45,
   ["trunk"] = 85,
-  ["trunk_link"] = 70,
+  ["trunk_link"] = 40,
   ["primary"] = 65,
-  ["primary_link"] = 60,
+  ["primary_link"] = 30,
   ["secondary"] = 55,
-  ["secondary_link"] = 50,
+  ["secondary_link"] = 25,
   ["tertiary"] = 40,
-  ["tertiary_link"] = 30,
+  ["tertiary_link"] = 20,
   ["unclassified"] = 25,
   ["residential"] = 25,
   ["living_street"] = 10,
@@ -29,191 +29,374 @@ speed_profile = {
 --  ["track"] = 5,
   ["ferry"] = 5,
   ["shuttle_train"] = 10,
-  ["default"] = 50
+  ["default"] = 10
 }
 
-take_minimum_of_speeds 	= false
-obey_oneway 			= true
-obey_bollards 			= true
-use_restrictions 		= true
-ignore_areas 			= true -- future feature
-traffic_signal_penalty 	= 2
-u_turn_penalty 			= 20
 
--- End of globals
+-- surface/trackype/smoothness
+-- values were estimated from looking at the photos at the relevant wiki pages
+
+-- max speed for surfaces
+surface_speeds = {
+  ["asphalt"] = nil,    -- nil mean no limit. removing the line has the same effect
+  ["concrete"] = nil,
+  ["concrete:plates"] = nil,
+  ["concrete:lanes"] = nil,
+  ["paved"] = nil,
+
+  ["cement"] = 80,
+  ["compacted"] = 80,
+  ["fine_gravel"] = 80,
+
+  ["paving_stones"] = 60,
+  ["metal"] = 60,
+  ["bricks"] = 60,
+
+  ["grass"] = 40,
+  ["wood"] = 40,
+  ["sett"] = 40,
+  ["grass_paver"] = 40,
+  ["gravel"] = 40,
+  ["unpaved"] = 40,
+  ["ground"] = 40,
+  ["dirt"] = 40,
+  ["pebblestone"] = 40,
+  ["tartan"] = 40,
+
+  ["cobblestone"] = 30,
+  ["clay"] = 30,
+
+  ["earth"] = 20,
+  ["stone"] = 20,
+  ["rocky"] = 20,
+  ["sand"] = 20,
+
+  ["mud"] = 10
+}
+
+-- max speed for tracktypes
+tracktype_speeds = {
+  ["grade1"] =  60,
+  ["grade2"] =  40,
+  ["grade3"] =  30,
+  ["grade4"] =  25,
+  ["grade5"] =  20
+}
+
+-- max speed for smoothnesses
+smoothness_speeds = {
+  ["intermediate"]    =  80,
+  ["bad"]             =  40,
+  ["very_bad"]        =  20,
+  ["horrible"]        =  10,
+  ["very_horrible"]   =  5,
+  ["impassable"]      =  0
+}
+
+-- http://wiki.openstreetmap.org/wiki/Speed_limits
+maxspeed_table_default = {
+  ["urban"] = 50,
+  ["rural"] = 90,
+  ["trunk"] = 110,
+  ["motorway"] = 130
+}
+
+-- List only exceptions
+maxspeed_table = {
+  ["ch:rural"] = 80,
+  ["ch:trunk"] = 100,
+  ["ch:motorway"] = 120,
+  ["de:living_street"] = 7,
+  ["ru:living_street"] = 20,
+  ["ru:urban"] = 60,
+  ["ua:urban"] = 60,
+  ["at:rural"] = 100,
+  ["de:rural"] = 100,
+  ["at:trunk"] = 100,
+  ["cz:trunk"] = 0,
+  ["ro:trunk"] = 100,
+  ["cz:motorway"] = 0,
+  ["de:motorway"] = 0,
+  ["ru:motorway"] = 110,
+  ["gb:nsl_single"] = (60*1609)/1000,
+  ["gb:nsl_dual"] = (70*1609)/1000,
+  ["gb:motorway"] = (70*1609)/1000,
+  ["uk:nsl_single"] = (60*1609)/1000,
+  ["uk:nsl_dual"] = (70*1609)/1000,
+  ["uk:motorway"] = (70*1609)/1000
+}
+
+traffic_signal_penalty          = 2
+use_turn_restrictions           = true
+
+local take_minimum_of_speeds    = false
+local obey_oneway               = true
+local obey_bollards             = true
+local ignore_areas              = true     -- future feature
+local u_turn_penalty            = 20
+
+local abs = math.abs
+local min = math.min
+local max = math.max
+
+local speed_reduction = 0.8
+
+--modes
+local mode_normal = 1
+local mode_ferry = 2
+
+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)
-	for i,v in ipairs(restriction_exception_tags) do
-		vector:Add(v)
-	end
+  for i,v in ipairs(restriction_exception_tags) do
+    vector:Add(v)
+  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)
+  if not source then
+    return 0
+  end
+  local n = tonumber(source:match("%d*"))
+  if n then
+    if string.match(source, "mph") or string.match(source, "mp/h") then
+      n = (n*1609)/1000;
+    end
+  else
+    -- parse maxspeed like FR:urban
+    source = string.lower(source)
+    n = maxspeed_table[source]
+    if not n then
+      local highway_type = string.match(source, "%a%a:(%a+)")
+      n = maxspeed_table_default[highway_type]
+      if not n then
+        n = 0
+      end
+    end
+  end
+  return n
 end
 
-function node_function (node)
-  local barrier = node.tags:Find ("barrier")
-  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
-		end
-	elseif barrier and barrier ~= "" then
-		if barrier_whitelist[barrier] then
-			return
-		else
-			node.bollard = true
-		end
-	end
-	return 1
+-- function turn_function (angle)
+--   -- print ("called at angle " .. angle )
+--   local index = math.abs(math.floor(angle/10+0.5))+1 -- +1 'coz LUA starts as idx 1
+--   local penalty = turn_cost_table[index]
+--   -- print ("index: " .. index .. ", bias: " .. penalty )
+--   return penalty
+-- end
+
+function node_function (node, result)
+  -- parse access and barrier tags
+  local access = find_access_tag(node, access_tags_hierachy)
+  if access ~= "" then
+    if access_tag_blacklist[access] then
+      result.barrier = true
+    end
+  else
+    local barrier = node:get_value_by_key("barrier")
+    if barrier and "" ~= barrier then
+      if barrier_whitelist[barrier] then
+        return
+      else
+        result.barrier = true
+      end
+    end
+  end
+
+  -- check if node is a traffic light
+  local tag = node:get_value_by_key("highway")
+  if tag and "traffic_signals" == tag then
+    result.traffic_lights = true;
+  end
 end
 
+function way_function (way, result)
+  local highway = way:get_value_by_key("highway")
+  local route = way:get_value_by_key("route")
+
+  if not ((highway and highway ~= "") or (route and route ~= "")) then
+    return
+  end
 
-function way_function (way)
   -- we dont route over areas
-  local area = way.tags:Find("area")
-  if ignore_areas and ("yes" == area) then
-    return 0
+  local area = way:get_value_by_key("area")
+  if ignore_areas and area and "yes" == area then
+    return
   end
 
   -- check if oneway tag is unsupported
-  local oneway = way.tags:Find("oneway")
-  if "reversible" == oneway then
-    return 0
+  local oneway = way:get_value_by_key("oneway")
+  if oneway and "reversible" == oneway then
+    return
   end
 
-  -- Check if we are allowed to access the way
-  local access = Access.find_access_tag(way, access_tags_hierachy)
-  if access_tag_blacklist[access] then
-    return 0
+  local impassable = way:get_value_by_key("impassable")
+  if impassable and "yes" == impassable then
+    return
   end
 
-  -- Second, parse the way according to these properties
-  local highway = way.tags:Find("highway")
-  local name = way.tags:Find("name")
-  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_forward = parse_maxspeed(way.tags:Find( "maxspeed:forward"))
-  local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward"))
-  local barrier = way.tags:Find("barrier")
-  local cycleway = way.tags:Find("cycleway")
-  local duration  = way.tags:Find("duration")
-  local service  = way.tags:Find("service")
-
+  local status = way:get_value_by_key("status")
+  if status and "impassable" == status then
+    return
+  end
 
-  -- Set the name that will be used for instructions
-	if "" ~= ref then
-	  way.name = ref
-	elseif "" ~= name then
-	  way.name = name
---	else
---      way.name = highway		-- if no name exists, use way type
-	end
-
-	if "roundabout" == junction then
-	  way.roundabout = true;
-	end
+  -- Check if we are allowed to access the way
+  local access = find_access_tag(way, access_tags_hierachy)
+  if access_tag_blacklist[access] then
+    return
+  end
 
   -- Handling ferries and piers
-  if (speed_profile[route] ~= nil and speed_profile[route] > 0) then
-    if durationIsValid(duration) then
-      way.duration = math.max( parseDuration(duration), 1 );
-    end
-    way.direction = Way.bidirectional
-    if speed_profile[route] ~= nil then
-      highway = route;
-    end
-    if tonumber(way.duration) < 0 then
-      way.speed = speed_profile[highway]
+  local route_speed = speed_profile[route]
+  if(route_speed and route_speed > 0) then
+    highway = route;
+    local duration  = way:get_value_by_key("duration")
+    if duration and durationIsValid(duration) then
+      result.duration = max( parseDuration(duration), 1 );
     end
+    result.forward_mode = mode_ferry
+    result.backward_mode = mode_ferry
+    result.forward_speed = route_speed
+    result.backward_speed = route_speed
+  end
+
+  -- leave early of this way is not accessible
+  if "" == highway then
+    return
   end
 
-  -- 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
+  if result.forward_speed == -1 then
+    local highway_speed = speed_profile[highway]
+    local max_speed = parse_maxspeed( way:get_value_by_key("maxspeed") )
+    -- Set the avg speed on the way if it is accessible by road class
+    if highway_speed then
+      if max_speed and max_speed > highway_speed then
+        result.forward_speed = max_speed
+        result.backward_speed = max_speed
+        -- max_speed = math.huge
+      else
+        result.forward_speed = highway_speed
+        result.backward_speed = highway_speed
+      end
     else
-      if 0 == maxspeed then
-        maxspeed = math.huge
+      -- Set the avg speed on ways that are marked accessible
+      if access_tag_whitelist[access] then
+        result.forward_speed = speed_profile["default"]
+        result.backward_speed = speed_profile["default"]
       end
-      way.speed = math.min(speed_profile[highway], maxspeed)
     end
+    if 0 == max_speed then
+      max_speed = math.huge
+    end
+    result.forward_speed = min(result.forward_speed, max_speed)
+    result.backward_speed = min(result.backward_speed, max_speed)
   end
 
-  -- Set the avg speed on ways that are marked accessible
-  if "" ~= highway and access_tag_whitelist[access] and way.speed == -1 then
-    if 0 == maxspeed then
-      maxspeed = math.huge
-    end
-    way.speed = math.min(speed_profile["default"], maxspeed)
+  if -1 == result.forward_speed and -1 == result.backward_speed then
+    return
+  end
+
+  -- reduce speed on bad surfaces
+  local surface = way:get_value_by_key("surface")
+  local tracktype = way:get_value_by_key("tracktype")
+  local smoothness = way:get_value_by_key("smoothness")
+
+  if surface and surface_speeds[surface] then
+    result.forward_speed = math.min(surface_speeds[surface], result.forward_speed)
+    result.backward_speed = math.min(surface_speeds[surface], result.backward_speed)
+  end
+  if tracktype and tracktype_speeds[tracktype] then
+    result.forward_speed = math.min(tracktype_speeds[tracktype], result.forward_speed)
+    result.backward_speed = math.min(tracktype_speeds[tracktype], result.backward_speed)
+  end
+  if smoothness and smoothness_speeds[smoothness] then
+    result.forward_speed = math.min(smoothness_speeds[smoothness], result.forward_speed)
+    result.backward_speed = math.min(smoothness_speeds[smoothness], result.backward_speed)
+  end
+
+  -- parse the remaining tags
+  local name = way:get_value_by_key("name")
+  local ref = way:get_value_by_key("ref")
+  local junction = way:get_value_by_key("junction")
+  -- local barrier = way:get_value_by_key("barrier", "")
+  -- local cycleway = way:get_value_by_key("cycleway", "")
+  local service = way:get_value_by_key("service")
+
+  -- Set the name that will be used for instructions
+  if ref and "" ~= ref then
+    result.name = ref
+  elseif name and "" ~= name then
+    result.name = name
+--  else
+      --    result.name = highway  -- if no name exists, use way type
+  end
+
+  if junction and "roundabout" == junction then
+    result.roundabout = true;
   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
+    result.is_access_restricted = true
   end
 
   -- Set access restriction flag if service is allowed under certain restrictions only
-  if service ~= "" and service_tag_restricted[service] then
-	  way.is_access_restricted = true
+  if service and service ~= "" and service_tag_restricted[service] then
+    result.is_access_restricted = true
   end
 
   -- Set direction according to tags on way
-  way.direction = Way.bidirectional
   if obey_oneway then
-	  if oneway == "-1" then
-	    way.direction = Way.opposite
-    elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then
-	    way.direction = Way.oneway
+    if oneway == "-1" then
+      result.forward_mode = 0
+    elseif oneway == "yes" or
+    oneway == "1" or
+    oneway == "true" or
+    junction == "roundabout" or
+    (highway == "motorway_link" and oneway ~="no") or
+    (highway == "motorway" and oneway ~= "no") then
+      result.backward_mode = 0
     end
   end
 
   -- Override speed settings if explicit forward/backward maxspeeds are given
-  if maxspeed_forward ~= nil and maxspeed_forward > 0 then
-    if Way.bidirectional == way.direction then
-      way.backward_speed = way.speed
+  local maxspeed_forward = parse_maxspeed(way:get_value_by_key( "maxspeed:forward"))
+  local maxspeed_backward = parse_maxspeed(way:get_value_by_key( "maxspeed:backward"))
+  if maxspeed_forward and maxspeed_forward > 0 then
+    if 0 ~= result.forward_mode and 0 ~= result.backward_mode then
+      result.backward_speed = result.forward_speed
     end
-    way.speed = maxspeed_forward
+    result.forward_speed = maxspeed_forward
   end
-  if maxspeed_backward ~= nil and maxspeed_backward > 0 then
-    way.backward_speed = maxspeed_backward
+  if maxspeed_backward and maxspeed_backward > 0 then
+    result.backward_speed = maxspeed_backward
   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
+  if ignore_in_grid[highway] then
+    result.ignore_in_grid = true
+  end
 
-	way.type = 1
-  return 1
+  -- scale speeds to get better avg driving times
+  if result.forward_speed > 0 then
+    result.forward_speed = result.forward_speed*speed_reduction + 11;
+  end
+  if result.backward_speed > 0 then
+    result.backward_speed = result.backward_speed*speed_reduction + 11;
+  end
 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
-  node_function(v)
- end
+  for v in vector.nodes do
+    node_function(v)
+  end
 end
diff --git a/debian/conffiles/foot.lua b/debian/conffiles/foot.lua
index 6a15fb2..5a37097 100644
--- a/debian/conffiles/foot.lua
+++ b/debian/conffiles/foot.lua
@@ -1,193 +1,211 @@
 -- Foot profile
 
--- Begin of globals
+require("lib/access")
 
-bollards_whitelist = { [""] = true, ["cattle_grid"] = true, ["border_control"] = true, ["toll_booth"] = true, ["sally_port"] = true, ["gate"] = 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_blacklist = { ["no"] = true, ["private"] = true, ["agricultural"] = true, ["forestery"] = true }
 access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
-access_tags = { "foot" }
+access_tags_hierachy = { "foot", "access" }
 service_tag_restricted = { ["parking_aisle"] = true }
 ignore_in_grid = { ["ferry"] = true }
 restriction_exception_tags = { "foot" }
 
-speed_profile = { 
-  ["primary"] = 5,
-  ["primary_link"] = 5,
-  ["secondary"] = 5,
-  ["secondary_link"] = 5,
-  ["tertiary"] = 5,
-  ["tertiary_link"] = 5,
-  ["unclassified"] = 5,
-  ["residential"] = 5,
-  ["road"] = 5,
-  ["living_street"] = 5,
-  ["service"] = 5,
-  ["track"] = 5,
-  ["path"] = 5,
-  ["steps"] = 5,
-  ["ferry"] = 5,
-  ["pedestrian"] = 5,
-  ["footway"] = 5,
-  ["pier"] = 5,
-  ["default"] = 5
+walking_speed = 5
+
+speeds = {
+  ["primary"] = walking_speed,
+  ["primary_link"] = walking_speed,
+  ["secondary"] = walking_speed,
+  ["secondary_link"] = walking_speed,
+  ["tertiary"] = walking_speed,
+  ["tertiary_link"] = walking_speed,
+  ["unclassified"] = walking_speed,
+  ["residential"] = walking_speed,
+  ["road"] = walking_speed,
+  ["living_street"] = walking_speed,
+  ["service"] = walking_speed,
+  ["track"] = walking_speed,
+  ["path"] = walking_speed,
+  ["steps"] = walking_speed,
+  ["pedestrian"] = walking_speed,
+  ["footway"] = walking_speed,
+  ["pier"] = walking_speed,
+  ["default"] = walking_speed
 }
 
+route_speeds = {
+	["ferry"] = 5
+}
+
+platform_speeds = {
+	["platform"] = walking_speed
+}
+
+amenity_speeds = {
+	["parking"] = walking_speed,
+	["parking_entrance"] = walking_speed
+}
+
+man_made_speeds = {
+	["pier"] = walking_speed
+}
+
+surface_speeds = {
+	["fine_gravel"] =   walking_speed*0.75,
+	["gravel"] =        walking_speed*0.75,
+	["pebbelstone"] =   walking_speed*0.75,
+	["mud"] =           walking_speed*0.5,
+	["sand"] =          walking_speed*0.5
+}
 
-take_minimum_of_speeds 	= true
-obey_oneway 			= true
-obey_bollards 			= false
-use_restrictions 		= false
-ignore_areas 			= true -- future feature
 traffic_signal_penalty 	= 2
 u_turn_penalty 			= 2
 use_turn_restrictions   = false
--- End of globals
+
+--modes
+local mode_normal = 1
+local mode_ferry = 2
 
 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)
 	end
 end
 
-function node_function (node)
-  local barrier = node.tags:Find ("barrier")
-  local access = node.tags:Find ("access")
-  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
-  
-  if obey_bollards then
-	  --flag node as unpassable if it black listed as unpassable
-	  if access_tag_blacklist[barrier] then
-		node.bollard = true;
-	  end
-	  
-	  --reverse the previous flag if there is an access tag specifying entrance
-	  if node.bollard and not bollards_whitelist[barrier] and not access_tag_whitelist[barrier] then
-		node.bollard = false;
-	  end
-  end
-  return 1
-end
+function node_function (node, result)
+	local barrier = node:get_value_by_key("barrier")
+	local access = Access.find_access_tag(node, access_tags_hierachy)
+	local traffic_signal = node:get_value_by_key("highway")
+
+	-- flag node if it carries a traffic light
+	if traffic_signal and traffic_signal == "traffic_signals" then
+		result.traffic_light = true
+	end
 
-function way_function (way)
-
-  -- First, get the properties of each way that we come across
-    local highway = way.tags:Find("highway")
-    local name = way.tags:Find("name")
-    local ref = way.tags:Find("ref")
-    local junction = way.tags:Find("junction")
-    local route = way.tags:Find("route")
-    local maxspeed = parseMaxspeed(way.tags:Find ( "maxspeed") )
-    local man_made = way.tags:Find("man_made")
-    local barrier = way.tags:Find("barrier")
-    local oneway = way.tags:Find("oneway")
-	local onewayClass = way.tags:Find("oneway:foot")
-    local duration  = way.tags:Find("duration")
-    local service  = way.tags:Find("service")
-    local area = way.tags:Find("area")
-    local access = way.tags:Find("access")
-
-  -- Second parse the way according to these properties
-
-	if ignore_areas and ("yes" == area) then
-		return 0
+	-- parse access and barrier tags
+	if access and access ~= "" then
+		if access_tag_blacklist[access] then
+			result.barrier = true
+		else
+			result.barrier = false
+		end
+	elseif barrier and barrier ~= "" then
+		if barrier_whitelist[barrier] then
+			result.barrier = false
+		else
+			result.barrier = true
+		end
 	end
-		
-  -- Check if we are allowed to access the way
-    if access_tag_blacklist[access] ~=nil and access_tag_blacklist[access] then
-		return 0;
+
+	return 1
+end
+
+function way_function (way, result)
+	-- initial routability check, filters out buildings, boundaries, etc
+	local highway = way:get_value_by_key("highway")
+	local route = way:get_value_by_key("route")
+	local man_made = way:get_value_by_key("man_made")
+	local railway = way:get_value_by_key("railway")
+	local amenity = way:get_value_by_key("amenity")
+	local public_transport = way:get_value_by_key("public_transport")
+	if (not highway or highway == '') and
+		(not route or route == '') and
+		(not railway or railway=='') and
+		(not amenity or amenity=='') and
+		(not man_made or man_made=='') and
+		(not public_transport or public_transport=='')
+		then
+		return
     end
-    
-  -- Check if our vehicle types are forbidden
-    for i,v in ipairs(access_tags) do 
-      local mode_value = way.tags:Find(v)
-      if nil ~= mode_value and "no" == mode_value then
-	    return 0;
-      end
+
+    -- don't route on ways that are still under construction
+    if highway=='construction' then
+        return
     end
-  
-    
-  -- Set the name that will be used for instructions  
-	if "" ~= ref then
-	  way.name = ref
-	elseif "" ~= name then
-	  way.name = name
+
+	-- access
+    local access = Access.find_access_tag(way, access_tags_hierachy)
+    if access_tag_blacklist[access] then
+		return
+    end
+
+	local name = way:get_value_by_key("name")
+	local ref = way:get_value_by_key("ref")
+	local junction = way:get_value_by_key("junction")
+	local onewayClass = way:get_value_by_key("oneway:foot")
+	local duration	= way:get_value_by_key("duration")
+	local service	= way:get_value_by_key("service")
+	local area = way:get_value_by_key("area")
+	local foot = way:get_value_by_key("foot")
+	local surface = way:get_value_by_key("surface")
+
+ 	-- name
+	if ref and "" ~= ref and name and "" ~= name then
+		result.name = name .. ' / ' .. ref
+    elseif ref and "" ~= ref then
+    	result.name = ref
+	elseif name and "" ~= name then
+		result.name = name
+	elseif highway then
+		result.name = "{highway:"..highway.."}"	-- if no name exists, use way type
+		                                        -- this encoding scheme is excepted to be a temporary solution
 	end
-	
+
+    -- roundabouts
 	if "roundabout" == junction then
-	  way.roundabout = true;
+	  result.roundabout = true;
 	end
 
-  -- Handling ferries and piers
-
-    if (speed_profile[route] ~= nil and speed_profile[route] > 0) or
-       (speed_profile[man_made] ~= nil and speed_profile[man_made] > 0) 
-    then
-      if durationIsValid(duration) then
-	    way.speed = parseDuration(duration) / math.max(1, numberOfNodesInWay-1);
-        way.is_duration_set = true;
-      end
-      way.direction = Way.bidirectional;
-      if speed_profile[route] ~= nil then
-         highway = route;
-      elseif speed_profile[man_made] ~= nil then
-         highway = man_made;
-      end
-      if not way.is_duration_set then
-        way.speed = speed_profile[highway]
-      end
-      
-    end
-    
-  -- Set the avg speed on the way if it is accessible by road class
-    if (speed_profile[highway] ~= nil and way.speed == -1 ) then 
-      way.speed = speed_profile[highway]
-    end
-    
-  -- Set the avg speed on ways that are marked accessible
-    if access_tag_whitelist[access]  and way.speed == -1 then
-      if (0 < maxspeed and not take_minimum_of_speeds) or maxspeed == 0 then
-        maxspeed = math.huge
-      end
-      way.speed = math.min(speed_profile["default"], maxspeed)
+    -- speed
+    if route_speeds[route] then
+		-- ferries (doesn't cover routes tagged using relations)
+		result.ignore_in_grid = true
+		if duration and durationIsValid(duration) then
+			result.duration = math.max( 1, parseDuration(duration) )
+		else
+			result.forward_speed = route_speeds[route]
+			result.backward_speed = route_speeds[route]
+		end
+		result.forward_mode = mode_ferry
+		result.backward_mode = mode_ferry
+	elseif railway and platform_speeds[railway] then
+		-- railway platforms (old tagging scheme)
+		result.forward_speed = platform_speeds[railway]
+		result.backward_speed = platform_speeds[railway]
+	elseif platform_speeds[public_transport] then
+		-- public_transport platforms (new tagging platform)
+		result.forward_speed = platform_speeds[public_transport]
+		result.backward_speed = platform_speeds[public_transport]
+	elseif amenity and amenity_speeds[amenity] then
+		-- parking areas
+		result.forward_speed = amenity_speeds[amenity]
+		result.backward_speed = amenity_speeds[amenity]
+	elseif speeds[highway] then
+		-- regular ways
+		result.forward_speed = speeds[highway]
+		result.backward_speed = speeds[highway]
+	elseif access and access_tag_whitelist[access] then
+	    -- unknown way, but valid access tag
+		result.forward_speed = walking_speed
+		result.backward_speed = walking_speed
     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
+	-- oneway
+	if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
+		result.backward_mode = 0
+	elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
+		-- nothing to do
+	elseif onewayClass == "-1" then
+		result.forward_mode = 0
     end
 
-  -- Set access restriction flag if service is allowed under certain restrictions only
-    if service ~= "" and service_tag_restricted[service] then
-	  way.is_access_restricted = true
-    end
-    
-  -- Set direction according to tags on way
-    if obey_oneway then
-		if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
-			way.direction = Way.oneway
-		elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
-			way.direction = Way.bidirectional
-		elseif onewayClass == "-1" then
-			way.direction = Way.opposite
-		else
-			way.direction = Way.bidirectional
-		end
-    else
-      way.direction = Way.bidirectional
+    -- surfaces
+    if surface then
+        surface_speed = surface_speeds[surface]
+        if surface_speed then
+            result.forward_speed = math.min(result.forward_speed, surface_speed)
+            result.backward_speed  = math.min(result.backward_speed, surface_speed)
+        end
     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
 end
diff --git a/debian/conffiles/maxspeed.lua b/debian/conffiles/maxspeed.lua
new file mode 100644
index 0000000..aca344a
--- /dev/null
+++ b/debian/conffiles/maxspeed.lua
@@ -0,0 +1,17 @@
+local math = math
+
+module "MaxSpeed"
+
+function limit(way,max,maxf,maxb)
+  if maxf and maxf>0 then
+    way.forward_speed = math.min(way.forward_speed, maxf)
+  elseif max and max>0 then
+    way.forward_speed = math.min(way.forward_speed, max)
+  end
+
+  if maxb and maxb>0 then
+    way.backward_speed = math.min(way.backward_speed, maxb)
+  elseif max and max>0 then
+    way.backward_speed = math.min(way.backward_speed, max)
+  end
+end
diff --git a/debian/conffiles/testbot.lua b/debian/conffiles/testbot.lua
index f934fea..7bd1416 100644
--- a/debian/conffiles/testbot.lua
+++ b/debian/conffiles/testbot.lua
@@ -2,106 +2,121 @@
 
 -- Moves at fixed, well-known speeds, practical for testing speed and travel times:
 
--- Primary road:	36km/h = 36000m/3600s = 100m/10s
--- Secondary road:	18km/h = 18000m/3600s = 100m/20s
--- Tertiary road:	12km/h = 12000m/3600s = 100m/30s
-
-speed_profile = { 
-	["primary"] = 36,
-	["secondary"] = 18,
-	["tertiary"] = 12,
-	["default"] = 24
+-- Primary road:  36km/h = 36000m/3600s = 100m/10s
+-- Secondary road:  18km/h = 18000m/3600s = 100m/20s
+-- Tertiary road:  12km/h = 12000m/3600s = 100m/30s
+
+-- modes:
+-- 1: normal
+-- 2: route
+-- 3: river downstream
+-- 4: river upstream
+-- 5: steps down
+-- 6: steps up
+
+speed_profile = {
+  ["primary"] = 36,
+  ["secondary"] = 18,
+  ["tertiary"] = 12,
+  ["steps"] = 6,
+  ["default"] = 24
 }
 
 -- these settings are read directly by osrm
 
-take_minimum_of_speeds 	= true
-obey_oneway 			= true
-obey_bollards 			= true
-use_restrictions 		= true
-ignore_areas 			= true	-- future feature
-traffic_signal_penalty 	= 7		-- seconds
-u_turn_penalty 			= 20
+take_minimum_of_speeds  = true
+obey_oneway             = true
+obey_barriers           = true
+use_turn_restrictions   = true
+ignore_areas            = true  -- future feature
+traffic_signal_penalty  = 7     -- seconds
+u_turn_penalty          = 20
 
 function limit_speed(speed, limits)
-    -- don't use ipairs(), since it stops at the first nil value
-    for i=1, #limits do
-        limit = limits[i]
-        if limit ~= nil and limit > 0 then
-            if limit < speed then
-                return limit        -- stop at first speedlimit that's smaller than speed
-            end
-        end
+  -- don't use ipairs(), since it stops at the first nil value
+  for i=1, #limits do
+    limit = limits[i]
+    if limit ~= nil and limit > 0 then
+      if limit < speed then
+        return limit        -- stop at first speedlimit that's smaller than speed
+      end
     end
-    return speed
+  end
+  return speed
 end
 
-function node_function (node)
-	local traffic_signal = node.tags:Find("highway")
+function node_function (node, result)
+  local traffic_signal = node:get_value_by_key("highway")
 
-	if traffic_signal == "traffic_signals" then
-		node.traffic_light = true;
-		-- TODO: a way to set the penalty value
-	end
-	return 1
+  if traffic_signal and traffic_signal == "traffic_signals" then
+    result.traffic_lights = true;
+    -- TODO: a way to set the penalty value
+  end
 end
 
-function way_function (way)
-	local highway = way.tags:Find("highway")
-	local name = way.tags:Find("name")
-	local oneway = way.tags:Find("oneway")
-	local route = way.tags:Find("route")
-	local duration = way.tags:Find("duration")
-    local maxspeed = tonumber(way.tags:Find ( "maxspeed"))
-    local maxspeed_forward = tonumber(way.tags:Find( "maxspeed:forward"))
-    local maxspeed_backward = tonumber(way.tags:Find( "maxspeed:backward"))
-	
-	way.name = name
-
-  	if route ~= nil and durationIsValid(duration) then
-		way.duration = math.max( 1, parseDuration(duration) )
-	else
-	    local speed_forw = speed_profile[highway] or speed_profile['default']
-	    local speed_back = speed_forw
-
-    	if highway == "river" then
-    		local temp_speed = speed_forw;
-    		speed_forw = temp_speed*1.5
-    		speed_back = temp_speed/1.5
-   	end
-            	
-        if maxspeed_forward ~= nil and maxspeed_forward > 0 then
-			speed_forw = maxspeed_forward
-		else
-			if maxspeed ~= nil and maxspeed > 0 and speed_forw > maxspeed then
-				speed_forw = maxspeed
-			end
-		end
-		
-		if maxspeed_backward ~= nil and maxspeed_backward > 0 then
-			speed_back = maxspeed_backward
-		else
-			if maxspeed ~=nil and maxspeed > 0 and speed_back > maxspeed then
-				speed_back = maxspeed
-			end
-		end
-        
-        way.speed = speed_forw
-        if speed_back ~= way_forw then
-            way.backward_speed = speed_back
-        end
-	end
-	
-	if oneway == "no" or oneway == "0" or oneway == "false" then
-		way.direction = Way.bidirectional
-	elseif oneway == "-1" then
-		way.direction = Way.opposite
-	elseif oneway == "yes" or oneway == "1" or oneway == "true" then
-		way.direction = Way.oneway
-	else
-		way.direction = Way.bidirectional
-	end
-	
-	way.type = 1
-	return 1
+function way_function (way, result)
+  local highway = way:get_value_by_key("highway")
+  local name = way:get_value_by_key("name")
+  local oneway = way:get_value_by_key("oneway")
+  local route = way:get_value_by_key("route")
+  local duration = way:get_value_by_key("duration")
+  local maxspeed = tonumber(way:get_value_by_key ( "maxspeed"))
+  local maxspeed_forward = tonumber(way:get_value_by_key( "maxspeed:forward"))
+  local maxspeed_backward = tonumber(way:get_value_by_key( "maxspeed:backward"))
+  local junction = way:get_value_by_key("junction")
+
+  if name then
+    result.name = name
+  end
+
+  if duration and durationIsValid(duration) then
+    result.duration = math.max( 1, parseDuration(duration) )
+    result.forward_mode = 2
+    result.backward_mode = 2
+  else
+    local speed_forw = speed_profile[highway] or speed_profile['default']
+    local speed_back = speed_forw
+
+    if highway == "river" then
+      local temp_speed = speed_forw;
+      result.forward_mode = 3
+      result.backward_mode = 4
+      speed_forw = temp_speed*1.5
+      speed_back = temp_speed/1.5
+    elseif highway == "steps" then
+      result.forward_mode = 5
+      result.backward_mode = 6
+    end
+
+    if maxspeed_forward ~= nil and maxspeed_forward > 0 then
+      speed_forw = maxspeed_forward
+    else
+      if maxspeed ~= nil and maxspeed > 0 and speed_forw > maxspeed then
+        speed_forw = maxspeed
+      end
+    end
+
+    if maxspeed_backward ~= nil and maxspeed_backward > 0 then
+      speed_back = maxspeed_backward
+    else
+      if maxspeed ~=nil and maxspeed > 0 and speed_back > maxspeed then
+        speed_back = maxspeed
+      end
+    end
+
+    result.forward_speed = speed_forw
+    result.backward_speed = speed_back
+  end
+
+  if oneway == "no" or oneway == "0" or oneway == "false" then
+    -- nothing to do
+  elseif oneway == "-1" then
+    result.forward_mode = 0
+  elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" then
+    result.backward_mode = 0
+  end
+
+  if junction == 'roundabout' then
+    result.roundabout = true
+  end
 end

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osrm.git



More information about the Pkg-grass-devel mailing list