- 헬퍼 동작 그대로(풀이 함수 본문은 옮겨 담음) · 제품 코드 안 고침 - 확인: 이 묶음 헬퍼를 쓰는 시험 236 개 전 230 통과 → 후 230 통과 (시험별 junit 대조 · 어긋남 0) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
37 lines
1.5 KiB
JavaScript
37 lines
1.5 KiB
JavaScript
/* 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));
|