From 5220eb66f5c18b7cb7583b7566e76a5173dd539f Mon Sep 17 00:00:00 2001 From: Emil Tin Date: Thu, 19 Jan 2012 16:27:13 +0100 Subject: [PATCH] updated Rakefile to allow specifying region on the terminal with area=... --- Rakefile | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Rakefile b/Rakefile index dd2cf1cf4..93a3f3c8a 100644 --- a/Rakefile +++ b/Rakefile @@ -5,9 +5,17 @@ Cucumber::Rake::Task.new do |t| t.cucumber_opts = %w{--format pretty} end -osm_data_country = 'denmark' -osm_data_area_name = 'kbh' -osm_data_area_bbox = 'top=55.6972 left=12.5222 right=12.624 bottom=55.6376' +areas = { + :kbh => { :country => 'denmark', :bbox => 'top=55.6972 left=12.5222 right=12.624 bottom=55.6376' }, + :frd => { :country => 'denmark', :bbox => 'top=55.7007 left=12.4765 bottom=55.6576 right=12.5698' }, + :regh => { :country => 'denmark', :bbox => 'top=56.164 left=11.792 bottom=55.403 right=12.731' }, + :dk => { :country => 'denmark', :bbox => nil }, + :skaane => { :counry => 'sweden', :bbox => 'top=56.55 left=12.4 bottom=55.3 right=14.6' } +} +osm_data_area_name = ENV['area'].to_s.to_sym || :kbh +raise "Unknown data area." unless areas[osm_data_area_name] +osm_data_country = areas[osm_data_area_name][:country] +osm_data_area_bbox = areas[osm_data_area_name][:bbox] desc "Rebuild and run tests" @@ -22,7 +30,15 @@ namespace :data do desc "Download OSM data extract for Denmark, and crop test areas" task :download do raise "Error while downloading data." unless system "curl http://download.geofabrik.de/osm/europe/#{osm_data_country}.osm.pbf -o test/data/#{osm_data_country}.osm.pbf" - raise "Error while cropping data." unless system "osmosis --read-pbf file=test/data/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=test/data/#{osm_data_area_name}.osm.pbf omitmetadata=true" + if osm_data_area_bbox + raise "Error while cropping data." unless system "osmosis --read-pbf file=test/data/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=test/data/#{osm_data_area_name}.osm.pbf omitmetadata=true" + end + end + + task :crop do + if osm_data_area_bbox + raise "Error while cropping data." unless system "osmosis --read-pbf file=test/data/#{osm_data_country}.osm.pbf --bounding-box #{osm_data_area_bbox} --write-pbf file=test/data/#{osm_data_area_name}.osm.pbf omitmetadata=true" + end end desc "Reprocess OSM data"