diff --git a/.gitignore b/.gitignore index e11ad70ba..298d8e371 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Test folder # +# Test folders # ################### test/speedprofile.ini test/cache @@ -8,10 +8,7 @@ test/stxxl # Sandbox folder # ################### -sandbox/speedprofile.ini -sandbox/data -sandbox/server.ini -sandbox/stxxl +sandbox # Compiled source # ################### diff --git a/Rakefile b/Rakefile index 7cfc225fe..bb0d960e1 100644 --- a/Rakefile +++ b/Rakefile @@ -3,6 +3,9 @@ require 'socket' require 'digest/sha1' require 'cucumber/rake/task' +SANDBOX = 'sandbox' +DATA_FOLDER = 'osm_data' + Cucumber::Rake::Task.new do |t| t.cucumber_opts = %w{--format pretty} end @@ -53,78 +56,89 @@ end def write_server_ini osm_file s=<<-EOF -Threads = 1 -IP = 0.0.0.0 -Port = 5000 + Threads = 1 + IP = 0.0.0.0 + Port = 5000 -hsgrData=data/#{osm_file}.osrm.hsgr -nodesData=data/#{osm_file}.osrm.nodes -ramIndex=data/#{osm_file}.osrm.ramIndex -fileIndex=data/#{osm_file}.osrm.fileIndex -namesData=data/#{osm_file}.osrm.names -EOF + hsgrData=#{DATA_FOLDER}/#{osm_file}.osrm.hsgr + nodesData=#{DATA_FOLDER}/#{osm_file}.osrm.nodes + ramIndex=#{DATA_FOLDER}/#{osm_file}.osrm.ramIndex + fileIndex=#{DATA_FOLDER}/#{osm_file}.osrm.fileIndex + namesData=#{DATA_FOLDER}/#{osm_file}.osrm.names + EOF File.open( 'server.ini', 'w') {|f| f.write( s ) } end -desc "Rebuild and run tests" +desc "Rebuild and run tests." task :default => [:build, :cucumber] -desc "Build using Scons" +desc "Build using SConsstruct." task :build do system "scons" end -desc "Download OSM data" -task :download do +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}" + end + end +end + +desc "Download OSM data." +task :download => :setup do puts "Downloading..." - raise "Error while downloading data." unless system "curl http://download.geofabrik.de/osm/europe/#{osm_data_country}.osm.pbf -o sandbox/data/#{osm_data_country}.osm.pbf" + 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" if osm_data_area_bbox puts "Cropping and converting to protobuffer..." - raise "Error while cropping data." unless system "osmosis --read-pbf file=sandbox/data/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=sandbox/data/#{osm_data_area_name}.osm.pbf omitmetadata=true" + 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" 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/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=sandbox/data/#{osm_data_area_name}.osm.pbf omitmetadata=true" + 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" end end -desc "Reprocess OSM data" -task :process do - Dir.chdir "sandbox" do - raise "Error while extracting data." unless system "../osrm-extract data/#{osm_data_area_name}.osm.pbf" +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" puts - raise "Error while preparing data." unless system "../osrm-prepare data/#{osm_data_area_name}.osrm #{osm_data_area_name}.osrm.restrictions" + raise "Error while preparing data." unless system "../osrm-prepare #{DATA_FOLDER}/#{osm_data_area_name}.osrm #{DATA_FOLDER}/#{osm_data_area_name}.osrm.restrictions" puts end end -desc "Delete preprocessing files" +desc "Delete preprocessing files." task :clean do - File.delete *Dir.glob('sandbox/data/*.osrm') - File.delete *Dir.glob('sandbox/data/*.osrm.*') + File.delete *Dir.glob("#{SANDBOX}/#{DATA_FOLDER}/*.osrm") + File.delete *Dir.glob("#{SANDBOX}/#{DATA_FOLDER}/*.osrm.*") end -desc "Run all test" +desc "Run all cucumber test" task :test do system "cucumber" puts end desc "Run the routing server in the terminal. Press Ctrl-C to stop." -task :run do - Dir.chdir "sandbox" do +task :run => :setup do + Dir.chdir SANDBOX do write_server_ini osm_data_area_name system "../osrm-routed" end end desc "Launch the routing server in the background. Use rake:down to stop it." -task :up do - Dir.chdir "sandbox" do +task :up => :setup do + Dir.chdir SANDBOX 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') @@ -147,7 +161,7 @@ task :down do Process.kill 'TERM', pid end -desc "Kill the routing server(s)." +desc "Kill all osrm-extract, osrm-prepare and osrm-routed processes." task :kill do each_process('osrm-routed') { |pid,state| Process.kill 'KILL', pid } each_process('osrm-prepare') { |pid,state| Process.kill 'KILL', pid } @@ -157,7 +171,7 @@ task :kill do wait_for_shutdown 'osrm-extract' end -desc "Get PID of routing server(s)." +desc "Get PIDs of all osrm-extract, osrm-prepare and osrm-routed processes." task :pid do each_process 'osrm-routed' do |pid,state| puts "#{pid}\t#{state}" diff --git a/sandbox/contractor.ini b/contractor.ini similarity index 100% rename from sandbox/contractor.ini rename to contractor.ini diff --git a/sandbox/extractor.ini b/extractor.ini similarity index 100% rename from sandbox/extractor.ini rename to extractor.ini diff --git a/features/oneway.feature b/features/oneway.feature index cd57995e5..1e5bc358c 100644 --- a/features/oneway.feature +++ b/features/oneway.feature @@ -2,29 +2,12 @@ Feature: Oneway streets Handle oneways streets, as defined at http://wiki.openstreetmap.org/wiki/OSM_tags_for_routing - Scenario: hmm Handle various oneway tag values - Given the speedprofile "bicycle" - Then routability should be - | highway | oneway | forw | backw | - | primary | | x | x | - | primary | | x | x | - | primary | | x | x | - | primary | | x | x | - | primary | | x | x | - | primary | true | x | | - - Scenario: Oneway street - Given the nodes - | a | b | c | - - And the ways - | nodes | oneway | - | abc | -1 | - - When I route I should get - | from | to | route | - | a | c | | - | c | a | abc | + @ba + Scenario: Simple oneway + Given the defaults + Then routability should be + | highway | oneway | forw | backw | + | primary | yes | x | | Scenario: Around the Block Given the nodes diff --git a/features/support/data.rb b/features/support/data.rb index 3600503d0..a3559c86b 100644 --- a/features/support/data.rb +++ b/features/support/data.rb @@ -129,6 +129,7 @@ end def write_osm #write .oms file if needed + Dir.mkdir DATA_FOLDER unless File.exist? DATA_FOLDER @osm_file = "#{DATA_FOLDER}/#{fingerprint}" unless File.exist?("#{@osm_file}.osm") File.open( "#{@osm_file}.osm", 'w') {|f| f.write(osm_str) } diff --git a/sandbox/.gitignore b/sandbox/.gitignore new file mode 100644 index 000000000..e69de29bb diff --git a/server.ini b/server.ini new file mode 100644 index 000000000..2a6d1dac5 --- /dev/null +++ b/server.ini @@ -0,0 +1,9 @@ +Threads = 8 +IP = 0.0.0.0 +Port = 5000 + +hsgrData=data/kbh.osrm.hsgr +nodesData=data/kbh.osrm.nodes +ramIndex=data/kbh.osrm.ramIndex +fileIndex=data/kbh.osrm.fileIndex +namesData=data/kbh.osrm.names diff --git a/speedprofile.ini b/speedprofile.ini new file mode 100644 index 000000000..d6e6187b7 --- /dev/null +++ b/speedprofile.ini @@ -0,0 +1,27 @@ +[bicycle] + accessTag = bicycle + defaultSpeed = 17 + obeyOneways = yes + useRestrictions = yes + obeyBollards = no + + cycleway = 19 + primary = 19 + primary_link = 19 + secondary = 17 + secondary_link = 17 + tertiary = 15 + residential = 15 + unclassified = 15 + living_street = 13 + road = 13 + service = 12 + track = 12 + path = 12 + footway = 10 + pedestrian = 5 + pier = 5 + steps = 3 + ferry = 5 + + excludeFromGrid = ferry