/* 380-3 노선 따라간 사토장 · 토취장(site) = 새 노선 일반 측점 중 가장 가까운 곳 — 진짜 * `common_util_route_follow` · `common_util_structure_station` 을 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 station = loadTs("common_util/common_util_structure_station.ts", { "./common_util_structure_catalog": require("./helper_322_catalog_module.cjs"), }); const follow = loadTs("common_util/common_util_route_follow.ts", { "./common_util_structure_station": station, }); const out = { grid: input.grids.map(([total, interval]) => station.gridStations(total, interval)), snap: input.snaps.map(([value, stations]) => station.snapExistingStation(value, stations)), follow: follow .followStructures(input.items, input.line, undefined, input.interval) .map((entry) => entry.item.chainage_m), plain: follow.followStructures(input.items, input.line).map((entry) => entry.item.chainage_m), }; process.stdout.write(JSON.stringify(out));