forked from utagawal/MapUtagawa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_country.py
62 lines (43 loc) · 1.39 KB
/
add_country.py
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/python
import sys
import os
import subprocess
from scripts_hgt.get_hgt import get_hgt
from scripts_hgt.hgt_to_osm import hgt_to_osm
from get_contours import get_contours
import os, shutil, fnmatch
import subprocess
import time
country_name=sys.argv[1]
style=sys.argv[2]
url=sys.argv[3]
start_time = time.perf_counter()
country_name_lower_case = country_name.lower().replace(" ", "_")
country_name_upper_case = country_name_lower_case.capitalize()
os.makedirs("dem/"+country_name_lower_case, exist_ok=True)
os.makedirs("carte_"+country_name_lower_case, exist_ok=True)
#Get Id
country_list=[]
#File country
file_in = open("country.txt", "rt")
lines = file_in.readlines()
for line in lines:
result = line.split(";")
country_list.append([result[0],result[1],result[2]])
file_in.close()
id=f'{len(country_list)+1:02d}'
#File country
file_in = open("country.txt", "rt")
file_source = file_in.read()
file_modif = file_source+'\n#'+country_name+';'+id+';'+style+';'+url
file_in.close()
file_out = open("country.txt", "wt")
file_out.write(file_modif)
file_out.close()
print("Start Add country"+country_name+ " "+id+ " "+" "+style,url)
#Get contours
get_contours(country_name, url)
#Launch script
subprocess.run(["bash", "update_map.sh",country_name,id,style,url])
stop_time = time.perf_counter()
print("End Add country in "+time.strftime('%H:%M:%S', time.gmtime(stop_time - start_time)))