Files
Aislo/resources/tester/helper_152_2_link_height.cjs
T
eomsangdonandClaude Opus 5.5 d3315da993 refactor(472-3 B06 벽 · 기슭막이 · 배치): 구조물 기하 logic 분리 · 그림 파일은 그리기만
- logic 새 파일 다섯 — Cross_Wall_Geom(벽 1매) · Cross_Wall_Hatch_Geom(무늬 띠 · 물빼기 · 도수로 띠 · 원지반선) · Cross_Excavation_Geom(벽 터파기) · Cross_Design_Surface_Geom(암선 · 포장층) · Cross_Revetment_Geom(독립 기슭막이 배치)
- logic 으로 옮김 — Body_Guard → Cross_Body_Guard · Structure_Layouts · Route_Carry_Patch(내용 그대로 · import 경로만)
- inferStationInterval → common_util_station(글자표 없는 자리 · common_util_svg 는 다시 내보냄) — Node 묶음 ui_template_locale 끌림 끊음
- 부르는 쪽 import 줄 · 등록부 ts 경로 · 시험 · 도우미 경로
- test_472_3 GEOMETRY_PULLS 다섯 줄 걷음 · Wall_Hatch · Excavation · Design_Surface 세 줄은 Culvert · Box · Ford 그림 파일(518-2)이 그리기 함수로 부르는 동안 남김

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 19:22:27 +09:00

81 lines
3.2 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 { makeLoader } = require("./helper_ts_stub_loader.cjs");
const ROOT = path.join(__dirname, "..", "..");
// 화면 전용 모듈(토스트 · 글) — 기하 계산엔 안 쓰임
const STUBS = {
"@ui/ui_template_toast": { showToast: () => undefined },
};
const { loadTs } = makeLoader({
root: ROOT,
interop: true,
requireFor: (full) => (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)));
},
});
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("logic/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));