- 규칙: 구조물 · 관 기준 측점 = 정수 m 사사오입(일반 측점 1 m 붙기 뺌) · 측점 심는 자리 TS 짝(plantedChainages ↔ resolve_extra_stations) · 같은 m 면 구조물 측점 하나(격자 자리 grid) · 떠나면 일반 측점(oneStationList ↔ _merge_irregular_into_longitudinal) - 서버: B05 [저장] · B06 저장 · [측점 만들기]가 목록 전체 다시 맞춤(빈 목록도 · 옛 글 · 횡단 파일 글) · 계획선 측점 줄 다시 셈 · 정본에 없는 횡단 행은 0.5 m 안 새 측점으로 옮기고 나머지 지움 · 옛 소수 측점 꼭짓점 · 편집은 정수 자리로 · 맞춤 실패는 저장을 안 막음 - 화면: 종단 그래프 · 3D · 표 · ▲▼ 한 목록(초안 반영) · C군 구간형 · 독립 기슭막이 시작 · 끝 측점 · B06 카드는 초안에 없는 옛 구조물 측점 숨김 · 고름은 같은 m 구조물 측점 먼저 · 폼 거리 칸 정수 표기 · C군 계산 구간 · 포장 나눔 경계 정수 - 옛 자료: [정수 맞춤] 단추 없앰 · 종단 보기 열 때 한 번 자동 정수 · 알림 한 줄 · [저장]하면 남음 - 시험: test_272_1 · test_272_2 새로 · 234_1 · 238_1 · b05_extra_stations_supplier · b06_patch_station · b05_station_roundtrip · b05_b06_save_roundtrip 맞춤 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LLCk2y5xE8YGVgjbTntWsY
117 lines
4.3 KiB
JavaScript
117 lines
4.3 KiB
JavaScript
/* 구조물 측점 왕복 단위검증 헬퍼 — `B05_Profile_UI_Structures_Fields.ts`(측점 칸)와
|
|
* `B05_Profile_UI_Profile_Edit.ts`(계획고 편집 저장소)를 그 자리에서 트랜스파일해 Node 로 돌린다.
|
|
* 확장자가 `.cjs` 인 까닭은 `helper_b05_cut_merged_loop.cjs` 머리와 같다.
|
|
*/
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
|
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
const cache = new Map();
|
|
|
|
function loadTs(file) {
|
|
const full = path.resolve(file);
|
|
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) =>
|
|
request.startsWith(".")
|
|
? loadTs(path.join(path.dirname(full), `${request}.ts`))
|
|
: require(request);
|
|
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
|
cache.set(full, box.exports);
|
|
return box.exports;
|
|
}
|
|
|
|
// 측점 칸이 쓰는 만큼만 흉내 낸 DOM
|
|
function fakeElement() {
|
|
const listeners = {};
|
|
const classes = new Set();
|
|
return {
|
|
value: "",
|
|
children: [],
|
|
style: {},
|
|
dataset: {},
|
|
classList: {
|
|
add: (c) => classes.add(c),
|
|
remove: (c) => classes.delete(c),
|
|
toggle: (c, on) => (on ? classes.add(c) : classes.delete(c)),
|
|
contains: (c) => classes.has(c),
|
|
},
|
|
setAttribute() {},
|
|
append(...kids) {
|
|
this.children.push(...kids);
|
|
},
|
|
appendChild(kid) {
|
|
this.children.push(kid);
|
|
return kid;
|
|
},
|
|
addEventListener: (type, fn) => (listeners[type] = listeners[type] || []).push(fn),
|
|
fire: (type) => (listeners[type] || []).forEach((fn) => fn({ type })),
|
|
};
|
|
}
|
|
global.document = { createElement: () => fakeElement(), createTextNode: () => fakeElement() };
|
|
|
|
const { stationFields } = loadTs(
|
|
path.join(ROOT, "B05_Profile", "B05_Profile_UI_Structures_Fields.ts"),
|
|
);
|
|
const { createProfileEditStore } = loadTs(
|
|
path.join(ROOT, "B05_Profile", "B05_Profile_UI_Profile_Edit.ts"),
|
|
);
|
|
|
|
const INTERVAL = 20;
|
|
const out = {};
|
|
const fields = stationFields("기준", () => INTERVAL);
|
|
|
|
// ① 실어 둔 값은 칸을 안 고치면 그대로(표시는 6 + 3 · 칸도 정수 m 167)
|
|
fields.write(123.37, INTERVAL);
|
|
out.shown = [fields.station.value, fields.remainder.value];
|
|
out.untouched = fields.read(INTERVAL, true);
|
|
fields.write(123.3721, INTERVAL);
|
|
out.untouchedRaw = fields.read(INTERVAL, true);
|
|
// 옛 소수 119.8 — 다시 열면 5 + 20 으로 보이고 그대로 읽힘
|
|
fields.write(119.8, INTERVAL);
|
|
out.r119 = [fields.station.value, fields.remainder.value, fields.read(INTERVAL, true)];
|
|
fields.write(123.3721, INTERVAL);
|
|
// 사용자가 잔여를 고치면 친 값으로
|
|
fields.remainder.value = "5.2";
|
|
fields.remainder.fire("change");
|
|
out.edited = fields.read(INTERVAL, true);
|
|
// 같은 글로 되돌려 치면 — 여전히 실어 둔 값(칸 글이 쓴 그대로)
|
|
fields.write(123.37, INTERVAL);
|
|
fields.remainder.value = "3";
|
|
out.retypedSame = fields.read(INTERVAL, true);
|
|
// 넘침 정규화(1 + 30 → 2 + 10)는 친 값으로
|
|
fields.station.value = "1";
|
|
fields.remainder.value = "30";
|
|
fields.remainder.fire("change");
|
|
out.normalized = [fields.station.value, fields.remainder.value, fields.read(INTERVAL, true)];
|
|
// 비운 폼은 읽기 null
|
|
fields.write(null, INTERVAL);
|
|
out.cleared = fields.read(INTERVAL, false);
|
|
|
|
// ② 계획고 편집 — 측점이 0.005m 안으로 옮겨 오면 편집을 옮기고, 아니면 지움
|
|
const saved = { station_offsets: { 123.372: 0.5, "200.000": 0.3 }, curve_radii: { 123.372: 40 } };
|
|
const store = createProfileEditStore(null, saved, () => {});
|
|
store.resetStation(123.372, 123.37);
|
|
out.moved = store.edits();
|
|
store.resetStation(200);
|
|
out.deleted = store.edits();
|
|
|
|
// 화면 표기 한 벌 — 거리는 정수로 보이기만(PLAN 20장 · 119.8 → 5+20)
|
|
const { stationLabel, stationPartsLabel } = loadTs(
|
|
path.join(ROOT, "common_util", "common_util_station.ts"),
|
|
);
|
|
out.labels = [
|
|
stationLabel(119.8, INTERVAL),
|
|
stationLabel(120, INTERVAL),
|
|
stationLabel(84.3, INTERVAL),
|
|
stationLabel(123.37, INTERVAL),
|
|
stationPartsLabel(5, 19.8),
|
|
];
|
|
|
|
process.stdout.write(JSON.stringify(out));
|