- 판정 = 저장 노선 대 초안이 그릴 선 정점 1 mm(`routeShapeChanged` · 파이썬 `route_shape_changed` 짝) · 스냅 · 간격 · 지형만 = 아님 - 띠 = 평면(노선 편집) 위 한 줄 · B06 평면 패널로 같이 옮겨짐 · 저장 노선 = 페이지 자료 줄 `pageRoutePlan`(조작마다 안 물음) - [저장] 확인 창 = 잠금 막 · 서버 요청 앞 · 구조물 · 관 · 추가 측점 · 종단 편집 수 · [취소] = 요청 0 · 추천 [적용] 같은 글 · 수 - 저장 뒤 = 응답 `steps.route.route_reset` 지운 수 한 줄 · 초기화면 세션 초안 통째 비움 → 서버 정본으로 다시 세움 · 옛 서버(칸 없음) = 알림 건너뜀 - 시험: 새 test_283_route_reset_confirm(띠 · 확인 창 수 · [취소] · 스냅만 · 거울) · 저장 헬퍼 셋 확인 창 가짜 · 476-2 확인 글 기대 고침 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
109 lines
4.0 KiB
JavaScript
109 lines
4.0 KiB
JavaScript
/* 283 노선 모양 바뀐 [저장] = 초기화 — 진짜 TS(`logic/B05_Profile_Route_Reset` · `logic/B05_Profile_Grade_Carry`
|
|
* routeShapeChanged · `logic/B05_Profile_Pipeline_RouteGround` draftLine)를 Node 로 돌림.
|
|
* 입력 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 straightJudge = loadTs("B05_Profile/logic/B05_Profile_Profile_Straight.ts");
|
|
const curveLaw = loadTs("B05_Profile/logic/B05_Profile_Profile_CurveLaw.ts");
|
|
const pivot = loadTs("B05_Profile/logic/B05_Profile_UI_Profile_Pivot.ts", {
|
|
"./B05_Profile_Profile_Straight": straightJudge,
|
|
});
|
|
const alignment = loadTs("B05_Profile/logic/B05_Profile_UI_Profile_Alignment.ts", {
|
|
"./B05_Profile_UI_Profile_Pivot": pivot,
|
|
"./B05_Profile_Profile_Straight": straightJudge,
|
|
"./B05_Profile_Profile_CurveLaw": curveLaw,
|
|
});
|
|
const carry = loadTs("B05_Profile/logic/B05_Profile_Grade_Carry.ts", {
|
|
"./B05_Profile_UI_Profile_Alignment": alignment,
|
|
});
|
|
const curve = loadTs("B05_Profile/logic/B05_Profile_UI_RouteEdit_Curve.ts");
|
|
const edits = loadTs("B05_Profile/logic/B05_Profile_UI_RouteEdit_Edits.ts", {
|
|
"./B05_Profile_UI_RouteEdit_Curve": curve,
|
|
});
|
|
const routeGround = loadTs("B05_Profile/logic/B05_Profile_Pipeline_RouteGround.ts", {
|
|
"../../common_util/common_util_surface_sampler": { heightAt: () => null },
|
|
"./B05_Profile_UI_RouteEdit_Curve": curve,
|
|
"./B05_Profile_UI_RouteEdit_Edits": edits,
|
|
"./B05_Profile_Sections_Ground": {},
|
|
});
|
|
const reset = loadTs("B05_Profile/logic/B05_Profile_Route_Reset.ts", {
|
|
"./B05_Profile_Grade_Carry": carry,
|
|
"./B05_Profile_Pipeline_RouteGround": routeGround,
|
|
});
|
|
|
|
const xy = (line) => line.map(([x, y]) => ({ x, y }));
|
|
|
|
async function main() {
|
|
const input = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
|
const minR = input.min_radius_m;
|
|
const base = input.base;
|
|
const saved = routeGround.draftLine(base, minR).line;
|
|
const lines = {};
|
|
const changed = {};
|
|
for (const [name, draft] of Object.entries(input.drafts)) {
|
|
lines[name] = routeGround.draftLine(draft, minR).line;
|
|
changed[name] = reset.draftShapeChanged(saved, draft, minR);
|
|
}
|
|
const pairs = input.pairs.map(([a, b]) => carry.routeShapeChanged(xy(a), xy(b)));
|
|
|
|
// 확인 창 줄 — 안 바뀜 = 묻지 않음 · [취소] = false · [저장] = true
|
|
const counts = input.counts;
|
|
const gate = [];
|
|
for (const [isChanged, answer] of [
|
|
[false, false],
|
|
[true, false],
|
|
[true, true],
|
|
]) {
|
|
const asked = [];
|
|
let counted = 0;
|
|
const ok = await reset.askRouteReset(
|
|
isChanged,
|
|
async () => (counted++, counts),
|
|
async (text) => (asked.push(text), answer),
|
|
);
|
|
gate.push({ changed: isChanged, answer, ok, asked, counted });
|
|
}
|
|
|
|
process.stdout.write(
|
|
JSON.stringify({
|
|
saved,
|
|
lines,
|
|
changed,
|
|
nullDraft: reset.draftShapeChanged(saved, null, minR),
|
|
unknownSaved: reset.draftShapeChanged(null, base, minR),
|
|
pairs,
|
|
gate,
|
|
band: reset.ROUTE_RESET_BAND,
|
|
applyText: reset.routeResetConfirmText(counts, "적용"),
|
|
notice: reset.routeResetNotice(input.reset, 2),
|
|
noticeNone: [
|
|
reset.routeResetNotice(undefined),
|
|
reset.routeResetNotice({ reset: false, dropped: { pipes: 3 } }),
|
|
],
|
|
}),
|
|
);
|
|
}
|
|
|
|
main().catch((error) => {
|
|
process.stderr.write(String(error?.stack ?? error));
|
|
process.exit(1);
|
|
});
|