test for empty highway tag

This commit is contained in:
Emil Tin 2012-10-05 15:39:23 +02:00
parent 7400e60599
commit b95596d6b7
3 changed files with 37 additions and 38 deletions

View File

@ -9,6 +9,7 @@ Feature: Bike - Accessability of different way types
Given the speedprofile "bicycle" Given the speedprofile "bicycle"
Then routability should be Then routability should be
| highway | forw | | highway | forw |
| (nil) | |
| motorway | | | motorway | |
| motorway_link | | | motorway_link | |
| trunk | | | trunk | |

View File

@ -7,6 +7,7 @@ Feature: Car - Accessability of different way types
Scenario: Car - Basic access Scenario: Car - Basic access
Then routability should be Then routability should be
| highway | forw | | highway | forw |
| (nil) | |
| motorway | x | | motorway | x |
| motorway_link | x | | motorway_link | x |
| trunk | x | | trunk | x |

View File

@ -105,13 +105,17 @@ function way_function (way, numberOfNodesInWay)
local area = way.tags:Find("area") local area = way.tags:Find("area")
local access = find_access_tag(way) local access = find_access_tag(way)
-- only route on things with highway tag set (not buildings, boundaries, etc)
if (not highway or highway == '') and (not route or route == '') then
return 0
end
-- Check if we are allowed to access the way -- access
if access_tag_blacklist[access] then if access_tag_blacklist[access] then
return 0 return 0
end end
-- Set the name that will be used for instructions -- name
if "" ~= ref then if "" ~= ref then
way.name = ref way.name = ref
elseif "" ~= name then elseif "" ~= name then
@ -120,45 +124,38 @@ function way_function (way, numberOfNodesInWay)
way.name = highway -- if no name exists, use way type way.name = highway -- if no name exists, use way type
end end
-- Handling ferries and piers if (speed_profile[route] and speed_profile[route] > 0) or (speed_profile[man_made] and speed_profile[man_made] > 0) then
if (speed_profile[route] ~= nil and speed_profile[route] > 0) or -- ferries and piers
(speed_profile[man_made] ~= nil and speed_profile[man_made] > 0) if durationIsValid(duration) then
then way.speed = math.max( duration / math.max(1, numberOfNodesInWay-1) )
if durationIsValid(duration) then way.is_duration_set = true;
way.speed = math.max( duration / math.max(1, numberOfNodesInWay-1) ); end
way.is_duration_set = true; way.direction = Way.bidirectional;
end if speed_profile[route] ~= nil then
way.direction = Way.bidirectional; highway = route;
if speed_profile[route] ~= nil then elseif speed_profile[man_made] ~= nil then
highway = route; highway = man_made;
elseif speed_profile[man_made] ~= nil then end
highway = man_made; if not way.is_duration_set then
end way.speed = speed_profile[highway]
if not way.is_duration_set then end
way.speed = speed_profile[highway] else
end -- ways
print("added "..route.." with speed "..way.speed) if speed_profile[highway] then
end way.speed = speed_profile[highway]
elseif access_tag_whitelist[access] then
way.speed = speed_profile["default"]
-- 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 (0 < maxspeed and not take_minimum_of_speeds) or (maxspeed == 0) then
maxspeed = math.huge
end
way.speed = math.min(speed_profile[highway], maxspeed)
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 end
way.speed = math.min(speed_profile["default"], maxspeed)
end end
-- maxspeed
if take_minimum_of_speeds then
if maxspeed and maxspeed>0 then
way.speed = math.min(way.speed, maxspeed)
end
end
-- Set direction -- direction
way.direction = Way.bidirectional way.direction = Way.bidirectional
local impliedOneway = false local impliedOneway = false
if junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then if junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then
@ -200,7 +197,7 @@ function way_function (way, numberOfNodesInWay)
way.direction = Way.oneway way.direction = Way.oneway
end end
-- Cycleways -- cycleways
if cycleway and cycleway_tags[cycleway] then if cycleway and cycleway_tags[cycleway] then
way.speed = speed_profile["cycleway"] way.speed = speed_profile["cycleway"]
elseif cycleway_left and cycleway_tags[cycleway_left] then elseif cycleway_left and cycleway_tags[cycleway_left] then