- 옮김: B04 2 · B05 23 · B06 11 · A00_Common/design 13 (9,299 줄) · 이미 logic/ 에 있던 16 파일 그대로 - 안 옮김: 묶음 입구(package.json build:*) · 파이썬 · 순수지만 계산 아닌 8 (보기 결선 · 콜백 · API 타입 · 갈아끼움 알림판) - import 266 줄(142 파일) · 시험 · 주석 · 짝 표시 문자열 경로 고침 · B05 · B06 CLAUDE.md 짝 줄 logic/ - 시험 도우미 새 경로: 가짜 require 열쇠 · B05()/B06() 부름 · 형제 import 자리 · tsc 묶어 돌리는 시험 · 정규식 · rglob - design_view_cross 줄 한도 시험 685 → 688 (긴 import 경로 줄바꿈 3줄) - 확인: typecheck 0 · 서버 묶음 넷(corridor · server-calc · b07-extent · b07-note) 다시 지어 코드 같음(//#region 경로 주석만 다름) · 관련 시험 270 파일 — 남은 실패 19 는 옮기기 전과 같음 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014utrjfoW831Vc5wJUd13kL
78 lines
3.1 KiB
JavaScript
78 lines
3.1 KiB
JavaScript
/* PLAN 344-3 · 346-1 측점 한 벌 거울 헬퍼 — 진짜 `B05_Profile/logic/B05_Profile_Sections_Stations.ts` ·
|
|
* `A00_Common/design/logic/design_pipeline_stations.ts`(단계 · 범위 밖 재사용)를 그 자리에서 트랜스파일해 Node 로 돌림.
|
|
* 입력 argv[2] JSON(파이썬과 같은 노선 · 곡선표 · 관 · 구조물) · 표준출력 JSON 한 벌.
|
|
* 짝 = `test_344_3_pipeline_stations_mirror.py`. */
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
|
const CATALOG = require("./helper_322_catalog_module.cjs"); // 구조물 표(322-1)
|
|
|
|
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 (CATALOG.isCatalogRequest(request)) return CATALOG;
|
|
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 logic = loadTs(path.join(ROOT, "B05_Profile", "logic", "B05_Profile_Sections_Stations.ts"));
|
|
const stage = loadTs(
|
|
path.join(ROOT, "A00_Common", "design", "logic", "design_pipeline_stations.ts"),
|
|
);
|
|
const job = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
|
|
|
const out = {
|
|
constants: {
|
|
interval: logic.SECTION_STATION_INTERVAL_M,
|
|
endpoint: logic.SECTION_INCLUDE_ENDPOINT,
|
|
taper: logic.CURVE_WIDENING_TAPER_M,
|
|
table: logic.CURVE_WIDENING_TABLE_M,
|
|
arm: logic.PLAN_RADIUS_ARM_M,
|
|
straight: logic.PLAN_RADIUS_STRAIGHT_M,
|
|
},
|
|
cases: job.cases.map((c) =>
|
|
logic.buildStations(c.line, c.curves, job.pipes, job.structures, {
|
|
types: job.types,
|
|
stationSnap: c.snap,
|
|
}),
|
|
),
|
|
text: [0, 12.345, 40, 699.996].map(logic.stationText),
|
|
};
|
|
|
|
// 노선 한 점 옮김 — 단계가 범위 밖 측점을 앞 객체 그대로 · 열쇠 그대로
|
|
const run = (line, curves, prev, range) =>
|
|
stage.createStationsStage({ types: () => job.types })({
|
|
generation: 1,
|
|
range,
|
|
signal: new AbortController().signal,
|
|
inputs: { route: { stationSnap: false }, pipes: job.pipes, structures: job.structures },
|
|
out: { route: line ? { line, curves, chainage: [], lengthM: 0 } : null },
|
|
before: {},
|
|
prev,
|
|
});
|
|
const before = run(job.move.line, job.move.curves, null, null);
|
|
const after = run(job.move.movedLine, job.move.movedCurves, before, {
|
|
sources: ["route"],
|
|
fromM: job.move.fromM,
|
|
toM: Infinity,
|
|
keys: [],
|
|
});
|
|
const byKey = new Map(before.map((s) => [s.key, s]));
|
|
out.move = {
|
|
before: before.map((s) => [s.key, s.chainageM]),
|
|
after: after.map((s) => [s.key, s.chainageM]),
|
|
same: after.map((s) => byKey.get(s.key) === s),
|
|
empty: run(null, null, null, null),
|
|
};
|
|
process.stdout.write(JSON.stringify(out));
|