-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenerateMap.py
More file actions
44 lines (34 loc) · 1.09 KB
/
Copy pathGenerateMap.py
File metadata and controls
44 lines (34 loc) · 1.09 KB
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
import svgwrite
import numpy as np
import json
import xml.etree.ElementTree as ET
COLOR_VISITED = "#ff0000"
COLOR_NOT_VISITED = "#d3d2d1"
#Read the json file
with open('countries.json', 'r') as f:
data = json.load(f)
N = len(data["countries"])
#Add the countries in the markdown list
with open('ListCountries.md', 'w') as f:
for i in range(N):
strike = ""
if(data["countries"][i]["visited"]):
strike = "~~"
f.write("- " + strike + data["countries"][i]["country"] + strike +"\n")
#Color the map
tree = ET.parse('Map.svg')
root = tree.getroot()
for child in root[0]:
#print(child.tag, child.attrib)
countryId = child.get('id')
if len(countryId)==2:
#print(countryId)
for i in range(N):
if data["countries"][i]["id"] == countryId:
print(countryId)
if data["countries"][i]["visited"]:
child.set('style', 'fill:' + COLOR_VISITED)
else:
child.set('style', 'fill:' + COLOR_NOT_VISITED)
break
tree.write('FinalMap.svg')