Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013QyNXY2TUKXCFMwAca2APG
50 lines
1.8 KiB
JavaScript
50 lines
1.8 KiB
JavaScript
/* 349-0v 바뀐 구간 거울 — 화면 planline 단계 차례 그대로: 새 노선 = `buildEditedPolyline`(노드 초안) ·
|
|
* 옛 노선 = 저장 계획 폴리라인 · `changedSpan` → `carryProfileEdits`. 입력 argv[2] JSON · 출력 JSON.
|
|
*/
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
|
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
|
|
function loadTs(file, stubs = {}) {
|
|
const js = ts.transpileModule(fs.readFileSync(path.join(ROOT, file), "utf8"), {
|
|
compilerOptions: { module: ts.ModuleKind.CommonJS, target: ts.ScriptTarget.ES2020 },
|
|
}).outputText;
|
|
const box = { exports: {} };
|
|
const localRequire = (request) => {
|
|
if (stubs[request]) return stubs[request];
|
|
throw new Error(`stub 없음: ${request} (${file})`);
|
|
};
|
|
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
|
return box.exports;
|
|
}
|
|
|
|
const curve = loadTs("B05_Profile/logic/B05_Profile_UI_RouteEdit_Curve.ts");
|
|
const pivot = loadTs("B05_Profile/logic/B05_Profile_UI_Profile_Pivot.ts");
|
|
const alignment = loadTs("B05_Profile/logic/B05_Profile_UI_Profile_Alignment.ts", {
|
|
"./B05_Profile_UI_Profile_Pivot": pivot,
|
|
});
|
|
const carry = loadTs("B05_Profile/logic/B05_Profile_Grade_Carry.ts", {
|
|
"./B05_Profile_UI_Profile_Alignment": alignment,
|
|
});
|
|
|
|
const input = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
|
const xy = (line) => line.map(([x, y]) => ({ x, y }));
|
|
const built = curve.buildEditedPolyline(
|
|
input.nodes,
|
|
input.curveOn,
|
|
input.curveRadius,
|
|
input.minRadiusM,
|
|
);
|
|
const span = carry.changedSpan(xy(input.old_line), xy(built.vertices));
|
|
process.stdout.write(
|
|
JSON.stringify({
|
|
new_line: built.vertices,
|
|
span,
|
|
result: span
|
|
? carry.carryProfileEdits(input.base_pvi, input.edits, span, input.ground_pvi)
|
|
: null,
|
|
}),
|
|
);
|