more robust check for parsed ways

This commit is contained in:
Emil Tin 2014-08-20 17:05:39 +02:00
parent bb3cbf2dda
commit 774e6346e7
5 changed files with 34 additions and 21 deletions

View File

@ -63,7 +63,11 @@ bool ExtractorCallbacks::ProcessRestriction(const InputRestrictionContainer &res
/** warning: caller needs to take care of synchronization! */ /** warning: caller needs to take care of synchronization! */
void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way) void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way)
{ {
if ((0 >= parsed_way.forward_speed) && (0 >= parsed_way.duration)) if (((0 >= parsed_way.forward_speed) ||
(TRAVEL_MODE_INACCESSIBLE == parsed_way.forward_travel_mode)) &&
((0 >= parsed_way.backward_speed) ||
(TRAVEL_MODE_INACCESSIBLE == parsed_way.backward_travel_mode)) &&
(0 >= parsed_way.duration))
{ // Only true if the way is specified by the speed profile { // Only true if the way is specified by the speed profile
return; return;
} }

View File

@ -168,18 +168,18 @@ function way_function (way)
(not man_made or man_made=='') and (not man_made or man_made=='') and
(not public_transport or public_transport=='') (not public_transport or public_transport=='')
then then
return 0 return
end end
-- don't route on ways or railways that are still under construction -- don't route on ways or railways that are still under construction
if highway=='construction' or railway=='construction' then if highway=='construction' or railway=='construction' then
return 0 return
end end
-- access -- access
local access = Access.find_access_tag(way, access_tags_hierachy) local access = Access.find_access_tag(way, access_tags_hierachy)
if access_tag_blacklist[access] then if access_tag_blacklist[access] then
return 0 return
end end
-- other tags -- other tags
@ -267,15 +267,18 @@ function way_function (way)
if pedestrian_speeds[highway] then if pedestrian_speeds[highway] then
-- pedestrian-only ways and areas -- pedestrian-only ways and areas
way.forward_speed = pedestrian_speeds[highway] way.forward_speed = pedestrian_speeds[highway]
way.backward_speed = pedestrian_speeds[highway]
way.forward_mode = mode_pushing way.forward_mode = mode_pushing
way.backward_mode = mode_pushing way.backward_mode = mode_pushing
elseif man_made and man_made_speeds[man_made] then elseif man_made and man_made_speeds[man_made] then
-- man made structures -- man made structures
way.forward_speed = man_made_speeds[man_made] way.forward_speed = man_made_speeds[man_made]
way.backward_speed = man_made_speeds[man_made]
way.forward_mode = mode_pushing way.forward_mode = mode_pushing
way.backward_mode = mode_pushing way.backward_mode = mode_pushing
elseif foot == 'yes' then elseif foot == 'yes' then
way.forward_speed = walking_speed way.forward_speed = walking_speed
way.backward_speed = walking_speed
way.forward_mode = mode_pushing way.forward_mode = mode_pushing
way.backward_mode = mode_pushing way.backward_mode = mode_pushing
elseif foot_forward == 'yes' then elseif foot_forward == 'yes' then
@ -308,6 +311,7 @@ function way_function (way)
if impliedOneway then if impliedOneway then
way.forward_mode = 0 way.forward_mode = 0
way.backward_mode = mode_normal way.backward_mode = mode_normal
way.backward_speed = bicycle_speeds["cycleway"]
end end
elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then elseif cycleway_left and cycleway_tags[cycleway_left] and cycleway_right and cycleway_tags[cycleway_right] then
-- prevent implied -- prevent implied
@ -315,10 +319,12 @@ function way_function (way)
if impliedOneway then if impliedOneway then
way.forward_mode = 0 way.forward_mode = 0
way.backward_mode = mode_normal way.backward_mode = mode_normal
way.backward_speed = bicycle_speeds["cycleway"]
end end
elseif cycleway_right and cycleway_tags[cycleway_right] then elseif cycleway_right and cycleway_tags[cycleway_right] then
if impliedOneway then if impliedOneway then
way.forward_mode = mode_normal way.forward_mode = mode_normal
way.backward_speed = bicycle_speeds["cycleway"]
way.backward_mode = 0 way.backward_mode = 0
end end
elseif oneway == "-1" then elseif oneway == "-1" then
@ -372,8 +378,6 @@ function way_function (way)
-- maxspeed -- maxspeed
MaxSpeed.limit( way, maxspeed, maxspeed_forward, maxspeed_backward ) MaxSpeed.limit( way, maxspeed, maxspeed_forward, maxspeed_backward )
return true
end end
function turn_function (angle) function turn_function (angle)

View File

@ -192,23 +192,27 @@ function way_function (way)
if highway_speed then if highway_speed then
if max_speed > highway_speed then if max_speed > highway_speed then
way.forward_speed = max_speed way.forward_speed = max_speed
way.backward_speed = max_speed
-- max_speed = math.huge -- max_speed = math.huge
else else
way.forward_speed = highway_speed way.forward_speed = highway_speed
way.backward_speed = highway_speed
end end
else else
-- Set the avg speed on ways that are marked accessible -- Set the avg speed on ways that are marked accessible
if access_tag_whitelist[access] then if access_tag_whitelist[access] then
way.forward_speed = speed_profile["default"] way.forward_speed = speed_profile["default"]
way.backward_speed = speed_profile["default"]
end end
end end
if 0 == max_speed then if 0 == max_speed then
max_speed = math.huge max_speed = math.huge
end end
way.forward_speed = min(way.forward_speed, max_speed) way.forward_speed = min(way.forward_speed, max_speed)
way.backward_speed = min(way.backward_speed, max_speed)
end end
if -1 == way.forward_speed then if -1 == way.forward_speed and -1 == way.backward_speed then
return return
end end
@ -280,7 +284,6 @@ function way_function (way)
if maxspeed_backward > 0 then if maxspeed_backward > 0 then
way.backward_speed = way.backward_speed*speed_reduction way.backward_speed = way.backward_speed*speed_reduction
end end
return true
end end
-- These are wrappers to parse vectors of nodes and ways and thus to speed up any tracing JIT -- These are wrappers to parse vectors of nodes and ways and thus to speed up any tracing JIT

View File

@ -102,32 +102,32 @@ function node_function (node)
end end
function way_function (way) function way_function (way)
-- initial routability check, filters out buildings, boundaries, etc -- initial routability check, filters out buildings, boundaries, etc
local highway = way.tags:Find("highway") local highway = way.tags:Find("highway")
local route = way.tags:Find("route") local route = way.tags:Find("route")
local man_made = way.tags:Find("man_made") local man_made = way.tags:Find("man_made")
local railway = way.tags:Find("railway") local railway = way.tags:Find("railway")
local amenity = way.tags:Find("amenity") local amenity = way.tags:Find("amenity")
local public_transport = way.tags:Find("public_transport") local public_transport = way.tags:Find("public_transport")
if (not highway or highway == '') and if (not highway or highway == '') and
(not route or route == '') and (not route or route == '') and
(not railway or railway=='') and (not railway or railway=='') and
(not amenity or amenity=='') and (not amenity or amenity=='') and
(not man_made or man_made=='') and (not man_made or man_made=='') and
(not public_transport or public_transport=='') (not public_transport or public_transport=='')
then then
return 0 return
end end
-- don't route on ways that are still under construction -- don't route on ways that are still under construction
if highway=='construction' then if highway=='construction' then
return 0 return
end end
-- access -- access
local access = Access.find_access_tag(way, access_tags_hierachy) local access = Access.find_access_tag(way, access_tags_hierachy)
if access_tag_blacklist[access] then if access_tag_blacklist[access] then
return 0 return
end end
local name = way.tags:Find("name") local name = way.tags:Find("name")
@ -164,25 +164,31 @@ function way_function (way)
if durationIsValid(duration) then if durationIsValid(duration) then
way.duration = math.max( 1, parseDuration(duration) ) way.duration = math.max( 1, parseDuration(duration) )
else else
way.forward_speed = route_speeds[route] way.forward_speed = route_speeds[route]
way.backward_speed = route_speeds[route]
end end
way.forward_mode = mode_ferry way.forward_mode = mode_ferry
way.backward_mode = mode_ferry way.backward_mode = mode_ferry
elseif railway and platform_speeds[railway] then elseif railway and platform_speeds[railway] then
-- railway platforms (old tagging scheme) -- railway platforms (old tagging scheme)
way.forward_speed = platform_speeds[railway] way.forward_speed = platform_speeds[railway]
way.backward_speed = platform_speeds[railway]
elseif platform_speeds[public_transport] then elseif platform_speeds[public_transport] then
-- public_transport platforms (new tagging platform) -- public_transport platforms (new tagging platform)
way.forward_speed = platform_speeds[public_transport] way.forward_speed = platform_speeds[public_transport]
way.backward_speed = platform_speeds[public_transport]
elseif amenity and amenity_speeds[amenity] then elseif amenity and amenity_speeds[amenity] then
-- parking areas -- parking areas
way.forward_speed = amenity_speeds[amenity] way.forward_speed = amenity_speeds[amenity]
way.backward_speed = amenity_speeds[amenity]
elseif speeds[highway] then elseif speeds[highway] then
-- regular ways -- regular ways
way.forward_speed = speeds[highway] way.forward_speed = speeds[highway]
way.backward_speed = speeds[highway]
elseif access and access_tag_whitelist[access] then elseif access and access_tag_whitelist[access] then
-- unknown way, but valid access tag -- unknown way, but valid access tag
way.forward_speed = walking_speed way.forward_speed = walking_speed
way.backward_speed = walking_speed
end end
-- oneway -- oneway
@ -202,6 +208,4 @@ function way_function (way)
way.backward_speed = math.min(way.backward_speed, surface_speed) way.backward_speed = math.min(way.backward_speed, surface_speed)
end end
end end
return true
end end

View File

@ -118,6 +118,4 @@ function way_function (way)
if junction == 'roundabout' then if junction == 'roundabout' then
way.roundabout = true way.roundabout = true
end end
return true
end end