Files
Aislo/resources/tester/helper_87_widening.cjs
T
eomsangdonandClaude Opus 5.5 0c22b7d4a1 feat(B05): 노면공 확폭 구간 단추에 확폭 면적 표시(138-2)
- wideningArea — 측점 사이 사다리꼴 합 · 구간 앞뒤 확폭 0 측점까지 · 노면공 범위로 자름
- 단추 오른쪽 끝 「n.nn ㎡」 · 끈 구간 회색 · 수량엔 안 넣음
- test_87 면적 경우 셋

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JywHxQuWPk6UYXTebyrBoU
2026-10-09 14:49:06 +09:00

68 lines
2.3 KiB
JavaScript

/* 노면공 확폭 구간 규칙(PLAN 87-3) — `design_structure_widening.ts` 를 그 자리에서 트랜스파일해 Node 로 돌림. */
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const file = path.join(
__dirname,
"..",
"..",
"A00_Common",
"design",
"design_structure_widening.ts",
);
const js = ts.transpileModule(fs.readFileSync(file, "utf8"), {
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
}).outputText;
const box = { exports: {} };
new Function("exports", "module", js)(box.exports, box);
const w = box.exports;
// 곡선 둘(앞 No.1+0~No.3+0 · 뒤 No.5+0~No.6+0) 사이에 직선 측점 하나 — 확폭 좌우 합
const at = (chainage_m, left = 0, right = 0) => ({
chainage_m,
design: { widening_left_m: left, widening_right_m: right },
});
const stations = [
at(0),
at(20, 0.3, 0),
at(40, 0.75, 0),
at(60, 0.4, 0),
at(80),
at(100, 0, 0.5),
at(120, 0, 0.6),
at(140),
];
const runs = w.wideningRuns(stations, 0, 140);
const inner = w.wideningRuns(stations, 30, 110); // 범위가 곡선을 가로지름
const off = w.formatOff([[20, 60]]);
const out = {
runs,
inner,
none: w.wideningRuns(stations, 0, 10),
fallback: w.wideningOf({ chainage_m: 1, curve_widening_m: 0.9, curve_outer_side: "left" }),
fallbackStraight: w.wideningOf({ chainage_m: 1, curve_widening_m: 0.9, curve_outer_side: null }),
off,
parsed: w.parseOff("20-60, 100-120,bad,5"),
isOff: runs.map((r) => w.isRunOff(r, off)),
toggledOff: w.toggleRun(runs, "", runs[1]),
toggledBoth: w.toggleRun(runs, off, runs[1]),
toggledOn: w.toggleRun(runs, off, runs[0]),
stale: w.offForRuns(runs, "20-60,0-5,100-130"),
empty: w.offForRuns([], "20-60"),
// 확폭 면적(138-2) — 앞뒤 확폭 0 측점까지 사다리꼴 · 범위로 자름
area: runs.map((r) => w.wideningArea(stations, r, { start: 0, end: 140 })),
areaClipped: w.wideningArea(stations, runs[0], { start: 30, end: 140 }),
areaSingle: w.wideningArea(
[at(0), at(20, 1, 0), at(40)],
{ start_m: 20, end_m: 20, widening_m: 1 },
{ start: 0, end: 40 },
),
areaMissing: w.wideningArea(
stations,
{ start_m: 999, end_m: 999, widening_m: 1 },
{ start: 0, end: 140 },
),
};
process.stdout.write(JSON.stringify(out));