forked from interactivethings/swiss-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
32 lines (25 loc) · 1.59 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
LILJSON_PRECISION = 3
TOPOJSON_PRECISION = 10e-9 # 1 nsr, see http://en.wikipedia.org/wiki/Steradian
desc "Generate GeoJSON files"
task :geojson do
rm Dir.glob("geojson/*.*json")
%w{ swiss-cantons swiss-cantons-simplified }.each do |file_name|
system "ogr2ogr -f geoJSON 'geojson/#{file_name}.json' 'shp/#{file_name}/#{file_name}.shp' -sql \"SELECT NR AS no, ABKUERZUNG AS abbr, NAME AS name FROM '#{file_name}'\""
system "python lib/liljson.py -p #{LILJSON_PRECISION} 'geojson/#{file_name}.json' 'geojson/#{file_name}.json'"
end
%w{ swiss-municipalities swiss-municipalities-simplified }.each do |file_name|
system "ogr2ogr -f geoJSON 'geojson/#{file_name}.json' 'shp/#{file_name}/#{file_name}.shp' -sql \"SELECT BFSNR AS bfsNo, GEMTEIL AS municipalityPart, KANTONSNR AS cantonNo, GEMNAME AS name FROM '#{file_name}'\""
system "python lib/liljson.py -p #{LILJSON_PRECISION} 'geojson/#{file_name}.json' 'geojson/#{file_name}.json'"
end
end
desc "Generate TopoJSON files"
task :topojson do
rm Dir.glob("topojson/*.*json")
src = %w{ swiss-cantons swiss-municipalities }
src.each do |file_name|
system "topojson 'geojson/#{file_name}.json' -o 'topojson/#{file_name}.json' --properties"
system "topojson 'geojson/#{file_name}.json' -o 'topojson/#{file_name}-simplified.json' -s #{TOPOJSON_PRECISION} --properties"
end
system "topojson #{src.map { |f| "'geojson/#{f}.json'" }.join(" ")} -o 'topojson/switzerland.json' --properties"
system "topojson #{src.map { |f| "'geojson/#{f}.json'" }.join(" ")} -o 'topojson/switzerland-simplified.json' -s #{TOPOJSON_PRECISION} --properties"
end