"""B07 유역도 메모리 — 배경선 배열 캐시 · 도곽 밖 선 거름 · 종이 0.1 mm 솎기 (59-4).""" import json from B07_DesignDetail.B07_DesignDetail_Engine_Cad_Basin import _thinned from B07_DesignDetail.B07_DesignDetail_Router_Support_Basin import _metric_lines def test_metric_lines_filters_by_box(tmp_path) -> None: path = tmp_path / "lines.geojson" inside = [[0.0, 0.0], [1.0, 1.0], [2.0, 0.5]] outside = [[50.0, 50.0], [51.0, 51.0]] path.write_text( json.dumps( { "type": "FeatureCollection", "features": [ {"geometry": {"type": "LineString", "coordinates": inside}}, {"geometry": {"type": "LineString", "coordinates": outside}}, ], } ), encoding="utf-8", ) every = _metric_lines(path, "EPSG:4326") assert every == [[tuple(p) for p in inside], [tuple(p) for p in outside]] assert _metric_lines(path, "EPSG:4326", (-1.0, -1.0, 5.0, 5.0)) == every[:1] assert _metric_lines(tmp_path / "none.geojson", "EPSG:4326") == [] def test_thinned_drops_sub_pen_wiggles() -> None: points = [(x * 0.5, 0.02 if x % 2 else 0.0) for x in range(21)] thinned = _thinned(points) assert thinned[0] == points[0] and thinned[-1] == points[-1] assert len(thinned) == 2 bend = [(0.0, 0.0), (5.0, 1.0), (10.0, 0.0)] assert _thinned(bend) == bend