Merge branch 'develop' of https://github.com/DennisOSRM/Project-OSRM into develop

This commit is contained in:
DennisOSRM 2012-10-20 21:12:49 +02:00
commit b6303626b5
12 changed files with 208 additions and 90 deletions

View File

@ -4,8 +4,8 @@ require 'digest/sha1'
require 'cucumber/rake/task'
require 'sys/proctable'
SANDBOX = 'sandbox'
DATA_FOLDER = 'osm_data'
DATA_FOLDER = 'sandbox'
PROFILE = 'bicycle'
Cucumber::Rake::Task.new do |t|
t.cucumber_opts = %w{--format pretty}
@ -62,12 +62,12 @@ def write_server_ini osm_file
IP = 0.0.0.0
Port = 5000
hsgrData=#{DATA_FOLDER}/#{osm_file}.osrm.hsgr
nodesData=#{DATA_FOLDER}/#{osm_file}.osrm.nodes
edgesData=#{DATA_FOLDER}/#{osm_file}.osrm.edges
ramIndex=#{DATA_FOLDER}/#{osm_file}.osrm.ramIndex
fileIndex=#{DATA_FOLDER}/#{osm_file}.osrm.fileIndex
namesData=#{DATA_FOLDER}/#{osm_file}.osrm.names
hsgrData=#{osm_file}.osrm.hsgr
nodesData=#{osm_file}.osrm.nodes
edgesData=#{osm_file}.osrm.edges
ramIndex=#{osm_file}.osrm.ramIndex
fileIndex=#{osm_file}.osrm.fileIndex
namesData=#{osm_file}.osrm.names
EOF
File.open( 'server.ini', 'w') {|f| f.write( s ) }
end
@ -83,46 +83,48 @@ end
desc "Setup config files."
task :setup do
Dir.mkdir "#{SANDBOX}/#{DATA_FOLDER}" unless File.exist? "#{SANDBOX}/#{DATA_FOLDER}"
['server.ini','speedprofile.ini','extractor.ini','contractor.ini'].each do |file|
unless File.exist? "#{SANDBOX}/#{file}"
puts "Copying #{file} template to sandbox/#{file}"
FileUtils.cp file, "#{SANDBOX}/#{file}"
Dir.mkdir "#{DATA_FOLDER}" unless File.exist? "#{DATA_FOLDER}"
['server.ini','extractor.ini','contractor.ini'].each do |file|
unless File.exist? "#{DATA_FOLDER}/#{file}"
puts "Copying #{file} template to #{DATA_FOLDER}/#{file}"
FileUtils.cp file, "#{DATA_FOLDER}/#{file}"
end
end
end
desc "Download OSM data."
task :download => :setup do
Dir.mkdir "#{DATA_FOLDER}" unless File.exist? "#{DATA_FOLDER}"
puts "Downloading..."
raise "Error while downloading data." unless system "curl http://download.geofabrik.de/osm/europe/#{osm_data_country}.osm.pbf -o #{SANDBOX}/#{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
puts "curl http://download.geofabrik.de/openstreetmap/europe/#{osm_data_country}.osm.pbf -o #{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
raise "Error while downloading data." unless system "curl http://download.geofabrik.de/openstreetmap/europe/#{osm_data_country}.osm.pbf -o #{DATA_FOLDER}/#{osm_data_country}.osm.pbf"
if osm_data_area_bbox
puts "Cropping and converting to protobuffer..."
raise "Error while cropping data." unless system "osmosis --read-pbf file=#{SANDBOX}/#{DATA_FOLDER}/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=#{SANDBOX}/#{DATA_FOLDER}/#{osm_data_area_name}.osm.pbf omitmetadata=true"
raise "Error while cropping data." unless system "osmosis --read-pbf file=#{DATA_FOLDER}/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=#{DATA_FOLDER}/#{osm_data_area_name}.osm.pbf omitmetadata=true"
end
end
desc "Crop OSM data"
task :crop do
if osm_data_area_bbox
raise "Error while cropping data." unless system "osmosis --read-pbf file=#{SANDBOX}/#{DATA_FOLDER}/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=#{SANDBOX}/#{DATA_FOLDER}/#{osm_data_area_name}.osm.pbf omitmetadata=true"
raise "Error while cropping data." unless system "osmosis --read-pbf file=#{DATA_FOLDER}/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=#{DATA_FOLDER}/#{osm_data_area_name}.osm.pbf omitmetadata=true"
end
end
desc "Reprocess OSM data."
task :process => :setup do
Dir.chdir SANDBOX do
raise "Error while extracting data." unless system "../osrm-extract #{DATA_FOLDER}/#{osm_data_area_name}.osm.pbf"
Dir.chdir DATA_FOLDER do
raise "Error while extracting data." unless system "../osrm-extract #{osm_data_area_name}.osm.pbf ../profiles/#{PROFILE}.lua"
puts
raise "Error while preparing data." unless system "../osrm-prepare #{DATA_FOLDER}/#{osm_data_area_name}.osrm #{DATA_FOLDER}/#{osm_data_area_name}.osrm.restrictions"
raise "Error while preparing data." unless system "../osrm-prepare #{osm_data_area_name}.osrm #{osm_data_area_name}.osrm.restrictions ../profiles/#{PROFILE}.lua"
puts
end
end
desc "Delete preprocessing files."
task :clean do
File.delete *Dir.glob("#{SANDBOX}/#{DATA_FOLDER}/*.osrm")
File.delete *Dir.glob("#{SANDBOX}/#{DATA_FOLDER}/*.osrm.*")
File.delete *Dir.glob("#{DATA_FOLDER}/*.osrm")
File.delete *Dir.glob("#{DATA_FOLDER}/*.osrm.*")
end
desc "Run all cucumber test"
@ -133,7 +135,7 @@ end
desc "Run the routing server in the terminal. Press Ctrl-C to stop."
task :run => :setup do
Dir.chdir SANDBOX do
Dir.chdir DATA_FOLDER do
write_server_ini osm_data_area_name
system "../osrm-routed"
end
@ -141,7 +143,7 @@ end
desc "Launch the routing server in the background. Use rake:down to stop it."
task :up => :setup do
Dir.chdir SANDBOX do
Dir.chdir DATA_FOLDER do
abort("Already up.") if up?
write_server_ini osm_data_area_name
pipe = IO.popen('../osrm-routed 1>>osrm-routed.log 2>>osrm-routed.log')
@ -160,8 +162,11 @@ end
desc "Stop the routing server."
task :down do
pid = find_pid 'osrm-routed'
abort("Already down.") unless pid
if pid
Process.kill 'TERM', pid
else
puts "Already down."
end
end
desc "Kill all osrm-extract, osrm-prepare and osrm-routed processes."
@ -180,3 +185,7 @@ task :pid do
puts "#{pid}\t#{state}"
end
end
desc "Stop, reprocess and restart."
task :update => [:down,:process,:up] do
end

View File

@ -72,6 +72,8 @@ conf = Configure(env, custom_tests = { 'CheckBoost' : CheckBoost, 'CheckProtobuf
if GetOption('cxx') is None:
#default Compiler
if sys.platform == 'darwin': #Mac OS X
env['CXX'] = 'clang++'
print 'Using default C++ Compiler: ', env['CXX'].strip()
else:
env.Replace(CXX = GetOption('cxx'))

View File

@ -4,6 +4,7 @@ Feature: Bike - Squares and other areas
Background:
Given the speedprofile "bicycle"
@square
Scenario: Bike - Route along edge of a squares
Given the node map
| x | |
@ -26,6 +27,7 @@ Feature: Bike - Squares and other areas
| d | a | abcda |
| a | d | abcda |
@building
Scenario: Bike - Don't route on buildings
Given the node map
| x | |
@ -47,3 +49,55 @@ Feature: Bike - Squares and other areas
| d | c | |
| d | a | |
| a | d | |
@parking
Scenario: Bike - parking areas
Given the node map
| e | | | f |
| x | a | b | y |
| | d | c | |
And the ways
| nodes | highway | amenity |
| xa | primary | |
| by | primary | |
| xefy | primary | |
| abcda | (nil) | parking |
When I route I should get
| from | to | route |
| x | y | xa,abcda,by |
| y | x | by,abcda,xa |
| a | b | abcda |
| a | d | abcda |
| b | c | abcda |
| c | b | abcda |
| c | d | abcda |
| d | c | abcda |
| d | a | abcda |
| a | d | abcda |
@train @platform
Scenario: Bike - railway platforms
Given the node map
| x | a | b | y |
| | d | c | |
And the ways
| nodes | highway | railway |
| xa | primary | |
| by | primary | |
| abcda | (nil) | platform |
When I route I should get
| from | to | route |
| x | y | xa,abcda,by |
| y | x | by,abcda,xa |
| a | b | abcda |
| a | d | abcda |
| b | c | abcda |
| c | b | abcda |
| c | d | abcda |
| d | c | abcda |
| d | a | abcda |
| a | d | abcda |

View File

@ -1,4 +1,4 @@
@routing @bicycle @train @todo
@routing @bicycle @train
Feature: Bike - Handle ferry routes
Bringing bikes on trains and subways
@ -18,6 +18,15 @@ Bringing bikes on trains and subways
| (nil) | subway | | |
| (nil) | subway | no | |
| (nil) | subway | yes | x |
| (nil) | tram | | |
| (nil) | tram | no | |
| (nil) | tram | yes | x |
| (nil) | light_rail | | |
| (nil) | light_rail | no | |
| (nil) | light_rail | yes | x |
| (nil) | monorail | | |
| (nil) | monorail | no | |
| (nil) | monorail | yes | x |
| (nil) | some_tag | | |
| (nil) | some_tag | no | |
| (nil) | some_tag | yes | x |

View File

@ -1,4 +1,4 @@
@routing @bicycle @destination @todo
@routing @car @destination @todo
Feature: Car - Destination only, no passing through
Background:

View File

@ -240,7 +240,7 @@ When /^I route I should get$/ do |table|
margin = 1 - $2.to_f*0.01
from = $1.to_f*margin
to = $1.to_f/margin
if (from..to).cover? got[key].to_f
if got[key].to_f >= from && got[key].to_f <= to
got[key] = row[key]
else
ok = false
@ -249,7 +249,7 @@ When /^I route I should get$/ do |table|
margin = $2.to_f
from = $1.to_f-margin
to = $1.to_f+margin
if (from..to).cover? got[key].to_f
if got[key].to_f >= from && got[key].to_f <= to
got[key] = row[key]
else
ok = false

View File

@ -11,10 +11,6 @@ def read_speedprofile profile
@speedprofile = profile
end
def write_speedprofile
FileUtils.copy_file "../profiles/#{@speedprofile}.lua", "profile.lua"
end
def write_server_ini
s=<<-EOF
Threads = 1

View File

@ -200,13 +200,12 @@ end
def reprocess
Dir.chdir TEST_FOLDER do
write_speedprofile
write_osm
convert_osm_to_pbf
unless extracted?
log_preprocess_info
log "== Extracting #{@osm_file}.osm...", :preprocess
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
unless system "../osrm-extract #{@osm_file}.osm.pbf 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@speedprofile}.lua"
log "*** Exited with code #{$?.exitstatus}.", :preprocess
raise OSRMError.new 'osrm-extract', $?.exitstatus, "*** osrm-extract exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
end
@ -215,7 +214,7 @@ def reprocess
unless prepared?
log_preprocess_info
log "== Preparing #{@osm_file}.osm...", :preprocess
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE}"
unless system "../osrm-prepare #{@osm_file}.osrm #{@osm_file}.osrm.restrictions 1>>#{PREPROCESS_LOG_FILE} 2>>#{PREPROCESS_LOG_FILE} ../profiles/#{@speedprofile}.lua"
log "*** Exited with code #{$?.exitstatus}.", :preprocess
raise OSRMError.new 'osrm-prepare', $?.exitstatus, "*** osrm-prepare exited with code #{$?.exitstatus}. The file preprocess.log might contain more info."
end

View File

@ -12,7 +12,7 @@ def hash_of_file path
end
def speedprofile_hash
@speedprofile_hash ||= hash_of_file "profile.lua"
@speedprofile_hash ||= hash_of_file "../profiles/#{@speedprofile}.lua"
end
def osm_hash

View File

@ -5,7 +5,7 @@ Testbot uses a signal penalty of 7s.
Background:
Given the speedprofile "testbot"
Scenario: Passing a traffic signal should incur a delay
Scenario: Traffic signals should incur a delay, without changing distance
Given the node map
| a | b | c |
| d | e | f |
@ -20,9 +20,9 @@ Testbot uses a signal penalty of 7s.
| def |
When I route I should get
| from | to | route | time |
| a | c | abc | 20s +-1 |
| d | f | def | 27s +-1 |
| from | to | route | time | distance |
| a | c | abc | 20s +-1 | 200m +-1 |
| d | f | def | 27s +-1 | 200m +-1 |
Scenario: Signal penalty should not depend on way type
Given the node map

View File

@ -6,9 +6,10 @@ access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
access_tags_hierachy = { "bicycle", "vehicle", "access" }
cycleway_tags = {["track"]=true,["lane"]=true,["opposite"]=true,["opposite_lane"]=true,["opposite_track"]=true,["share_busway"]=true,["sharrow"]=true,["shared"]=true }
service_tag_restricted = { ["parking_aisle"] = true }
ignore_in_grid = { ["ferry"] = true }
speed_profile = {
default_speed = 16
main_speeds = {
["cycleway"] = 18,
["primary"] = 17,
["primary_link"] = 17,
@ -23,11 +24,38 @@ speed_profile = {
["service"] = 16,
["track"] = 13,
["path"] = 13,
["footway"] = 12,
["pedestrian"] = 12,
["pier"] = 12,
["steps"] = 2
}
pedestrian_speeds = {
["footway"] = 5,
["pedestrian"] = 5,
["pier"] = 5,
["steps"] = 1,
["default"] = 18,
["steps"] = 2
}
railway_speeds = {
["train"] = 10,
["railway"] = 10,
["subway"] = 10,
["light_rail"] = 10,
["monorail"] = 10,
["tram"] = 10
}
platform_speeds = {
["platform"] = 5
}
amenity_speeds = {
["parking"] = 10,
["parking_entrance"] = 10
}
route_speeds = {
["ferry"] = 5
}
@ -92,6 +120,7 @@ function way_function (way, numberOfNodesInWay)
local ref = way.tags:Find("ref")
local junction = way.tags:Find("junction")
local route = way.tags:Find("route")
local railway = way.tags:Find("railway")
local maxspeed = parseMaxspeed(way.tags:Find ( "maxspeed") )
local man_made = way.tags:Find("man_made")
local barrier = way.tags:Find("barrier")
@ -103,10 +132,14 @@ function way_function (way, numberOfNodesInWay)
local duration = way.tags:Find("duration")
local service = way.tags:Find("service")
local area = way.tags:Find("area")
local amenity = way.tags:Find("amenity")
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
if (not highway or highway == '') and
(not route or route == '') and
(not railway or railway=='') and
(not amenity or amenity=='') then
return 0
end
@ -124,27 +157,43 @@ function way_function (way, numberOfNodesInWay)
way.name = highway -- if no name exists, use way type
end
if (speed_profile[route] and speed_profile[route] > 0) or (speed_profile[man_made] and speed_profile[man_made] > 0) then
-- ferries and piers
if route_speeds[route] then
-- ferries
way.direction = Way.bidirectional
way.ignore_in_grid = true
if durationIsValid(duration) then
way.speed = math.max( duration / math.max(1, numberOfNodesInWay-1) )
way.is_duration_set = true;
end
way.direction = Way.bidirectional;
if speed_profile[route] ~= nil then
highway = route;
elseif speed_profile[man_made] ~= nil then
highway = man_made;
end
if not way.is_duration_set then
way.speed = speed_profile[highway]
end
way.speed = math.max( parseDuration(duration) / math.max(1, numberOfNodesInWay-1) )
way.is_duration_set = true
else
-- ways
if speed_profile[highway] then
way.speed = speed_profile[highway]
way.speed = route_speeds[route]
end
elseif railway and platform_speeds[railway] then
-- railway platforms
way.speed = platform_speeds[railway]
elseif railway and railway_speeds[railway] then
-- railways
if access and access_tag_whitelist[access] then
way.speed = railway_speeds[railway]
way.direction = Way.bidirectional
end
elseif pedestrian_speeds[highway] and main_speeds[highway] then
-- pedestrian areas
if access_tag_whitelist[access] then
way.speed = main_speeds[highway] -- biking
else
way.speed = pedestrian_speeds[highway] -- pushing bikes
end
elseif amenity and amenity_speeds[amenity] then
-- parking areas
way.speed = amenity_speeds[amenity]
else
-- regular ways
if main_speeds[highway] then
way.speed = main_speeds[highway]
elseif main_speeds[man_made] then
way.speed = main_speeds[man_made]
elseif access_tag_whitelist[access] then
way.speed = speed_profile["default"]
way.speed = default_speed
end
end
@ -199,11 +248,11 @@ function way_function (way, numberOfNodesInWay)
-- cycleways
if cycleway and cycleway_tags[cycleway] then
way.speed = speed_profile["cycleway"]
way.speed = main_speeds["cycleway"]
elseif cycleway_left and cycleway_tags[cycleway_left] then
way.speed = speed_profile["cycleway"]
way.speed = main_speeds["cycleway"]
elseif cycleway_right and cycleway_tags[cycleway_right] then
way.speed = speed_profile["cycleway"]
way.speed = main_speeds["cycleway"]
end
way.type = 1

View File

@ -7,7 +7,7 @@ access_tag_restricted = { ["destination"] = true, ["delivery"] = true }
access_tags = { "motorcar", "motor_vehicle", "vehicle" }
access_tags_hierachy = { "motorcar", "motor_vehicle", "vehicle", "access" }
service_tag_restricted = { ["parking_aisle"] = true }
ignore_in_grid = { ["ferry"] = true, ["pier"] = true }
ignore_in_grid = { ["ferry"] = true }
speed_profile = {
["motorway"] = 90,
@ -26,7 +26,7 @@ speed_profile = {
["service"] = 15,
-- ["track"] = 5,
["ferry"] = 5,
["pier"] = 5,
-- ["pier"] = 5,
["default"] = 50
}
@ -93,7 +93,7 @@ function way_function (way, numberOfNodesInWay)
local junction = way.tags:Find("junction")
local route = way.tags:Find("route")
local maxspeed = parseMaxspeed(way.tags:Find ( "maxspeed") )
local man_made = way.tags:Find("man_made")
--local man_made = way.tags:Find("man_made")
local barrier = way.tags:Find("barrier")
local oneway = way.tags:Find("oneway")
local cycleway = way.tags:Find("cycleway")
@ -138,8 +138,8 @@ function way_function (way, numberOfNodesInWay)
-- Handling ferries and piers
if (speed_profile[route] ~= nil and speed_profile[route] > 0) or
(speed_profile[man_made] ~= nil and speed_profile[man_made] > 0)
if (speed_profile[route] ~= nil and speed_profile[route] > 0) --or
--(speed_profile[man_made] ~= nil and speed_profile[man_made] > 0)
then
if durationIsValid(duration) then
way.speed = math.max( parseDuration(duration) / math.max(1, numberOfNodesInWay-1) );
@ -148,8 +148,8 @@ function way_function (way, numberOfNodesInWay)
way.direction = Way.bidirectional;
if speed_profile[route] ~= nil then
highway = route;
elseif speed_profile[man_made] ~= nil then
highway = man_made;
--elseif speed_profile[man_made] ~= nil then
-- highway = man_made;
end
if not way.is_duration_set then
way.speed = speed_profile[highway]
@ -166,7 +166,7 @@ function way_function (way, numberOfNodesInWay)
end
-- Set the avg speed on ways that are marked accessible
if speed_profile[highway] and access_tag_whitelist[access] and way.speed == -1 then
if "" ~= highway and 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