From f0592abb8aafd4fc0d044919aabc250c0ba81620 Mon Sep 17 00:00:00 2001 From: nobohan Date: Thu, 22 Jun 2023 14:26:41 +0200 Subject: [PATCH] FEATURE add an utility for generating tiles --- utils/generate-tiles-list.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 utils/generate-tiles-list.py diff --git a/utils/generate-tiles-list.py b/utils/generate-tiles-list.py new file mode 100644 index 0000000..7e7487f --- /dev/null +++ b/utils/generate-tiles-list.py @@ -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)) \ No newline at end of file