/* 284 알약 고름 헬퍼 — 진짜 `B05_Profile_UI_Profile_Structures.ts`(plantsStation · stationIdAtStructure · * structureIdKeeping)를 Node 로 돌려 표준출력 JSON 한 벌로(요구 178 · 179-1). * 등록부 꼴 = 구조물정의.json 의 group · placement · managed_by 그대로. */ const fs = require("fs"); const path = require("path"); const { makeLoader } = require("./helper_ts_stub_loader.cjs"); const CATALOG = require("./helper_322_catalog_module.cjs"); // 구조물 표(322-1) const ROOT = path.join(__dirname, "..", ".."); function loadTs(file, stubs = {}) { return makeLoader({ root: ROOT, cache: false, requireFor: (full) => (request) => { if (CATALOG.isCatalogRequest(request)) return CATALOG; if (stubs[request]) return stubs[request]; throw new Error(`stub 없음: ${request}`); }, }).loadTs(file); } const selection = loadTs(path.join(ROOT, "A00_Common", "design", "design_selection.ts"), { "../../common_util/common_util_pipe_match": { PIPE_MATCH_M: 0.51 }, // 찾는 거리 정의 자리(472-6) "../b_page_state": { readState: () => null, writeState() {} }, }); const PREFIX = "irregular:"; const rule = loadTs(path.join(ROOT, "B05_Profile", "B05_Profile_UI_Profile_Structures.ts"), { "../A00_Common/touch_bridge": { pickPx: (px) => px }, // 기기대응 4-4 — 마우스 반경 그대로 "@ui/ui_template_context_menu": { createMapContextMenu() {} }, "./B05_Profile_UI_IrregularStations": { irregularStationId: (id) => `${PREFIX}${id}`, isPipeStation: (station) => station.origin === "pipe", }, "./B05_Profile_Api_Structures": { structureAnchorM: (s) => s.chainage_m ?? s.start_m ?? 0, }, "../A00_Common/design/design_selection": selection, "../common_util/common_util_structure_station": loadTs( path.join(ROOT, "common_util", "common_util_structure_station.ts"), ), }); const TYPES = [ { type_id: "cross_underdrain", group: "A", placement: "point", managed_by: null }, { type_id: "retaining_wall", group: "C", placement: "interval", managed_by: null }, { type_id: "ditch_side", group: "B", placement: "interval", managed_by: null }, { type_id: "hazard_sign", group: "E", placement: "point", managed_by: null }, { type_id: "bed_sill", group: "D", placement: "point", managed_by: null }, ]; const S = (id, type, at, extra = {}) => ({ structure_id: id, type_id: type, chainage_m: at, ...extra, }); const STRUCTURES = [ S("drain", "cross_underdrain", 40), S("wall", "retaining_wall", 100, { start_m: 90, end_m: 110 }), S("ditch", "ditch_side", 80, { start_m: 60, end_m: 100 }), S("sign", "hazard_sign", 80), // 관 측점(80)과 같은 m — 측점 없는 구조물 S("sill", "bed_sill", 140), S("unknown", "legacy_x", 160), S("pipe-80.00", "pipe", 80), S("pipe-120.00", "ford_pavement", 120), ]; // 종단도 구조물 측점(관 투영 + 심은 구조물) — 물넘이포장도 측점 심음(286-1) const STATIONS = [ { id: "drain", chainage_m: 40, origin: "structure" }, { id: "pipe-80.00", chainage_m: 80, origin: "pipe" }, { id: "wall", chainage_m: 100, origin: "structure" }, { id: "pipe-120.00", chainage_m: 120, origin: "pipe" }, ]; const byId = (id) => STRUCTURES.find((s) => s.structure_id === id); const plants = Object.fromEntries( STRUCTURES.map((s) => [s.structure_id, rule.plantsStation(s, TYPES)]), ); const line = Object.fromEntries( STRUCTURES.map((s) => [ s.structure_id, rule.stationIdAtStructure(s.structure_id, STATIONS, STRUCTURES, TYPES), ]), ); // 종류 없이 부르면(옛 부름) 구조물은 옛 길 — 같은 자리 측점선 const lineNoTypes = rule.stationIdAtStructure("sign", STATIONS, STRUCTURES); // 관 측점선(80)을 다시 누름 — 고른 것이 측점 없는 표지면 관 알약으로(표지는 선 짝 아님) const keepSign = rule.structureIdKeeping( `${PREFIX}pipe-80.00`, "sign", STATIONS, STRUCTURES, null, TYPES, ); // 고른 것이 관이면 그대로 const keepPipe = rule.structureIdKeeping( `${PREFIX}pipe-80.00`, "pipe-80.00", STATIONS, STRUCTURES, null, TYPES, ); process.stdout.write( JSON.stringify({ plants, line, lineNoTypes, keepSign, keepPipe, sample: byId("sign") }), );