/* 368-4 아무 누가거리 측점 하나 거울 — 진짜 `design_pipeline_probe_station.ts`(probeStation) 와 * `B05_Profile_Sections_Stations.ts`(buildStations + 추가 측점)를 Node 로 돌려 같은 측점인지 냄. * 입력 argv[2] JSON {line, curves, pipes, structures, types, at: [m...]} · 짝 = test_368_4_probe_station.py. */ const fs = require("fs"); const path = require("path"); const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript")); const CATALOG = require("./helper_322_catalog_module.cjs"); const ROOT = path.join(__dirname, "..", ".."); const cache = new Map(); function loadTs(full) { 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) => { if (CATALOG.isCatalogRequest(request)) return CATALOG; if (request.startsWith(".")) return loadTs(path.join(path.dirname(full), `${request}.ts`)); return require(request); }; new Function("exports", "module", "require", js)(box.exports, box, localRequire); return box.exports; } const logic = loadTs(path.join(ROOT, "B05_Profile", "logic", "B05_Profile_Sections_Stations.ts")); const station = loadTs(path.join(ROOT, "common_util", "common_util_structure_station.ts")); const probe = loadTs( path.join(ROOT, "A00_Common", "design", "logic", "design_pipeline_probe_station.ts"), ); const job = JSON.parse(fs.readFileSync(process.argv[2], "utf8")); const build = (curves) => logic.buildStations(job.line, curves, job.pipes, job.structures, { types: job.types, stationSnap: false, }); const out = []; for (const curves of [job.curves, []]) { for (const at of job.at) { station.setPlusStations(null); const before = build(curves); const mine = probe.probeStation(job.line, curves, before, at); station.setPlusStations(() => [at]); const after = build(curves).find((s) => s.key === mine.key) ?? null; out.push({ curves: curves.length, at, mine, after }); } } process.stdout.write(JSON.stringify(out));