⚠ **뿌리** — `tmp/` 는 창 사이에 안 건너감(실측 확인: 상대 창이 놓은 `tmp/_sync_probe.txt` 가 시간을 두고 두 번 봐도 안 보임). 그래서 **정본(등록부 스키마)만 건너가고 그것을 읽는 시험은 안 건너가** 오늘 두 번, 같은 시험이 **연 창은 통과·받은 창은 실패**가 됐음. - `tmp/tests/*` 를 `resources/tester/` 로 **복사**(127 파일). 내용은 **한 줄도 안 고침** - `tmp/tests` 는 **남겨 둠** — 되돌릴 자리(사용자 지시) - 실행: `./venv/Scripts/python.exe -m pytest resources/tester/ -q` 옮기기 전과 **같은 수**: 617 통과 / 22 건너뜀 / 실패 0 ⇒ 이제 시험·예외·까닭이 **정본과 함께** 움직임. 오늘 세운 「예외는 정본 스키마에」와 짝임. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
76 lines
2.9 KiB
Python
76 lines
2.9 KiB
Python
"""작업 좌표계 창구(`resolve_project_crs`) 사다리 검사 (2026-09-03 일원화).
|
|
|
|
같은 폴백 사다리가 네 곳에 서로 다른 모양으로 흩어져 있었다 — 그중 배수유역 라우터는
|
|
노선 CSV 의 `crs_epsg` **라벨**을 변환 좌표에 그대로 써서 좌표가 1,500km 밖으로 나간
|
|
사례가 있었다(2026-09-01 용화: 라벨 5179 / 실제 5176).
|
|
"""
|
|
|
|
from pathlib import Path
|
|
|
|
from pyproj import CRS
|
|
|
|
from common_util.common_util_crs import project_prj_crs, resolve_project_crs
|
|
|
|
|
|
def _project_with_prj(tmp_path: Path, epsg: int) -> Path:
|
|
prj_dir = tmp_path / "B03_FileInput" / "input" / "prj"
|
|
prj_dir.mkdir(parents=True)
|
|
(prj_dir / "terrain.prj").write_text(CRS.from_epsg(epsg).to_wkt(), encoding="utf-8")
|
|
return tmp_path
|
|
|
|
|
|
def test_route_crs_input_wins(tmp_path):
|
|
"""① 노선 `crs_input` — 이미 작업 좌표계로 맞춰 둔 값이 가장 먼저다."""
|
|
root = _project_with_prj(tmp_path, 5187)
|
|
assert (
|
|
resolve_project_crs(root, route_crs_input="EPSG:5176", file_label_epsg=5179, db_epsg=5186)
|
|
== "EPSG:5176"
|
|
)
|
|
|
|
|
|
def test_file_label_only_when_given(tmp_path):
|
|
"""② 원본 파일 좌표를 읽는 자리만 파일 라벨을 넘긴다 — 지형 PRJ 보다 앞선다."""
|
|
root = _project_with_prj(tmp_path, 5187)
|
|
assert resolve_project_crs(root, file_label_epsg=5179) == "EPSG:5179"
|
|
# 라벨을 안 넘기면 지형 PRJ 가 이긴다(변환이 끝난 좌표를 다루는 자리).
|
|
assert resolve_project_crs(root) == "EPSG:5187"
|
|
|
|
|
|
def test_terrain_prj_is_work_crs(tmp_path):
|
|
"""③ 지형 PRJ 가 작업 좌표계 정본(2026-09-03 사용자 결정: 현행 유지)."""
|
|
root = _project_with_prj(tmp_path, 5186)
|
|
assert project_prj_crs(root) == "EPSG:5186"
|
|
assert resolve_project_crs(root, db_epsg=5179) == "EPSG:5186"
|
|
|
|
|
|
def test_db_epsg_then_default(tmp_path):
|
|
"""④·⑤ PRJ 가 없으면 DB 좌표계, 그것도 없으면 중부원점."""
|
|
(tmp_path / "B03_FileInput" / "input").mkdir(parents=True)
|
|
assert project_prj_crs(tmp_path) is None
|
|
assert resolve_project_crs(tmp_path, db_epsg=5176) == "EPSG:5176"
|
|
assert resolve_project_crs(tmp_path) == "EPSG:5186"
|
|
|
|
|
|
class _Grid:
|
|
"""트림 진단용 최소 sampler — bbox 만 있으면 된다."""
|
|
|
|
def __init__(self, xs, ys):
|
|
self.x = xs
|
|
self.y = ys
|
|
|
|
|
|
def test_trim_wipeout_logs_both_bboxes(caplog):
|
|
"""트림이 노선을 통째로 지우면 두 bbox 를 수치로 남긴다(좌표계 판별용)."""
|
|
from common_util.common_util_route_geometry import _log_trim_wipeout
|
|
|
|
with caplog.at_level("WARNING"):
|
|
_log_trim_wipeout(
|
|
[(1141951.0, 1723000.0), (1143784.0, 1725000.0)],
|
|
_Grid([208402.0, 209637.0], [340000.0, 341000.0]),
|
|
"EPSG:5176",
|
|
)
|
|
message = caplog.text
|
|
assert "1141951~1143784" in message
|
|
assert "208402~209637" in message
|
|
assert "EPSG:5176" in message
|