forked from interactivethings/swiss-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
31 lines (24 loc) · 1.52 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
LILJSON_PRECISION = 3
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 1000 --properties"
end
system "topojson #{src.map { |f| "'geojson/#{f}.json'" }.join(" ")} -o 'topojson/swiss-cantons-municipalities.json' --properties"
system "topojson #{src.map { |f| "'geojson/#{f}.json'" }.join(" ")} -o 'topojson/swiss-cantons-municipalities-simplified.json' -s 1000 --properties"
end