- B05 · B06 [추가] = 그 측점 횡단(카드 · 측점선) 바로 + 세부유역 뒤에서 다시 나눔(세션 초안 · 저장 안 함 · 최신 응답만 · 지도 칸 표시만) — 있던 길 그대로 - 까닭 1: B06 [추가]는 높이 기다림을 판에 안 알려 새 세월교 · 물넘이 월류 높이(126-1)가 빈칸 — 기다림 표를 프로젝트마다 한 벌(fordWaitsOf)로 판 · B06 이 같이 씀 · 채운 높이를 B06 목록 · 폼이 받음(adoptFordHeights) - 까닭 2: B06 알림 글이 「세부 배수유역은 [저장]·[확정] 뒤 계산」 — 실제는 뒤에서 바로 다시 나눔 · 넣기 · 빼기 · 옮기기 글 고침 - 다시 나눔 실패 = 지도 칸 문구 + 토스트 한 줄(analyzeFailed) - 시험: test_298_add_reanalyze 새로 · test_126 · test_291_1 · helper_165 · helper_231_1 맞춤 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VmC34fsxxbweEG3RUjs3Mn
89 lines
3.4 KiB
JavaScript
89 lines
3.4 KiB
JavaScript
/* PLAN 298-1 헬퍼 — B06 [추가]가 적은 「높이 기다림」을 배수유역도 판이 같은 표(`fordWaitsOf`)로 보고
|
|
* 다시 나눈 유량으로 빈 월류 높이를 채움(126-1) · 프로젝트마다 따로 · 실패 = 토스트 한 줄(`analyzeFailed`).
|
|
* TS 로더는 `helper_126_ford_fill.cjs` 와 같다 · 결과 = 표준출력 JSON 한 벌.
|
|
*/
|
|
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 toasts = [];
|
|
const STUBS = {
|
|
"@ui/ui_template_elements": { showToast: (message, kind) => toasts.push([message, kind]) },
|
|
};
|
|
|
|
function loadTs(file) {
|
|
const full = path.resolve(file);
|
|
if (cache.has(full)) return cache.get(full);
|
|
const js = ts.transpileModule(fs.readFileSync(full, "utf8"), {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
|
}).outputText;
|
|
const box = { exports: {} };
|
|
cache.set(full, box.exports);
|
|
const localRequire = (request) => {
|
|
if (STUBS[request]) return STUBS[request];
|
|
if (request === "@config/config_frontend")
|
|
return loadTs(path.join(ROOT, "config", "config_frontend.ts"));
|
|
if (request.startsWith(".")) return loadTs(path.join(path.dirname(full), `${request}.ts`));
|
|
if (request.startsWith("@")) return new Proxy({}, { get: () => () => {} });
|
|
return require(request);
|
|
};
|
|
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
|
cache.set(full, box.exports);
|
|
return box.exports;
|
|
}
|
|
|
|
const B05 = path.join(ROOT, "B05_Profile");
|
|
const fill = loadTs(path.join(B05, "B05_Profile_UI_Drainage_Ford_Fill.ts"));
|
|
const { fordHeightM } = loadTs(
|
|
path.join(ROOT, "A00_Common", "design", "design_structure_ford_calc.ts"),
|
|
);
|
|
|
|
const flow = 8.0;
|
|
const points = () => [
|
|
{ chainage_m: 185, facility: "ford_bridge", options: { ford_width_m: 10 } },
|
|
{ chainage_m: 300, facility: "ford_pavement", options: {} },
|
|
];
|
|
const basins = [
|
|
{ chainage_m: 185, design_flow_m3s: flow },
|
|
{ chainage_m: 300, design_flow_m3s: flow },
|
|
];
|
|
|
|
// ① B06 [추가] — 그 프로젝트 표에 측점을 적음(판과 같은 표)
|
|
const b06Wants = fill.waitsFordHeight("ford_bridge", { ford_width_m: 10 });
|
|
if (b06Wants) fill.fordWaitsOf("p1").add(185);
|
|
const same = fill.fordWaitsOf("p1") === fill.fordWaitsOf("p1");
|
|
// ② 판의 다시 나눔 응답 — 같은 표로 채움 · 기다리지 않던 300 은 빈칸 그대로
|
|
const p1 = points();
|
|
const filled = fill.fillFordHeights(p1, basins, fill.fordWaitsOf("p1"));
|
|
// ③ 다른 프로젝트 같은 측점은 안 채움
|
|
const p2 = points();
|
|
const otherFilled = fill.fillFordHeights(p2, basins, fill.fordWaitsOf("p2"));
|
|
|
|
let failed = null;
|
|
try {
|
|
const parts = loadTs(path.join(B05, "B05_Profile_UI_Drainage_Parts.ts"));
|
|
failed = {
|
|
status: parts.analyzeFailed(new Error("502 Bad Gateway"), "세부유역 산정에 실패했습니다."),
|
|
plain: parts.analyzeFailed("x", "세부유역 산정에 실패했습니다."),
|
|
toasts: [...toasts],
|
|
};
|
|
} catch (error) {
|
|
failed = { error: String(error) };
|
|
}
|
|
|
|
process.stdout.write(
|
|
JSON.stringify({
|
|
b06Wants,
|
|
same,
|
|
filled,
|
|
heights: p1.map((p) => p.options.ford_height_m ?? null),
|
|
left: [...fill.fordWaitsOf("p1")],
|
|
otherFilled,
|
|
otherHeights: p2.map((p) => p.options.ford_height_m ?? null),
|
|
need: fordHeightM(flow, 10),
|
|
failed,
|
|
}),
|
|
);
|