ancient-map-tiler 0.1.0__py3-none-any.whl → 0.2.0__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.
- ancient_map_tiler/tiles.py +33 -34
- {ancient_map_tiler-0.1.0.dist-info → ancient_map_tiler-0.2.0.dist-info}/METADATA +28 -11
- ancient_map_tiler-0.2.0.dist-info/RECORD +6 -0
- ancient_map_tiler-0.2.0.dist-info/entry_points.txt +3 -0
- ancient_map_tiler-0.1.0.dist-info/RECORD +0 -6
- ancient_map_tiler-0.1.0.dist-info/entry_points.txt +0 -3
- {ancient_map_tiler-0.1.0.dist-info → ancient_map_tiler-0.2.0.dist-info}/WHEEL +0 -0
ancient_map_tiler/tiles.py
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import sys
|
|
3
|
-
from argparse import Namespace
|
|
4
1
|
from math import ceil, log
|
|
5
2
|
from pathlib import Path
|
|
6
3
|
|
|
4
|
+
import click
|
|
7
5
|
import numpy as np
|
|
8
6
|
import numpy.typing as npt
|
|
9
7
|
from PIL import Image
|
|
@@ -155,36 +153,37 @@ def get_tiles_for_all_zoom_levels(
|
|
|
155
153
|
return res
|
|
156
154
|
|
|
157
155
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
156
|
+
@click.command()
|
|
157
|
+
@click.argument(
|
|
158
|
+
"map-source",
|
|
159
|
+
type=click.Path(exists=True),
|
|
160
|
+
)
|
|
161
|
+
@click.option(
|
|
162
|
+
"-o",
|
|
163
|
+
"--output-directory",
|
|
164
|
+
type=click.Path(),
|
|
165
|
+
help="Output directory where to store the tiles, must not exist",
|
|
166
|
+
required=True,
|
|
167
|
+
)
|
|
168
|
+
@click.option(
|
|
169
|
+
"-t", "--tile-size", help="Size of a tile. Default: 256", type=int, default=256
|
|
170
|
+
)
|
|
171
|
+
@click.option(
|
|
172
|
+
"--image-format",
|
|
173
|
+
"-f",
|
|
174
|
+
help="Output image format. Default: .webp .Tested for .png and .webp",
|
|
175
|
+
default=".webp",
|
|
176
|
+
)
|
|
177
|
+
def main(
|
|
178
|
+
map_source: str, output_directory: str, tile_size: int, image_format: str
|
|
179
|
+
) -> None:
|
|
180
|
+
"""map-source: Path or identifier of the map source to generate tiles from"""
|
|
181
|
+
output_directory = Path(output_directory)
|
|
182
|
+
assert not output_directory.exists(), f"{output_directory} must not exist"
|
|
183
|
+
click.echo(f"Loading {map_source}...")
|
|
185
184
|
map_image = np.asarray(Image.open(map_source), dtype="uint8")
|
|
186
|
-
tiled_maps_by_zoom_level = get_tiles_for_all_zoom_levels(map_image,
|
|
187
|
-
Path.mkdir(
|
|
185
|
+
tiled_maps_by_zoom_level = get_tiles_for_all_zoom_levels(map_image, tile_size)
|
|
186
|
+
Path.mkdir(output_directory)
|
|
188
187
|
nb_images_to_save = sum(
|
|
189
188
|
tiled_map.shape[0] * tiled_map.shape[1]
|
|
190
189
|
for tiled_map in tiled_maps_by_zoom_level
|
|
@@ -193,8 +192,8 @@ def main() -> None:
|
|
|
193
192
|
for zoom_level, tiled_map in enumerate(tiled_maps_by_zoom_level):
|
|
194
193
|
save_to_directory(
|
|
195
194
|
tiled_map,
|
|
196
|
-
|
|
197
|
-
image_format=
|
|
195
|
+
output_directory / str(zoom_level),
|
|
196
|
+
image_format=image_format,
|
|
198
197
|
progress_bar=progress_bar,
|
|
199
198
|
)
|
|
200
199
|
|
|
@@ -1,31 +1,48 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ancient-map-tiler
|
|
3
|
-
Version: 0.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Provide tiles data for a web view of an ancient map
|
|
5
5
|
Author: Noan Cloarec
|
|
6
6
|
Author-email: noan.cloarec@gmail.com
|
|
7
7
|
Requires-Python: >=3.13
|
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
|
9
9
|
Classifier: Programming Language :: Python :: 3.13
|
|
10
10
|
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
-
Requires-Dist:
|
|
12
|
-
Requires-Dist:
|
|
11
|
+
Requires-Dist: click (>=8)
|
|
12
|
+
Requires-Dist: numpy (>=2)
|
|
13
|
+
Requires-Dist: tqdm (>=4)
|
|
13
14
|
Description-Content-Type: text/markdown
|
|
14
15
|
|
|
15
16
|
# Ancient-map-tiler
|
|
16
|
-
This
|
|
17
|
-
The source image of the map may be very large. To be usable in a web view such as Leaflet it must be splitted into tiles at different zooms
|
|
18
|
-
|
|
17
|
+
This project aims to generate tiles data for a web view of any ancient map.
|
|
18
|
+
The source image of the map may be very large. To be usable in a web view such as Leaflet it must be splitted into tiles at different zooms.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
```shell
|
|
22
|
+
# (Optional) Download a large map from wikipedia
|
|
23
|
+
wget https://upload.wikimedia.org/wikipedia/commons/5/50/TabulaPeutingeriana.jpg
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
pip install ancient-map-tiler
|
|
27
|
+
ancient-map-tiler TabulaPeutingeriana.jpg -o tiles
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Development
|
|
31
|
+
### Prerequisites
|
|
19
32
|
- python (tested on 3.13)
|
|
20
33
|
- poetry
|
|
21
|
-
|
|
34
|
+
- pre-commit
|
|
35
|
+
|
|
36
|
+
### Getting started
|
|
22
37
|
```shell
|
|
38
|
+
git clone git@gitlab.com:noan-cloarec/ancient-map-tiler.git
|
|
23
39
|
cd ancient-map-tiler
|
|
40
|
+
|
|
24
41
|
poetry install
|
|
25
|
-
|
|
26
|
-
|
|
42
|
+
pre-commit install
|
|
43
|
+
|
|
27
44
|
# Generate the tiles into a directory named tiles
|
|
28
|
-
poetry run
|
|
45
|
+
poetry run ancient-map-tiler TabulaPeutingeriana.jpg -o tiles
|
|
29
46
|
# Open the preview in your web browser
|
|
30
47
|
open simple_map_preview.html
|
|
31
48
|
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
ancient_map_tiler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
ancient_map_tiler/tiles.py,sha256=2XPRIIJMTMiwfhv91F9HYt_trDpmQw9TF_tN33gqiT4,7867
|
|
3
|
+
ancient_map_tiler-0.2.0.dist-info/METADATA,sha256=I7_ZKcQMRJKGLkJLzMKk5B67SXSV7YE6Cp8znYEkprk,1369
|
|
4
|
+
ancient_map_tiler-0.2.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
5
|
+
ancient_map_tiler-0.2.0.dist-info/entry_points.txt,sha256=mJS_XU5F_ra8fsrPcvogp13EZEU1CGk1vu2Aqe9WLm8,66
|
|
6
|
+
ancient_map_tiler-0.2.0.dist-info/RECORD,,
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
ancient_map_tiler/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
ancient_map_tiler/tiles.py,sha256=cPpE4PTycdRSmVT-scLilc4g-Xz6XEJat3c7xxM-ah8,7889
|
|
3
|
-
ancient_map_tiler-0.1.0.dist-info/METADATA,sha256=IxFxtnnUuTtwyAPf0kU_B4nTkTWaIjJbJvGoRKlDL1U,1065
|
|
4
|
-
ancient_map_tiler-0.1.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
5
|
-
ancient_map_tiler-0.1.0.dist-info/entry_points.txt,sha256=8g5jcREn9ACPtgJuvUtNSs3U1jviizdx0tBD772Brqc,59
|
|
6
|
-
ancient_map_tiler-0.1.0.dist-info/RECORD,,
|
|
File without changes
|