more tests passing
This commit is contained in:
parent
a5ee7e78f6
commit
235a52032a
@ -134,12 +134,9 @@ int Prepare::Process(int argc, char *argv[])
|
||||
#ifdef WIN32
|
||||
#pragma message("Memory consumption on Windows can be higher due to different bit packing")
|
||||
#else
|
||||
SimpleLogger().Write() << "sizeof(ImportEdge): " << sizeof(ImportEdge);
|
||||
SimpleLogger().Write() << "sizeof(NodeBasedEdgeData): " << sizeof(NodeBasedEdgeData);
|
||||
|
||||
//TODO
|
||||
//static_assert(sizeof(ImportEdge) == 21,
|
||||
// "changing ImportEdge type has influence on memory consumption!");
|
||||
static_assert(sizeof(ImportEdge) == 20,
|
||||
"changing ImportEdge type has influence on memory consumption!");
|
||||
#endif
|
||||
NodeID number_of_node_based_nodes =
|
||||
readBinaryOSRMGraphFromStream(input_stream,
|
||||
|
@ -106,14 +106,28 @@ void ExtractorCallbacks::ProcessWay(ExtractionWay &parsed_way)
|
||||
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)
|
||||
{
|
||||
std::reverse(parsed_way.path.begin(), parsed_way.path.end());
|
||||
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)
|
||||
{
|
||||
external_memory.all_edges_list.push_back(InternalExtractorEdge(
|
||||
|
@ -4,9 +4,9 @@ Feature: Bike - Accessability of different way types
|
||||
Background:
|
||||
Given the profile "bicycle"
|
||||
Given the shortcuts
|
||||
| key | value |
|
||||
| bike | 49s ~20% |
|
||||
| foot | 121s ~20% |
|
||||
| key | value |
|
||||
| bike | 15 km/h ~20% |
|
||||
| foot | 5 km/h ~20% |
|
||||
|
||||
Scenario: Bike - Pushing bikes on pedestrian-only ways
|
||||
Then routability should be
|
||||
@ -98,11 +98,11 @@ Feature: Bike - Accessability of different way types
|
||||
| cd | primary | |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns |
|
||||
| a | d | ab,bc,cd | head,right,left,destination |
|
||||
| d | a | cd,bc,ab | head,enter_contraflow,leave_contraflow,destination |
|
||||
| c | a | bc,ab | head,leave_contraflow,destination |
|
||||
| d | b | cd,bc | head,enter_contraflow,destination |
|
||||
| from | to | route | turns |
|
||||
| a | d | ab,bc,cd | head,right,left,destination |
|
||||
| d | a | cd,bc,ab | head,right,left,destination |
|
||||
| c | a | bc,ab | head,left,destination |
|
||||
| d | b | cd,bc | head,right,destination |
|
||||
|
||||
@todo
|
||||
Scenario: Bike - Instructions when pushing bike on footway/pedestrian, etc.
|
||||
@ -117,8 +117,8 @@ Feature: Bike - Accessability of different way types
|
||||
| cd | primary |
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | turns |
|
||||
| a | d | ab,bc,cd | head,right,left,destination |
|
||||
| d | a | cd,bc,ab | head,enter_contraflow,leave_contraflow,destination |
|
||||
| c | a | bc,ab | head,leave_contraflow,destination |
|
||||
| d | b | cd,bc | head,enter_contraflow,destination |
|
||||
| from | to | route | turns |
|
||||
| a | d | ab,bc,cd | head,right,left,destination |
|
||||
| d | a | cd,bc,ab | head,right,left,destination |
|
||||
| c | a | bc,ab | head,left,destination |
|
||||
| d | b | cd,bc | head,right,destination |
|
||||
|
@ -54,11 +54,11 @@ Then /^routability should be$/ do |table|
|
||||
want = shortcuts_hash[row[direction]] || row[direction] #expand shortcuts
|
||||
case want
|
||||
when '', 'x'
|
||||
output_row[direction] = result[direction][:status].to_s
|
||||
output_row[direction] = result[direction][:time] ? result[direction][:status].to_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/
|
||||
output_row[direction] = "#{result[direction][:speed]} km/h"
|
||||
output_row[direction] = result[direction][:speed] ? "#{result[direction][:speed]} km/h" : ''
|
||||
else
|
||||
raise "*** Unknown expectation format: #{want}"
|
||||
end
|
||||
|
@ -104,22 +104,22 @@ When /^I route I should get$/ do |table|
|
||||
end
|
||||
end
|
||||
if table.headers.include? 'bearing'
|
||||
got['bearing'] = bearings
|
||||
got['bearing'] = instructions ? bearings : ''
|
||||
end
|
||||
if table.headers.include? 'compass'
|
||||
got['compass'] = compasses
|
||||
got['compass'] = instructions ? compasses : ''
|
||||
end
|
||||
if table.headers.include? 'turns'
|
||||
got['turns'] = turns
|
||||
got['turns'] = instructions ? turns : ''
|
||||
end
|
||||
if table.headers.include? 'modes'
|
||||
got['modes'] = modes
|
||||
got['modes'] = instructions ? modes : ''
|
||||
end
|
||||
if table.headers.include? 'times'
|
||||
got['times'] = times
|
||||
got['times'] = instructions ? times : ''
|
||||
end
|
||||
if table.headers.include? 'distances'
|
||||
got['distances'] = distances
|
||||
got['distances'] = instructions ? distances : ''
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -157,7 +157,20 @@ Feature: Testbot - Mode flag
|
||||
| a,0,d | ab,bc,cd | 1,3,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
|
||||
| a | b |
|
||||
|
||||
@ -167,4 +180,5 @@ Feature: Testbot - Mode flag
|
||||
|
||||
When I route I should get
|
||||
| from | to | route | modes |
|
||||
| a | b | | |
|
||||
| b | a | ab | 4 |
|
||||
|
@ -1,4 +1,5 @@
|
||||
require("lib/access")
|
||||
require("lib/maxspeed")
|
||||
|
||||
-- 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 }
|
||||
@ -221,115 +222,121 @@ function way_function (way)
|
||||
-- speed
|
||||
if route_speeds[route] then
|
||||
-- ferries (doesn't cover routes tagged using relations)
|
||||
way.mode = mode_ferry
|
||||
way.direction = Way.bidirectional
|
||||
way.ignore_in_grid = true
|
||||
if durationIsValid(duration) then
|
||||
way.duration = math.max( 1, parseDuration(duration) )
|
||||
else
|
||||
way.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.backward_speed = platform_speeds[railway]
|
||||
elseif platform_speeds[public_transport] then
|
||||
-- public_transport platforms (new tagging platform)
|
||||
way.speed = platform_speeds[public_transport]
|
||||
way.backward_speed = platform_speeds[public_transport]
|
||||
elseif railway and railway_speeds[railway] then
|
||||
way.mode = mode_train
|
||||
-- railways
|
||||
if access and access_tag_whitelist[access] then
|
||||
way.speed = railway_speeds[railway]
|
||||
way.backward_speed = railway_speeds[railway]
|
||||
way.direction = Way.bidirectional
|
||||
end
|
||||
elseif amenity and amenity_speeds[amenity] then
|
||||
-- parking areas
|
||||
way.speed = amenity_speeds[amenity]
|
||||
way.backward_speed = amenity_speeds[amenity]
|
||||
elseif bicycle_speeds[highway] then
|
||||
-- regular ways
|
||||
way.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.backward_speed = default_speed
|
||||
else
|
||||
-- biking not allowed, maybe we can push our 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' then
|
||||
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.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.backward_mode = mode_pushing
|
||||
elseif foot == 'yes' then
|
||||
way.speed = walking_speed
|
||||
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
|
||||
|
||||
-- direction
|
||||
way.direction = Way.bidirectional
|
||||
local impliedOneway = false
|
||||
if junction == "roundabout" or highway == "motorway_link" or highway == "motorway" then
|
||||
way.direction = Way.oneway
|
||||
impliedOneway = true
|
||||
end
|
||||
|
||||
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
|
||||
way.direction = Way.bidirectional
|
||||
-- prevent implied oneway
|
||||
elseif onewayClass == "-1" then
|
||||
way.direction = Way.opposite
|
||||
way.mode = 0
|
||||
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
|
||||
if impliedOneway then
|
||||
way.direction = Way.opposite
|
||||
else
|
||||
way.direction = Way.bidirectional
|
||||
way.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
|
||||
way.direction = Way.bidirectional
|
||||
-- prevent implied
|
||||
elseif cycleway_left and cycleway_tags[cycleway_left] then
|
||||
if impliedOneway then
|
||||
way.direction = Way.opposite
|
||||
else
|
||||
way.direction = Way.bidirectional
|
||||
way.mode = 0
|
||||
way.backward_mode = mode_normal
|
||||
end
|
||||
elseif cycleway_right and cycleway_tags[cycleway_right] then
|
||||
if impliedOneway then
|
||||
way.direction = Way.oneway
|
||||
else
|
||||
way.direction = Way.bidirectional
|
||||
way.mode = mode_normal
|
||||
way.backward_mode = 0
|
||||
end
|
||||
elseif oneway == "-1" then
|
||||
way.direction = Way.opposite
|
||||
elseif oneway == "yes" or oneway == "1" or oneway == "true" then
|
||||
way.direction = Way.oneway
|
||||
way.mode = 0
|
||||
elseif oneway == "yes" or oneway == "1" or oneway == "true" or impliedOneway then
|
||||
way.backward_mode = 0
|
||||
end
|
||||
|
||||
|
||||
-- pushing bikes
|
||||
if bicycle_speeds[highway] or pedestrian_speeds[highway] then
|
||||
if foot ~= 'no' then
|
||||
if junction ~= "roundabout" then
|
||||
if way.direction == Way.oneway then
|
||||
way.backward_speed = walking_speed
|
||||
way.mode = mode_pushing
|
||||
elseif way.direction == Way.opposite then
|
||||
way.backward_speed = walking_speed
|
||||
way.speed = way.speed
|
||||
way.mode = mode_pushing
|
||||
end
|
||||
if foot ~= "no" and junction ~= "roundabout" then
|
||||
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
|
||||
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
|
||||
@ -341,6 +348,14 @@ function way_function (way)
|
||||
way.speed = bicycle_speeds["cycleway"]
|
||||
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
|
||||
if surface then
|
||||
surface_speed = surface_speeds[surface]
|
||||
@ -355,12 +370,8 @@ function way_function (way)
|
||||
end
|
||||
|
||||
-- maxspeed
|
||||
-- TODO: maxspeed of backward direction
|
||||
if take_minimum_of_speeds then
|
||||
if maxspeed and maxspeed>0 then
|
||||
way.speed = math.min(way.speed, maxspeed)
|
||||
end
|
||||
end
|
||||
MaxSpeed.limit( way, maxspeed, maxspeed_forward, maxspeed_backward )
|
||||
|
||||
|
||||
-- Override speed settings if explicit forward/backward maxspeeds are given
|
||||
if way.speed > 0 and maxspeed_forward ~= nil and maxspeed_forward > 0 then
|
||||
|
17
profiles/lib/maxspeed.lua
Normal file
17
profiles/lib/maxspeed.lua
Normal 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
|
Loading…
Reference in New Issue
Block a user