feat(extract): Koordinaten, Kachel-Download und Mosaik
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2280617d9e
commit
3d112e98cd
7 files changed
+596
No files matched your search
@@ -0,0 +1,28 @@
|
||||
"""Umrechnung zwischen gtadb-Weltkoordinaten, Kacheln und Mosaikpixeln.
|
||||
|
||||
Spiegelt src/world/coords.js. Beide Seiten müssen dieselben Werte liefern.
|
||||
"""
|
||||
TILE_PX = 256
|
||||
WORLD_HALF = 16384
|
||||
CHUNK_SIZE = 250
|
||||
SLICE = {"x0": -1000, "x1": 2000, "y0": -500, "y1": 2500}
|
||||
|
||||
|
||||
def tile_for_world(x: float, y: float) -> tuple[int, int]:
|
||||
return (int((WORLD_HALF - y) // TILE_PX), int((x + WORLD_HALF) // TILE_PX))
|
||||
|
||||
|
||||
def slice_tiles() -> list[tuple[int, int]]:
|
||||
r0, c0 = tile_for_world(SLICE["x0"], SLICE["y1"])
|
||||
r1, c1 = tile_for_world(SLICE["x1"] - 1, SLICE["y0"] + 1)
|
||||
return [(r, c) for r in range(r0, r1 + 1) for c in range(c0, c1 + 1)]
|
||||
|
||||
|
||||
def mosaic_origin_px() -> tuple[int, int]:
|
||||
"""Pixelversatz der Ausschnittsecke innerhalb des ungeschnittenen Kachelrasters."""
|
||||
r0, c0 = tile_for_world(SLICE["x0"], SLICE["y1"])
|
||||
return (SLICE["x0"] + WORLD_HALF - c0 * TILE_PX, (WORLD_HALF - SLICE["y1"]) - r0 * TILE_PX)
|
||||
|
||||
|
||||
def pixel_to_world(px: int, py: int) -> tuple[float, float]:
|
||||
return (SLICE["x0"] + px, SLICE["y1"] - py)
|
||||
Reference in new issue
Block a user