걷은 함수(운영 부름 0 · 전수 확인 = 화면 · 서버 · 체인 · 추천 엔진 · B07 · 시험) - common_util/common_util_excavation.py 통째(126 줄 · pipe_trench_width_m · wall_trench_area_m2 · wall_trench_width_m · 서버 = Node excavation.trench) - Engine_Grade_Carry.carry_edits(Node carry_seat 겉) · Route_Save_Parts.seat_route_moved(시험 헬퍼 helper_475_1_moved 로 옮김) - Engine_Tilt.attach_underdrains · Engine_Structures_Wall.attach_wall_structures · load_wall_structures - Engine_Grade_Alignment.tangent_elevation(부름 0) · station_key.dedupe_station_keys · loose_chainage 줄 수 전 → 후: excavation.py 126 → 0 · Grade_Carry 178 → 157 · Save_Parts 289 → 269 · Wall 221 → 197 · Tilt 115 → 112 · station_key 141 → 122 · Alignment 657 → 654 남는 짝(머리 「남는 까닭」 한 줄) — Grade · Grade_Profile · Alignment · CurveLaw(2~4 순위 폴백 · 추천) · NodeEdits · SampleExtend · Router_Design · Ranges · Engine_Design · Areas · cross_berm(DTM 아닌 지표면 · Node 못 부를 때 · B07 · 추천) · Tilt · Wall · Culvert(B04 B07 B08) · route_follow · structure_station · station_key · route_polyline(745 줄 · 까닭 = 등록부 R1 줄) 등록부 — until 칸 걷음(G1 = py 표본기 남김 · 까닭 note) · C6 pair = attach_underdrain_specs · F8 pair null 알려진 차 — golden KNOWN 셋 그대로 나타남(R7 표본 출처 · W0 저장 때 경고 · X2 입력 선 자릿수 · 까닭 고침) · underdrain 알려진 차 까닭 · 511_b5 KNOWN_ARC 그대로 계산 자리 창 — 45 줄 · 서버만 아닌 41(바꿀 수 있음 40 + F9) · 서버만 넷(G3 D1 D2 N1 줄마다 까닭) · 옛 까닭 「짝 모으는 중 · B-4」 글 걷음 test_322_3_flow 빨강 — 헬퍼가 @config/config_frontend 흉내(511-A design_calc_server import) 시험 기준 — 걷은 짝 거울 = 걷기 전 파이썬 값 고정(excavation · station_key) · Node carry_seat · attach_underdrain_specs · wall_specs_from 검증: 고친 대상 시험 97 파일 562 통과 · 21 건너뜀 · typecheck 0 · 700 줄 넘는 새 파일 없음 — 요구 320-4 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
108 lines
4.6 KiB
Python
108 lines
4.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""344-3 측점 열쇠 거울 — `common_util_station_key.py` ↔ `common_util_station_key.ts` 같은 열쇠.
|
|
|
|
일반 grid:k(누가거리 ÷ 간격 반올림 · 0.5 는 위로) · 관 pipe:<id> · 구조물 structure:<id> ·
|
|
시종점 end:BP/EP · id 모름 at:<0.01 m> · 옛 열쇠(누가거리 글) · at: 의 누가거리.
|
|
"""
|
|
|
|
import json
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
PROJECT_ROOT = Path(__file__).resolve().parents[2]
|
|
if str(PROJECT_ROOT) not in sys.path:
|
|
sys.path.insert(0, str(PROJECT_ROOT))
|
|
|
|
from common_util.common_util_station_key import chainage_key, station_key # noqa: E402
|
|
|
|
TS = PROJECT_ROOT / "common_util" / "common_util_station_key.ts"
|
|
TYPESCRIPT = PROJECT_ROOT / "config" / "node_modules" / "typescript"
|
|
|
|
CASES = [
|
|
("bp", 0.0, 20.0, None, "structure", "anchor"),
|
|
# 5파 — 묶음 측점 종류(grid · end) · 구간형 시작 · 끝(:start · :end)
|
|
("grid", 41.3, 20.0, "2", "structure", "anchor"),
|
|
("grid", 41.3, 20.0, None, "structure", "anchor"),
|
|
("end", 0.0, 20.0, None, "structure", "anchor"),
|
|
("end", 99.0, 20.0, None, "structure", "anchor"),
|
|
("end", 99.0, 20.0, "EP", "structure", "anchor"),
|
|
("structure", 30.0, 20.0, "st-9", "structure", "start"),
|
|
("structure", 36.0, 20.0, "st-9", "structure", "end"),
|
|
("irregular", 30.0, 20.0, "st-9", "structure", "start"),
|
|
("pipe", 30.0, 20.0, None, "structure", "end"),
|
|
("ep", 812.345, 20.0, None, "structure"),
|
|
("regular", 40.0, 20.0, None, "structure"),
|
|
("regular", 50.0, 20.0, None, "structure"), # 2.5 → 3(위로)
|
|
("regular", 69.996, 20.0, None, "structure"),
|
|
("regular", 40.0, None, None, "structure"),
|
|
("irregular", 85.054, 20.0, "pipe-s3", "pipe"),
|
|
("irregular", 85.054, 20.0, "st-7", "structure"),
|
|
("irregular", 85.054, 20.0, None, "structure"),
|
|
("irregular", 1.005, 20.0, None, "structure"),
|
|
("pipe", 12.344, 20.0, "pipe-s1", "structure"),
|
|
("structure", 12.345, 20.0, None, "structure"),
|
|
# 252-2 곡선 측점(MC) — curve:<누가거리 0.01 m>
|
|
("curve", 107.0, 20.0, None, "structure"),
|
|
("curve", 107.35, 20.0, None, "structure"),
|
|
]
|
|
DEDUPE = (["grid:1", "structure:st-1", "grid:1", "structure:st-1"], [20.0, 25.0, 20.004, 25.006])
|
|
LOOSE = ["85.05", "at:85.05", "grid:4", "pipe:pipe-s3", "-1.5", "end:BP"]
|
|
# 파이썬 `loose_chainage` · `dedupe_station_keys` = 운영 부름 0 → 걷음(511-B B-6) · 걷기 전 값
|
|
LOOSE_WANT = [85.05, 85.05, None, None, -1.5, None]
|
|
DEDUPE_WANT = ["grid:1", "structure:st-1", "at:20.00", "at:25.01"]
|
|
|
|
SCRIPT = r"""
|
|
const ts = require(process.argv[1]);
|
|
const fs = require("fs");
|
|
const src = fs.readFileSync(process.argv[2], "utf8");
|
|
const opts = { compilerOptions: { module: ts.ModuleKind.CommonJS } };
|
|
const js = ts.transpileModule(src, opts).outputText;
|
|
const box = { exports: {} };
|
|
new Function("exports", "module", js)(box.exports, box);
|
|
const m = box.exports;
|
|
const input = JSON.parse(process.argv[3]);
|
|
process.stdout.write(JSON.stringify({
|
|
keys: input.cases.map((c) => m.stationKey(c[0], c[1], c[2], c[3], c[4], c[5] ?? "anchor")),
|
|
dedupe: m.dedupeStationKeys(input.dedupe[0], input.dedupe[1]),
|
|
chainage: input.cases.map((c) => m.chainageKey(c[1])),
|
|
loose: input.loose.map((k) => m.looseChainage(k)),
|
|
}));
|
|
"""
|
|
|
|
|
|
def test_파이썬과_TS_열쇠_같음():
|
|
proc = subprocess.run(
|
|
[
|
|
"node",
|
|
"-e",
|
|
SCRIPT,
|
|
str(TYPESCRIPT),
|
|
str(TS),
|
|
json.dumps({"cases": CASES, "loose": LOOSE, "dedupe": DEDUPE}),
|
|
],
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
timeout=60,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
out = json.loads(proc.stdout)
|
|
assert out["keys"] == [station_key(*case) for case in CASES]
|
|
assert out["chainage"] == [chainage_key(case[1]) for case in CASES]
|
|
assert out["loose"] == LOOSE_WANT
|
|
assert out["dedupe"] == DEDUPE_WANT
|
|
|
|
|
|
def test_열쇠_규칙():
|
|
assert station_key("bp", 0.0, 20.0) == "end:BP"
|
|
assert station_key("ep", 812.3, 20.0) == "end:EP"
|
|
assert station_key("regular", 50.0, 20.0) == "grid:3"
|
|
assert station_key("irregular", 85.054, 20.0, "pipe-s3", "pipe") == "pipe:pipe-s3"
|
|
assert station_key("irregular", 85.054, 20.0) == "at:85.05"
|
|
# 5파 — 구간형 시작 · 끝 · 기준은 그대로 · 원래 격자 번호 · 같은 열쇠 둘째는 at:
|
|
assert station_key("structure", 30.0, 20.0, "st-9", role="start") == "structure:st-9:start"
|
|
assert station_key("structure", 33.0, 20.0, "st-9") == "structure:st-9"
|
|
assert station_key("grid", 41.3, 20.0, "2") == "grid:2"
|
|
assert station_key("end", 99.0, 20.0) == "end:EP"
|