Files
Aislo/resources/tester/helper_178_3_slope_tiers.cjs
T
eomsangdonandClaude Opus 5.5 bbd6254892 feat(구조물표): 322-1 부품 상자 · 표 읽기 — 목록 · 측점 · 카드 이름 · 형상 고르기 · 3D 몸체 · 알약 띠가 종류 키 · 군 글자 · 자리꼴 · managed_by 대신 구조물 표(catalog) 한 줄을 읽음 · 코드 숨김 목록 걷음 · ★ 넷 + 관 공식 한 벌
- 부품 상자 common_util_structure_parts.json(갈래마다 부품 · 읽는 칸 · 자리꼴 · 정본 · 42종 처음값) · 표 읽기 common_util_structure_catalog.ts / .py 짝(정의 반영 ⊕ 처음값 ⊕ 부품 끔) · 거울 시험 test_322_1_catalog_mirror
- 목록: pickGroups 군 차례 = 구조물군 열쇠 · 페이지 거르기 listPick(B05 both · B06 both + b06) · HIDDEN_PICK_GROUPS · HIDDEN_PICK_TYPES · pickable 걷음(옛 대피 셋 asRoad 그대로)
- 측점: structureStationMarks · pipeStationMarks · is_station_planting_type · resolve_extra_stations = 표 횡단도(anchor · span3 · none)
- 카드 이름: cardTitle / card_title 한 공식(빈칸 = 그 종류 정의 기본값) · 표시 이름이 정의 관종도 앎
- 형상: 벽 = shape wall(형태 = 형상칸.form · 물빼기 = 형상칸.weep) · 포장 = shape pavement(「사용 중」 거르기 없앰) · 맹암거 · 사토 · 관 지점 시설 세트 = shape
- 3D 몸체 = 그림 자료 주인 종류의 표 3D 부품 · 알약 띠 = 표 자리꼴 구간(관 지점 시설은 알약만)
- ★1 노출형 · 개거 횡단도 none · ★2 쇄석 화면에서도 포장층 · ★3 기슭막이 표 자리꼴 interval(정의 파일 그대로) · ★4 코드 숨김 10종 list hidden · ★5 관 빈칸 D800 → 정의 기본 D1000
- 옛 시험: 도움 파일 로더 27개가 표 모듈 공용 한 벌(helper_322_catalog_module) 씀 · 기대값 고침(272_1 · b05_extra_stations · roundtrip · 314 · 52_7 · walls 거울 · wall_drain_pipe)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ji4nuyLVHcxrXWHTdb5nRD
2026-10-14 15:09:45 +09:00

115 lines
4.7 KiB
JavaScript

/* 178-3 사면안정 흙막이 · 옹벽 「추가 단」 헬퍼 — 화면 TS 를 그 자리에서 트랜스파일해 Node 로 돌림.
* ① 명세 상자 저장 왕복(readState → writeOptions) ② 구조물 정본 → 벽 제원(`wallSpecsFrom`) → 횡단 형상
* (`computeRevetmentLayout`) 단 수 · 단마다 형태 · 높이. 입력 측점 = 73-4 픽스처(helper_79 와 같은 180 측점).
* 결과 = 표준출력 JSON 한 벌 · 짝 = `test_178_3_slope_tiers.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"); // 구조물 표(322-1)
const ROOT = path.join(__dirname, "..", "..");
const cache = new Map();
const STUBS = { "@ui/ui_template_toast": { showToast: () => undefined } };
function loadTs(file) {
const full = path.resolve(file);
if (cache.has(full)) return cache.get(full);
if (full.endsWith(".json")) {
const data = JSON.parse(fs.readFileSync(full, "utf8"));
cache.set(full, data);
return data;
}
const js = ts.transpileModule(fs.readFileSync(full, "utf8"), {
compilerOptions: {
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.ES2020,
esModuleInterop: true,
},
}).outputText;
const box = { exports: {} };
cache.set(full, box.exports);
const localRequire = (request) => {
if (CATALOG.isCatalogRequest(request)) return CATALOG;
if (STUBS[request]) return STUBS[request];
const alias = { "@util/": "common_util", "@ui/": "ui_template", "@config/": "config" };
for (const [prefix, dir] of Object.entries(alias))
if (request.startsWith(prefix))
return loadTs(resolve(path.join(ROOT, dir, request.slice(prefix.length))));
return loadTs(resolve(path.join(path.dirname(full), request)));
};
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
cache.set(full, box.exports);
return box.exports;
}
const resolve = (base) =>
[base, `${base}.ts`, path.join(base, "index.ts")].find(
(p) => fs.existsSync(p) && fs.statSync(p).isFile(),
) ?? `${base}.ts`;
const design = (f) => path.join(ROOT, "A00_Common", "design", f);
const spec = loadTs(design("design_structure_spec.ts"));
const { ADDON_SPECS } = loadTs(design("design_structure_slope_tier.ts"));
const { STRUCTURE_SPECS } = loadTs(design("design_structure_pipe.ts"));
const { wallSpecsFrom } = loadTs(path.join(ROOT, "common_util", "common_util_structure_walls.ts"));
const { computeRevetmentLayout } = loadTs(
path.join(ROOT, "B06_Section", "B06_Section_UI_Cross_Revetment.ts"),
);
const r3 = (v) => Math.round(v * 1000) / 1000;
const out = {};
// ① 저장 왕복 — 상자 둘(흙막이) · 하나(옹벽) · 빈 상자(값 없이 추가만)
const soil = ADDON_SPECS.soil_guard;
const wall = ADDON_SPECS.retaining_wall;
const soilOptions = {
form: "돌쌓기(찰)",
height_m: 2,
tier_1_form: "콘크리트",
tier_1_height: 2,
tier_2_form: "돌망태",
tier_2_height: 1.2,
};
const soilState = spec.readState(soil, soilOptions);
out.roundTrip = {
items: Object.fromEntries(
Object.entries(ADDON_SPECS).map(([k, s]) => [k, s.containers[0].items.map((i) => i.id)]),
),
soilState: soilState.tier,
soilBack: spec.writeOptions(soil, soilState),
wallBack: spec.writeOptions(wall, { tier: [{ height: "1.8" }] }),
emptyBox: spec.writeOptions(soil, { tier: [{}] }),
notMainSpecs: Object.keys(ADDON_SPECS).filter((k) => k in STRUCTURE_SPECS),
};
// ② 형상 — 정본 → 벽 제원 → 횡단 단
const fixture = JSON.parse(
fs.readFileSync(path.join(__dirname, "fixtures", "b06_73_4_body_guard_sections.json"), "utf8"),
);
const base = fixture.cross_sections.find((s) => Math.abs(s.chainage_m - 180) < 0.6);
const names = new Map([
["soil_guard", "흙막이"],
["retaining_wall", "옹벽"],
]);
function shape(typeId, options) {
const [wallSpec] = wallSpecsFrom(
[{ structure_id: "t", type_id: typeId, chainage_m: 180, start_m: 170, end_m: 190, options }],
names,
);
const section = JSON.parse(JSON.stringify(base));
section.revetment = { ...wallSpec, side: "우" };
const layout = computeRevetmentLayout(section, null);
return {
tiers: wallSpec.tiers,
extras: wallSpec.extras,
requested: layout?.requestedTiers ?? null,
walls: (layout?.walls ?? []).map((w) => ({ form: w.form, pure: r3(w.height + 0.5) })),
};
}
out.soil2 = shape("soil_guard", soilOptions);
out.wall1 = shape("retaining_wall", { height_m: 2.5, tier_1_height: 1.8 });
out.emptyBox = shape("soil_guard", { form: "돌망태", height_m: 2, tier_1_form: "" });
out.legacy = shape("soil_guard", { form: "돌망태", height_m: 2, tiers: 2 });
out.none = shape("retaining_wall", { height_m: 2.5 });
process.stdout.write(JSON.stringify(out));