feat(extract): Flamingo Park in run.py, Parkwege in der Chunk-Ausgabe
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
2ef9e6774a
commit
442f5b2ada
5 files changed
+64
-12
No files matched your search
@@ -20,9 +20,18 @@ def test_coordinates_are_chunk_local_three_js():
|
||||
|
||||
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 set(payload) == {"chunk", "origin", "land", "surfaces", "roads", "centerlines", "buildings", "palms", "paths"}
|
||||
assert payload["chunk"] == [2, 3]
|
||||
|
||||
def test_paths_are_chunk_local_rings_like_roads():
|
||||
path = Polygon([(-990, 2490), (-980, 2490), (-980, 2480), (-990, 2480)])
|
||||
payload = chunk_payload(0, 0, land=[], surfaces=[], roads=[], centerlines=[], buildings=[], palms=[], paths=[path])
|
||||
(entry,) = payload["paths"]
|
||||
assert set(entry) == {"poly"}
|
||||
ring = entry["poly"][0]
|
||||
assert (min(x for x, _ in ring), max(x for x, _ in ring)) == (10, 20)
|
||||
assert (min(z for _, z in ring), max(z for _, z in ring)) == (10, 20)
|
||||
|
||||
def test_polygon_holes_survive_into_the_payload():
|
||||
"""Ein von Strassen umschlossener Block darf nicht zu Asphalt werden. An echten Daten
|
||||
gehen sonst 449.876 m2 Strassenloch und 208.657 m2 Stadtloch verloren."""
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
from shapely.geometry import LineString, Point, box
|
||||
from shapely.geometry import LineString, Point, Polygon, box
|
||||
|
||||
from leonida.heights import PALM_CLEARANCE
|
||||
from leonida.park import ParkError, ParkLayout, World, apply_park, check_corners
|
||||
from leonida.park import ParkError, ParkLayout, World, apply_flamingo_park, apply_park, check_corners, load_park
|
||||
|
||||
DATA = Path(__file__).resolve().parents[1] / "data"
|
||||
|
||||
QUAD = box(0, 0, 100, 200)
|
||||
SERVICE = box(60, 0, 66, 30)
|
||||
@@ -75,3 +78,17 @@ def test_corners_must_lie_at_a_road():
|
||||
far = SimpleNamespace(game={"sw": (0.0, 0.0), "se": (100.0, 0.0), "ne": (100.0, 200.0), "nw": (30.0, 200.0)})
|
||||
with pytest.raises(ParkError, match="Spielecke nw"):
|
||||
check_corners(far, roads)
|
||||
|
||||
|
||||
def test_flamingo_park_goes_into_a_world_with_roads_around_the_park():
|
||||
config = load_park(DATA / "flamingo-park.toml")
|
||||
park = Polygon([config.game[key] for key in ("sw", "se", "ne", "nw")])
|
||||
ring = park.buffer(15, join_style="mitre").difference(park)
|
||||
start = World(land=[park.buffer(400)], surfaces=[], roads=[(ring, False)], centerlines=[], buildings=[], palms=[])
|
||||
result, messages = apply_flamingo_park(start, DATA / "flamingo-park.toml", seed=20260912)
|
||||
assert {"park", "field", "court", "pool", "parking", "sand"} <= {kind for _, kind in result.surfaces}
|
||||
assert len([b for b in result.buildings if b[1]["source"] == "osm"]) == 11
|
||||
assert result.paths and result.palms
|
||||
assert LineString([config.street.start, config.street.end]) in result.centerlines
|
||||
assert not any(message.startswith("Warnung") for message in messages)
|
||||
assert any(message.startswith("Flamingo Park:") for message in messages)
|
||||
Reference in new issue
Block a user