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,6 +14,7 @@ file "#{sandbox}/amager.osm.pbf" => "amager.osm.pbf" do |t|
raise unless system "cp #{t.prerequisites.join} #{t.name}"
end
namespace :data do
desc "Reprocess OSM test data"
task :process => ["#{sandbox}/amager.osm.pbf", :setup] do
prev = Dir.pwd
@ -23,6 +24,18 @@ task :process => ["#{sandbox}/amager.osm.pbf", :setup] do
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"
task :setup => ["#{sandbox}/speedprofile.ini", "#{sandbox}/extractor.ini", "#{sandbox}/server.ini"]