/* 구조물 측점과 겹치는 규칙 측점 제거 — 2026-09-06. TS 를 프로젝트 tsc 로 옮겨 실제 코드를 그대로 돌린다. */ import assert from "node:assert/strict"; import { execFileSync } from "node:child_process"; import { mkdtempSync } from "node:fs"; import { tmpdir } from "node:os"; import { join } from "node:path"; import { pathToFileURL } from "node:url"; const out = mkdtempSync(join(tmpdir(), "aislo-station-")); execFileSync( process.execPath, [ "./config/node_modules/typescript/bin/tsc", "B05_Profile/logic/B05_Profile_Util_Station.ts", "--outDir", out, "--module", "esnext", "--target", "es2022", "--moduleResolution", "bundler", "--ignoreConfig", ], { stdio: "inherit" }, ); const { dropStationsNear, STATION_MERGE_TOLERANCE_M } = await import( pathToFileURL(join(out, "B05_Profile_Util_Station.js")).href ); const regular = [0, 20, 40, 60, 80].map((chainage_m) => ({ chainage_m, kind: "regular" })); const structures = [{ chainage_m: 40.05 }, { chainage_m: 63.0 }]; const kept = dropStationsNear(regular, structures); assert.deepEqual( kept.map((s) => s.chainage_m), [0, 20, 60, 80], "0.1m 안에서 겹친 40m 규칙 측점만 빠져야 한다", ); assert.equal(STATION_MERGE_TOLERANCE_M, 0.1); // 구조물이 없으면 아무것도 지우지 않는다. assert.equal(dropStationsNear(regular, []).length, regular.length); console.log("OK — 구조물 측점과 겹친 규칙 측점만 제거");