- D01 시작 · 종료 칸 이름 측점 말로 · 입력 옆 즉시 `= 61+14.5` (저장값 m 그대로) - D04 표 측점 열 · xlsx 시점 · 종점 측점 칸 덧(m 칸 · shp 숫자 칸 유지) - 파이썬 station_label ↔ stationLabel 거울 시험 · 도움말 D01 · D04 글 · 그림 열여섯 장 다시 찍음 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""545-1 측점 표기 거울 — D04 `station_label`(py) ↔ `common_util_station.ts` `stationLabel(…, 1)`."""
|
|
|
|
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 D04_PlanConfirm.D04_PlanConfirm_Export import station_label # noqa: E402
|
|
|
|
TS = PROJECT_ROOT / "common_util" / "common_util_station.ts"
|
|
TYPESCRIPT = PROJECT_ROOT / "config" / "node_modules" / "typescript"
|
|
VALUES = [
|
|
0,
|
|
19.96,
|
|
20,
|
|
39.99,
|
|
100,
|
|
1234.5,
|
|
1234.56,
|
|
1234.44,
|
|
1234.05,
|
|
1234.95,
|
|
61 * 20 + 14.5,
|
|
812.345,
|
|
]
|
|
|
|
SCRIPT = r"""
|
|
const ts = require(process.argv[1]);
|
|
const src = require("fs").readFileSync(process.argv[2], "utf8");
|
|
const js = ts.transpileModule(src, { compilerOptions: { module: ts.ModuleKind.CommonJS } }).outputText;
|
|
const box = { exports: {} };
|
|
new Function("exports", "module", js)(box.exports, box);
|
|
process.stdout.write(JSON.stringify(JSON.parse(process.argv[3]).map((v) => box.exports.stationLabel(v, 20, 1))));
|
|
"""
|
|
|
|
|
|
def test_파이썬과_TS_측점_표기_같음():
|
|
proc = subprocess.run(
|
|
["node", "-e", SCRIPT, str(TYPESCRIPT), str(TS), json.dumps(VALUES)],
|
|
capture_output=True,
|
|
text=True,
|
|
encoding="utf-8",
|
|
timeout=60,
|
|
)
|
|
assert proc.returncode == 0, proc.stderr
|
|
assert json.loads(proc.stdout) == [station_label(v) for v in VALUES]
|
|
|
|
|
|
def test_표기_꼴():
|
|
assert station_label(1234.5) == "61+14.5"
|
|
assert station_label(0) == "0+0"
|
|
assert station_label(39.99) == "2+0"
|