From 39872e9867a85652a718671e8a474d0a89a3b716 Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Tue, 6 Dec 2011 13:52:39 +0100 Subject: [PATCH] rake task for downloading osm data --- Rakefile | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/Rakefile b/Rakefile index d7fd2d11d..c1a3a1fe3 100644 --- a/Rakefile +++ b/Rakefile @@ -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"