more tests passing

This commit is contained in:
Emil Tin 2014-08-12 14:18:02 +02:00
parent a5ee7e78f6
commit 235a52032a
8 changed files with 125 additions and 72 deletions

View File

@ -134,12 +134,9 @@ int Prepare::Process(int argc, char *argv[])
#ifdef WIN32 #ifdef WIN32
#pragma message("Memory consumption on Windows can be higher due to different bit packing") #pragma message("Memory consumption on Windows can be higher due to different bit packing")
#else #else
SimpleLogger().Write() << "sizeof(ImportEdge): " << sizeof(ImportEdge);
SimpleLogger().Write() << "sizeof(NodeBasedEdgeData): " << sizeof(NodeBasedEdgeData);
//TODO //TODO
//static_assert(sizeof(ImportEdge) == 21, static_assert(sizeof(ImportEdge) == 20,
// "changing ImportEdge type has influence on memory consumption!"); "changing ImportEdge type has influence on memory consumption!");
#endif #endif
NodeID number_of_node_based_nodes = NodeID number_of_node_based_nodes =
readBinaryOSRMGraphFromStream(input_stream, readBinaryOSRMGraphFromStream(input_stream,

View File

@ -106,13 +106,27 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way)
parsed_way.nameID = string_map_iterator->second; parsed_way.nameID = string_map_iterator->second;
} }
if (0 == parsed_way.travel_mode )
{
parsed_way.direction = ExtractionWay::opposite;
}
if (0 == parsed_way.backward_travel_mode )
{
parsed_way.direction = ExtractionWay::oneway;
}
if (ExtractionWay::opposite == parsed_way.direction) if (ExtractionWay::opposite == parsed_way.direction)
{ {
std::reverse(parsed_way.path.begin(), parsed_way.path.end()); std::reverse(parsed_way.path.begin(), parsed_way.path.end());
parsed_way.direction = ExtractionWay::oneway; parsed_way.direction = ExtractionWay::oneway;
} }
bool split_edge = parsed_way.IsBidirectional() && parsed_way.HasDiffDirections(); const bool split_edge =
(parsed_way.speed>0) && (parsed_way.travel_mode>0) &&
(parsed_way.backward_speed>0) && (parsed_way.backward_travel_mode>0) &&
((parsed_way.speed != parsed_way.backward_speed) ||
(parsed_way.travel_mode != parsed_way.backward_travel_mode));
for (unsigned n = 0; n < (parsed_way.path.size() - 1); ++n) for (unsigned n = 0; n < (parsed_way.path.size() - 1); ++n)
{ {

View File

@ -5,8 +5,8 @@ Feature: Bike - Accessability of different way types
Given the profile "bicycle" Given the profile "bicycle"
Given the shortcuts Given the shortcuts
| key | value | | key | value |
| bike | 49s ~20% | | bike | 15 km/h ~20% |
| foot | 121s ~20% | | foot | 5 km/h ~20% |
Scenario: Bike - Pushing bikes on pedestrian-only ways Scenario: Bike - Pushing bikes on pedestrian-only ways
Then routability should be Then routability should be
@ -100,9 +100,9 @@ Feature: Bike - Accessability of different way types
When I route I should get When I route I should get
| from | to | route | turns | | from | to | route | turns |
| a | d | ab,bc,cd | head,right,left,destination | | a | d | ab,bc,cd | head,right,left,destination |
| d | a | cd,bc,ab | head,enter_contraflow,leave_contraflow,destination | | d | a | cd,bc,ab | head,right,left,destination |
| c | a | bc,ab | head,leave_contraflow,destination | | c | a | bc,ab | head,left,destination |
| d | b | cd,bc | head,enter_contraflow,destination | | d | b | cd,bc | head,right,destination |
@todo @todo
Scenario: Bike - Instructions when pushing bike on footway/pedestrian, etc. Scenario: Bike - Instructions when pushing bike on footway/pedestrian, etc.
@ -119,6 +119,6 @@ Feature: Bike - Accessability of different way types
When I route I should get When I route I should get
| from | to | route | turns | | from | to | route | turns |
| a | d | ab,bc,cd | head,right,left,destination | | a | d | ab,bc,cd | head,right,left,destination |
| d | a | cd,bc,ab | head,enter_contraflow,leave_contraflow,destination | | d | a | cd,bc,ab | head,right,left,destination |
| c | a | bc,ab | head,leave_contraflow,destination | | c | a | bc,ab | head,left,destination |
| d | b | cd,bc | head,enter_contraflow,destination | | d | b | cd,bc | head,right,destination |

View File

@ -54,11 +54,11 @@ Then /^routability should be$/ do |table|
want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts
case want case want
when '', 'x' when '', 'x'
output_row[direction] = result[direction][:status].to_s output_row[direction] = result[direction][:time] ? result[direction][:status].to_s : ''
when /^\d+s/ when /^\d+s/
output_row[direction] = "#{result[direction][:time]}s" output_row[direction] = result[direction][:time] ? "#{result[direction][:time]}s" : ''
when /^\d+ km\/h/ when /^\d+ km\/h/
output_row[direction] = "#{result[direction][:speed]} km/h" output_row[direction] = result[direction][:speed] ? "#{result[direction][:speed]} km/h" : ''
else else
raise "*** Unknown expectation format: #{want}" raise "*** Unknown expectation format: #{want}"
end end

View File

@ -104,22 +104,22 @@ When /^I route I should get$/ do |table|
end end
end end
if table.headers.include? 'bearing' if table.headers.include? 'bearing'
got['bearing'] = bearings got['bearing'] = instructions ? bearings : ''
end end
if table.headers.include? 'compass' if table.headers.include? 'compass'
got['compass'] = compasses got['compass'] = instructions ? compasses : ''
end end
if table.headers.include? 'turns' if table.headers.include? 'turns'
got['turns'] = turns got['turns'] = instructions ? turns : ''
end end
if table.headers.include? 'modes' if table.headers.include? 'modes'
got['modes'] = modes got['modes'] = instructions ? modes : ''
end end
if table.headers.include? 'times' if table.headers.include? 'times'
got['times'] = times got['times'] = instructions ? times : ''
end end
if table.headers.include? 'distances' if table.headers.include? 'distances'
got['distances'] = distances got['distances'] = instructions ? distances : ''
end end
end end
end end

View File

@ -157,7 +157,20 @@ Feature: Testbot - Mode flag
| a,0,d | ab,bc,cd | 1,3,1 | | a,0,d | ab,bc,cd | 1,3,1 |
| d,0,a | cd,bc,ab | 1,4,1 | | d,0,a | cd,bc,ab | 1,4,1 |
Scenario: Testbot - Modes when starting on opposite oneway Scenario: Testbot - Modes when starting on forward oneway
Given the node map
| a | b |
And the ways
| nodes | highway | oneway |
| ab | river | yes |
When I route I should get
| from | to | route | modes |
| a | b | ab | 3 |
| b | a | | |
Scenario: Testbot - Modes when starting on reverse oneway
Given the node map Given the node map
| a | b | | a | b |
@ -167,4 +180,5 @@ Feature: Testbot - Mode flag
When I route I should get When I route I should get
| from | to | route | modes | | from | to | route | modes |
| a | b | | |
| b | a | ab | 4 | | b | a | ab | 4 |

View File

@ -1,4 +1,5 @@
require("lib/access") require("lib/access")
require("lib/maxspeed")
-- Begin of globals -- 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 } 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 }
@ -221,116 +222,122 @@ function way_function (way)
-- speed -- speed
if route_speeds[route] then if route_speeds[route] then
-- ferries (doesn't cover routes tagged using relations) -- ferries (doesn't cover routes tagged using relations)
way.mode = mode_ferry
way.direction = Way.bidirectional way.direction = Way.bidirectional
way.ignore_in_grid = true way.ignore_in_grid = true
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.speed = route_speeds[route] way.speed = route_speeds[route]
way.backward_speed = route_speeds[route]
end end
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.speed = platform_speeds[railway] way.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.speed = platform_speeds[public_transport] way.speed = platform_speeds[public_transport]
way.backward_speed = platform_speeds[public_transport]
elseif railway and railway_speeds[railway] then elseif railway and railway_speeds[railway] then
way.mode = mode_train way.mode = mode_train
-- railways -- railways
if access and access_tag_whitelist[access] then if access and access_tag_whitelist[access] then
way.speed = railway_speeds[railway] way.speed = railway_speeds[railway]
way.backward_speed = railway_speeds[railway]
way.direction = Way.bidirectional way.direction = Way.bidirectional
end end
elseif amenity and amenity_speeds[amenity] then elseif amenity and amenity_speeds[amenity] then
-- parking areas -- parking areas
way.speed = amenity_speeds[amenity] way.speed = amenity_speeds[amenity]
way.backward_speed = amenity_speeds[amenity]
elseif bicycle_speeds[highway] then elseif bicycle_speeds[highway] then
-- regular ways -- regular ways
way.speed = bicycle_speeds[highway] way.speed = bicycle_speeds[highway]
way.backward_speed = bicycle_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.speed = default_speed way.speed = default_speed
way.backward_speed = default_speed
else else
-- biking not allowed, maybe we can push our bike? -- biking not allowed, maybe we can push our bike?
-- essentially requires pedestrian profiling, for example foot=no mean we can't push a 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' and junction ~= "roundabout" then
if foot ~= 'no' then
if pedestrian_speeds[highway] then if pedestrian_speeds[highway] then
-- pedestrian-only ways and areas -- pedestrian-only ways and areas
way.speed = pedestrian_speeds[highway] way.speed = pedestrian_speeds[highway]
way.mode = mode_pushing way.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.speed = man_made_speeds[man_made] way.speed = man_made_speeds[man_made]
way.mode = mode_pushing way.mode = mode_pushing
way.backward_mode = mode_pushing
elseif foot == 'yes' then elseif foot == 'yes' then
way.speed = walking_speed way.speed = walking_speed
way.mode = mode_pushing way.mode = mode_pushing
way.backward_mode = mode_pushing
elseif foot_forward == 'yes' then
way.speed = walking_speed
way.mode = mode_pushing
way.backward_mode = 0
elseif foot_backward == 'yes' then
way.speed = walking_speed
way.mode = 0
way.backward_mode = mode_pushing
end end
end end
end end
-- direction -- direction
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
way.direction = Way.oneway
impliedOneway = true impliedOneway = true
end end
if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then if onewayClass == "yes" or onewayClass == "1" or onewayClass == "true" then
way.direction = Way.oneway way.backward_mode = 0
elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then elseif onewayClass == "no" or onewayClass == "0" or onewayClass == "false" then
way.direction = Way.bidirectional -- prevent implied oneway
elseif onewayClass == "-1" then elseif onewayClass == "-1" then
way.direction = Way.opposite way.mode = 0
elseif oneway == "no" or oneway == "0" or oneway == "false" then elseif oneway == "no" or oneway == "0" or oneway == "false" then
way.direction = Way.bidirectional -- prevent implied oneway
elseif cycleway and string.find(cycleway, "opposite") == 1 then elseif cycleway and string.find(cycleway, "opposite") == 1 then
if impliedOneway then if impliedOneway then
way.direction = Way.opposite way.mode = 0
else way.backward_mode = mode_normal
way.direction = Way.bidirectional
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
way.direction = Way.bidirectional -- prevent implied
elseif cycleway_left and cycleway_tags[cycleway_left] then elseif cycleway_left and cycleway_tags[cycleway_left] then
if impliedOneway then if impliedOneway then
way.direction = Way.opposite way.mode = 0
else way.backward_mode = mode_normal
way.direction = Way.bidirectional
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.direction = Way.oneway way.mode = mode_normal
else way.backward_mode = 0
way.direction = Way.bidirectional
end end
elseif oneway == "-1" then elseif oneway == "-1" then
way.direction = Way.opposite way.mode = 0
elseif oneway == "yes" or oneway == "1" or oneway == "true" then elseif oneway == "yes" or oneway == "1" or oneway == "true" or impliedOneway then
way.direction = Way.oneway way.backward_mode = 0
end end
-- pushing bikes -- pushing bikes
if bicycle_speeds[highway] or pedestrian_speeds[highway] then if bicycle_speeds[highway] or pedestrian_speeds[highway] then
if foot ~= 'no' then if foot ~= "no" and junction ~= "roundabout" then
if junction ~= "roundabout" then if way.backward_mode == 0 then
if way.direction == Way.oneway then
way.backward_speed = walking_speed way.backward_speed = walking_speed
way.mode = mode_pushing way.backward_mode = mode_pushing
elseif way.direction == Way.opposite then elseif way.mode == 0 then
way.backward_speed = walking_speed way.speed = walking_speed
way.speed = way.speed
way.mode = mode_pushing way.mode = mode_pushing
end end
end 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
end
-- cycleways -- cycleways
if cycleway and cycleway_tags[cycleway] then if cycleway and cycleway_tags[cycleway] then
@ -341,6 +348,14 @@ function way_function (way)
way.speed = bicycle_speeds["cycleway"] way.speed = bicycle_speeds["cycleway"]
end end
-- dismount
if bicycle == "dismount" then
way.mode = mode_pushing
way.backward_mode = mode_pushing
way.speed = walking_speed
way.backward_speed = walking_speed
end
-- surfaces -- surfaces
if surface then if surface then
surface_speed = surface_speeds[surface] surface_speed = surface_speeds[surface]
@ -355,12 +370,8 @@ function way_function (way)
end end
-- maxspeed -- maxspeed
-- TODO: maxspeed of backward direction MaxSpeed.limit( way, maxspeed, maxspeed_forward, maxspeed_backward )
if take_minimum_of_speeds then
if maxspeed and maxspeed>0 then
way.speed = math.min(way.speed, maxspeed)
end
end
-- Override speed settings if explicit forward/backward maxspeeds are given -- Override speed settings if explicit forward/backward maxspeeds are given
if way.speed > 0 and maxspeed_forward ~= nil and maxspeed_forward > 0 then if way.speed > 0 and maxspeed_forward ~= nil and maxspeed_forward > 0 then

17
profiles/lib/maxspeed.lua Normal file
View File

@ -0,0 +1,17 @@
local math = math
module "MaxSpeed"
function limit(way,max,maxf,maxb)
if maxf and maxf>0 then
way.speed = math.min(way.speed, maxf)
elseif max and max>0 then
way.speed = math.min(way.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