/* PLAN 472-8 헬퍼 — 브라우저 다시 셈(`B06_Section_Cross_Refresh_Calc.refreshDesigns`)을 Node 로. * 입력 argv[2] JSON {sections, plan: [[누가거리, 계획고]], standard} · 결과 = 표준출력 JSON(측점 설계 목록). * 짝 = `test_472_8_section_mode_default.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(); function loadTs(full) { 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 (request.endsWith(".json")) return require( request.startsWith("@util/") ? path.join(ROOT, "common_util", request.slice(6)) : path.join(path.dirname(full), request), ); if (request.startsWith("@util/")) return loadTs(path.join(ROOT, "common_util", `${request.slice(6)}.ts`)); if (request.startsWith(".")) return loadTs(path.join(path.dirname(full), `${request}.ts`)); return require(request); }; new Function("exports", "module", "require", js)(box.exports, box, localRequire); return box.exports; } const job = JSON.parse(fs.readFileSync(process.argv[2], "utf8")); const { refreshDesigns } = loadTs( path.join(ROOT, "B06_Section", "logic", "B06_Section_Cross_Refresh_Calc.ts"), ); const samples = job.plan.map(([chainage_m, elevation_m]) => ({ chainage_m, elevation_m })); const alignment = { stations: samples.map((s) => ({ chainage_m: s.chainage_m, plan_elevation_m: s.elevation_m })), samples, balance: { cut_area_m2: 0, fill_area_m2: 0, cut_volume_m3: 0, fill_volume_m3: 0 }, }; const detail = { longitudinal: { design_profiles: [] }, cross_sections: job.sections }; refreshDesigns( detail, { alignment, standard: job.standard, rockOffsets: [], rockDefault: job.rockDefault, cutSlopes: [], bermDepths: [], choices: [], shoulderExtends: [], canon: [], }, null, ); process.stdout.write(JSON.stringify(detail.cross_sections.map((s) => s.design)));