Files
Aislo/resources/tester/helper_380_2_site_station.cjs
T
eomsangdonandClaude Sonnet 5.5 8bbdbb9f69 test(508-1b 옛 헬퍼 공용 불러오기 4/7): 헬퍼 28 곳 loadTs 베낌 걷고 makeLoader 로
- 헬퍼 동작 그대로(풀이 함수 본문은 옮겨 담음) · 제품 코드 안 고침
- 확인: 이 묶음 헬퍼를 쓰는 시험 236 개 전 230 통과 → 후 230 통과 (시험별 junit 대조 · 어긋남 0)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-21 17:11:59 +09:00

51 lines
2.2 KiB
JavaScript

/* 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));