Merge remote-tracking branch 'origin/sub_laptop_7' into sub_laptop_4

This commit is contained in:
2026-10-27 20:16:28 +09:00
5 changed files with 139 additions and 7 deletions
@@ -271,6 +271,39 @@ def test_노선면_솎음(project):
assert max(abs(v) for v in ribbon["positions"]) < 5000 # 원점 뺀 자리
def test_노선면_설계_지형(project):
"""지형 = E04 Grid 꼴 · 리본과 같은 원점 · 노면 발자국 안 = None · 노면 옆 표고 ≈ 비탈 끝."""
body = asyncio.run(router.corridor3d(UUID(PID)))
terrain = body["terrain"]
g, z = terrain["grid"], terrain["z"]
assert len(z) == g["nx"] * g["ny"] and g["dx"] >= router.TERRAIN_STEP_M
assert g["nx"] * g["ny"] <= router.TERRAIN_MAX_CELLS * 1.05
have = [v for v in z if v is not None]
assert have and max(abs(v) for v in have) < 500 # 원점 표고 뺀 값
def cell(x, y):
ix = round((x - g["x0"]) / g["dx"])
iy = round((y - g["y0"]) / g["dx"])
return z[iy * g["nx"] + ix]
# 노면 리본 가운데 열 = 발자국 안 → 구멍
road = next(r for r in body["ribbons"] if r["colCount"] >= 3)
cols = road["colCount"]
mid = [
road["positions"][(i * cols + cols // 2) * 3 : (i * cols + cols // 2) * 3 + 2]
for i in range(len(road["chainages"]))
]
holes = [cell(*p) is None for p in mid]
assert sum(holes) / len(holes) > 0.9
# 지형 있는 칸의 원래 표고 = DTM 표본 − 원점 표고
sampler = router.DtmGridSampler.from_npz(src.terrain_grid_path(src.source_dir(project)))
i = next(k for k, v in enumerate(z) if v is not None)
x = g["x0"] + (i % g["nx"]) * g["dx"] + body["origin"][0]
y = g["y0"] + (i // g["nx"]) * g["dx"] + body["origin"][1]
want, ok = sampler.sample_xy([[x, y]])
assert ok[0] and z[i] == pytest.approx(want[0] - body["origin"][2], abs=0.02)
class _Cursor:
def __init__(self, rows):
self.rows = rows