feat(b06): 묻힌 흙막이 끝 = 3도 수평 절토선 · 못 만나면 복합경사 · 유출 절토 면적 반영(139-4 · 139-5)
- 끝 연결선 한 규칙: 묻히면 3도 내림 선 먼저 · 원지반 못 만나면 수평공간 뒤 절토 경사(배관 · 세월교 · 박스) - 유출 3도 절토선 = 보라 선으로 그림 · 폐회로 절토 면적에 넣음(집수정 계류측은 그림만) - 시험 test_139_4_buried_outlet.py 새로 · test_79 · test_91 유출 기대 고침 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018jonfdxn1Xit9bdkNJpE4G
This commit is contained in:
@@ -0,0 +1,142 @@
|
||||
/* 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 ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
||||
|
||||
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);
|
||||
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 (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 B06 = (f) => path.join(ROOT, "B06_Section", `${f}.ts`);
|
||||
const { computeStoredLayouts } = loadTs(B06("B06_Section_Structure_Layouts"));
|
||||
const { computeStructureAreas } = loadTs(
|
||||
path.join(ROOT, "common_util", "common_util_cross_structure_areas.ts"),
|
||||
);
|
||||
const { PIPE_CONNECT_GRADE } = loadTs(B06("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;
|
||||
if (t >= 0 && 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도 선이 못 만남 → 복합경사
|
||||
process.stdout.write(JSON.stringify(out));
|
||||
@@ -0,0 +1,73 @@
|
||||
"""PLAN 139-4 · 139-5 — 묻힌 흙막이 유출 끝 = 3도 수평 절토선(보라 · 절토 면적) · 못 만나면 복합경사.
|
||||
|
||||
짝: `B06_Section/B06_Section_UI_Cross_Culvert_Extra.ts`(끝 구간 규칙) · `_Culvert_Tiers.ts`(채널 입력) ·
|
||||
`_Culvert_Geom.ts`(유출 절토선 면적에 넣음) · `_Culvert.ts`(그림 · 툴팁). 실제 TS 를 `helper_139_4_buried_outlet.cjs` 가 돌린다.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
import pytest
|
||||
|
||||
HERE = os.path.dirname(__file__)
|
||||
ROOT = os.path.join(HERE, "..", "..")
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not os.path.isdir(os.path.join(ROOT, "config", "node_modules")),
|
||||
reason="프론트엔드 의존성 미설치",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def out() -> dict:
|
||||
proc = subprocess.run( # noqa: S603 — 고정 실행 파일
|
||||
["node", os.path.join(HERE, "helper_139_4_buried_outlet.cjs")],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=60,
|
||||
)
|
||||
assert proc.returncode == 0, proc.stderr
|
||||
return json.loads(proc.stdout)
|
||||
|
||||
|
||||
def _src(rel: str) -> str:
|
||||
with open(os.path.join(ROOT, rel), encoding="utf-8") as f:
|
||||
return f.read()
|
||||
|
||||
|
||||
@pytest.mark.parametrize("case", ["box", "pipeDown"])
|
||||
def test_묻힌_유출_끝은_3도_절토선_면적에_듦(out: dict, case: str) -> None:
|
||||
"""세월교 · 박스 흙막이도 배관 관보호공도 같은 3도 선 · 원지반 교점에서 끝 · 절토 면적 > 0."""
|
||||
study = out[case]
|
||||
assert study["cut"] == [{"points": 2, "grade": out["grade3"], "rises": False, "endGap": 0}]
|
||||
assert study["inTrim"] is True
|
||||
assert study["cutArea"] - study["cutAreaWithout"] > 0.1
|
||||
|
||||
|
||||
def test_3도_선이_원지반을_못_만나면_복합경사(out: dict) -> None:
|
||||
"""유출 바깥이 오르막 — 그때만 절토 경사(1:1.0)로 원지반까지."""
|
||||
study = out["pipeUp"]
|
||||
assert len(study["cut"]) == 1
|
||||
tail = study["cut"][0]
|
||||
assert tail["rises"] is True and tail["grade"] == -1 and tail["endGap"] == 0
|
||||
assert study["cutArea"] > study["cutAreaWithout"]
|
||||
|
||||
|
||||
def test_성토_끝은_그대로(out: dict) -> None:
|
||||
assert out["pipeBase"] == ["fill", "fill"] # 묻히지 않은 기본 = 성토부선 그대로
|
||||
|
||||
|
||||
def test_유출_절토선은_그리고_면적에_넣음() -> None:
|
||||
culvert = _src("B06_Section/B06_Section_UI_Cross_Culvert.ts")
|
||||
assert 'if (segment.kind === "cut" && !culvert.body) continue;' not in culvert
|
||||
assert 'planLine(segment.points, cutLineTip("유출부", segment));' in culvert
|
||||
geom = _src("B06_Section/B06_Section_UI_Cross_Culvert_Geom.ts")
|
||||
assert "extendTrimSlope(drawnFillPoints(extrasForArea, true), outletInfo.outward);" in geom
|
||||
# 집수정 계류측 3도 선은 그림만(면적 밖) — 세월교 · 박스 계류측만 면적
|
||||
assert (
|
||||
"extendTrimSlope(drawnFillPoints(basinExtrasForArea, !!body), inletInfo.outward);" in geom
|
||||
)
|
||||
@@ -8,6 +8,7 @@
|
||||
"""
|
||||
|
||||
import json
|
||||
import math
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -87,13 +88,16 @@ def test_흙막이_끝_절토는_수평공간_뒤(shape: dict) -> None:
|
||||
assert tail["flat"] == pytest.approx(0, abs=1e-6)
|
||||
assert tail["berm"] == pytest.approx(1.0, abs=1e-3)
|
||||
else:
|
||||
# 유출은 수평공간 없음 — 묻히면 첫 꺾임부터 바로 절토(89-4)
|
||||
assert tail["flat"] > 0
|
||||
# 유출 = 묻히면 3도 내림 절토선 하나로 원지반까지(139-4)
|
||||
assert tail["points"] == 2
|
||||
assert tail["flat"] == pytest.approx(
|
||||
-tail["berm"] * math.tan(math.radians(3)), abs=2e-3
|
||||
)
|
||||
for tail in shape["cutBerm2"]:
|
||||
if tail["role"] == "inlet":
|
||||
assert tail["berm"] == pytest.approx(2.0, abs=1e-3)
|
||||
else:
|
||||
assert tail["flat"] > 0
|
||||
assert tail["points"] == 2 and tail["flat"] < 0 # 유출 수평공간 칸 무시 · 3도 선
|
||||
|
||||
|
||||
def test_유입_수평공간_시작은_본체_바닥(shape: dict) -> None:
|
||||
|
||||
@@ -96,9 +96,10 @@ def _knee(cut: dict) -> bool:
|
||||
def test_흙막이_수평공간_뒤_절토_복합경사(fit: dict) -> None:
|
||||
tails = fit["guardTails"]
|
||||
assert tails and all(cut["endGap"] < 0.01 for cut in tails)
|
||||
# 유입 = 수평공간 먼저 · 유출 = 수평공간 없이 바로 절토(89-4)
|
||||
# 유입 = 3도 선이 못 만나 수평공간 뒤 복합경사 · 유출 = 묻히면 3도 내림 선 하나(139-4)
|
||||
for cut in tails:
|
||||
assert (cut["legs"][0]["ratio"] is None) == (cut["role"] == "inlet")
|
||||
assert cut["legs"][0]["ratio"] is None
|
||||
assert (len(cut["legs"]) == 1) == (cut["role"] == "outlet")
|
||||
assert sum(_knee(cut) for cut in tails) >= 2
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user