Files
Aislo/resources/tester/helper_152_2_link_height.cjs
T
eomsangdonandClaude Opus 5.5 f8a13e234d feat(b06): 연동 흙막이 높이 = 본 흙막이 그린 높이 · 풀린 카드 「이 측점 높이」 줄(152-2)
- 소유 측점 적용값의 빈 높이 = 그린 순수 높이 — 옆 카드 · B07 · 서버 면적 · 연동 풂 굳힘이 같은 값(박스 옆 측점 0.5 → 2.0 m)
- 연동 푼 카드의 유입 · 유출 흙막이 = 좌측 칸에 「이 측점 높이」 ±0.1 줄(날개벽 칸 포함)
- 새 시험 test_152_2_link_height · 받는 줄 문자열 시험 셋 고침

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01F3mdb91125mPoC6tpsQx4P
2026-10-09 19:09:04 +09:00

99 lines
3.8 KiB
JavaScript

/* 152-2 연동 흙막이 높이 헬퍼 — 높이 칸 빈 박스 흙막이(73-4 픽스처 352.14)의 연동 옆 측점(340 · 360)이
* 소유 측점이 그린 순수 높이를 물려받는지 · 연동을 푼 카드만 자기 높이로 서는지. 결과 = 표준출력 JSON.
* 짝 = `test_152_2_link_height.py`.
*/
const fs = require("fs");
const path = require("path");
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
const ROOT = path.join(__dirname, "..", "..");
const cache = new Map();
// 화면 전용 모듈(토스트 · 글) — 기하 계산엔 안 쓰임
const STUBS = {
"@ui/ui_template_toast": { showToast: () => undefined },
};
function loadTs(file) {
const full = path.resolve(file);
if (cache.has(full)) return cache.get(full);
if (full.endsWith(".json")) {
const data = JSON.parse(fs.readFileSync(full, "utf8"));
cache.set(full, data);
return data;
}
const js = ts.transpileModule(fs.readFileSync(full, "utf8"), {
compilerOptions: {
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES2020,
esModuleInterop: true,
},
}).outputText;
const box = { exports: {} };
cache.set(full, box.exports);
const localRequire = (request) => {
if (STUBS[request]) return STUBS[request];
const alias = { "@util/": "common_util", "@ui/": "ui_template", "@config/": "config" };
for (const [prefix, dir] of Object.entries(alias))
if (request.startsWith(prefix))
return loadTs(resolve(path.join(ROOT, dir, request.slice(prefix.length))));
return loadTs(resolve(path.join(path.dirname(full), request)));
};
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
cache.set(full, box.exports);
return box.exports;
}
const resolve = (base) =>
[base, `${base}.ts`, path.join(base, "index.ts")].find(
(p) => fs.existsSync(p) && fs.statSync(p).isFile(),
) ?? `${base}.ts`;
const B06 = (f) => path.join(ROOT, "B06_Section", f);
const { computeStoredLayouts } = loadTs(B06("B06_Section_Structure_Layouts.ts"));
const fixture = JSON.parse(
fs.readFileSync(path.join(__dirname, "fixtures", "b06_73_4_body_guard_sections.json"), "utf8"),
);
// 높이 칸 비움(= 자동 · 세월교 · 박스 흙막이 기본) — 원본은 3.5 를 넣은 상태
const sections = fixture.cross_sections.map((s) => {
if (!s.culvert?.body) return s;
const copy = JSON.parse(JSON.stringify(s));
copy.culvert.inlet.revet_height_m = null;
copy.culvert.outlet.revet_height_m = null;
return copy;
});
const at = (list, c) => list.find((s) => Math.abs(s.chainage_m - c) < 0.6);
const round = (v) => Math.round(v * 1000) / 1000;
const heightsOf = (list, c) => {
const culvert = computeStoredLayouts(at(list, c), list)?.culvert;
return {
pure: culvert?.pureHeights
? { inlet: round(culvert.pureHeights.inlet), outlet: round(culvert.pureHeights.outlet) }
: null,
walls: (culvert?.walls ?? []).map((w) => ({ role: w.role, height: round(w.height) })),
shift: culvert?.revetShift ?? null,
};
};
const out = { owner: heightsOf(sections, 352.14), linked: {} };
for (const c of [340, 360]) out.linked[c] = heightsOf(sections, c);
// 340 연동 풂 + 유출 흙막이만 +0.1 m(좌측 「이 측점 높이」 줄이 그 측점 값을 고친 것)
const shift = out.linked[340].shift;
const detached = sections.map((s) => {
if (Math.abs(s.chainage_m - 340) >= 0.6) return s;
const copy = JSON.parse(JSON.stringify(s));
copy.design.revet_link_detached = true;
copy.design.revet_adjust = {
...(copy.design.revet_adjust ?? {}),
inlet: { ...shift.inlet },
outlet: { ...shift.outlet, h: round(shift.outlet.h + 0.1) },
};
return copy;
});
out.detached = {
340: heightsOf(detached, 340),
360: heightsOf(detached, 360),
owner: heightsOf(detached, 352.14),
};
process.stdout.write(JSON.stringify(out));