forked from interactivethings/swiss-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate
executable file
·43 lines (33 loc) · 1.06 KB
/
generate
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
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env python3
import sys
from datetime import date
from pathlib import Path
from shutil import copyfile, rmtree
from subprocess import check_call, DEVNULL
cantons = {
'ag', 'ai', 'ar', 'be', 'bl', 'bs', 'fr', 'ge', 'gl', 'gr', 'ju', 'lu',
'ne', 'nw', 'ow', 'sg', 'sh', 'so', 'sz', 'tg', 'ti', 'ur', 'vd', 'vs',
'zg', 'zh'
}
year = int(len(sys.argv) >= 2 and sys.argv[1] or date.today().year)
output = Path.cwd() / 'topo'
final = Path.cwd() / str(year)
if year < 2013:
print("Years before 2013 do not exist")
sys.exit(1)
print("Removing existing data")
if final.exists():
rmtree(str(final))
final.mkdir()
check_call("make clean", stdout=DEVNULL, stderr=DEVNULL, shell=True)
print("Generating maps for {}".format(year))
check_call(
"make all YEAR={}".format(year),
stdout=DEVNULL, stderr=DEVNULL, shell=True
)
print("Organizing result")
for canton in cantons:
target = final / '{}.json'.format(canton)
without_lakes = output / '{}-municipalities.json'.format(canton)
copyfile(str(without_lakes), str(target))
print("Done")