fix(B06): 단면 유형 없는 옛 설계 기본값 = 상단측 깎기 하나 (PLAN 472-8 ① · 요구 409)
- 브라우저 다시 셈(Cross_Refresh_Calc) · 묶음 cross 단계(Cross_Stage) 의 좌 깎기 고정 폴백 걷음 · cross 단계는 이미 있는 uphillSide(Pipeline_Detail) 다시 씀 - 서버 [저장] 두 길도 같은 규칙 — 파이썬 stored_section_mode(Router_Design 셋 · SampleExtend) · Node Cross_Save storedOptions · Node 에 측점 uphill_side 넘김(Server_Calc_Prebuild) · 화면만 상단측이면 [저장] 뒤 좌 깎기로 뒤집혀 같이 고침 - 값 바뀜 = section_mode 없는 설계뿐(지금 DB 16 측점 · 한 프로젝트) · 그 밖 0 차 - 거울 시험 test_472_8_section_mode_default(파이썬 = Node = 브라우저 · 없음 = 상단측 적음) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -127,6 +127,7 @@ def extend_unclosed_sections(
|
||||
ford_surface_drops,
|
||||
stored_berm,
|
||||
stored_cut_slope,
|
||||
stored_section_mode,
|
||||
)
|
||||
from common_util.common_util_route_profile import design_elevation_from_longitudinal
|
||||
from config.config_system import STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M
|
||||
@@ -146,7 +147,7 @@ def extend_unclosed_sections(
|
||||
elevation = design_elevation_from_longitudinal(longitudinal, chainage)
|
||||
options = dict(
|
||||
ground_type=str(design.get("ground_type") or "ripping_rock"),
|
||||
section_mode=str(design.get("section_mode") or "left_cut"),
|
||||
section_mode=stored_section_mode(design, section),
|
||||
ditch_side=design.get("ditch_side"),
|
||||
ditch_type=str(design.get("ditch_type") or "standard"),
|
||||
paved=bool(design.get("paved", False)),
|
||||
|
||||
@@ -179,7 +179,7 @@ def enforce_pavement_ranges(
|
||||
try:
|
||||
options = dict(
|
||||
ground_type=str(design.get("ground_type") or "ripping_rock"),
|
||||
section_mode=str(design.get("section_mode") or "left_cut"),
|
||||
section_mode=stored_section_mode(design, section),
|
||||
ditch_side=design.get("ditch_side"),
|
||||
ditch_type=str(design.get("ditch_type") or "standard"),
|
||||
paved=wanted,
|
||||
@@ -230,7 +230,7 @@ def enforce_design_lines(
|
||||
try:
|
||||
options = dict(
|
||||
ground_type=str(design.get("ground_type") or "ripping_rock"),
|
||||
section_mode=str(design.get("section_mode") or "left_cut"),
|
||||
section_mode=stored_section_mode(design, section),
|
||||
ditch_side=design.get("ditch_side"),
|
||||
ditch_type=str(design.get("ditch_type") or "standard"),
|
||||
paved=bool(design.get("paved", False)),
|
||||
@@ -280,7 +280,7 @@ def enforce_ford_surface_drops(
|
||||
try:
|
||||
options = dict(
|
||||
ground_type=str(design.get("ground_type") or "ripping_rock"),
|
||||
section_mode=str(design.get("section_mode") or "left_cut"),
|
||||
section_mode=stored_section_mode(design, section),
|
||||
ditch_side=design.get("ditch_side"),
|
||||
ditch_type=str(design.get("ditch_type") or "standard"),
|
||||
paved=bool(design.get("paved", False)),
|
||||
@@ -395,6 +395,16 @@ def attach_default_designs(
|
||||
section["design"] = design
|
||||
|
||||
|
||||
def stored_section_mode(stored: dict[str, Any], section: dict[str, Any]) -> str:
|
||||
"""저장분 단면 유형 — 없으면(옛 설계) 상단측 깎기(지형이 정함 · 요구 409) · 상단측 모르면 좌.
|
||||
|
||||
짝: TS `B06_Section_Cross_Save` storedOptions · `B06_Section_Cross_Refresh_Calc` ·
|
||||
`B06_Section_Cross_Stage`(`uphillSide`) · 거울 시험 `test_472_8_section_mode_default.py`.
|
||||
"""
|
||||
side = section.get("uphill_side")
|
||||
return str(stored.get("section_mode") or f"{side if side in ('left', 'right') else 'left'}_cut")
|
||||
|
||||
|
||||
def stored_cut_slope(stored: dict[str, Any]) -> float | None:
|
||||
"""저장분에 남은 측점별 암 절토 경사비 — 없거나 0(표준값으로 되돌림)이면 None.
|
||||
|
||||
|
||||
@@ -310,7 +310,7 @@ def _enforce_on_node(
|
||||
from common_util.common_util_json import atomic_write_json
|
||||
from config.config_system import STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M
|
||||
|
||||
keys = ("chainage_m", "design", "samples", "frame", *CURVE_KEYS)
|
||||
keys = ("chainage_m", "design", "samples", "frame", "uphill_side", *CURVE_KEYS)
|
||||
profiles = longitudinal.get("design_profiles") or []
|
||||
results = run_calc(
|
||||
["cross.enforce"],
|
||||
|
||||
@@ -209,9 +209,12 @@ export function refreshDesigns(
|
||||
groundType:
|
||||
choice?.ground_type ??
|
||||
(typeof design.ground_type === "string" ? design.ground_type : "ripping_rock"),
|
||||
// 없으면(옛 설계) 상단측 깎기 · 모르면 좌(요구 409 · 서버 `stored_section_mode` 짝)
|
||||
sectionMode:
|
||||
choice?.section_mode ??
|
||||
(typeof design.section_mode === "string" ? design.section_mode : "left_cut"),
|
||||
(typeof design.section_mode === "string" && design.section_mode
|
||||
? design.section_mode
|
||||
: `${section.uphill_side === "right" ? "right" : "left"}_cut`),
|
||||
ditchSide:
|
||||
choice?.ditch_side ?? (typeof design.ditch_side === "string" ? design.ditch_side : null),
|
||||
// 저장분은 측구가 없으면 `ditch_type: null` 이다 — 서버와 같이 기본형으로 되돌린다.
|
||||
|
||||
@@ -165,7 +165,10 @@ export function elevationAt(
|
||||
function storedOptions(design: Raw, section: Raw, rockDefaultM: number): Raw {
|
||||
return {
|
||||
ground_type: String(design.ground_type || "ripping_rock"),
|
||||
section_mode: String(design.section_mode || "left_cut"),
|
||||
// 없으면(옛 설계) 상단측 깎기 · 모르면 좌(요구 409 · 파이썬 `stored_section_mode`)
|
||||
section_mode: String(
|
||||
design.section_mode || `${section.uphill_side === "right" ? "right" : "left"}_cut`,
|
||||
),
|
||||
ditch_side: design.ditch_side ?? null,
|
||||
ditch_type: String(design.ditch_type || "standard"),
|
||||
paved: Boolean(design.paved),
|
||||
@@ -190,6 +193,7 @@ export interface SaveSection {
|
||||
plan_radius_m?: number | null;
|
||||
curve_outer_side?: string | null;
|
||||
curve_widening_m?: number | null;
|
||||
uphill_side?: "left" | "right" | null;
|
||||
}
|
||||
|
||||
export interface SaveCrossInput {
|
||||
|
||||
@@ -29,10 +29,11 @@ import { extendUnclosed } from "../../B05_Profile/logic/B05_Profile_Sections_Gro
|
||||
import type { DtmGrid } from "@util/common_util_surface_sampler";
|
||||
import type { CulvertPipePoint } from "@util/common_util_culvert_sets";
|
||||
import { facilityAt, facilityRanges, type FacilityStructure } from "./B06_Section_Cross_Enforce";
|
||||
import { uphillSide } from "../../B05_Profile/logic/B05_Profile_Pipeline_Detail";
|
||||
|
||||
export { groundSamples };
|
||||
|
||||
/** 측점 하나의 횡단 입력 — 비면 기본(지반 리핑암 · 좌절토 · 표준 측구 · 표준 경사). 확폭은 측점(stations)이 줌. */
|
||||
/** 측점 하나의 횡단 입력 — 비면 기본(지반 리핑암 · 상단측 절토 · 표준 측구 · 표준 경사). 확폭은 측점(stations)이 줌. */
|
||||
export type CrossStationInput = Partial<
|
||||
Omit<CrossDesignOptions, "standard" | "planRadiusM" | "curveOuterSide" | "curveWideningM">
|
||||
>;
|
||||
@@ -53,7 +54,7 @@ function optionsFor(
|
||||
): CrossDesignOptions {
|
||||
return {
|
||||
groundType: "ripping_rock",
|
||||
sectionMode: "left_cut",
|
||||
sectionMode: `${uphillSide(station) ?? "left"}_cut`, // 상단측 깎기 · 모르면 좌(요구 409)
|
||||
ditchType: "standard",
|
||||
...input,
|
||||
standard,
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* PLAN 472-8 헬퍼 — 브라우저 다시 셈(`B06_Section_Cross_Refresh_Calc.refreshDesigns`)을 Node 로.
|
||||
* 입력 argv[2] JSON {sections, plan: [[누가거리, 계획고]], standard} · 결과 = 표준출력 JSON(측점 설계 목록).
|
||||
* 짝 = `test_472_8_section_mode_default.py`. */
|
||||
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();
|
||||
function loadTs(full) {
|
||||
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 },
|
||||
}).outputText;
|
||||
const box = { exports: {} };
|
||||
cache.set(full, box.exports);
|
||||
const localRequire = (request) => {
|
||||
if (request.endsWith(".json"))
|
||||
return require(
|
||||
request.startsWith("@util/")
|
||||
? path.join(ROOT, "common_util", request.slice(6))
|
||||
: path.join(path.dirname(full), request),
|
||||
);
|
||||
if (request.startsWith("@util/"))
|
||||
return loadTs(path.join(ROOT, "common_util", `${request.slice(6)}.ts`));
|
||||
if (request.startsWith(".")) return loadTs(path.join(path.dirname(full), `${request}.ts`));
|
||||
return require(request);
|
||||
};
|
||||
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
||||
return box.exports;
|
||||
}
|
||||
|
||||
const job = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
||||
const { refreshDesigns } = loadTs(
|
||||
path.join(ROOT, "B06_Section", "logic", "B06_Section_Cross_Refresh_Calc.ts"),
|
||||
);
|
||||
const samples = job.plan.map(([chainage_m, elevation_m]) => ({ chainage_m, elevation_m }));
|
||||
const alignment = {
|
||||
stations: samples.map((s) => ({ chainage_m: s.chainage_m, plan_elevation_m: s.elevation_m })),
|
||||
samples,
|
||||
balance: { cut_area_m2: 0, fill_area_m2: 0, cut_volume_m3: 0, fill_volume_m3: 0 },
|
||||
};
|
||||
const detail = { longitudinal: { design_profiles: [] }, cross_sections: job.sections };
|
||||
refreshDesigns(
|
||||
detail,
|
||||
{
|
||||
alignment,
|
||||
standard: job.standard,
|
||||
rockOffsets: [],
|
||||
rockDefault: job.rockDefault,
|
||||
cutSlopes: [],
|
||||
bermSpans: null,
|
||||
bermDepths: [],
|
||||
choices: [],
|
||||
shoulderExtends: [],
|
||||
canon: [],
|
||||
},
|
||||
null,
|
||||
);
|
||||
process.stdout.write(JSON.stringify(detail.cross_sections.map((s) => s.design)));
|
||||
@@ -0,0 +1,118 @@
|
||||
"""PLAN 472-8 (요구 409) — 단면 유형이 없는 (옛) 설계의 기본 = 상단측 깎기 하나
|
||||
(지형이 정함 · 모르면 좌).
|
||||
|
||||
못박는 것
|
||||
- 서버 [저장] 파이썬 길(`stored_section_mode`)
|
||||
= Node 길(TS `B06_Section_Cross_Save` storedOptions).
|
||||
- 브라우저 다시 셈(TS `B06_Section_Cross_Refresh_Calc`) = 같은 규칙.
|
||||
- 셋 다 「단면 유형 없음」 = 「상단측 깎기를 적어 넣음」과 0 차
|
||||
· 우 상단측 측점은 옛 좌 깎기와 다름.
|
||||
- 묶음 cross 단계(`B06_Section_Cross_Stage`) 기본도 상단측
|
||||
(`uphillSide` 다시 씀 · 좌 고정 폴백 없음).
|
||||
|
||||
./venv/Scripts/python.exe -m pytest resources/tester/test_472_8_section_mode_default.py -q
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import copy
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
ROOT = HERE.parents[1]
|
||||
for path in (ROOT, HERE):
|
||||
if str(path) not in sys.path:
|
||||
sys.path.insert(0, str(path))
|
||||
|
||||
from test_511_b4_cross_save_mirror import SURFACE, _facilities, _npz, _plan, _sections # noqa: E402
|
||||
|
||||
from B06_Section import B06_Section_Server_Calc_Prebuild as prebuild # noqa: E402
|
||||
from B06_Section.B06_Section_Engine_Design_Node import full_standard # noqa: E402
|
||||
from config.config_system import STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M # noqa: E402
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not (ROOT / "config" / "node_modules" / "vite").is_dir(), reason="프론트엔드 의존성 미설치"
|
||||
)
|
||||
|
||||
|
||||
def _uphill(index: int) -> str | None:
|
||||
return None if index == 3 else ("right" if index % 2 else "left")
|
||||
|
||||
|
||||
def _expected(index: int) -> str:
|
||||
return f"{_uphill(index) or 'left'}_cut"
|
||||
|
||||
|
||||
def _stripped(sections: list[dict], mode=None) -> list[dict]:
|
||||
"""단면 유형을 지운 옛 설계 · `mode(index)` 가 오면 그 값을 적어 넣은 짝."""
|
||||
out = copy.deepcopy(sections)
|
||||
for index, section in enumerate(out):
|
||||
section["uphill_side"] = _uphill(index)
|
||||
section["design"].pop("section_mode", None)
|
||||
if mode:
|
||||
section["design"]["section_mode"] = mode(index)
|
||||
return out
|
||||
|
||||
|
||||
def _server(root: Path, longitudinal: dict, sections: list[dict]) -> tuple[list, list]:
|
||||
py, node = copy.deepcopy(sections), copy.deepcopy(sections)
|
||||
prebuild._enforce_on_python(longitudinal, py, root, None, SURFACE)
|
||||
grid = prebuild.design_grid_file(root, SURFACE)
|
||||
assert prebuild._enforce_on_node(longitudinal, node, root, None, grid)
|
||||
return [s["design"] for s in py], [s["design"] for s in node]
|
||||
|
||||
|
||||
def _browser(tmp_path: Path, sections: list[dict]) -> list[dict]:
|
||||
job = tmp_path / "job.json"
|
||||
plan = [[s["chainage_m"], _plan(s["chainage_m"])] for s in sections]
|
||||
job.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"sections": sections,
|
||||
"plan": plan,
|
||||
"standard": full_standard(None),
|
||||
"rockDefault": STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M,
|
||||
}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
proc = subprocess.run(
|
||||
["node", str(HERE / "helper_472_8_section_mode.cjs"), str(job)],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=120,
|
||||
)
|
||||
assert proc.returncode == 0, proc.stderr
|
||||
return json.loads(proc.stdout)
|
||||
|
||||
|
||||
def test_단면_유형_없음_상단측_서버_두_길_브라우저_같음(tmp_path, monkeypatch):
|
||||
root = tmp_path / "p"
|
||||
_npz(root)
|
||||
_facilities(monkeypatch)
|
||||
longitudinal, sections = _sections(root)
|
||||
bare = _stripped(sections)
|
||||
|
||||
py, node = _server(root, longitudinal, bare)
|
||||
assert py == node # 파이썬 길 = Node 길(TS Cross_Save)
|
||||
py_set, _ = _server(root, longitudinal, _stripped(sections, _expected))
|
||||
assert py == py_set # 없음 = 상단측 적어 넣음
|
||||
py_left, _ = _server(root, longitudinal, _stripped(sections, lambda _i: "left_cut"))
|
||||
assert any(a != b for a, b in zip(py, py_left)) # 옛 좌 고정과 다름(우 상단측 측점)
|
||||
|
||||
browser = _browser(tmp_path, bare)
|
||||
assert browser == _browser(tmp_path, _stripped(sections, _expected))
|
||||
assert [d["section_mode"] for d in browser] == [d["section_mode"] for d in py]
|
||||
assert browser != _browser(tmp_path, _stripped(sections, lambda _i: "left_cut"))
|
||||
|
||||
|
||||
def test_묶음_cross_단계_기본은_상단측():
|
||||
stage = (ROOT / "B06_Section/logic/B06_Section_Cross_Stage.ts").read_text(encoding="utf-8")
|
||||
assert 'sectionMode: `${uphillSide(station) ?? "left"}_cut`' in stage
|
||||
assert '"left_cut"' not in stage
|
||||
Reference in New Issue
Block a user