import json from shapely.geometry import Polygon from leonida.emit import chunk_payload, split_by_chunk BIG = Polygon([(-1000, 2500), (-700, 2500), (-700, 2200), (-1000, 2200)]) # Chunk (0,0) und Nachbarn def test_polygon_is_clipped_into_its_chunks(): parts = split_by_chunk(BIG) assert set(parts) >= {(0, 0), (1, 0), (0, 1), (1, 1)} assert abs(sum(p.area for p in parts.values()) - BIG.area) < 1.0 def test_coordinates_are_chunk_local_three_js(): # chunk_payload() nimmt (wie in run.py) bereits chunk-geschnittene Geometrie entgegen; # BIG selbst überspannt vier Chunks (siehe Test oben), darum hier zuerst zuschneiden. clipped = split_by_chunk(BIG)[(0, 0)] payload = chunk_payload(0, 0, land=[clipped], surfaces=[], roads=[], centerlines=[], buildings=[], palms=[]) ring = payload["land"][0] assert payload["origin"] == [-1000, -2500] # three-z = -Y assert min(x for x, _ in ring) >= -0.01 assert max(x for x, _ in ring) <= 250.01 def test_payload_matches_schema(): payload = chunk_payload(2, 3, land=[], surfaces=[], roads=[], centerlines=[], buildings=[], palms=[]) assert set(payload) == {"chunk", "origin", "land", "surfaces", "roads", "centerlines", "buildings", "palms"} assert payload["chunk"] == [2, 3]