- logic 새 파일 다섯 — Cross_Wall_Geom(벽 1매) · Cross_Wall_Hatch_Geom(무늬 띠 · 물빼기 · 도수로 띠 · 원지반선) · Cross_Excavation_Geom(벽 터파기) · Cross_Design_Surface_Geom(암선 · 포장층) · Cross_Revetment_Geom(독립 기슭막이 배치) - logic 으로 옮김 — Body_Guard → Cross_Body_Guard · Structure_Layouts · Route_Carry_Patch(내용 그대로 · import 경로만) - inferStationInterval → common_util_station(글자표 없는 자리 · common_util_svg 는 다시 내보냄) — Node 묶음 ui_template_locale 끌림 끊음 - 부르는 쪽 import 줄 · 등록부 ts 경로 · 시험 · 도우미 경로 - test_472_3 GEOMETRY_PULLS 다섯 줄 걷음 · Wall_Hatch · Excavation · Design_Surface 세 줄은 Culvert · Box · Ford 그림 파일(518-2)이 그리기 함수로 부르는 동안 남김 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
134 lines
5.9 KiB
JavaScript
134 lines
5.9 KiB
JavaScript
/* PLAN 139-4 · 139-5 헬퍼 — 묻힌 흙막이 유출 끝 = 3도 절토선(면적에 듦) · 3도 선이 원지반을 못 만나면 복합경사.
|
|
* 화면 TS 를 그 자리에서 트랜스파일해 Node 로 돌림 · 결과 = 표준출력 JSON 한 벌. 짝 = `test_139_4_buried_outlet.py`.
|
|
* 입력 = 박스 352.14(`b06_73_4_body_guard_sections.json`) · 배관 85.052(`b07_cross_overlay_sections.json` · 원지반 고친 사본).
|
|
*/
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const { makeLoader } = require("./helper_ts_stub_loader.cjs");
|
|
const CATALOG = require("./helper_322_catalog_module.cjs"); // 구조물 표(322-1)
|
|
|
|
const ROOT = path.join(__dirname, "..", "..");
|
|
const STUBS = { "@ui/ui_template_toast": { showToast: () => undefined } };
|
|
|
|
const { loadTs } = makeLoader({
|
|
root: ROOT,
|
|
interop: true,
|
|
requireFor: (full) => (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)));
|
|
},
|
|
});
|
|
const resolve = (base) =>
|
|
[base, `${base}.ts`, path.join(base, "index.ts")].find(
|
|
(p) => fs.existsSync(p) && fs.statSync(p).isFile(),
|
|
) ?? `${base}.ts`;
|
|
|
|
const B06 = (f) => path.join(ROOT, "B06_Section", `${f}.ts`);
|
|
const { computeStoredLayouts } = loadTs(B06("logic/B06_Section_Structure_Layouts"));
|
|
const { computeStructureAreas } = loadTs(
|
|
path.join(ROOT, "common_util", "common_util_cross_structure_areas.ts"),
|
|
);
|
|
const { PIPE_CONNECT_GRADE } = loadTs(B06("logic/B06_Section_UI_Cross_Culvert_Const"));
|
|
const fixture = (name) =>
|
|
JSON.parse(fs.readFileSync(path.join(__dirname, "fixtures", name), "utf8")).cross_sections;
|
|
const clone = (v) => JSON.parse(JSON.stringify(v));
|
|
const r3 = (v) => Math.round(v * 1000) / 1000;
|
|
const same = (a, b) =>
|
|
Math.abs(a.offset - b.offset) < 1e-9 && Math.abs(a.elevation - b.elevation) < 1e-9;
|
|
|
|
const groundOf = (s) =>
|
|
s.samples
|
|
.filter((p) => p.valid !== false && typeof p.elevation_m === "number")
|
|
.map((p) => ({ offset: p.offset_m ?? 0, elevation: p.elevation_m }))
|
|
.sort((a, b) => a.offset - b.offset);
|
|
const groundZ = (s, offset) => {
|
|
const g = groundOf(s);
|
|
for (let i = 1; i < g.length; i += 1)
|
|
if (offset <= g[i].offset)
|
|
return (
|
|
g[i - 1].elevation +
|
|
((g[i].elevation - g[i - 1].elevation) * (offset - g[i - 1].offset)) /
|
|
(g[i].offset - g[i - 1].offset || 1)
|
|
);
|
|
return g[g.length - 1].elevation;
|
|
};
|
|
const areasOf = (s, trim) =>
|
|
computeStructureAreas({
|
|
designLine: s.design.design_line,
|
|
ground: groundOf(s),
|
|
trim,
|
|
rockBoundaryOffsetM: null,
|
|
});
|
|
|
|
/** 측점 하나 — 유출 끝 절토선 모양 · 그 선을 넣은 면적 대 뺀 면적. */
|
|
function study(section, list) {
|
|
const culvert = computeStoredLayouts(section, list).culvert;
|
|
const cut = culvert.outletFill.segments.filter((g) => g.kind === "cut");
|
|
const trim = culvert.designTrim;
|
|
// 옛 면적 = 유출 절토선 꼭짓점(시작점 빼고)을 사면 폴리선에서 걷어 낸 것
|
|
const drop = cut.flatMap((g) => g.points.slice(1));
|
|
const strip = (slope) =>
|
|
slope && { points: slope.points.filter((p) => !drop.some((q) => same(p, q))) };
|
|
const without = { ...trim, minSlope: strip(trim.minSlope), maxSlope: strip(trim.maxSlope) };
|
|
const withCut = areasOf(section, trim);
|
|
const withoutCut = areasOf(section, without);
|
|
return {
|
|
cut: cut.map((g) => {
|
|
const [a, b] = [g.points[0], g.points[g.points.length - 1]];
|
|
return {
|
|
points: g.points.length,
|
|
grade: r3((a.elevation - g.points[1].elevation) / Math.abs(g.points[1].offset - a.offset)),
|
|
rises: b.elevation > a.elevation,
|
|
endGap: r3(Math.abs(groundZ(section, b.offset) - b.elevation)),
|
|
};
|
|
}),
|
|
cutArea: r3(withCut?.cutAreaM2 ?? 0),
|
|
cutAreaWithout: r3(withoutCut?.cutAreaM2 ?? 0),
|
|
inTrim:
|
|
drop.length > 0 &&
|
|
[trim.minSlope, trim.maxSlope].some((sl) =>
|
|
sl?.points.some((p) => drop.some((q) => same(p, q))),
|
|
),
|
|
};
|
|
}
|
|
|
|
const out = { grade3: r3(PIPE_CONNECT_GRADE) };
|
|
// ① 박스 352.14 — 유출 흙막이 끝이 원지반에 묻힘
|
|
const bodies = fixture("b06_73_4_body_guard_sections.json");
|
|
out.box = study(
|
|
bodies.find((s) => Math.abs(s.chainage_m - 352.14) < 0.6),
|
|
bodies,
|
|
);
|
|
|
|
// ② 배관 85.052 — 유출 끝 바깥 원지반을 고쳐 묻힘(내림) · 오르막 두 갈래
|
|
const pipes = fixture("b07_cross_overlay_sections.json");
|
|
const pipe = pipes.find((s) => s.culvert && !s.culvert.hidden_pipe);
|
|
const base = computeStoredLayouts(pipe, pipes).culvert;
|
|
// 끝 구간 시작점(마지막 단 다음 자리) — 그 바깥 원지반만 고침
|
|
const tail = base.outletFill.segments[base.outletFill.segments.length - 1];
|
|
const start = tail.points[0];
|
|
const outward = Math.sign(tail.points[1].offset - start.offset) || 1;
|
|
out.pipeBase = base.outletFill.segments.map((g) => g.kind ?? "fill");
|
|
function reshaped(rise, slope) {
|
|
const s = clone(pipe);
|
|
for (const p of s.samples) {
|
|
const t = ((p.offset_m ?? 0) - start.offset) * outward;
|
|
// 시작점 바로 앞 표본까지(−1 m) — 보간이 시작점을 옛 지반에 두지 않게(371-1 벽 자리 이동)
|
|
if (t >= -1 && typeof p.elevation_m === "number")
|
|
p.elevation_m = start.elevation + rise + slope * t;
|
|
}
|
|
return study(
|
|
s,
|
|
pipes.map((x) => (x === pipe ? s : x)),
|
|
);
|
|
}
|
|
out.pipeDown = reshaped(0.3, -0.15); // 3도보다 가파르게 내림 → 3도 선이 만남
|
|
out.pipeUp = reshaped(0.3, 0.1); // 오르막 → 3도 선이 못 만남 → 복합경사
|
|
out.pipeOpen = reshaped(-0.3, -0.5); // 끝 바깥이 지반 아래로 열림 → 성토부선(371-1)
|
|
process.stdout.write(JSON.stringify(out));
|