FEATURE add an utility for generating tiles

This commit is contained in:
nobohan 2023-06-22 14:26:41 +02:00
parent fad138600a
commit f0592abb8a
1 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,35 @@
# usage: python3 generate-tiles-list.py > tiles.list
import math
def deg2num(lat_deg, lon_deg, zoom):
lat_rad = math.radians(lat_deg)
n = 2.0 ** zoom
xtile = int((lon_deg + 180.0) / 360.0 * n)
ytile = int((1.0 - math.asinh(math.tan(lat_rad)) / math.pi) / 2.0 * n)
return (xtile, ytile)
# GD lux coordinates
max_x = 6.531
max_y = 50.184
min_x = 5.735
min_y = 49.452
min_z = 9
max_z = 17
for z in range(min_z, max_z+1):
x1_tile, y1_tile = deg2num(max_y, max_x, z)
x2_tile, y2_tile = deg2num(min_y, min_x, z)
min_x_tile = x1_tile if x1_tile < x2_tile else x2_tile
max_x_tile = x1_tile if x1_tile > x2_tile else x2_tile
min_y_tile = y1_tile if y1_tile < y2_tile else y2_tile
max_y_tile = y1_tile if y1_tile > y2_tile else y2_tile
for tx in range(min_x_tile, max_x_tile):
if tx % 8 != 0:
continue
for ty in range(min_y_tile, max_y_tile):
if ty % 8 != 0:
continue
print("{} {} {}".format(tx, ty, z))