/* 380-2 사토장 · 토취장(site) = 가장 가까운 기존 측점(일반 · 구조물 · 추가) · 새 측점 안 심음. * 진짜 `common_util_structure_station` · `_Structures_Snap` 을 Node 로 돌림. 입력 argv[2] JSON · 표준출력 JSON. */ const fs = require("fs"); const path = require("path"); const { makeLoader } = require("./helper_ts_stub_loader.cjs"); const ROOT = path.join(__dirname, "..", ".."); function loadTs(file, stubs = {}) { return makeLoader({ root: ROOT, cache: false, requireFor: (full) => (request) => { if (stubs[request]) return stubs[request]; throw new Error(`stub 없음: ${request} (${file})`); }, }).loadTs(path.join(ROOT, file)); } const input = JSON.parse(fs.readFileSync(process.argv[2], "utf8")); const catalog = require("./helper_322_catalog_module.cjs"); const station = loadTs("common_util/common_util_structure_station.ts", { "./common_util_structure_catalog": catalog, }); const snap = loadTs("B05_Profile/B05_Profile_UI_Structures_Snap.ts", { "@ui/ui_template_elements": { showToast: () => {}, showConfirmDialog: async () => true }, "../common_util/common_util_structure_station": station, "../A00_Common/design/design_selection": { PIPE_MATCH_M: 0.51 }, "./B05_Profile_Api_Structures": { structureAnchorM: (entry) => entry.chainage_m ?? entry.start_m ?? 0, }, }); const out = {}; out.emptySnap = station.snapExistingStation(25.4); // 목록 전 = 정수 m station.setGeneralStations(input.stations); station.setPlusStations(() => input.plus); out.existing = station.existingStations(); out.snap = input.typed.map((value) => station.snapExistingStation(value)); out.twice = out.snap.map((value) => station.snapExistingStation(value)); out.siteFor = station.snapStationFor(25.4, "site"); out.pointFor = station.snapStationFor(25.4, "point"); out.movedSite = snap.movedStructure({ placement: "site", chainage_m: 20 }, 35.2).chainage_m; out.movedPoint = snap.movedStructure({ placement: "point", chainage_m: 20 }, 35.2).chainage_m; out.offGrid = input.offGrid.map((entry) => snap.structureOffGrid(entry)); out.planned = snap .snapPlan(input.offGrid, []) .structures.map((entry) => [entry.index, entry.next.chainage_m]); process.stdout.write(JSON.stringify(out));