-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
executable file
·68 lines (55 loc) · 1.48 KB
/
main.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
63
64
65
66
67
68
#!/usr/bin/env python3
"""
Controls most of the system.
"""
from typing import Optional
from tqdm import tqdm
import data
import tiles
import image
def main() -> None:
"""
Default functionality (for Elgeis).
"""
run(
"http://dynmap.elgeis.com:2121/",
"8302018",
"dynmap.png",
"cache",
None,
0,
)
def run(
link: str,
worldname: str,
output: str,
cache: Optional[str],
size: Optional[tuple[tuple[int, int], tuple[int, int]]],
zoom: int,
) -> None:
"""
The primary function that delegates to the other modules.
"""
if size is None:
size = data.worldborder(link, worldname)
templates = data.templating(link, cache, worldname, zoom)
tilesize = tiles.get_tilesize(zoom)
rangeX, rangeZ = tiles.blocks_to_tiles(*size[0], *size[1], tilesize)
full_map = image.init(rangeX, rangeZ)
pbar = tqdm(
total=(rangeX[1] + 1 - rangeX[0]) * (rangeZ[1] + 1 - rangeZ[0])
)
startX = rangeX[0]
startZ = rangeZ[0]
for X in range(rangeX[0], rangeX[1] + 1):
for Z in range(rangeZ[0], rangeZ[1] + 1):
tile = data.getimage(templates, X, Z, zoom)
image.append(full_map, tile, X - startX, Z - startZ)
del tile
pbar.update(1)
pbar.close()
full_map = image.trim(full_map, zoom, size, (rangeX, rangeZ))
print("Saving image. This may take a while.")
full_map.save(output)
if __name__ == "__main__":
main()