"""368-2 추가 측점 정본(`plus_stations.json`) — 정수 m · 좌표 · 노선 바뀌면 좌표로 따라감 · 저장 차례.""" from __future__ import annotations from pathlib import Path from B05_Profile.B05_Profile_Plus_Stations import ( follow_plus_stations, load_plus_stations, plus_chainages, save_plus_stations, ) ROOT = Path(__file__).resolve().parents[2] LINE = [(0.0, 0.0, 0.0), (100.0, 0.0, 0.0)] def test_저장_정수_m_좌표_노선_안(tmp_path: Path) -> None: saved = save_plus_stations(tmp_path, [12.4, 47.0, 47.2, -3.0, 140.0], LINE) assert saved == [12.0, 47.0] # 반올림 · 같은 m 하나 · 노선 밖 버림 rows = load_plus_stations(tmp_path) assert [(r["chainage_m"], r["x"], r["y"]) for r in rows] == [ (12.0, 12.0, 0.0), (47.0, 47.0, 0.0), ] assert save_plus_stations(tmp_path, [], LINE) == [] and plus_chainages(tmp_path) == [] def test_노선이_바뀌면_좌표로_따라감(tmp_path: Path) -> None: save_plus_stations(tmp_path, [12.0, 47.0], LINE) # 시점을 10 m 앞으로 늘린 새 노선 — 같은 땅 자리 = 누가거리 +10 moved = follow_plus_stations(tmp_path, [(-10.0, 0.0), (100.0, 0.0)]) assert moved == 2 and plus_chainages(tmp_path) == [22.0, 57.0] def test_저장_차례_계획고_앞() -> None: save = (ROOT / "A00_Common/design/design_save.ts").read_text(encoding="utf-8") order = save[save.index("DESIGN_SAVE_ORDER = [") :] assert order.index('"structures"') < order.index('"plusStations"') < order.index('"alignment"') def test_옛_측점_옮기기는_추가_측점을_구조물로_안_만듦() -> None: # 저장된 추가 측점 = 이름 "" 비정규 측점 — 옛 자유 글 옮기기가 「기타」 구조물로 바꾸면 안 됨 router = (ROOT / "B05_Profile/B05_Profile_Structures_Router.py").read_text(encoding="utf-8") block = router[router.index("async def migrate_structures") :] assert "plus_chainages(root)" in block[: block.index("migrate_irregular_stations(")]