update lua interface to speed and mode

This commit is contained in:
Emil Tin
2014-08-18 15:38:07 +02:00
parent 6cdc590db5
commit 30362cfc0c
14 changed files with 100 additions and 100 deletions
+34 -34
View File
@@ -223,42 +223,42 @@ function way_function (way)
-- speed
if route_speeds[route] then
-- ferries (doesn't cover routes tagged using relations)
way.mode = mode_ferry
way.forward_mode = mode_ferry
way.backward_mode = mode_ferry
way.ignore_in_grid = true
if durationIsValid(duration) then
way.duration = math.max( 1, parseDuration(duration) )
else
way.speed = route_speeds[route]
way.forward_speed = route_speeds[route]
way.backward_speed = route_speeds[route]
end
elseif railway and platform_speeds[railway] then
-- railway platforms (old tagging scheme)
way.speed = platform_speeds[railway]
way.forward_speed = platform_speeds[railway]
way.backward_speed = platform_speeds[railway]
elseif platform_speeds[public_transport] then
-- public_transport platforms (new tagging platform)
way.speed = platform_speeds[public_transport]
way.forward_speed = platform_speeds[public_transport]
way.backward_speed = platform_speeds[public_transport]
elseif railway and railway_speeds[railway] then
way.mode = mode_train
way.forward_mode = mode_train
way.backward_mode = mode_train
-- railways
if access and access_tag_whitelist[access] then
way.speed = railway_speeds[railway]
way.forward_speed = railway_speeds[railway]
way.backward_speed = railway_speeds[railway]
end
elseif amenity and amenity_speeds[amenity] then
-- parking areas
way.speed = amenity_speeds[amenity]
way.forward_speed = amenity_speeds[amenity]
way.backward_speed = amenity_speeds[amenity]
elseif bicycle_speeds[highway] then
-- regular ways
way.speed = bicycle_speeds[highway]
way.forward_speed = bicycle_speeds[highway]
way.backward_speed = bicycle_speeds[highway]
elseif access and access_tag_whitelist[access] then
-- unknown way, but valid access tag
way.speed = default_speed
way.forward_speed = default_speed
way.backward_speed = default_speed
else
-- biking not allowed, maybe we can push our bike?
@@ -266,25 +266,25 @@ function way_function (way)
if foot ~= 'no' and junction ~= "roundabout" then
if pedestrian_speeds[highway] then
-- pedestrian-only ways and areas
way.speed = pedestrian_speeds[highway]
way.mode = mode_pushing
way.forward_speed = pedestrian_speeds[highway]
way.forward_mode = mode_pushing
way.backward_mode = mode_pushing
elseif man_made and man_made_speeds[man_made] then
-- man made structures
way.speed = man_made_speeds[man_made]
way.mode = mode_pushing
way.forward_speed = man_made_speeds[man_made]
way.forward_mode = mode_pushing
way.backward_mode = mode_pushing
elseif foot == 'yes' then
way.speed = walking_speed
way.mode = mode_pushing
way.forward_speed = walking_speed
way.forward_mode = mode_pushing
way.backward_mode = mode_pushing
elseif foot_forward == 'yes' then
way.speed = walking_speed
way.mode = mode_pushing
way.forward_speed = walking_speed
way.forward_mode = mode_pushing
way.backward_mode = 0
elseif foot_backward == 'yes' then
way.speed = walking_speed
way.mode = 0
way.forward_speed = walking_speed
way.forward_mode = 0
way.backward_mode = mode_pushing
end
end
@@ -301,28 +301,28 @@ function way_function (way)
elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
-- prevent implied oneway
elseif onewayClass == "-1" then
way.mode = 0
way.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
way.mode = 0
way.forward_mode = 0
way.backward_mode = mode_normal
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
way.mode = 0
way.forward_mode = 0
way.backward_mode = mode_normal
end
elseif cycleway_right and cycleway_tags[cycleway_right] then
if impliedOneway then
way.mode = mode_normal
way.forward_mode = mode_normal
way.backward_mode = 0
end
elseif oneway == "-1" then
way.mode = 0
way.forward_mode = 0
elseif oneway == "yes" or oneway == "1" or oneway == "true" or impliedOneway then
way.backward_mode = 0
end
@@ -333,27 +333,27 @@ function way_function (way)
if way.backward_mode == 0 then
way.backward_speed = walking_speed
way.backward_mode = mode_pushing
elseif way.mode == 0 then
way.speed = walking_speed
way.mode = mode_pushing
elseif way.forward_mode == 0 then
way.forward_speed = walking_speed
way.forward_mode = mode_pushing
end
end
end
-- cycleways
if cycleway and cycleway_tags[cycleway] then
way.speed = bicycle_speeds["cycleway"]
way.forward_speed = bicycle_speeds["cycleway"]
elseif cycleway_left and cycleway_tags[cycleway_left] then
way.speed = bicycle_speeds["cycleway"]
way.forward_speed = bicycle_speeds["cycleway"]
elseif cycleway_right and cycleway_tags[cycleway_right] then
way.speed = bicycle_speeds["cycleway"]
way.forward_speed = bicycle_speeds["cycleway"]
end
-- dismount
if bicycle == "dismount" then
way.mode = mode_pushing
way.forward_mode = mode_pushing
way.backward_mode = mode_pushing
way.speed = walking_speed
way.forward_speed = walking_speed
way.backward_speed = walking_speed
end
@@ -361,8 +361,8 @@ function way_function (way)
if surface then
surface_speed = surface_speeds[surface]
if surface_speed then
if way.speed > 0 then
way.speed = surface_speed
if way.forward_speed > 0 then
way.forward_speed = surface_speed
end
if way.backward_speed > 0 then
way.backward_speed = surface_speed
Regular → Executable
+10 -10
View File
@@ -170,7 +170,7 @@ function way_function (way)
way.duration = max( parseDuration(duration), 1 );
end
way.direction = Way.bidirectional
way.speed = route_speed
way.forward_speed = route_speed
end
-- leave early of this way is not accessible
@@ -178,30 +178,30 @@ function way_function (way)
return
end
if way.speed == -1 then
if way.forward_speed == -1 then
local highway_speed = speed_profile[highway]
local max_speed = parse_maxspeed( way.tags:Find("maxspeed") )
-- Set the avg speed on the way if it is accessible by road class
if highway_speed then
if max_speed > highway_speed then
way.speed = max_speed
way.forward_speed = max_speed
-- max_speed = math.huge
else
way.speed = highway_speed
way.forward_speed = highway_speed
end
else
-- Set the avg speed on ways that are marked accessible
if access_tag_whitelist[access] then
way.speed = speed_profile["default"]
way.forward_speed = speed_profile["default"]
end
end
if 0 == max_speed then
max_speed = math.huge
end
way.speed = min(way.speed, max_speed)
way.forward_speed = min(way.forward_speed, max_speed)
end
if -1 == way.speed then
if -1 == way.forward_speed then
return
end
@@ -256,9 +256,9 @@ function way_function (way)
local maxspeed_backward = parse_maxspeed(way.tags:Find( "maxspeed:backward"))
if maxspeed_forward > 0 then
if Way.bidirectional == way.direction then
way.backward_speed = way.speed
way.backward_speed = way.forward_speed
end
way.speed = maxspeed_forward
way.forward_speed = maxspeed_forward
end
if maxspeed_backward > 0 then
way.backward_speed = maxspeed_backward
@@ -271,7 +271,7 @@ function way_function (way)
way.type = 1
-- scale speeds to get better avg driving times
way.speed = way.speed * speed_reduction
way.forward_speed = way.forward_speed * speed_reduction
if maxspeed_backward > 0 then
way.backward_speed = way.backward_speed*speed_reduction
end
+2 -2
View File
@@ -65,11 +65,11 @@ function way_function (way)
local cursor = assert( sql_con:execute(sql_query) ) -- execute querty
local row = cursor:fetch( {}, "a" ) -- fetch first (and only) row
way.speed = 20.0 -- default speed
way.forward_speed = 20.0 -- default speed
if row then
local val = tonumber(row.val) -- read 'val' from row
if val > 10 then
way.speed = way.speed / math.log10( val ) -- reduce speed by amount of industry close by
way.forward_speed = way.forward_speed / math.log10( val ) -- reduce speed by amount of industry close by
end
end
cursor:close() -- done with this query
+7 -7
View File
@@ -161,23 +161,23 @@ function way_function (way)
if durationIsValid(duration) then
way.duration = math.max( 1, parseDuration(duration) )
else
way.speed = route_speeds[route]
way.forward_speed = route_speeds[route]
end
elseif railway and platform_speeds[railway] then
-- railway platforms (old tagging scheme)
way.speed = platform_speeds[railway]
way.forward_speed = platform_speeds[railway]
elseif platform_speeds[public_transport] then
-- public_transport platforms (new tagging platform)
way.speed = platform_speeds[public_transport]
way.forward_speed = platform_speeds[public_transport]
elseif amenity and amenity_speeds[amenity] then
-- parking areas
way.speed = amenity_speeds[amenity]
way.forward_speed = amenity_speeds[amenity]
elseif speeds[highway] then
-- regular ways
way.speed = speeds[highway]
way.forward_speed = speeds[highway]
elseif access and access_tag_whitelist[access] then
-- unknown way, but valid access tag
way.speed = walking_speed
way.forward_speed = walking_speed
end
-- oneway
@@ -195,7 +195,7 @@ function way_function (way)
if surface then
surface_speed = surface_speeds[surface]
if surface_speed then
way.speed = math.min(way.speed, surface_speed)
way.forward_speed = math.min(way.forward_speed, surface_speed)
way.backward_speed = math.min(way.backward_speed, surface_speed)
end
end
+2 -2
View File
@@ -4,9 +4,9 @@ module "MaxSpeed"
function limit(way,max,maxf,maxb)
if maxf and maxf>0 then
way.speed = math.min(way.speed, maxf)
way.forward_speed = math.min(way.forward_speed, maxf)
elseif max and max>0 then
way.speed = math.min(way.speed, max)
way.forward_speed = math.min(way.forward_speed, max)
end
if maxb and maxb>0 then
+8 -8
View File
@@ -70,22 +70,22 @@ function way_function (way)
if route ~= nil and durationIsValid(duration) then
way.duration = math.max( 1, parseDuration(duration) )
way.mode = 2
way.backward_mode = 2
way.forward_mode = 2
way.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.mode = 3
way.backward_mode = 4
way.forward_mode = 3
way.backward_mode = 4
speed_forw = temp_speed*1.5
speed_back = temp_speed/1.5
elseif highway == "steps" then
way.mode = 5
way.forward_mode = 5
way.backward_mode = 6
end
end
if maxspeed_forward ~= nil and maxspeed_forward > 0 then
speed_forw = maxspeed_forward
@@ -103,14 +103,14 @@ function way_function (way)
end
end
way.speed = speed_forw
way.forward_speed = speed_forw
way.backward_speed = speed_back
end
if oneway == "no" or oneway == "0" or oneway == "false" then
-- nothing to do
elseif oneway == "-1" then
way.mode = 0
way.forward_mode = 0
elseif oneway == "yes" or oneway == "1" or oneway == "true" or junction == "roundabout" then
way.backward_mode = 0
end