- 고른 적 없으면 설계 지형(라이다가 있으면 라이다) · 사용자가 바꿀 때만 기억 - 하나뿐인 프로젝트는 있는 지형만 · 옛 값 무시 - 바꾸면 노선 초안으로 계산 묶음에 알림 · 설계 지형이 수치지형도면 확정 모델 등고선을 LAS 로 쓰지 않음 - 시험 test_352_3 추가 · 133_1 · 133_2 고쳐 씀 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VmC34fsxxbweEG3RUjs3Mn
62 lines
2.8 KiB
JavaScript
62 lines
2.8 KiB
JavaScript
/* PLAN 352-3 단위검증 헬퍼 — 분석 지형 기본값(고른 적 없으면 데이터대로) · 사용자가 바꿀 때만 기억.
|
|
* 진짜 `B05_Profile_Api_Replan.ts` 를 트랜스파일해 Node 로 돌림. 화면 상태 보관소만 가짜(쓰기 횟수 셈).
|
|
* 결과 = 표준출력 JSON 한 벌. 짝 = `test_352_3_analysis_terrain_default.py`. */
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
|
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
const store = new Map();
|
|
let writes = 0;
|
|
const STUBS = {
|
|
config_frontend: { API_BASE_URL: "" },
|
|
b_page_state: {
|
|
readState: (key, scope) => store.get(`${key}|${scope}`) ?? null,
|
|
writeState: (key, value, scope) => (writes++, store.set(`${key}|${scope}`, value)),
|
|
},
|
|
common_util_surface_sampler: { heightAt: () => 0 },
|
|
B05_Profile_Api_TerrainGrid: { loadDesignTerrainGrid: async () => null },
|
|
};
|
|
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) => {
|
|
const key = Object.keys(STUBS).find((name) => request.endsWith(name));
|
|
if (key) return STUBS[key];
|
|
return require(request);
|
|
};
|
|
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
|
return box.exports;
|
|
}
|
|
const api = loadTs(path.join(ROOT, "B05_Profile", "B05_Profile_Api_Replan.ts"));
|
|
|
|
const out = {};
|
|
// ① 사정을 모를 때 — 라이다
|
|
out.unknown = api.analysisTerrain("p0");
|
|
// ② 둘 다 있고 고른 적 없음 — 데이터대로(설계 라이다 → 라이다) · 쓰기 0
|
|
api.setTerrainContext("p1", true, "las");
|
|
out.bothNoPick = api.analysisTerrain("p1");
|
|
out.writesAfterOpen = writes;
|
|
// ③ 설계가 수치지형도인 프로젝트 · 고른 적 없음 — 설계대로(고르기 글 = 실제 쓰는 지형)
|
|
api.setTerrainContext("p2", true, "sheet");
|
|
out.sheetDesignNoPick = api.analysisTerrain("p2");
|
|
// ④ 사용자가 바꿈 — 그때만 기억 · 다음 접근(사정 다시 알림)에도 남음
|
|
api.setAnalysisTerrain("p1", "sheet");
|
|
out.afterPick = api.analysisTerrain("p1");
|
|
out.writesAfterPick = writes;
|
|
api.setTerrainContext("p1", true, "las");
|
|
out.nextAccess = api.analysisTerrain("p1");
|
|
// ⑤ 하나뿐인 프로젝트 — 옛 값이 남아 있어도 있는 것만 씀
|
|
store.set("routeedit-terrain|p3", "las");
|
|
api.setTerrainContext("p3", false, "sheet");
|
|
out.sheetOnlyStale = api.analysisTerrain("p3");
|
|
store.set("routeedit-terrain|p4", "sheet");
|
|
api.setTerrainContext("p4", false, "las");
|
|
out.lasOnlyStale = api.analysisTerrain("p4");
|
|
process.stdout.write(JSON.stringify(out));
|