Files
Aislo/B06_Section/B06_Section_UI_Cross_Ford_Pavement.ts
T
eomsangdonandClaude Opus 5 80c2a265f9 feat(B05,B06): 물넘이 횡단 표현 + 포장 구간 수기 지정, 경사 자동 포장 폐지
2026-08-28 사용자 확정 스펙.

물넘이포장 — 노면을 판 자리로 그린다
- 서버가 _ford_pavement_set(월류 폭·월류 높이·바닥 경사)을 만들고 물넘이만
  span 연동을 켜 **범위 안 측점 전부**에 얹는다. 깊이가 없으면 None으로 두어
  화면이 그리지 않는다(수치를 지어내지 않는다).
- 횡단도: 기존 계획고 점선 + 물넘이 바닥 실선 + 진한 회색 빗금 포장.
  깊이는 노선 중심 기준, 바닥은 유입(상단측)이 높게 기운다. 경사를 비우면
  그 측점의 노면 횡단경사를 쓴다.
- 물넘이 폼에 "바닥 경사 유입→유출(%)" 칸을 추가하고, 월류 폭 기본값
  리터럴을 config_frontend 상수로 모아 서버 값과 짝지었다.

포장 — 사용자가 구간으로 지정한다
- 구조물 레지스트리 G군 pavement_concrete 를 되살려 기준측점 + 길이 + 전/후로
  받는다(기슭막이와 같은 폼). 길이 기본값은 0 = 미지정.
- pavement_ranges/paved_at 이 구간을 판정하고, enforce_pavement_ranges 가
  저장분이 비포장이어도 구간 안이면 포장으로 다시 계산한다(사용자 조작값 승계).
- **종단경사 자동 포장 적용을 없앴다** — paved=suggested 3곳 제거. 별표1-2 상한
  초과 경고(pavement_suggested 배지·근거 문구)는 그대로 남는다.
- 포장 구간이 물넘이를 통째로 품으면 모달로 알리고 앞/뒤로 나눠 저장하고,
  끝만 걸치면 값을 고치라고 안내하고 멈춘다.

700줄 제한: _compute_default_designs 를 Router_Design 으로 옮겼다(657/306줄).

검증: pytest 238 passed / 7 skipped(신규 9건). 공용 브라우저 실측 — 물넘이 임시
투입 시 240m 카드에만 파임 3요소가 그려지고(일반 포장 박스 0), 바닥이 계획고보다
0.4m 아래·노면 전폭 4.0m에 1.5% 기울기, 220·260은 비포장 유지. 겹침 규칙은
브라우저에서 모듈을 직접 불러 3분할·안내·취소를 확인했다. 실측용 임시 관 지점은
매번 원래 정본 4건으로 복구했다.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-28 12:16:38 +09:00

123 lines
4.9 KiB
TypeScript

/* =============================================================================
* B06_Section_UI_Cross_Ford_Pavement.ts
* 물넘이포장 — 계획고를 파낸 노면을 횡단도에 그린다(2026-08-28 사용자 확정).
*
* 다른 시설은 구조물을 얹지만 물넘이는 **노면 자체가 내려앉는다**. 그래서 그림도 다르다.
* · 파임 범위 = 노견까지 **전폭**.
* · 깊이 = **노선 중심**에서 잰 월류 높이(`depth_m`).
* · 바닥은 **유입(상류)이 높고 유출이 낮게** 기운다. 경사를 비우면 그 측점의 노면
* 횡단경사(`cross_slope_pct`)를 쓴다 — 사용자가 폼에서 바꿀 수 있다.
* · 기존 계획고는 **점선**, 물넘이 바닥은 **실선**.
* · 포장 필수 — 일반 포장층과 구분되게 진한 회색 + 빗금으로 채운다.
*
* 유입측 판정은 `section_mode`(상단측 절토 = 등고가 높은 쪽 = 상류)를 따른다.
* ========================================================================== */
import type { CrossDesign } from "./B06_Section_Api_Fetch";
const SVG_NS = "http://www.w3.org/2000/svg";
/** 빗금 패턴 id는 문서 안에서 유일해야 한다 — 카드마다 하나씩 번호를 준다. */
let hatchSeq = 0;
/** 백엔드 `section.ford_pavement` 제원(치수 결정은 서버 몫 — 여기서는 좌표만 만든다). */
export interface FordPavementSpec {
span_m: number;
/** 노선 중심에서 잰 파임 깊이(m). 없으면 그리지 않는다 — 수치를 지어내지 않는다. */
depth_m: number | null;
/** 유입 → 유출 바닥 경사(%). 비우면 노면 횡단경사를 쓴다. */
slope_pct: number | null;
}
interface Edge {
offset_m: number;
elevation_m: number;
}
/** 유입측(상류) 부호 — 그 방향으로 갈수록 바닥이 높아진다. */
function inflowSign(design: CrossDesign, offsetM: number): number {
const inflowLeft = design.section_mode !== "right_cut";
const towardLeft = offsetM > 0;
return towardLeft === inflowLeft ? 1 : -1;
}
function bottomAt(design: CrossDesign, spec: FordPavementSpec, edge: Edge): number {
const depth = spec.depth_m ?? 0;
const slope = (spec.slope_pct ?? design.cross_slope_pct) / 100;
const center = design.design_elevation_m ?? edge.elevation_m;
return center - depth + slope * Math.abs(edge.offset_m) * inflowSign(design, edge.offset_m);
}
function line(points: string[], className: string): SVGPolylineElement {
const polyline = document.createElementNS(SVG_NS, "polyline");
polyline.setAttribute("points", points.join(" "));
polyline.setAttribute("class", className);
return polyline;
}
/**
* 물넘이 파임을 그린다. 그렸으면 true — 호출부는 일반 포장층 박스를 건너뛴다
* (같은 자리에 두 겹으로 깔리면 색 구분이 사라진다).
*/
export function appendFordPavementOverlay(
svg: SVGElement,
spec: FordPavementSpec | undefined,
design: CrossDesign,
x: (offset: number) => number,
y: (elevation: number) => number,
): boolean {
if (!spec || !spec.depth_m || !design.road_edges) return false;
const { left, right } = design.road_edges;
const bottomLeft = bottomAt(design, spec, left);
const bottomRight = bottomAt(design, spec, right);
// ① 기존 계획고(점선) — 파기 전 노면이 어디였는지 남긴다.
svg.append(
line(
[
`${x(left.offset_m)},${y(left.elevation_m)}`,
`${x(right.offset_m)},${y(right.elevation_m)}`,
],
"b06-chart__ford-deck-plan",
),
);
// ② 포장층 — 바닥선에서 두께만큼 아래로. 일반 포장과 색·빗금으로 구분한다.
const thickness = design.pavement_thickness_m ?? 0.2;
const hatchId = `b06-ford-hatch-${(hatchSeq += 1)}`;
const defs = document.createElementNS(SVG_NS, "defs");
const pattern = document.createElementNS(SVG_NS, "pattern");
pattern.setAttribute("id", hatchId);
pattern.setAttribute("patternUnits", "userSpaceOnUse");
pattern.setAttribute("width", "6");
pattern.setAttribute("height", "6");
const stroke = document.createElementNS(SVG_NS, "path");
stroke.setAttribute("d", "M0,6 L6,0");
stroke.setAttribute("class", "b06-chart__ford-pavement-hatch");
pattern.append(stroke);
defs.append(pattern);
svg.append(defs);
const polygon = document.createElementNS(SVG_NS, "polygon");
polygon.setAttribute(
"points",
[
`${x(left.offset_m)},${y(bottomLeft)}`,
`${x(right.offset_m)},${y(bottomRight)}`,
`${x(right.offset_m)},${y(bottomRight - thickness)}`,
`${x(left.offset_m)},${y(bottomLeft - thickness)}`,
].join(" "),
);
polygon.setAttribute("class", "b06-chart__ford-pavement");
polygon.setAttribute("fill", `url(#${hatchId})`);
svg.append(polygon);
// ③ 물넘이 바닥(실선) — 횡단 기준선이라 가장 위에 올린다.
svg.append(
line(
[`${x(left.offset_m)},${y(bottomLeft)}`, `${x(right.offset_m)},${y(bottomRight)}`],
"b06-chart__ford-deck",
),
);
return true;
}