rake task for downloading osm data

This commit is contained in:
Emil Tin 2011-12-06 13:52:39 +01:00
parent fa548f3fbc
commit 39872e9867

View File

@ -2,7 +2,7 @@ sandbox = "sandbox" #where to locate builds, server configs and test data
osm_data = "amager" #name of OSM data file
desc "Recompile, reprocess OSM data and run server"
task :default => [:compile, :process, :run]
task :default => [:compile, "data:process", :run]
desc "Compile"
task :compile do
@ -14,13 +14,26 @@ file "#{sandbox}/amager.osm.pbf" => "amager.osm.pbf" do |t|
raise unless system "cp #{t.prerequisites.join} #{t.name}"
end
desc "Reprocess OSM test data"
task :process => ["#{sandbox}/amager.osm.pbf", :setup] do
prev = Dir.pwd
cd sandbox #we must be in the sandbox folder to use the speedprofile.ini in that folder
raise "Error while extracting data." unless system "./osrm-extract amager.osm.pbf"
raise "Error while preparing data." unless system "./osrm-prepare amager.osrm amager.osrm.restrictions"
cd prev
namespace :data do
desc "Reprocess OSM test data"
task :process => ["#{sandbox}/amager.osm.pbf", :setup] do
prev = Dir.pwd
cd sandbox #we must be in the sandbox folder to use the speedprofile.ini in that folder
raise "Error while extracting data." unless system "./osrm-extract amager.osm.pbf"
raise "Error while preparing data." unless system "./osrm-prepare amager.osrm amager.osrm.restrictions"
cd prev
end
desc "Download fresh OSM for the test data"
task :download => :setup do
start = Time.now
country = 'denmark'
bbox = 'top=55.6655 left=12.5589 bottom=55.6462 right=12.5963'
area = 'amager'
raise "Error while downloading data." unless system "curl http://download.geofabrik.de/osm/europe/#{country}.osm.pbf -o #{sandbox}/#{country}.osm.pbf"
raise "Error while cropping data." unless system "osmosis --read-pbf file=#{sandbox}/#{country}.osm.pbf --bounding-box #{bbox} --write-pbf file=#{sandbox}/#{area}.osm.pbf omitmetadata=true"
end
end
desc "Setup server files"