diff --git a/features/testbot/distance.feature b/features/testbot/distance.feature index 1f777d24f..55b5f6416 100644 --- a/features/testbot/distance.feature +++ b/features/testbot/distance.feature @@ -145,7 +145,7 @@ Feature: Distance calculation | a | h | abcdefgh | 70m +-14 | Scenario: Geometric distances - Given a grid size of 1000 meters + Given a grid size of 100 meters Given the node map | v | w | y | a | b | c | d | | u | | | | | | e | @@ -184,30 +184,30 @@ Feature: Distance calculation When I route I should get | from | to | route | distance | - | x | a | xa | 3000m +-2 | - | x | b | xb | 3162m +-2 | - | x | c | xc | 3606m +-2 | - | x | d | xd | 4243m +-2 | - | x | e | xe | 3606m +-2 | - | x | f | xf | 3162m +-2 | - | x | g | xg | 3000m +-2 | - | x | h | xh | 3162m +-2 | - | x | i | xi | 3606m +-2 | - | x | j | xj | 4243m +-2 | - | x | k | xk | 3606m +-2 | - | x | l | xl | 3162m +-2 | - | x | m | xm | 3000m +-2 | - | x | n | xn | 3162m +-2 | - | x | o | xo | 3606m +-2 | - | x | p | xp | 4243m +-2 | - | x | q | xq | 3606m +-2 | - | x | r | xr | 3162m +-2 | - | x | s | xs | 3000m +-2 | - | x | t | xt | 3162m +-2 | - | x | u | xu | 3606m +-2 | - | x | v | xv | 4243m +-2 | - | x | w | xw | 3606m +-2 | - | x | y | xy | 3162m +-2 | + | x | a | xa | 300m +-2 | + | x | b | xb | 316m +-2 | + | x | c | xc | 360m +-2 | + | x | d | xd | 424m +-2 | + | x | e | xe | 360m +-2 | + | x | f | xf | 316m +-2 | + | x | g | xg | 300m +-2 | + | x | h | xh | 316m +-2 | + | x | i | xi | 360m +-2 | + | x | j | xj | 424m +-2 | + | x | k | xk | 360m +-2 | + | x | l | xl | 316m +-2 | + | x | m | xm | 300m +-2 | + | x | n | xn | 316m +-2 | + | x | o | xo | 360m +-2 | + | x | p | xp | 424m +-2 | + | x | q | xq | 360m +-2 | + | x | r | xr | 316m +-2 | + | x | s | xs | 300m +-2 | + | x | t | xt | 316m +-2 | + | x | u | xu | 360m +-2 | + | x | v | xv | 424m +-2 | + | x | w | xw | 360m +-2 | + | x | y | xy | 316m +-2 | @maze Scenario: Distance of a maze of short segments diff --git a/profiles/lib/access.lua b/profiles/lib/access.lua index 094db6290..c6097bfba 100644 --- a/profiles/lib/access.lua +++ b/profiles/lib/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) + local tag = source:get_value_by_key(v) if tag ~= '' then return tag end end return nil -end \ No newline at end of file +end diff --git a/profiles/testbot.lua b/profiles/testbot.lua index a0b06f56d..dcf0130c2 100644 --- a/profiles/testbot.lua +++ b/profiles/testbot.lua @@ -45,46 +45,48 @@ function limit_speed(speed, limits) 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; + if traffic_signal and traffic_signal == "traffic_signals" then + io.write("traffic_signal\n") + result.traffic_lights = true; -- TODO: a way to set the penalty value end - return 1 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")) - local junction = way.tags:Find("junction") +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") - way.name = name + if name then + result.name = name + end - if route ~= nil and durationIsValid(duration) then - way.duration = math.max( 1, parseDuration(duration) ) - way.forward_mode = 2 - way.backward_mode = 2 + 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; - way.forward_mode = 3 - way.backward_mode = 4 + result.forward_mode = 3 + result.backward_mode = 4 speed_forw = temp_speed*1.5 speed_back = temp_speed/1.5 elseif highway == "steps" then - way.forward_mode = 5 - way.backward_mode = 6 + result.forward_mode = 5 + result.backward_mode = 6 end if maxspeed_forward ~= nil and maxspeed_forward > 0 then @@ -103,19 +105,19 @@ function way_function (way) end end - way.forward_speed = speed_forw - way.backward_speed = speed_back + 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 - way.forward_mode = 0 + result.forward_mode = 0 elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" then - way.backward_mode = 0 + result.backward_mode = 0 end if junction == 'roundabout' then - way.roundabout = true + result.roundabout = true end end