tilegrab 1.1.0__py3-none-any.whl → 1.2.0b2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- tilegrab/__init__.py +1 -1
- tilegrab/cli.py +95 -121
- tilegrab/dataset.py +12 -9
- tilegrab/downloader.py +32 -28
- tilegrab/images.py +178 -57
- tilegrab/logs.py +84 -0
- tilegrab/sources.py +14 -8
- tilegrab/tiles.py +166 -80
- {tilegrab-1.1.0.dist-info → tilegrab-1.2.0b2.dist-info}/METADATA +65 -100
- tilegrab-1.2.0b2.dist-info/RECORD +15 -0
- tilegrab/mosaic.py +0 -75
- tilegrab-1.1.0.dist-info/RECORD +0 -15
- {tilegrab-1.1.0.dist-info → tilegrab-1.2.0b2.dist-info}/WHEEL +0 -0
- {tilegrab-1.1.0.dist-info → tilegrab-1.2.0b2.dist-info}/entry_points.txt +0 -0
- {tilegrab-1.1.0.dist-info → tilegrab-1.2.0b2.dist-info}/licenses/LICENSE +0 -0
- {tilegrab-1.1.0.dist-info → tilegrab-1.2.0b2.dist-info}/top_level.txt +0 -0
tilegrab/mosaic.py
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
2
|
-
from pathlib import Path
|
|
3
|
-
from typing import List
|
|
4
|
-
from PIL import Image
|
|
5
|
-
import re
|
|
6
|
-
import os
|
|
7
|
-
|
|
8
|
-
from tilegrab.tiles import TileCollection
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class Mosaic:
|
|
12
|
-
|
|
13
|
-
def __init__(
|
|
14
|
-
self, directory: str = "saved_tiles", ext: str = ".png", recursive: bool = False
|
|
15
|
-
):
|
|
16
|
-
self.directory = directory
|
|
17
|
-
self.ext = ext
|
|
18
|
-
self.recursive = recursive
|
|
19
|
-
|
|
20
|
-
self.image_col = self._get_images()
|
|
21
|
-
assert len(self.image_col) > 0
|
|
22
|
-
|
|
23
|
-
pat = re.compile(
|
|
24
|
-
r"^([0-9]+)_([0-9]+)_([0-9]+)\.[A-Za-z0-9]+$"
|
|
25
|
-
)
|
|
26
|
-
self.image_data = {}
|
|
27
|
-
|
|
28
|
-
for i in self.image_col:
|
|
29
|
-
m = pat.match(os.path.basename(str(i)))
|
|
30
|
-
if m:
|
|
31
|
-
first = m.group(1)
|
|
32
|
-
second = m.group(2)
|
|
33
|
-
third = m.group(3)
|
|
34
|
-
|
|
35
|
-
self.image_data[i] = [int(second), int(third), int(first)]
|
|
36
|
-
|
|
37
|
-
assert len(self.image_data.keys()) > 0
|
|
38
|
-
|
|
39
|
-
print(f"Processing {len(self.image_data.keys())} tiles...")
|
|
40
|
-
|
|
41
|
-
def _get_images(self) -> List[Path]:
|
|
42
|
-
|
|
43
|
-
directory = Path(self.directory)
|
|
44
|
-
ext = self.ext
|
|
45
|
-
|
|
46
|
-
if not ext.startswith("."):
|
|
47
|
-
ext = "." + self.ext
|
|
48
|
-
|
|
49
|
-
if self.recursive:
|
|
50
|
-
return [p for p in directory.rglob(f"*{ext}") if p.is_file()]
|
|
51
|
-
else:
|
|
52
|
-
return [p for p in directory.glob(f"*{ext}") if p.is_file()]
|
|
53
|
-
|
|
54
|
-
def merge(self, tiles: TileCollection, tile_size: int = 256):
|
|
55
|
-
|
|
56
|
-
img_w = int((tiles.MAX_X - tiles.MIN_X + 1) * tile_size)
|
|
57
|
-
img_h = int((tiles.MAX_Y - tiles.MIN_Y + 1) * tile_size)
|
|
58
|
-
print(f"Image size: {img_w}x{img_h}")
|
|
59
|
-
|
|
60
|
-
merged_image = Image.new("RGB", (img_w, img_h))
|
|
61
|
-
|
|
62
|
-
for img_path, img_id in self.image_data.items():
|
|
63
|
-
x, y, _ = img_id
|
|
64
|
-
|
|
65
|
-
print(x - tiles.MIN_X + 1, "x" ,y - tiles.MIN_Y + 1)
|
|
66
|
-
|
|
67
|
-
img = Image.open(img_path)
|
|
68
|
-
img.load()
|
|
69
|
-
|
|
70
|
-
px = int((x - tiles.MIN_X) * tile_size)
|
|
71
|
-
py = int((y - tiles.MIN_Y) * tile_size)
|
|
72
|
-
|
|
73
|
-
merged_image.paste(img, (px, py))
|
|
74
|
-
|
|
75
|
-
merged_image.save(os.path.join(self.directory, "merged_output.png"))
|
tilegrab-1.1.0.dist-info/RECORD
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
tilegrab/__init__.py,sha256=0L3afZyDycCUGuBO0w7DQ9fOd798dUyinbGsM77aQOg,289
|
|
2
|
-
tilegrab/__main__.py,sha256=wT62aXCuN7iwRPQoswnmeGiBS5Cou0CIBvMxbOTfvFs,33
|
|
3
|
-
tilegrab/cli.py,sha256=4AxEpxBhl8REUFAc7Dqa-bCxCo5oUNJGZ1Om3QnTHV0,7700
|
|
4
|
-
tilegrab/dataset.py,sha256=dNZ52mTkX_FC4e-hKAdEsvL5JVeo-MXhhAHpxKjwyGE,2525
|
|
5
|
-
tilegrab/downloader.py,sha256=ge3o4PS0v3_npaiOvFmlNSx62VqL8nwjcefy4Jr_UQo,5120
|
|
6
|
-
tilegrab/images.py,sha256=rld-BLuGA8LPcq0QbGsVY48mbMRivvzxdyfAwVfe0dk,7466
|
|
7
|
-
tilegrab/mosaic.py,sha256=H2-Mr2j9AmwSicPGwYE5z5t0wdAfj2m42J0G7IxE0zA,2191
|
|
8
|
-
tilegrab/sources.py,sha256=GzldtFGndziw9NNB1YMG4WUrD0fTRET1FjGCfIMMDlQ,2188
|
|
9
|
-
tilegrab/tiles.py,sha256=WEWv96fCeHlZs_Gxzg0m3wYAy_qsHfAwkCQHcWEFwf4,6137
|
|
10
|
-
tilegrab-1.1.0.dist-info/licenses/LICENSE,sha256=bcZProekTTcPtnEpRKB2i1kUJ6ujlaxBZchNWKeoXc8,1094
|
|
11
|
-
tilegrab-1.1.0.dist-info/METADATA,sha256=ddmKHnd5A9LaTsjOIxSics7kovf_AXKC92bN3rrhdYY,10197
|
|
12
|
-
tilegrab-1.1.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
13
|
-
tilegrab-1.1.0.dist-info/entry_points.txt,sha256=z-WoKN8NnA5_ZsWXucSeq-r4TeEscu0xjWYu560uNTk,47
|
|
14
|
-
tilegrab-1.1.0.dist-info/top_level.txt,sha256=lVio8bCk3r4Bu_INLgaj4PZCrhFY2UcxHjnFBdHwyPo,9
|
|
15
|
-
tilegrab-1.1.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|