-
Notifications
You must be signed in to change notification settings - Fork 0
/
intel_to_map.py
38 lines (30 loc) · 1.31 KB
/
intel_to_map.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
import csv
from PIL import Image
import annotate_map
from calc import DATA_PATH
WEEK_COLORS = ['lime', 'yellow', 'cyan', 'magenta', 'crimson', 'blueviolet', 'red', 'green', 'tan', 'slategrey']
ALT_LOC = [(2, 4), (4, 2)] # hard-coded alternate text locations to prevent overlap
def main():
with open(DATA_PATH / 'intel_challenges.csv') as f:
table = csv.reader(f)
with Image.open(DATA_PATH / 'stitched_map.png') as im:
week = 0
step = 1 # Current step
for row in table:
if row[2] == '1': # Check if challenge has interactable (coords)
text_loc = (1, 1)
if (week, step) in ALT_LOC:
text_loc = (1, -4)
annotate_map.annotate(im, (int(float(row[5])), int(float(row[6]))), f'W{week} S{step}',
marker_color=WEEK_COLORS[week-1], text_loc=text_loc)
step += 1
else:
week += 1
step = 1
print("Success. Saving map.")
im = annotate_map.crop_out_of_bounds(im)
im = annotate_map.rescale(im, 2)
im.show()
im.convert('RGB').save(DATA_PATH / 'intel_map.jpg', quality=85)
if __name__ == '__main__':
main()