Files
Aislo/resources/tester/helper_344_3_pipeline_stations.cjs
T
eomsangdonandClaude Opus 5.5 97b5a78695 fix(441 B05 스냅 끌기): 맞춤 교점 이동 한도 = 간격 · 미리보기 측점 밖 늘면 그 걸음 되돌림 · 초안 없는 측점 단계 = 저장 스냅
- StationFit reach = intervalM(반 간격이면 MC 18+9 ~ 19+1 못 맞춤)
- 끌기 · 방향키 — 미리보기 측점 밖 곡선 수가 누를 때보다 늘면 그 걸음 되돌림 · dragMoved 는 막힘 검사 뒤(433-14)
- 계산 줄 stations 단계 · follow 새 측점 — 초안 없으면 저장 노선 station_snap · station_snap_step(snapOptions)
- 시험 — 390_5 끌기 훑기(놓은 뒤 측점 밖 0 · 자동 · 고정 R) · 344_3 저장 스냅 · 266 사면 이동 한 걸음 · 다시 그림 한 번

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ji4nuyLVHcxrXWHTdb5nRD
2026-10-18 18:42:06 +09:00

102 lines
4.2 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 station = loadTs(path.join(ROOT, "common_util", "common_util_structure_station.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) => {
station.setPlusStations(() => c.plus ?? []); // 368-2 추가 측점 — 화면이 둔 읽는 곳
return logic.buildStations(c.line, c.curves, job.pipes, job.structures, {
types: job.types,
stationSnap: c.snap,
stationSnapStep: c.step ?? null, // 390-5 · 252-2 곡선 측점 값 자릿수
});
}),
text: [0, 12.345, 40, 699.996].map(logic.stationText),
};
station.setPlusStations(null);
// 노선 한 점 옮김 — 단계가 범위 밖 측점을 앞 객체 그대로 · 열쇠 그대로
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),
};
// 441 — 초안 없는 저장 노선 = 저장 스냅 설정 따름 · 초안이 있으면 초안 값(스냅 case = cases[1])
const snapCase = job.cases[1];
const savedRun = (route, saved) =>
stage
.createStationsStage({ types: () => job.types, saved: () => saved })({
generation: 1,
range: null,
signal: new AbortController().signal,
inputs: { route, pipes: job.pipes, structures: job.structures },
out: { route: { line: snapCase.line, curves: snapCase.curves, chainage: [], lengthM: 0 } },
before: {},
prev: null,
})
.map((s) => s.chainageM);
out.savedSnap = {
saved: savedRun(null, { station_snap: true, station_snap_step: null }),
savedOff: savedRun(null, { station_snap: false }),
noPlan: savedRun(null, null),
draftWins: savedRun({ stationSnap: false }, { station_snap: true }),
};
process.stdout.write(JSON.stringify(out));