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:
2026-10-09 15:12:57 +09:00
co-authored by Claude Opus 5.5
parent 3dffcfe89b
commit e055de13e1
8 changed files with 255 additions and 31 deletions
+13 -11
View File
@@ -102,6 +102,13 @@ export function appendCulvertOverlay(
line.append(title);
layer.append(line);
};
// 묻힌 끝 절토선 툴팁 — 3도 내림 선(끝이 시작보다 낮음) / 못 만나 복합경사 절토(139-4 · 139-5).
const cutLineTip = (name: string, segment: (typeof layout.outletFill.segments)[number]) => {
const [first, last] = [segment.points[0], segment.points[segment.points.length - 1]];
return last.elevation < first.elevation
? `${name} 3도 절토선 — 구조물이 원지반에 묻혀 원지반 교차까지 ${segment.lengthM.toFixed(2)}m`
: `${name} 절토선 — 3도 선이 원지반을 못 만나 절토 경사로 원지반까지`;
};
const drawOutletFill = (): void => {
// 도수로 · 돌붙임 띠(90-2) — 유출 끝 ~ 원지반 성토 조각(단 사이 포함) · 연동 카드엔 안 그림
if (culvert.chute && !linked)
@@ -113,13 +120,10 @@ export function appendCulvertOverlay(
toDisplayY,
);
for (const segment of layout.outletFill.segments) {
// 유출부가 지면에 닿은 뒤의 절토선은 그리지 않는다(2026-08-24 사용자) — 벽이
// 이미 원지반에 묻힌 구간이라 도면에 더 보탤 정보가 없다. 면적·수량 계산은
// 건드리지 않는다(그림만 — 면적은 전면 개편 대상).
// 세월교 · 박스 흙막이는 수평공간 뒤 절토선을 그림(79-7 · 면적에도 듦).
if (segment.kind === "cut" && !culvert.body) continue;
// 묻힌 유출 끝 = 3도 수평 절토선(보라 · 면적에도 듦 · 139-4) — 3도 선이 원지반을
// 못 만나면 복합경사 절토선(89-4).
if (segment.kind === "cut") {
planLine(segment.points, `유출부 절토선 — 수평공간 뒤 절토 경사로 원지반까지`);
planLine(segment.points, cutLineTip("유출부", segment));
continue;
}
planLine(
@@ -144,11 +148,9 @@ export function appendCulvertOverlay(
for (const segment of layout.basinFill.segments) {
planLine(
segment.points,
segment.kind === "cut" && culvert.body
? `${basinFillName} 절토선 — 수평공간 뒤 절토 경사로 원지반까지`
: segment.kind === "cut"
? `${basinFillName} 3도 절토선 — 구조물이 원지반에 묻혀 성토 불필요, 원지반 교차까지 ${segment.lengthM.toFixed(2)}m`
: `${basinFillName} 성토부선 — 사면길이 ${segment.lengthM.toFixed(2)}m` +
segment.kind === "cut"
? cutLineTip(basinFillName, segment)
: `${basinFillName} 성토부선 — 사면길이 ${segment.lengthM.toFixed(2)}m` +
(segment.overLimit
? " (법정 5m 이상 — 흙막이 의무 구간, 조정창에서 추가)"
: " (법정 5m 이내)") +
@@ -50,8 +50,8 @@ export interface OutletExtrasInput {
equalize?: boolean;
/** 단 벽의 전면 기울기 — 형태·순수 높이로 표준경사를 고름(없으면 종전 1:0.3). */
leanFor?: (form: string, pureHeightM: number) => number;
/** 끝이 원지반에 묻힐 때 수평공간 뒤 절토(본선과 같은 복합경사 · 91-4)로 지반까지(세월교 · 박스
* 흙막이 · 79-7). 없으면 종전 3도 선. */
/** 끝이 원지반에 묻혀 3도 선이 원지반을 못 만날 때만 — 수평공간 뒤 절토(본선과 같은 복합경사 ·
* 91-4)로 지반까지(139-4). 없으면 3도 선만(못 만나면 선 없음). */
cutBerm?: { lengthM: number; cut: StructureCutSpec };
}
@@ -379,14 +379,13 @@ export function buildOutletExtras(input: OutletExtrasInput): OutletExtrasResult
}
// 끝 구간(2026-08-22 사용자 ③): 시작점이 지반 위면 성토부선, 지반 아래(매몰)면
// **0도 절토선**을 원지반 교차까지 연장한다(교차가 없는 자리는 placeable이 막는다).
// **3도 내림 절토선**을 원지반 교차까지(139-4 · 139-5 — 끝 연결선 한 규칙). 3도 선이
// 원지반을 못 만나면(바깥이 오르막) 그때만 수평공간 뒤 복합경사 절토(`cutBerm` · 89-4).
let addable = false;
if (groundAt(src.offset) < src.elevation - 0.01) {
const tail = trailingFill(src, outward, groundAt);
segments.push(tail);
addable = tail.overLimit;
} else if (input.cutBerm) {
segments.push(bermCut(src, outward, input.cutBerm, groundAt, limitOffset));
} else {
const cross = slopedCrossing(src, outward, -PIPE_CONNECT_GRADE, groundAt, limitOffset);
if (cross !== null) {
@@ -400,6 +399,8 @@ export function buildOutletExtras(input: OutletExtrasInput): OutletExtrasResult
overLimit: false,
kind: "cut",
});
} else if (input.cutBerm) {
segments.push(bermCut(src, outward, input.cutBerm, groundAt, limitOffset));
}
}
return { walls, segments, appliedAdjusts, addable };
@@ -642,7 +642,7 @@ export function computeCulvertLayout(
trimMinSlope = { points: [...(trimMinSlope?.points ?? []), ...points] };
}
};
extendTrimSlope(drawnFillPoints(extrasForArea, !!body), outletInfo.outward);
extendTrimSlope(drawnFillPoints(extrasForArea, true), outletInfo.outward); // 묻힌 유출 3도 절토(139-4)
extendTrimSlope(drawnFillPoints(basinExtrasForArea, !!body), inletInfo.outward);
const ownTrim: CulvertDesignTrim | null =
@@ -42,8 +42,8 @@ export const outletPipeEnd = (wall: WallLayout): OffsetPoint => {
// 다단 기슭막이의 성토부선까지 트림에 넣는다 — 넣지 않으면 단을 올려도 폐회로가 그대로라
// **물량이 안 바뀐다**(2026-09-07 사용자 확정). 화면이 그리는 선(`outletFill.segments`)과
// 같은 선을 면적도 보게 맞춘다 — 그리지 않는 `cut` 갈래(벽이 원지반에 묻힌 자리)는 뺀다.
// 세월교 · 박스 흙막이(`withCut`)는 수평공간 뒤 절토선을 그리므로 넣음(79-7).
// 같은 선을 면적도 보게 맞춘다 — `withCut` 이면 묻힌 끝 절토선(`cut` 갈래)도 넣음(유출 = 늘 ·
// 139-4 · 계류측 = 세월교 · 박스만 79-7). 집수정 계류측 3도 선은 그림만.
export const drawnFillPoints = (result: OutletExtrasResult, withCut = false): OffsetPoint[] =>
result.segments
.filter((segment) => withCut || segment.kind !== "cut")
@@ -85,15 +85,16 @@ export function buildCulvertTiers(input: {
section_mode: section.design?.section_mode,
side: culvert?.hidden_pipe ? culvert.inlet.face_side : null,
});
// 세월교 · 박스 흙막이 끝 절토 = 컨테이너 수평공간 뒤 절토 경사(79-7) · 배관은 종전(3도 선).
const cutBerm = (lengthM: number) =>
culvert?.body
? { lengthM: Math.max(lengthM, 0), cut: structureCutSpec(section.design) }
: undefined;
// 묻힌 끝 = 3도 절토선 먼저 · 원지반을 못 만나면 수평공간 뒤 절토 경사(139-4 · 139-5 — 배관 ·
// 세월교 · 박스 한 규칙). 수평공간 = 세월교 · 박스 유입 흙막이 값(79-7)만 · 나머지는 0.
const cutBerm = (lengthM: number) => ({
lengthM: Math.max(lengthM, 0),
cut: structureCutSpec(section.design),
});
// 성토부선 + 다단 기슭막이(2026-08-22 — 보호공 삭제, 윗면 선만 성토부선으로).
// 유출측과 **집수정 계류측**이 같은 체계를 쓴다: 5m 넘으면 다단을 둘 수 있다.
const outletInput = {
cutBerm: cutBerm(0), // 유출 수평공간 없음 — 끝이 원지반에 묻히면 바로 절토(89-4)
cutBerm: cutBerm(0), // 유출 수평공간 없음 — 3도 선이 못 만날 때만 바로 절토(89-4)
startBottomElevation: input.outletBottom,
outward: input.outletInfo.outward,
groundAt,
@@ -107,7 +108,7 @@ export function buildCulvertTiers(input: {
// 독립 기슭막이(관 숨김)는 집수정이 없어 이 채널이 **유입측 벽의 성토부선·다단**이다 —
// 유출측(`extras`)과 같은 시작점(관 하단 꼭짓점)·같은 `bextra` 키(2026-08-29 사용자).
const basinInput = {
cutBerm: cutBerm(culvert?.inlet.revet_berm_m ?? GUARD_CUT_BERM_M),
cutBerm: cutBerm(culvert?.body ? (culvert.inlet.revet_berm_m ?? GUARD_CUT_BERM_M) : 0),
startBottomElevation: input.basinBottom,
outward: input.inletInfo.outward,
groundAt,
@@ -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
)
+7 -3
View File
@@ -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:
+3 -2
View File
@@ -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