Files
Aislo/resources/tester/helper_415_swap.mjs
T
eomsangdonandClaude Opus 5.5 a02367e615 feat(475-3 요구 275-3): 노선이 바뀌면 자리 칸(암 경계 · 2단 경사 · 손 상단측)은 같은 자리 측점만 넘김 — 새 자리 = 기본값
- 자리 칸 목록 한 벌 = TS `SEAT_KEYS`(Station_Swap · 파이썬 Router_Design 이 그 글을 읽음) — two_stage_slope · rock_boundary_offset_m · cut_slope_ratio_user · section_mode · ditch_side
- 자리 판정 한 벌 = `sameSeat` ↔ 파이썬 `same_seat`(중심 0.01 m · 왼쪽 축 1e-3 · 모르면 같은 자리 = 옛 동작)
- 끌기 세션 넘김 · Node stations.carry = `carryKeyedStates`(목록 측점 자리 · 값마다 쓴 때 자리 `@seat` — 되돌리기로 되살린 값도 제 자리로)
- 미리보기 = `pipelineCrossSource` 가 저장분 · 세션 자리 칸에 자리째 실음 → `crossAtSeat` 가 새 자리면 뺌
- B06 갈아끼움(노선 초안) = 자리 바뀐 측점 설계의 자리 칸 걷고 기본값(`unseated` · 브레인 덧)
- 서버 노선 저장 = `carry_cross_inputs` 자리 칸 같은 자리만 · 손 단면 유형 · 측구 방향 = `compute_default_designs` 입력
- 옛 단언 시험 고침(자리 모름 목록 = 같은 자리 = 손 상단측도 넘김 · 「@seat」 칸 거름) · 새 시험 test_475_3_seat_carry
- 위키 rules 넘김 규칙 줄

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 14:29:38 +09:00

159 lines
6.0 KiB
JavaScript

/* 415 H1 헬퍼 — 관만 옮김 = 횡단 고침을 측점 열쇠째 옮김 · 노선이 바뀜 = 「노선 바뀜」 넘김 규칙.
* node helper_415_swap.mjs <묶음.mjs>
* 묶음 = 346-2 진입점(`helper_346_2_swap_entry.ts` · vite ssr 진짜 모듈) · 표준출력 JSON 한 벌. 짝 = test_415_page_split.py.
*/
import { pathToFileURL } from "node:url";
const store = () => {
const m = new Map();
return {
getItem: (k) => (m.has(k) ? m.get(k) : null),
setItem: (k, v) => m.set(k, String(v)),
removeItem: (k) => m.delete(k),
key: (i) => [...m.keys()][i] ?? null,
get length() {
return m.size;
},
clear: () => m.clear(),
};
};
globalThis.window = globalThis;
globalThis.sessionStorage = store();
globalThis.localStorage = store();
const any = new Proxy(function () {}, {
get: (_t, k) => (k === Symbol.toPrimitive ? () => 0 : any),
apply: () => any,
construct: () => any,
});
globalThis.document = any;
globalThis.requestAnimationFrame = (run) => setTimeout(run, 0);
globalThis.__toasts = [];
const m = await import(pathToFileURL(process.argv[2]).href);
const P = "p415";
const R = 3;
const out = {};
/* 옛 목록 — 시점 · 격자 넷 · 관 하나(45.054) · 종점(간격 20 m) */
const section = (chainage_m, kind, extra = {}) => ({
station_id: `station_${String(Math.round(chainage_m * 1000)).padStart(12, "0")}`,
chainage_m,
label: "",
kind,
center_z: 100,
azimuth_deg: 90,
center_x: chainage_m,
center_y: 0,
frame: { left_xy: [0, 1] },
samples: [{ offset_m: 0, elevation_m: 100, valid: true }],
design: { design_elevation_m: 101 },
...extra,
});
const detail = () => ({
longitudinal: {
length_m: 100,
stations: [],
profile_alignment: { policy: { station_interval_m: 20 } },
},
cross_sections: [
section(0, "bp"),
section(20, "regular"),
section(40, "regular"),
section(45.054, "irregular", { structure: "파형강관 D800", culvert: {} }),
section(60, "regular"),
section(80, "regular"),
section(100, "ep"),
],
});
const station = (key, chainageM, kind, id = null, dy = 0) => ({
key,
chainageM,
x: chainageM,
y: dy,
azimuthDeg: 90,
left: [0, 1],
kind,
id,
ground: { centerZ: 99, left: [{ offsetM: 0.5, z: 99.1 }], right: [{ offsetM: 0.5, z: 98.9 }] },
planRadiusM: null,
curveOuterSide: null,
curveWideningM: null,
});
/** 관 자리 `pipeAt` · 노선 옆 밀림 `dy`(0 = 노선 그대로) · 종점 `endAt`. */
const list = (pipeAt, dy = 0, endAt = 100) =>
[
station("end:BP", 0, "end", null, dy),
station("grid:1", 20, "grid", null, dy),
station("grid:2", 40, "grid", null, dy),
station("pipe:pipe-s1", pipeAt, "pipe", "pipe-s1", dy),
station("grid:3", 60, "grid", null, dy),
station("grid:4", 80, "grid", null, dy),
station("end:EP", endAt, "end", null, dy),
].sort((a, b) => a.chainageM - b.chainageM);
const choice = (mode) => ({ ground_type: "soil", section_mode: mode, ditch_side: "right" });
const snap = () => ({
choices: [...m.crossDesignChoices(P, R).entries()]
.sort((a, b) => a[0] - b[0])
.map(([at, c]) => [at, c.ground_type ?? null, c.section_mode ?? null]),
shoulder: Object.entries(m.readState("shoulderext", P, R) ?? {})
.filter(([k]) => !k.startsWith("@"))
.map(([k, v]) => [k, v]),
berm: Object.entries(m.readState("bermdepth", P, R) ?? {})
.filter(([k]) => !k.startsWith("@"))
.map(([k, v]) => [k, v]),
});
/* 1. 순수 — 관만 옮김 = moved 아님 · 노선이 옆으로 밀림 = moved */
{
const keys = ["end:BP", "grid:1", "grid:2", "pipe:pipe-s1", "grid:3", "grid:4", "end:EP"];
out.pure = {
pipeOnly: m.swapCrossSections(detail(), list(50), keys, 20).moved,
route: m.swapCrossSections(detail(), list(50, 0.5, 95), keys, 20).moved,
};
}
/* 2. 가게 측점 → 상세 갈아끼움 · 세션 고침 */
{
m.writeState("section-detail", detail(), P, R);
m.writeState("pipe-ids", { next: 2, ids: [{ id: "pipe-s1", at: 45.054 }] }, P);
await m.loadSectionDetail(P, R); // 세션 한 벌 → 캐시 · 측점 열쇠 세움
m.writeCrossDesignChoice(P, R, 40, choice("right_cut")); // 단면 유형
m.writeCrossDesignChoice(P, R, 45.054, choice("left_cut")); // 관 측점 고침
m.writeState("shoulderext", { "@at": { "grid:1": 20 }, "grid:1": { left: 0.7 } }, P, R); // 사면 쉬프트
m.writeState("bermdepth", { "@at": { "grid:3": 60 }, "grid:3": { right: 0.4 } }, P, R); // 소단 깊이
// 누가거리 조절(415-3) — 조정창 맵 없이(B05 만 연 페이지 · 새로고침) · 관 자리 옹벽 · 세월 · 연동 두 겹 · 격자 폭
m.writeState("revetx", { "45.05:outlet": { x: 0.3 }, "20.00:inlet": { x: 0.1 } }, P, R);
m.writeState("fordadjust", { 45.05: { w: 1 } }, P, R);
m.writeState("revetlink", { detached: { 45.05: true }, grade: {} }, P, R);
out.before = snap();
const stop = m.followSwaps(
P,
() => R,
{ visible: () => true },
async () => undefined,
);
// 관 5 m 옮김(노선 그대로) — 관 자리 장부도 새 자리
m.writeState("pipe-ids", { next: 2, ids: [{ id: "pipe-s1", at: 50 }] }, P);
m.useDesignStore(P, null).set("stations", list(50));
await new Promise((resolve) => setTimeout(resolve, 30));
out.pipeMoved = { ...snap(), toasts: globalThis.__toasts.length };
out.adjusts = {
revetx: m.readState("revetx", P, R),
fordadjust: m.readState("fordadjust", P, R),
revetlink: m.readState("revetlink", P, R),
};
// 관 한 번 더(10 m) — 둘째 옮김도 그대로(첫 옮김 뒤 관 id 를 앎)
m.writeState("pipe-ids", { next: 2, ids: [{ id: "pipe-s1", at: 55 }] }, P);
m.useDesignStore(P, null).set("stations", list(55));
await new Promise((resolve) => setTimeout(resolve, 30));
out.pipeMovedAgain = snap();
// 노선이 바뀜(옆으로 0.5 m · 종점 95 m) = 넘김 규칙 — 단면 유형 · 사면 쉬프트 · 소단 깊이 버림 · 지반 유형 넘김
m.useDesignStore(P, null).set("stations", list(55, 0.5, 95));
await new Promise((resolve) => setTimeout(resolve, 30));
out.routeMoved = snap();
stop();
}
process.stdout.write(JSON.stringify(out));