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>
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
"""B06 라우터의 횡단 설계 파일 읽기와 프리뷰 계산."""
|
||||
|
||||
import json
|
||||
import logging
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
from B05_Profile.B05_Profile_Engine_Sections import cross_filename
|
||||
from B05_Profile.B05_Profile_Structures_Repository import load_structures
|
||||
from B05_Profile.B05_Profile_Structures_Schema import structure_type_map
|
||||
from B06_Section.B06_Section_Engine_Culvert import load_culvert_sets
|
||||
from B06_Section.B06_Section_Engine_Design import compute_cross_design
|
||||
from common_util.common_util_route_profile import design_elevation_from_longitudinal
|
||||
from config.config_system import STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
PREVIEW_DESIGN_FIELDS = (
|
||||
"ground_type",
|
||||
"roadbed_width_m",
|
||||
@@ -32,6 +38,104 @@ def pavement_suggestions(longitudinal: dict[str, Any]) -> dict[float, bool]:
|
||||
return mapping
|
||||
|
||||
|
||||
def pavement_ranges(project_root: Path) -> list[tuple[float, float]]:
|
||||
"""포장으로 볼 누가거리 구간 — 구조물 정본 G군 + 물넘이포장(포장 필수).
|
||||
|
||||
포장 지정은 **사용자가 구간으로 준다**(2026-08-28 사용자 확정). 종단경사 자동 판정은
|
||||
더 이상 포장을 켜지 않는다 — 경고 표기(`pavement_suggested`)만 남는다.
|
||||
물넘이포장은 콘크리트 등으로 노면을 만드는 시설이라 범위 안이 항상 포장이다.
|
||||
읽기 실패는 비치명 — 빈 목록이면 사용자 지정이 없는 것과 같다.
|
||||
"""
|
||||
ranges: list[tuple[float, float]] = []
|
||||
try:
|
||||
types = structure_type_map()
|
||||
for structure in load_structures(str(project_root))[1]:
|
||||
definition = types.get(structure.type_id)
|
||||
if definition is None or definition.group != "G":
|
||||
continue
|
||||
anchor = structure.chainage_m
|
||||
start = structure.start_m if structure.start_m is not None else anchor
|
||||
end = structure.end_m if structure.end_m is not None else anchor
|
||||
if start is None or end is None:
|
||||
continue
|
||||
ranges.append((min(float(start), float(end)), max(float(start), float(end))))
|
||||
except Exception: # noqa: BLE001 — 정본을 못 읽어도 설계 계산은 이어 간다
|
||||
logger.exception("B06 포장 구간을 읽지 못했습니다 (사용자 지정 없음으로 본다)")
|
||||
for chainage, spec in load_culvert_sets(project_root).items():
|
||||
if spec.get("type") != "ford_pavement":
|
||||
continue
|
||||
half = float(spec.get("span_m") or 0.0) / 2.0
|
||||
ranges.append((chainage - half, chainage + half))
|
||||
return ranges
|
||||
|
||||
|
||||
def paved_at(chainage_m: float, ranges: list[tuple[float, float]], stored: Any = None) -> bool:
|
||||
"""이 측점을 포장으로 볼 것인가 — 구간 안이면 강제, 밖이면 사용자 저장값(기본 비포장)."""
|
||||
for start, end in ranges:
|
||||
if start - 1e-9 <= chainage_m <= end + 1e-9:
|
||||
return True
|
||||
return bool(stored) if isinstance(stored, bool) else False
|
||||
|
||||
|
||||
# 사용자 조작값 — 포장 강제로 다시 계산해도 그대로 승계한다.
|
||||
_USER_TOUCHED_KEYS = (
|
||||
"display_half_width_m",
|
||||
"inlet_structure",
|
||||
"basin_adjust",
|
||||
"revet_adjust",
|
||||
"ford_adjust",
|
||||
"box_adjust",
|
||||
"extra_wall_counts",
|
||||
"revet_link_detached",
|
||||
"revet_follow_grade",
|
||||
)
|
||||
|
||||
|
||||
def enforce_pavement_ranges(
|
||||
longitudinal: dict[str, Any], cross_sections: list[dict[str, Any]], project_root: Path
|
||||
) -> int:
|
||||
"""포장 구간·물넘이 범위 안 측점을 포장으로 맞춘다 — 저장분이 비포장이어도 그렇다.
|
||||
|
||||
사용자가 구간을 지정하면 그 안 횡단도에 **자동 반영**된다(2026-08-28 사용자 확정).
|
||||
포장 여부는 횡단경사·포장층을 바꾸므로 플래그만 갈아 끼우지 않고 다시 계산한다.
|
||||
사용자 조작값(반폭·구조물 조정)은 그대로 승계한다.
|
||||
"""
|
||||
ranges = pavement_ranges(project_root)
|
||||
if not ranges:
|
||||
return 0
|
||||
changed = 0
|
||||
for section in cross_sections:
|
||||
design = section.get("design")
|
||||
if not isinstance(design, dict) or design.get("paved"):
|
||||
continue
|
||||
chainage = float(section.get("chainage_m", 0.0))
|
||||
if not paved_at(chainage, ranges):
|
||||
continue
|
||||
try:
|
||||
recomputed = compute_cross_design(
|
||||
section.get("samples", []),
|
||||
design_elevation_from_longitudinal(longitudinal, chainage),
|
||||
ground_type=str(design.get("ground_type") or "ripping_rock"),
|
||||
section_mode=str(design.get("section_mode") or "left_cut"),
|
||||
ditch_side=design.get("ditch_side"),
|
||||
ditch_type=str(design.get("ditch_type") or "standard"),
|
||||
paved=True,
|
||||
rock_boundary_offset_m=design.get(
|
||||
"rock_boundary_offset_m", STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M
|
||||
),
|
||||
two_stage_slope=bool(design.get("two_stage_slope", True)),
|
||||
ditch_enabled=design.get("ditch_enabled"),
|
||||
)
|
||||
except (ValueError, KeyError):
|
||||
continue
|
||||
for key in ("status", "pavement_suggested", *_USER_TOUCHED_KEYS):
|
||||
if design.get(key) is not None:
|
||||
recomputed[key] = design[key]
|
||||
section["design"] = recomputed
|
||||
changed += 1
|
||||
return changed
|
||||
|
||||
|
||||
def default_section_modes(longitudinal: dict[str, Any]) -> dict[float, str]:
|
||||
mapping: dict[float, str] = {}
|
||||
stations = longitudinal.get("stations")
|
||||
@@ -66,10 +170,13 @@ def read_cross_design_inputs(
|
||||
|
||||
|
||||
def attach_default_designs(
|
||||
longitudinal: dict[str, Any], cross_sections: list[dict[str, Any]]
|
||||
longitudinal: dict[str, Any],
|
||||
cross_sections: list[dict[str, Any]],
|
||||
project_root: Path | None = None,
|
||||
) -> None:
|
||||
modes = default_section_modes(longitudinal)
|
||||
pavement = pavement_suggestions(longitudinal)
|
||||
paved_ranges = pavement_ranges(project_root) if project_root else []
|
||||
for section in cross_sections:
|
||||
if section.get("design"):
|
||||
continue
|
||||
@@ -81,7 +188,8 @@ def attach_default_designs(
|
||||
design_elevation_from_longitudinal(longitudinal, chainage),
|
||||
ground_type="ripping_rock",
|
||||
section_mode=modes.get(round(chainage, 3), "left_cut"),
|
||||
paved=suggested,
|
||||
# 포장은 사용자 구간 지정만 켠다 — 경사 제안은 경고로만 남는다(2026-08-28).
|
||||
paved=paved_at(chainage, paved_ranges),
|
||||
rock_boundary_offset_m=STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M,
|
||||
)
|
||||
design.update(status="provisional", pavement_suggested=suggested)
|
||||
@@ -96,9 +204,11 @@ def recompute_designs_for_alignment(
|
||||
stored_designs: list[dict[str, Any]],
|
||||
standard: dict[str, Any] | None,
|
||||
rock_boundary_offsets: dict[str, float] | None = None,
|
||||
project_root: Path | None = None,
|
||||
) -> None:
|
||||
modes = default_section_modes(longitudinal)
|
||||
pavement = pavement_suggestions(longitudinal)
|
||||
paved_ranges = pavement_ranges(project_root) if project_root else []
|
||||
stored_by_chainage = {
|
||||
round(float(record["chainage_m"]), 3): (record.get("design") or {})
|
||||
for record in stored_designs
|
||||
@@ -122,7 +232,7 @@ def recompute_designs_for_alignment(
|
||||
section_mode=str(stored.get("section_mode") or modes.get(key, "left_cut")),
|
||||
ditch_side=stored.get("ditch_side"),
|
||||
ditch_type=str(stored.get("ditch_type") or "standard"),
|
||||
paved=bool(stored.get("paved", suggested)),
|
||||
paved=paved_at(chainage, paved_ranges, stored.get("paved")),
|
||||
standard=standard,
|
||||
rock_boundary_offset_m=session_offsets.get(
|
||||
key,
|
||||
@@ -145,3 +255,52 @@ def recompute_designs_for_alignment(
|
||||
if stored.get("box_adjust") is not None:
|
||||
design["box_adjust"] = stored["box_adjust"]
|
||||
section["design"] = design
|
||||
|
||||
|
||||
def compute_default_designs(
|
||||
project_root: Path,
|
||||
longitudinal_file_path: str,
|
||||
chainages: list[float],
|
||||
standard: dict[str, Any] | None = None,
|
||||
) -> list[tuple[float, dict[str, Any]]]:
|
||||
"""미지정 측점들을 기본값(리핑암 + 암반 경계 0.5m/상단측 절토)으로 계산한 목록을 만든다.
|
||||
|
||||
standard가 오면(확정 요청의 패널 편집값) 그 값으로 표준단면 기하를 계산한다.
|
||||
계획고 부재 등으로 계산 불가한 측점은 조용히 건너뛴다(확정을 막지 않기 위함).
|
||||
"""
|
||||
root = project_root.resolve()
|
||||
longitudinal_path = (root / longitudinal_file_path).resolve()
|
||||
if root not in longitudinal_path.parents or not longitudinal_path.is_file():
|
||||
return []
|
||||
longitudinal = json.loads(longitudinal_path.read_text(encoding="utf-8"))
|
||||
cross_dir = longitudinal_path.parent.parent / "cross_sections"
|
||||
default_modes = default_section_modes(longitudinal)
|
||||
pavement = pavement_suggestions(longitudinal)
|
||||
paved_ranges = pavement_ranges(root)
|
||||
results: list[tuple[float, dict[str, Any]]] = []
|
||||
for chainage_m in chainages:
|
||||
cross_path = cross_dir / cross_filename(chainage_m)
|
||||
if not cross_path.is_file():
|
||||
continue
|
||||
try:
|
||||
cross = json.loads(cross_path.read_text(encoding="utf-8"))
|
||||
samples = cross.get("samples")
|
||||
if not isinstance(samples, list):
|
||||
continue
|
||||
suggested = pavement.get(round(chainage_m, 3), False)
|
||||
design = compute_cross_design(
|
||||
samples,
|
||||
design_elevation_from_longitudinal(longitudinal, chainage_m),
|
||||
ground_type="ripping_rock",
|
||||
section_mode=default_modes.get(round(chainage_m, 3), "left_cut"),
|
||||
# 포장은 사용자 구간 지정만 켠다 — 경사 제안은 경고로만 남는다(2026-08-28).
|
||||
paved=paved_at(chainage_m, paved_ranges),
|
||||
standard=standard,
|
||||
rock_boundary_offset_m=STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M,
|
||||
)
|
||||
design["status"] = "provisional"
|
||||
design["pavement_suggested"] = suggested
|
||||
results.append((chainage_m, design))
|
||||
except (ValueError, KeyError, OSError, json.JSONDecodeError):
|
||||
continue
|
||||
return results
|
||||
|
||||
Reference in New Issue
Block a user