Files
Aislo/resources/tester/test_472_d_route_pipe_readers.py
T
eomsangdonandClaude Opus 5.5 fa41db8b4f fix(472 덧 관 자리): 관 파일 누가거리를 그대로 읽던 남은 서버 자리 = 지금 노선에 얹은 관 자리(route_pipe_points 한 벌)
- 옛 노선 지문 관 파일(옛 누가거리 394 · 좌표 351) — 측점 계획 · 관 지점 GET · 화면 · 상세 얹기는 351 인데
  세월교 노면 하강(ford_surface_drops) · 물넘이포장 구간(ford_pavement_ranges · tilt_ranges) · 카드 이름
  (relabel_pipe_stations) · B07 관 글 재료(load_note_sources) · 옛 비정규 측점 이관 심는 자리만 394 로 읽음
  → [저장] 재계산 · [확정] · 상세 값이 화면과 갈림
- B05_Profile_Engine_Sections.route_pipe_points — 관 지점 정본을 지금 노선에 얹어 읽음(_load_pipe_points 이월)
  · 노선 경로 안 줌 = 노선 파일 하나(ROUTE_DATA_FILE · 노선 풀기도 같은 이름을 씀) · 노선 못 읽으면 저장분 그대로
- load_culvert_sets · attach_saved_shapes(saved_pipes 걷음) · relabel_pipe_stations(상세 GET 은 노선 경로 넘김)
  · B07 load_note_sources · Structures_Router 이관 심는 자리 = 이 한 벌
- 시험 test_472_d_route_pipe_readers(옛 코드 빨강 2) · test_472_d_pipe_route_attach 「노선 모름 = 파일 누가거리」
  단언은 옛 동작이라 「노선 파일 하나 = 351」로 고침 · 위키 rules · calculations 줄

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 12:22:09 +09:00

129 lines
4.7 KiB
Python

"""PLAN 472 덧 (요구 272) — 관 파일 누가거리를 그대로 읽던 남은 서버 자리 = 지금 노선 관 자리.
관 지점 정본의 노선 지문이 지금 노선과 어긋난 저장분(옛 노선 누가거리 · 좌표는 지금 노선) —
측점 계획(`_load_pipe_points`) · 관 지점 GET · 화면 · 서버 상세 얹기(`attach_saved_shapes`)는 좌표로
얹는데 세월교 노면 하강(`ford_surface_drops`) · 물넘이포장 구간(`ford_pavement_ranges` ·
`tilt_ranges`) · 카드 이름(`relabel_pipe_stations`) · B07 관 글 재료(`load_note_sources`)는
파일 누가거리로 읽어 [저장] 재계산 · 상세 값이 화면과 갈렸음.
관 = 좌표 주인 · 파일 지문이 어긋나도 같은 값.
./venv/Scripts/python.exe -m pytest resources/tester/test_472_d_route_pipe_readers.py -q
"""
from __future__ import annotations
import json
import sys
from pathlib import Path
import pytest
ROOT = Path(__file__).resolve().parents[2]
sys.path.insert(0, str(ROOT))
from B05_Profile.B05_Profile_Engine_Sections import relabel_pipe_stations # noqa: E402
from B06_Section.B06_Section_Engine_Attach import attach_saved_shapes # noqa: E402
from B06_Section.B06_Section_Engine_Tilt import tilt_ranges # noqa: E402
from B06_Section.B06_Section_Router_Design_Ranges import ( # noqa: E402
ford_drop_at,
ford_pavement_ranges,
ford_surface_drops,
paved_at,
pavement_ranges,
)
from B07_DesignDetail.B07_DesignDetail_Engine_Cad_CulvertNote import ( # noqa: E402
load_note_sources,
)
ROUTE = "B05_Profile/route/route_main.geojson"
# (옛 노선 누가거리, 지금 노선 x) — 지금 노선 = x 축 0 → 1000 · 지금 누가거리 = x
PIPES = [
(194.0, 151.0, "box_culvert", {}),
(394.0, 351.0, "ford_bridge", {"ford_height_m": 0.5, "ford_width_m": 10}),
(594.0, 551.0, "ford_pavement", {"ford_width_m": 10, "ford_slope_deg": 3}),
(894.0, 751.0, "pipe", {"pipe_kind": "파형강관", "pipe_diameter_mm": "1000"}),
]
def _project(root: Path, stale: bool) -> Path:
route = root / ROUTE
route.parent.mkdir(parents=True)
route.write_text(
json.dumps(
{
"type": "Feature",
"geometry": {"type": "LineString", "coordinates": [[0, 0, 0], [1000, 0, 0]]},
}
),
encoding="utf-8",
)
edits = root / "B04_PreProcess" / "drainage" / "edits"
edits.mkdir(parents=True)
points = [
{
"id": f"p{int(x)}",
"chainage_m": old if stale else x,
"x": x,
"y": 0.3,
"facility": facility,
"options": options,
}
for old, x, facility, options in PIPES
]
(edits / "pipe_points.json").write_text(
json.dumps({"route_signature": "옛-노선", "points": points}), encoding="utf-8"
)
return root
def _read(root: Path) -> dict:
sections = [
{"chainage_m": 151.0, "structure": "파형강관 D900"},
{"chainage_m": 351.0, "center_x": 351.0, "center_y": 0.0},
{"chainage_m": 551.0, "center_x": 551.0, "center_y": 0.0},
{"chainage_m": 751.0, "center_x": 751.0, "center_y": 0.0},
]
relabel_pipe_stations(root, sections)
attach_saved_shapes(root, sections) # 노선 경로 안 줌 = 노선 파일 하나
pipes, _things = load_note_sources(root)
drops = ford_surface_drops(root)
return {
"drops": drops,
"ford_pavement": ford_pavement_ranges(root),
"tilts": [(a, b) for a, b, _ in tilt_ranges(root)],
"label_151": sections[0].get("structure"),
"ford_at_351": sections[1].get("ford", {}).get("chainage_m"),
"drop_351": ford_drop_at(351.0, drops),
"paved_551": paved_at(551.0, pavement_ranges(root)),
"note_pipes": [at for at, _spec, _options in pipes],
}
def test_지문_어긋난_관_파일_지금_노선_자리(tmp_path: Path) -> None:
got = _read(_project(tmp_path, stale=True))
assert got["drops"] == [(351.0, 0.5)]
assert got["ford_pavement"] == [(546.0, 556.0)]
assert got["tilts"] == [(546.0, 556.0)]
assert got["label_151"] == "BOX암거"
assert got["ford_at_351"] == 351.0
assert got["drop_351"] == 0.5
assert got["paved_551"] is True
assert got["note_pipes"] == [751.0]
def test_지문_어긋나도_같은_값(tmp_path: Path) -> None:
stale = _read(_project(tmp_path / "옛", stale=True))
fresh = _read(_project(tmp_path / "새", stale=False))
assert stale == fresh
def test_노선_파일_없음_저장분_그대로(tmp_path: Path) -> None:
root = _project(tmp_path, stale=True)
(root / ROUTE).unlink()
assert ford_surface_drops(root) == [(394.0, 0.5)]
if __name__ == "__main__":
sys.exit(pytest.main([__file__, "-q"]))