fix(467 값 안 변함 ②): 갈아끼움 정본 표본 유지 · 소단 원천 한 벌
- (B1) 노선 초안 없는 차례 = 같은 열쇠 · 누가거리 0.01 m 안 앞 횡단 기하 · 표본 그대로(축 허용 1e-3) · 노선 초안 차례는 옛 규칙 · 가게 routeDraft 로 가름(Section_Store 한 줄) - (B2) 소단 사본(세션 berm) = 페이지 시설 줄이 씀(같으면 안 씀 · 쓰면 cross 한 번 · 늦은 import) · 횡단 보기 syncBermSpans 쓰기 뺌 · 다시 셈 = 사본 없으면 저장분 design.berm(파이썬 berm_from 짝 storedBermSpec) - 새 시험 test_272_swap_keeps_canon · test_272_berm_source(TS ↔ 파이썬 거울) · helper_271 에 Persist 덧대기(import.meta 로더 밖) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -8,9 +8,17 @@
|
||||
* 입력 = 관 알림(배수유역도 · B06 관 목록) · 구조물(보기 고침 · 저장분) · 종류 표 · 측점 간격 · 추가 측점(가게)
|
||||
* 관 id 장부 = 관 고정 id 가 쥔 세션 id 를 그 자리로(411-B) · 헛 id 정리(411-E) — 어느 보기에서 고쳐도
|
||||
* 계획고 편집 옮김(사라진 측점 → 새 측점 · 213-2) = 사용자 고침만 · 노선 따라감(`follow`)은 안 옮김(계산 묶음 몫 · 349-0d)
|
||||
* 소단 사본(세션 `berm`) = 구조물 소단 구간 — 쓰는 자리 여기 하나(B05 만 열어도 · 같으면 안 씀 · 쓰면 cross 한 번 · 467)
|
||||
* ========================================================================== */
|
||||
|
||||
import { useDesignStore } from "./design_store";
|
||||
import { pageRouteId } from "./design_page_route";
|
||||
import { readState } from "../b_page_state";
|
||||
import {
|
||||
bermSpansFromStructures,
|
||||
writeBermSpans,
|
||||
type BermSpan,
|
||||
} from "../../B06_Section/B06_Section_UI_Page_Persist";
|
||||
import { pipeIdAt, placePipeIds, prunePipeIds, withPipeIds } from "./design_pipe_ids";
|
||||
import { plannedIrregular } from "./design_structure_status";
|
||||
import { planStations } from "../../common_util/common_util_structure_station";
|
||||
@@ -85,8 +93,9 @@ export function createFacilityLane(
|
||||
): FacilityLane {
|
||||
const store = useDesignStore(projectId, null);
|
||||
let types: StructureType[] = [];
|
||||
let stored: StructureInstance[] = [];
|
||||
let stored: StructureInstance[] | null = null;
|
||||
let structures: StructureInstance[] = [];
|
||||
let structuresKnown = false; // 구조물을 받기 전 = 소단 사본 안 씀(빈 목록으로 저장분 소단을 지우지 않게)
|
||||
/** 마지막 관 알림 — 노선 따라감 · 관 초안이 바뀌면 이것을 초안 측점으로 다시 맞춤. */
|
||||
let reported: LanePipe[] | null = null;
|
||||
let pipes: LanePipe[] = [];
|
||||
@@ -139,6 +148,23 @@ export function createFacilityLane(
|
||||
|
||||
const marks = (): StructureInstance[] => [...structures, ...pipesToStructureMarks(pipes)];
|
||||
|
||||
/** 소단 사본 = 지금 구조물의 소단 구간(467 · 사본 없는 동안 다시 셈 = 저장분 `design.berm`) · 같으면 안 씀 ·
|
||||
* 쓰면 저장 노선 cross 한 번 더(같은 값 측점은 다시 셈 기억이 건너뜀 · 묶음은 늦게 불러옴 · 순환 없음). */
|
||||
function syncBerm(): void {
|
||||
const routeId = pageRouteId(projectId);
|
||||
if (!structuresKnown || routeId === null) return;
|
||||
const copy = readState<BermSpan[]>("berm", projectId, routeId);
|
||||
const next = bermSpansFromStructures(structures);
|
||||
if (Array.isArray(copy) && JSON.stringify(copy) === JSON.stringify(next)) return;
|
||||
writeBermSpans(projectId, routeId, next);
|
||||
void Promise.all([import("./design_pipeline_cross"), import("./design_pipeline_page")])
|
||||
.then(([cross, page]) => {
|
||||
cross.forceCross();
|
||||
page.pipelineCross(projectId);
|
||||
})
|
||||
.catch(() => undefined);
|
||||
}
|
||||
|
||||
function paint(force = false): void {
|
||||
const to = profile();
|
||||
if (!to) return;
|
||||
@@ -179,13 +205,20 @@ export function createFacilityLane(
|
||||
stored = next;
|
||||
},
|
||||
set(next, carryEdits = true) {
|
||||
if (next.structures) structures = next.structures;
|
||||
if (next.structures) {
|
||||
structures = next.structures;
|
||||
structuresKnown = true;
|
||||
}
|
||||
if (next.pipes) reported = [...next.pipes];
|
||||
refresh(carryEdits);
|
||||
if (next.structures) run(syncBerm);
|
||||
},
|
||||
follow() {
|
||||
structures = store.get("structures") ?? stored;
|
||||
const drafted = store.get("structures");
|
||||
structures = drafted ?? stored ?? [];
|
||||
structuresKnown ||= drafted !== null || stored !== null;
|
||||
refresh(false);
|
||||
run(syncBerm);
|
||||
},
|
||||
setIntervalM(next) {
|
||||
if (next > 0 && next !== intervalM) {
|
||||
|
||||
@@ -34,8 +34,15 @@ import {
|
||||
readCutSlopeSession,
|
||||
readRockBoundarySession,
|
||||
} from "./B06_Section_UI_Page_Persist";
|
||||
import type { BermSessionSpec } from "./B06_Section_UI_Page_Persist";
|
||||
import type { BermSpec } from "@util/common_util_cross_berm";
|
||||
import type { BermSessionSpec, BermSpan } from "./B06_Section_UI_Page_Persist";
|
||||
import {
|
||||
BERM_DEFAULT_DEPTH_M,
|
||||
BERM_DEFAULT_INTERVAL_M,
|
||||
BERM_DEFAULT_SLOPE_DEG,
|
||||
BERM_DEFAULT_WIDTH_M,
|
||||
type BermSpec,
|
||||
} from "@util/common_util_cross_berm";
|
||||
import { readState } from "../A00_Common/b_page_state";
|
||||
import {
|
||||
crossDesignChoices,
|
||||
readBermDepths,
|
||||
@@ -260,6 +267,24 @@ function bermPayload(
|
||||
type Side = "left" | "right";
|
||||
const SIDES: Side[] = ["left", "right"];
|
||||
|
||||
/** 저장분 소단 제원(`design.berm`) — 짝: 파이썬 `berm_from`(빈 칸 = 기본값 · 깊이 0 미만 = 0 · 못 읽으면 없음). */
|
||||
export function storedBermSpec(berm: unknown): BermSessionSpec | null {
|
||||
if (!berm || typeof berm !== "object" || Array.isArray(berm)) return null;
|
||||
const spec = berm as Record<string, unknown>;
|
||||
const value = (key: string, fallback: number): number => {
|
||||
const raw = spec[key];
|
||||
if (raw === undefined) return fallback;
|
||||
return raw === null || raw === "" || typeof raw === "object" ? Number.NaN : Number(raw);
|
||||
};
|
||||
const out = {
|
||||
width_m: value("width_m", BERM_DEFAULT_WIDTH_M),
|
||||
interval_m: value("interval_m", BERM_DEFAULT_INTERVAL_M),
|
||||
slope_deg: value("slope_deg", BERM_DEFAULT_SLOPE_DEG),
|
||||
depth_m: Math.max(value("depth_m", BERM_DEFAULT_DEPTH_M), 0),
|
||||
};
|
||||
return Object.values(out).every(Number.isFinite) ? out : null;
|
||||
}
|
||||
|
||||
/** 소단 쪽마다 옮긴 깊이(194-1) — 세션 → 저장분 순 · 없으면 null(구간 깊이를 씀). */
|
||||
function bermDepthReader(projectId: string, routeId: number) {
|
||||
const session = readBermDepths(projectId, routeId);
|
||||
@@ -333,11 +358,13 @@ function refreshLocally(input: CrossRefreshInput): number[] | null {
|
||||
// 그려진다. 계산 뒤에 값만 베껴 붙이면 그림은 옛 경사, 숫자만 새것이 된다(2026-09-07).
|
||||
const cutSlopeRatios = readCutSlopeRatios(projectId, input.routeId);
|
||||
// 소단도 같은 성격 — 세션에만 있는 값이라 여기서 실어 주지 않으면 계획선을 고치는
|
||||
// 순간 계단이 사라진다(계획서 3-9).
|
||||
const bermSpans = readBermSpans(projectId, input.routeId);
|
||||
// 순간 계단이 사라진다(계획서 3-9). 사본 없음(시설 줄이 구조물을 받기 전) = 저장분 `design.berm`
|
||||
// (파이썬 `load_berm_spans` 못 읽음 → 저장분 · `stored_berm` 짝 · 467).
|
||||
const bermCopy = readState<BermSpan[]>("berm", projectId, input.routeId);
|
||||
const bermSpans = Array.isArray(bermCopy) ? bermCopy : null;
|
||||
const bermDepthAt = bermDepthReader(projectId, input.routeId);
|
||||
const bermAt = (chainageM: number, design: Record<string, unknown>): BermSpec | null => {
|
||||
const spec = bermSpecAt(bermSpans, chainageM);
|
||||
const spec = bermSpans ? bermSpecAt(bermSpans, chainageM) : storedBermSpec(design.berm);
|
||||
return spec
|
||||
? {
|
||||
widthM: spec.width_m,
|
||||
|
||||
@@ -41,6 +41,7 @@ import { staleKeyAgainstScreen, USER_TOUCHED_KEYS } from "./B06_Section_Cross_Re
|
||||
import { kindChangedChainages, STRUCTURE_ADJUST_KEYS } from "./B06_Section_Api_Culvert_Options";
|
||||
import type { PipelineStation } from "../A00_Common/design/logic/design_pipeline_types";
|
||||
import type { DesignStoreValues } from "../A00_Common/design/design_store";
|
||||
import { useDesignStore } from "../A00_Common/design/design_store";
|
||||
import {
|
||||
carryStationKeys,
|
||||
KEYED_STATES,
|
||||
@@ -237,7 +238,13 @@ export async function swapSectionStations(
|
||||
const interval = stationIntervalOf(current);
|
||||
const oldKeys = registeredKeys(projectId, routeId, current.cross_sections, interval);
|
||||
if (sameStationList(current.cross_sections, oldKeys, stations)) return null;
|
||||
const swap = swapCrossSections(current, stations, oldKeys, interval);
|
||||
const swap = swapCrossSections(
|
||||
current,
|
||||
stations,
|
||||
oldKeys,
|
||||
interval,
|
||||
useDesignStore(projectId, null).get("routeDraft") !== null,
|
||||
); // 초안 없으면 정본 표본(467)
|
||||
// 설계는 사본 — 면적 얹기 · 다시 셈이 앞 상세(초안 전 상세 등)의 설계를 제자리로 안 고침(349-0o)
|
||||
for (const section of swap.detail.cross_sections)
|
||||
if (section.design) section.design = { ...section.design };
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* - `handleDesignChange` : 버튼 선택 즉시 반영 + 세션 초안 기록 + 재계산
|
||||
* - `recomputeIfRock` : 암 경계·암 절토 경사 변경 후 암 측점만 재계산
|
||||
* - `reconcileStaleDesigns`: 횡단 다시 셈을 계산 묶음에 부탁(cross 단계 한 곳 · 387-4)
|
||||
* - `syncBermSpans` : 구조물 목록의 소단을 세션 사본으로 펴기
|
||||
* - `syncBermSpans` : 구조물 측점 열쇠(소단 사본은 페이지 시설 줄이 씀 · 467)
|
||||
* - `applyPanelToAll` : 표준 횡단면 설정 [전체 반영]
|
||||
* 고친 뒤 계산 묶음 cross 입력도 다시(`pipelineCross` · 노선 초안 동안 카드 = 묶음 새 노선 상세 · 365-2).
|
||||
* ========================================================================== */
|
||||
@@ -15,11 +15,6 @@ import {
|
||||
writeCrossDesignChoice,
|
||||
writeShoulderExtend,
|
||||
} from "./B06_Section_Cross_Design_Session";
|
||||
import {
|
||||
bermSpansFromStructures,
|
||||
readBermSpans,
|
||||
writeBermSpans,
|
||||
} from "./B06_Section_UI_Page_Persist";
|
||||
import { showToast } from "@ui/ui_template_elements";
|
||||
import { L } from "./B06_Section_UI_Page_Common";
|
||||
import type { SectionDetailResponse } from "./B06_Section_Api_Fetch";
|
||||
@@ -137,20 +132,10 @@ export function createDesignSync(ctx: DesignSyncContext): DesignSyncController {
|
||||
await reconcilePagePipeline(projectId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 구조물 목록의 **소단**(C군 사면안정)을 세션 사본으로 편다 — 재계산이 측점마다 읽는 값이다.
|
||||
*
|
||||
* 사용자는 「구조물 배치」에서 놓고(2026-09-07 확정), 계산은 그 사본만 본다. 달라졌을 때만
|
||||
* 다시 계산한다 — 목록은 화면을 열 때도 오므로 매번 돌리면 진입이 느려진다.
|
||||
*/
|
||||
/** 구조물 측점 열쇠 = 구조물 id(344-3) — 소단 사본(세션 `berm`)은 페이지 시설 줄 한 곳이 씀(B05 만 열어도 · 467). */
|
||||
function syncBermSpans(structures: ReadonlyArray<StructureInstance>): void {
|
||||
const currentRouteId = ctx.routeId();
|
||||
if (!projectId || currentRouteId === null) return;
|
||||
useStructureIds(projectId, structures); // 구조물 측점 열쇠 = 구조물 id(344-3)
|
||||
const next = bermSpansFromStructures(structures);
|
||||
if (JSON.stringify(next) === JSON.stringify(readBermSpans(projectId, currentRouteId))) return;
|
||||
writeBermSpans(projectId, currentRouteId, next);
|
||||
void reconcileStaleDesigns({ force: true });
|
||||
if (!projectId || ctx.routeId() === null) return;
|
||||
useStructureIds(projectId, structures);
|
||||
}
|
||||
|
||||
/** 패널 [전체 반영](N-2-1 · 346-2): 표준값으로 전 측점을 **한 번** 다시 셈 — 측점마다 돌면
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
* 받음 — 설계 · 구조물 제원 · 이름 그대로 · 자리(누가거리 · 좌표 · 방위 · 확폭)만 새것(433-4).
|
||||
* · 지반 표본 · 상단측 · 중심고 = 자리 · 축이 같은 앞 횡단이면 앞 값(서버 샘플링 정본 · 덧 측점만 넣어도 나머지
|
||||
* 측점 면적이 브라우저 지형으로 안 바뀜 · 433-11) · 새 측점 · 옮긴 측점만 지반 표본(채워 왔으면).
|
||||
* · 노선 초안 없는 차례(관 · 구조물 · 추가 측점만) = 같은 열쇠 · 누가거리 0.01 m 안 앞 횡단의 기하 · 표본 그대로
|
||||
* (축 허용 1e-3 · 브라우저 측점 틀 ↔ 서버 틀 mm 차가 정본 표본을 안 덮음 · 467 · 요구 272).
|
||||
* · 새 측점 = 지반 표본 + 기본 설계(계획고 0 → 낡음 → 브라우저 다시 셈이 곧 채움).
|
||||
* · 상단측 = 새 지반 표본으로 다시 셈한 측점은 다시(단면 유형 기본값 재료 · 서버 횡단 파일 `uphill_side` 짝 · 428).
|
||||
* · 0.5 m 넘게 옮긴 관 · 구조물 측점 = 기본 설계 + 사용자 칸(만진 칸 · 지반 등 입력 `ROW_CARRY_KEYS`) — 서버가
|
||||
@@ -146,27 +148,31 @@ export interface StationSwap {
|
||||
moved: boolean;
|
||||
}
|
||||
|
||||
/** 앞 횡단과 자리(누가거리 · 좌표 0.01 m) · 축(왼쪽 단위 벡터)이 같은가 — 같으면 앞 지반 표본을 그대로 씀. */
|
||||
function samePlace(prior: CrossSection, station: PipelineStation): boolean {
|
||||
/** 앞 횡단과 자리(누가거리 · 좌표 0.01 m) · 축(왼쪽 단위 벡터 · 허용 `axisTol`)이 같은가 — 같으면 앞 지반 표본을 그대로 씀. */
|
||||
function samePlace(prior: CrossSection, station: PipelineStation, axisTol = 1e-4): boolean {
|
||||
const [lx, ly] = prior.frame?.left_xy ?? [Number.NaN, Number.NaN];
|
||||
return (
|
||||
Math.abs(prior.chainage_m - station.chainageM) < 0.01 &&
|
||||
Math.hypot(prior.center_x - station.x, prior.center_y - station.y) <= 0.01 &&
|
||||
Math.abs(lx - station.left[0]) < 1e-4 &&
|
||||
Math.abs(ly - station.left[1]) < 1e-4
|
||||
Math.abs(lx - station.left[0]) < axisTol &&
|
||||
Math.abs(ly - station.left[1]) < axisTol
|
||||
);
|
||||
}
|
||||
|
||||
/** 노선 초안 없는 차례의 축 허용(측점 축 0.06° · 20 m 끝 2 cm) — 브라우저 틀 ↔ 서버 틀 차(R 12 곡선 3.3e-4)를 넘김. */
|
||||
const CANON_AXIS_TOL = 1e-3;
|
||||
|
||||
/**
|
||||
* 새 측점 목록으로 상세를 새로 짬. `oldKeys` = 지금 상세 측점마다 열쇠(같은 차례 · `stationKeysOf`) ·
|
||||
* 열쇠가 안 맞으면 옮긴 곡선 열쇠(`curveMoves` · 서버 `carry_cross_inputs` 같은 규칙) · 그다음 같은 자리(0.01 m) ·
|
||||
* 같은 종류의 앞 횡단을 씀.
|
||||
* 같은 종류의 앞 횡단을 씀. `routeDraft` = 노선 초안 차례(가게 `routeDraft` · 아니면 정본 기하 · 표본 유지 · 467).
|
||||
*/
|
||||
export function swapCrossSections(
|
||||
detail: SectionDetailResponse,
|
||||
stations: ReadonlyArray<PipelineStation>,
|
||||
oldKeys: ReadonlyArray<string>,
|
||||
intervalM: number | null,
|
||||
routeDraft = false,
|
||||
): StationSwap {
|
||||
const byKey = new Map(detail.cross_sections.map((section, i) => [oldKeys[i], section]));
|
||||
const used = new Set<CrossSection>();
|
||||
@@ -209,8 +215,15 @@ export function swapCrossSections(
|
||||
moved = true;
|
||||
if (prior && text(prior.chainage_m) !== text(station.chainageM))
|
||||
moves.set(text(prior.chainage_m), text(station.chainageM));
|
||||
// 노선 초안 없는 차례 · 같은 열쇠 · 같은 자리 = 앞 횡단 기하 · 표본 그대로(467 · 되돌리면 정본과 같음)
|
||||
const canon =
|
||||
!routeDraft &&
|
||||
!!prior &&
|
||||
byKey.get(station.key) === prior &&
|
||||
samePlace(prior, station, CANON_AXIS_TOL);
|
||||
// 자리 같은 앞 횡단 = 서버 표본 그대로(433-11) · 아니면 새 지반 표본(채워 왔으면)
|
||||
const fresh = !!station.ground && !(prior?.samples?.length && samePlace(prior, station));
|
||||
const fresh =
|
||||
!canon && !!station.ground && !(prior?.samples?.length && samePlace(prior, station));
|
||||
const kind = kindOf(station);
|
||||
const onGrid =
|
||||
kind === "irregular" &&
|
||||
@@ -233,13 +246,25 @@ export function swapCrossSections(
|
||||
center_z: fresh
|
||||
? (station.ground?.centerZ ?? prior?.center_z ?? null)
|
||||
: (prior?.center_z ?? null),
|
||||
azimuth_deg: station.azimuthDeg,
|
||||
plan_radius_m: station.planRadiusM,
|
||||
curve_outer_side: station.curveOuterSide,
|
||||
curve_widening_m: station.curveWideningM,
|
||||
center_x: station.x,
|
||||
center_y: station.y,
|
||||
frame: { left_xy: [station.left[0], station.left[1]] as [number, number] },
|
||||
...(canon && prior
|
||||
? {
|
||||
azimuth_deg: prior.azimuth_deg,
|
||||
plan_radius_m: prior.plan_radius_m,
|
||||
curve_outer_side: prior.curve_outer_side,
|
||||
curve_widening_m: prior.curve_widening_m,
|
||||
center_x: prior.center_x,
|
||||
center_y: prior.center_y,
|
||||
frame: prior.frame,
|
||||
}
|
||||
: {
|
||||
azimuth_deg: station.azimuthDeg,
|
||||
plan_radius_m: station.planRadiusM,
|
||||
curve_outer_side: station.curveOuterSide,
|
||||
curve_widening_m: station.curveWideningM,
|
||||
center_x: station.x,
|
||||
center_y: station.y,
|
||||
frame: { left_xy: [station.left[0], station.left[1]] as [number, number] },
|
||||
}),
|
||||
};
|
||||
longStations.push({ ...place, ...(prior?.structure ? { structure: prior.structure } : {}) });
|
||||
const samples = fresh ? groundSamples(station) : (prior?.samples ?? []);
|
||||
|
||||
@@ -35,6 +35,8 @@ const STUBS = {
|
||||
}),
|
||||
"ui_template_elements.ts": anyModule(),
|
||||
"B04_PreProcess_Api_Fetch.ts": anyModule(),
|
||||
// 소단 사본(467) — 끌어오는 줄이 import.meta 를 써 이 로더로 못 읽음 · 소단 몫은 test_272_berm_source(vite 묶음)
|
||||
"B06_Section_UI_Page_Persist.ts": anyModule({ bermSpansFromStructures: () => [] }),
|
||||
};
|
||||
|
||||
const cache = new Map();
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
/* 467 헬퍼 — 소단 원천 한 벌: 구조물 → 소단 구간(TS) · 저장분 소단 제원(TS) · 시설 줄이 세션 사본을 씀 ·
|
||||
* 다시 셈 = 사본 없으면 저장분 `design.berm`.
|
||||
* node helper_272_berm_source.mjs <묶음.mjs> <job.json>
|
||||
* job = { standard, rockDefault, structureCases, storedCases, ground } · 짝 = `test_272_berm_source.py`.
|
||||
*/
|
||||
import { readFileSync } from "node:fs";
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
const writes = [];
|
||||
const memory = () => {
|
||||
const m = new Map();
|
||||
return {
|
||||
getItem: (k) => (m.has(k) ? m.get(k) : null),
|
||||
setItem: (k, v) => {
|
||||
writes.push(k);
|
||||
m.set(k, String(v));
|
||||
},
|
||||
removeItem: (k) => m.delete(k),
|
||||
key: (i) => [...m.keys()][i] ?? null,
|
||||
get length() {
|
||||
return m.size;
|
||||
},
|
||||
clear: () => m.clear(),
|
||||
};
|
||||
};
|
||||
globalThis.window = globalThis;
|
||||
globalThis.sessionStorage = memory();
|
||||
globalThis.localStorage = memory();
|
||||
const any = new Proxy(function () {}, {
|
||||
get: (_t, k) => (k === Symbol.toPrimitive ? () => 0 : any),
|
||||
apply: () => any,
|
||||
construct: () => any,
|
||||
});
|
||||
globalThis.document = any;
|
||||
globalThis.requestAnimationFrame = (run) => setTimeout(run, 0);
|
||||
globalThis.fetch = async () => new Response("{}", { status: 404 });
|
||||
|
||||
const m = await import(pathToFileURL(process.argv[2]).href);
|
||||
const job = JSON.parse(readFileSync(process.argv[3], "utf8"));
|
||||
const P = "p272berm";
|
||||
const R = 5;
|
||||
const out = {};
|
||||
|
||||
/* 1. 거울 — 구조물 → 소단 구간 · 저장분 제원 */
|
||||
out.spans = job.structureCases.map((list) => m.bermSpansFromStructures(list));
|
||||
out.stored = job.storedCases.map((spec) => m.storedBermSpec(spec));
|
||||
|
||||
/* 2. 시설 줄이 사본을 씀 — 구조물 받기 전 안 씀 · 같으면 안 씀 · 바뀌면 한 번 */
|
||||
{
|
||||
m.setPageRouteId(P, R);
|
||||
const key = m.stateKey("berm", P, R);
|
||||
const count = () => writes.filter((k) => k === key).length;
|
||||
const copy = () => m.readState("berm", P, R);
|
||||
const lane = m.createFacilityLane(P, () => null);
|
||||
const steps = {};
|
||||
lane.setTypes([]);
|
||||
lane.follow(); // 저장분 · 가게 구조물 없음 = 아직 모름
|
||||
steps.beforeKnown = { copy: copy(), writes: count() };
|
||||
const saved = job.structureCases[0];
|
||||
lane.setStored(saved);
|
||||
lane.set({ structures: saved }, false);
|
||||
steps.loaded = { copy: copy(), writes: count() };
|
||||
lane.set({ structures: saved.map((item) => ({ ...item })) });
|
||||
lane.set({ pipes: [] });
|
||||
steps.same = { writes: count() };
|
||||
const moved = saved.map((item) =>
|
||||
item.type_id === "berm" ? { ...item, start_m: item.start_m + 5, end_m: item.end_m + 5 } : item,
|
||||
);
|
||||
lane.set({ structures: moved });
|
||||
steps.moved = { copy: copy(), writes: count() };
|
||||
lane.set({ structures: [] });
|
||||
steps.removed = { copy: copy(), writes: count() };
|
||||
lane.dispose();
|
||||
out.lane = steps;
|
||||
}
|
||||
|
||||
/* 3. 다시 셈 소단 원천 — 사본 없음(저장분 design.berm) · 사본 = 같은 구간 · 사본 = 빈 목록 */
|
||||
{
|
||||
m.writeState("std-cross", job.standard, P);
|
||||
m.rememberRockBoundaryDefault(P, job.rockDefault);
|
||||
const detailOf = () => ({
|
||||
longitudinal: { length_m: 200, stations: [], profile_alignment: { policy: {} } },
|
||||
cross_sections: [
|
||||
{
|
||||
station_id: "station_000000040000",
|
||||
chainage_m: 40,
|
||||
label: "",
|
||||
kind: "regular",
|
||||
center_z: 96,
|
||||
azimuth_deg: 90,
|
||||
center_x: 40,
|
||||
center_y: 0,
|
||||
frame: { left_xy: [0, 1] },
|
||||
uphill_side: "left",
|
||||
samples: job.ground,
|
||||
design: {
|
||||
design_elevation_m: 100,
|
||||
ground_type: "soil",
|
||||
section_mode: "both_fill",
|
||||
ditch_type: "standard",
|
||||
berm: job.storedBerm,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
const alignment = {
|
||||
stations: [{ chainage_m: 40, plan_elevation_m: 100 }],
|
||||
samples: [
|
||||
{ chainage_m: 0, elevation_m: 100 },
|
||||
{ chainage_m: 100000, elevation_m: 100 },
|
||||
],
|
||||
balance: { cut_area_m2: 0, fill_area_m2: 0, net_area_m2: 0 },
|
||||
};
|
||||
const run = async (copy) => {
|
||||
if (copy === undefined) sessionStorage.removeItem(m.stateKey("berm", P, R));
|
||||
else m.writeState("berm", copy, P, R);
|
||||
const detail = detailOf();
|
||||
await m.refreshCrossDesigns({
|
||||
projectId: P,
|
||||
routeId: R,
|
||||
detail,
|
||||
edits: { station_offsets: {}, curve_radii: {} },
|
||||
alignment,
|
||||
});
|
||||
const design = detail.cross_sections[0].design;
|
||||
return { fill: design.fill_area_m2 ?? null, cut: design.cut_area_m2 ?? null };
|
||||
};
|
||||
out.refresh = {
|
||||
noCopy: await run(undefined),
|
||||
copySame: await run(m.bermSpansFromStructures(job.structureCases[0])),
|
||||
copyEmpty: await run([]),
|
||||
};
|
||||
}
|
||||
|
||||
process.stdout.write(JSON.stringify(out));
|
||||
@@ -0,0 +1,7 @@
|
||||
/* 467 시험 묶음 진입점 — 소단 원천 한 벌(시설 줄 사본 · 다시 셈 저장분 폴백 · 진짜 모듈 · vite ssr). */
|
||||
export { createFacilityLane } from "../../A00_Common/design/design_facility_lane";
|
||||
export { setPageRouteId } from "../../A00_Common/design/design_page_route";
|
||||
export { refreshCrossDesigns, storedBermSpec } from "../../B06_Section/B06_Section_Cross_Refresh";
|
||||
export { bermSpansFromStructures } from "../../B06_Section/B06_Section_UI_Page_Persist";
|
||||
export { rememberRockBoundaryDefault } from "../../B06_Section/B06_Section_UI_Standard_Panel";
|
||||
export { readState, stateKey, writeState } from "../../A00_Common/b_page_state";
|
||||
@@ -0,0 +1,217 @@
|
||||
/* 467 헬퍼 — 노선 초안 없는 차례(관만 옮김)의 갈아끼움이 정본(서버) 횡단 기하 · 표본을 지키는지.
|
||||
* node helper_272_swap_canon.mjs <묶음.mjs>
|
||||
* 정본 = 서버 틀(표본 A) · 묶음 측점 = 브라우저 틀(중심 0.5 mm · R 12 곡선 축 3.3e-4 차 · 표본 B).
|
||||
* 짝 = `test_272_swap_keeps_canon.py` · 표준출력 JSON 한 벌.
|
||||
*/
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
const memory = () => {
|
||||
const m = new Map();
|
||||
return {
|
||||
getItem: (k) => (m.has(k) ? m.get(k) : null),
|
||||
setItem: (k, v) => m.set(k, String(v)),
|
||||
removeItem: (k) => m.delete(k),
|
||||
key: (i) => [...m.keys()][i] ?? null,
|
||||
get length() {
|
||||
return m.size;
|
||||
},
|
||||
clear: () => m.clear(),
|
||||
};
|
||||
};
|
||||
globalThis.window = globalThis;
|
||||
globalThis.sessionStorage = memory();
|
||||
globalThis.localStorage = memory();
|
||||
const any = new Proxy(function () {}, {
|
||||
get: (_t, k) => (k === Symbol.toPrimitive ? () => 0 : any),
|
||||
apply: () => any,
|
||||
construct: () => any,
|
||||
});
|
||||
globalThis.document = any;
|
||||
globalThis.requestAnimationFrame = (run) => setTimeout(run, 0);
|
||||
globalThis.fetch = async () => new Response("{}", { status: 404 });
|
||||
|
||||
const m = await import(pathToFileURL(process.argv[2]).href);
|
||||
const idOf = (c) => `station_${String(Math.round(c * 1000)).padStart(12, "0")}`;
|
||||
const OFFSETS = [-10, -6, -3, 0, 3, 6, 10];
|
||||
const groundA = (c, o) => 100 + 0.03 * c + 0.4 * o; // 서버 표본(정본)
|
||||
const groundB = (c, o) => groundA(c, o) + 0.0004 * Math.sin(c + o) + 0.0001; // 브라우저 지형(mm 차)
|
||||
|
||||
/* 측점 — [열쇠 · 누가거리 · 묶음 종류 · 상세 종류 · 축 차(rad)] · 곡선 셋 = R 12 */
|
||||
const LIST = [
|
||||
["end:BP", 0, "end", "bp", 1e-5],
|
||||
["grid:1", 20, "grid", "regular", 1e-5],
|
||||
["curve:27.50", 27.5, "curve", "curve", 3.3e-4],
|
||||
["curve:33.20", 33.2, "curve", "curve", -3.3e-4],
|
||||
["curve:38.90", 38.9, "curve", "curve", 2.1e-4],
|
||||
["grid:2", 40, "grid", "regular", 1e-5],
|
||||
["pipe:p1", 45, "pipe", "irregular", 1e-5],
|
||||
["grid:3", 60, "grid", "regular", 1e-5],
|
||||
["end:EP", 70, "end", "ep", 1e-5],
|
||||
];
|
||||
const azOf = (c) => 0.6 + c / 40; // 진행 방향(rad · 곡선 둘레가 휨)
|
||||
const leftOf = (a) => [-Math.sin(a), Math.cos(a)];
|
||||
const xyOf = (c) => [1000 + 12 * Math.sin(azOf(c)), 2000 - 12 * Math.cos(azOf(c))];
|
||||
|
||||
const canonSection = ([, c, , kind]) => {
|
||||
const [x, y] = xyOf(c);
|
||||
const samples = OFFSETS.map((o) => ({ offset_m: o, elevation_m: groundA(c, o), valid: true }));
|
||||
return {
|
||||
station_id: idOf(c),
|
||||
chainage_m: c,
|
||||
label: "",
|
||||
kind,
|
||||
center_z: groundA(c, 0),
|
||||
azimuth_deg: (azOf(c) * 180) / Math.PI,
|
||||
plan_radius_m: kind === "curve" ? 12 : null,
|
||||
curve_outer_side: kind === "curve" ? "left" : null,
|
||||
curve_widening_m: kind === "curve" ? 1.25 : null,
|
||||
center_x: x,
|
||||
center_y: y,
|
||||
frame: { left_xy: leftOf(azOf(c)) },
|
||||
uphill_side: "left",
|
||||
samples,
|
||||
design: { design_elevation_m: groundA(c, 0) + 0.3, mark: `canon@${c}` },
|
||||
...(kind === "irregular" ? { structure: "관", culvert: {} } : {}),
|
||||
};
|
||||
};
|
||||
const canonDetail = () => ({
|
||||
longitudinal: {
|
||||
length_m: 70,
|
||||
stations: [],
|
||||
profile_alignment: { policy: { station_interval_m: 20 } },
|
||||
},
|
||||
cross_sections: LIST.map(canonSection),
|
||||
});
|
||||
/** 묶음 측점 — 브라우저 틀(중심 0.5 mm · 축 차) · 표본 B · `shift` = 노선 초안이 옮긴 자리(m · y). */
|
||||
const station = ([key, c0, kind, , tilt], pipeAt, shift = () => 0) => {
|
||||
const c = key === "pipe:p1" ? pipeAt : c0;
|
||||
const [x, y] = xyOf(c);
|
||||
const a = azOf(c) + tilt;
|
||||
const side = (sign) =>
|
||||
OFFSETS.filter((o) => o * sign > 0).map((o) => ({ offsetM: Math.abs(o), z: groundB(c, o) }));
|
||||
return {
|
||||
key,
|
||||
chainageM: c,
|
||||
x: x + 0.0004,
|
||||
y: y - 0.0003 + shift(c),
|
||||
azimuthDeg: (a * 180) / Math.PI,
|
||||
left: leftOf(a),
|
||||
kind,
|
||||
id: key === "pipe:p1" ? "p1" : null,
|
||||
ground: { centerZ: groundB(c, 0), left: side(1), right: side(-1) },
|
||||
planRadiusM: kind === "curve" ? 12.0004 : null,
|
||||
curveOuterSide: kind === "curve" ? "left" : null,
|
||||
curveWideningM: kind === "curve" ? 1.2501 : null,
|
||||
};
|
||||
};
|
||||
const stationsAt = (pipeAt, shift) =>
|
||||
LIST.map((row) => station(row, pipeAt, shift)).sort((p, q) => p.chainageM - q.chainageM);
|
||||
const KEYS = LIST.map(([key]) => key);
|
||||
const keysOf = (list) => list.map((s) => s.key);
|
||||
const json = (v) => JSON.stringify(v);
|
||||
const canonOf = new Map(canonDetail().cross_sections.map((s) => [s.chainage_m, s]));
|
||||
/** 상세 측점마다 [정본과 같은가(기하 · 표본 · 중심고) · 표본이 브라우저 B 인가 · 설계 표시]. */
|
||||
const GEOM = ["center_x", "center_y", "frame", "azimuth_deg", "plan_radius_m", "curve_widening_m"];
|
||||
const report = (detail) =>
|
||||
Object.fromEntries(
|
||||
detail.cross_sections.map((s) => {
|
||||
const c = canonOf.get(s.chainage_m);
|
||||
const same =
|
||||
!!c &&
|
||||
GEOM.every((k) => json(s[k]) === json(c[k])) &&
|
||||
json(s.samples) === json(c.samples) &&
|
||||
s.center_z === c.center_z;
|
||||
const browser = s.samples.every(
|
||||
(p) => Math.abs(p.elevation_m - groundB(s.chainage_m, p.offset_m)) < 1e-12,
|
||||
);
|
||||
return [s.chainage_m.toFixed(2), { same, browser, mark: s.design?.mark ?? null }];
|
||||
}),
|
||||
);
|
||||
/** `skip` 밖 횡단이 정본과 바이트 같은가(이름 글은 갈아끼움이 새로 씀 · 뺌). */
|
||||
const bytesSame = (detail, skip) =>
|
||||
detail.cross_sections
|
||||
.filter((s) => !skip.includes(s.chainage_m))
|
||||
.every((s) => {
|
||||
const c = canonOf.get(s.chainage_m);
|
||||
if (!c) return false;
|
||||
const { label: _a, ...got } = s;
|
||||
const { label: _b, ...want } = c;
|
||||
return (
|
||||
json(
|
||||
Object.keys(got)
|
||||
.sort()
|
||||
.map((k) => [k, got[k]]),
|
||||
) ===
|
||||
json(
|
||||
Object.keys(want)
|
||||
.sort()
|
||||
.map((k) => [k, want[k]]),
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
const out = {};
|
||||
|
||||
/* 1. 순수 — 관만 옮김(45 → 55) · 노선 초안 없음 대 있음 · 되돌림 */
|
||||
{
|
||||
const moved = stationsAt(55);
|
||||
const keep = m.swapCrossSections(canonDetail(), moved, KEYS, 20, false);
|
||||
const draft = m.swapCrossSections(canonDetail(), moved, KEYS, 20, true);
|
||||
const back = m.swapCrossSections(keep.detail, stationsAt(45), keysOf(moved), 20, false);
|
||||
out.pure = {
|
||||
keep: report(keep.detail),
|
||||
draft: report(draft.detail),
|
||||
keepMoved: keep.moved,
|
||||
back: report(back.detail),
|
||||
backBytes: bytesSame(back.detail, [45]),
|
||||
defaultIsKeep:
|
||||
json(m.swapCrossSections(canonDetail(), moved, KEYS, 20).detail) === json(keep.detail),
|
||||
};
|
||||
}
|
||||
|
||||
/* 2. 가게 길(swapSectionStations) — 가게 routeDraft 로 가름: 없음 · 있음 · 초안 버린 직후 */
|
||||
const seed = (P, R) => {
|
||||
m.writeState("section-detail", canonDetail(), P, R);
|
||||
m.writeState("pipe-ids", { next: 2, ids: [{ id: "p1", at: 45 }] }, P);
|
||||
};
|
||||
const pipeAt = (P, at) => m.writeState("pipe-ids", { next: 2, ids: [{ id: "p1", at }] }, P);
|
||||
const keyList = () => KEYS.map((key, i) => ({ key, chainageM: LIST[i][1] }));
|
||||
{
|
||||
const P = "p272a";
|
||||
const R = 3;
|
||||
seed(P, R);
|
||||
await m.loadSectionDetail(P, R);
|
||||
m.useStationKeyList(P, R, keyList());
|
||||
pipeAt(P, 55);
|
||||
const moved = await m.swapSectionStations(P, R, stationsAt(55));
|
||||
pipeAt(P, 45);
|
||||
const back = await m.swapSectionStations(P, R, stationsAt(45));
|
||||
out.storeNoDraft = {
|
||||
moved: moved && report(moved.detail),
|
||||
back: back && report(back.detail),
|
||||
backBytes: !!back && bytesSame(back.detail, [45]),
|
||||
};
|
||||
}
|
||||
{
|
||||
const P = "p272b";
|
||||
const R = 4;
|
||||
seed(P, R);
|
||||
await m.loadSectionDetail(P, R);
|
||||
m.useStationKeyList(P, R, keyList());
|
||||
const shop = m.useDesignStore(P, null);
|
||||
shop.set("routeDraft", { nodes: [], rev: 1 });
|
||||
pipeAt(P, 55);
|
||||
// 초안 = 곡선 둘레만 3 cm 옮김(나머지 자리 그대로)
|
||||
const bend = (c) => (c > 25 && c < 39 ? 0.03 : 0);
|
||||
const draft = await m.swapSectionStations(P, R, stationsAt(55, bend));
|
||||
shop.set("routeDraft", null); // 초안 버림 → 저장 노선 측점(묶음 「no-saved」 길)
|
||||
pipeAt(P, 45);
|
||||
const dropped = await m.swapSectionStations(P, R, stationsAt(45));
|
||||
out.storeDraft = {
|
||||
routeDraftSet: draft !== null,
|
||||
draft: draft && report(draft.detail),
|
||||
dropped: dropped && report(dropped.detail),
|
||||
};
|
||||
}
|
||||
|
||||
process.stdout.write(JSON.stringify(out));
|
||||
@@ -0,0 +1,9 @@
|
||||
/* 467 시험 묶음 진입점 — 갈아끼움 정본 표본 유지(진짜 모듈 · vite ssr). */
|
||||
export { swapCrossSections } from "../../B06_Section/logic/B06_Section_Station_Swap";
|
||||
export {
|
||||
loadSectionDetail,
|
||||
swapSectionStations,
|
||||
} from "../../B06_Section/B06_Section_Section_Store";
|
||||
export { useStationKeyList } from "../../B06_Section/B06_Section_Station_Keys";
|
||||
export { useDesignStore } from "../../A00_Common/design/design_store";
|
||||
export { writeState } from "../../A00_Common/b_page_state";
|
||||
@@ -0,0 +1,200 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""467 (요구 272 · 분석 4장 (B2)) — 소단 원천 한 벌.
|
||||
|
||||
못박는 것
|
||||
- 소단 사본(세션 `berm`) 쓰는 자리 = 페이지 시설 줄 하나 — 구조물 받기 전 안 씀 ·
|
||||
같으면 안 씀 · 바뀌면 한 번 · 지우면 빈 목록(B05 만 열어도 씀 · 횡단 보기는 안 씀).
|
||||
- 다시 셈 = 사본 없으면 저장분 `design.berm`(파이썬 `load_berm_spans` 규칙) —
|
||||
B05 만 연 값 = B06 연 뒤 값 = [저장] 서버 값(`enforce_design_lines`) · 빈 사본 = 소단 없음.
|
||||
- 거울 — TS `bermSpansFromStructures` ↔ 파이썬 `load_berm_spans` ·
|
||||
TS `storedBermSpec` ↔ 파이썬 `berm_from`.
|
||||
|
||||
Node 헬퍼 `helper_272_berm_source.mjs` 가 vite ssr 로 묶은 진짜 모듈을 부름.
|
||||
"""
|
||||
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
ROOT = HERE.parents[1]
|
||||
if str(ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from B06_Section.B06_Section_Engine_Structures_Wall import load_berm_spans # noqa: E402
|
||||
from B06_Section.B06_Section_Router_Design import berm_from, enforce_design_lines # noqa: E402
|
||||
from config.config_system import ( # noqa: E402
|
||||
STANDARD_CROSS_SECTION,
|
||||
STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M,
|
||||
)
|
||||
|
||||
|
||||
def _berm(start, end, **options):
|
||||
return {
|
||||
"type_id": "berm",
|
||||
"placement": "interval",
|
||||
"start_m": start,
|
||||
"end_m": end,
|
||||
"options": options,
|
||||
}
|
||||
|
||||
|
||||
SAVED = [_berm(0.0, 100.0, width_m=1.0, interval_m=3.0, slope_deg=0.0, depth_m=1.0)]
|
||||
STRUCTURE_CASES = [
|
||||
SAVED,
|
||||
[
|
||||
_berm(50.0, 80.0, width_m=0), # 폭 0 = 없음
|
||||
_berm(10.0, 30.0, depth_m=""), # 빈 깊이 = 기본 1.0
|
||||
_berm(30.0, 40.0, depth_m=-2, width_m="0.7"), # 음수 깊이 = 0 · 글 수
|
||||
_berm(60.0, 70.0, width_m="abc", interval_m=2.5, slope_deg=4), # 못 읽는 폭 = 기본
|
||||
],
|
||||
[{"type_id": "berm", "placement": "point", "chainage_m": 25.0, "options": {}}],
|
||||
[],
|
||||
]
|
||||
STORED_CASES = [
|
||||
{"width_m": 0.5},
|
||||
{"width_m": 0.5, "depth_m": -1},
|
||||
{},
|
||||
{"width_m": "0.7", "interval_m": 2},
|
||||
None,
|
||||
{"width_m": None},
|
||||
{"width_m": ""},
|
||||
]
|
||||
GROUND = [
|
||||
{"offset_m": o / 2, "elevation_m": round(96.0 + 0.02 * o / 2, 4), "valid": True}
|
||||
for o in range(-40, 41)
|
||||
]
|
||||
STORED_BERM = {"width_m": 1.0, "interval_m": 3.0, "slope_deg": 0.0, "depth_m": 1.0}
|
||||
LONG = {
|
||||
"design_profiles": [
|
||||
{
|
||||
"samples": [
|
||||
{"chainage_m": 0, "elevation_m": 100},
|
||||
{"chainage_m": 200, "elevation_m": 100},
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
def _project(root: Path, structures: list[dict]) -> Path:
|
||||
route = root / "B05_Profile" / "route"
|
||||
route.mkdir(parents=True)
|
||||
(route / "structures.json").write_text(
|
||||
json.dumps({"revision": 1, "structures": structures}, ensure_ascii=False), encoding="utf-8"
|
||||
)
|
||||
return root
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def out(tmp_path_factory):
|
||||
work = tmp_path_factory.mktemp("b272berm")
|
||||
build = subprocess.run( # noqa: S603 — 고정 실행 파일
|
||||
[
|
||||
"node",
|
||||
str(ROOT / "config" / "node_modules" / "vite" / "bin" / "vite.js"),
|
||||
"build",
|
||||
"--configLoader",
|
||||
"runner",
|
||||
"--ssr",
|
||||
"../resources/tester/helper_272_berm_source_entry.ts",
|
||||
"--outDir",
|
||||
str(work),
|
||||
"--logLevel",
|
||||
"error",
|
||||
],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=300,
|
||||
)
|
||||
assert build.returncode == 0, build.stderr
|
||||
bundle = work / "bundle.mjs"
|
||||
shutil.copy(work / "helper_272_berm_source_entry.js", bundle)
|
||||
job = work / "job.json"
|
||||
job.write_text(
|
||||
json.dumps(
|
||||
{
|
||||
"standard": STANDARD_CROSS_SECTION,
|
||||
"rockDefault": STANDARD_ROCK_BOUNDARY_DEFAULT_OFFSET_M,
|
||||
"structureCases": STRUCTURE_CASES,
|
||||
"storedCases": STORED_CASES,
|
||||
"ground": GROUND,
|
||||
"storedBerm": STORED_BERM,
|
||||
},
|
||||
ensure_ascii=False,
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
proc = subprocess.run( # noqa: S603
|
||||
["node", str(HERE / "helper_272_berm_source.mjs"), str(bundle), str(job)],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=120,
|
||||
)
|
||||
assert proc.returncode == 0, proc.stderr
|
||||
return json.loads(proc.stdout)
|
||||
|
||||
|
||||
def test_거울_구조물_소단_구간(out, tmp_path):
|
||||
for index, (structures, ts) in enumerate(zip(STRUCTURE_CASES, out["spans"], strict=True)):
|
||||
py = load_berm_spans(_project(tmp_path / f"c{index}", structures))
|
||||
assert py is not None, index
|
||||
want = [{"start_m": s, "end_m": e, **spec} for s, e, spec in py]
|
||||
assert len(ts) == len(want), (index, ts, want)
|
||||
for got, exp in zip(ts, want, strict=True):
|
||||
assert got == pytest.approx(exp), (index, got, exp)
|
||||
|
||||
|
||||
def test_거울_저장분_소단_제원(out):
|
||||
for spec, ts in zip(STORED_CASES, out["stored"], strict=True):
|
||||
py = berm_from(spec, {})
|
||||
if py is None:
|
||||
assert ts is None, spec
|
||||
continue
|
||||
want = {k: getattr(py, k) for k in ("width_m", "interval_m", "slope_deg", "depth_m")}
|
||||
assert ts == pytest.approx(want), spec
|
||||
|
||||
|
||||
def test_시설_줄이_사본을_씀(out):
|
||||
lane = out["lane"]
|
||||
assert lane["beforeKnown"] == {"copy": None, "writes": 0} # 구조물 받기 전 = 안 씀
|
||||
assert lane["loaded"]["writes"] == 1
|
||||
assert lane["loaded"]["copy"] == out["spans"][0] # 저장 구조물 소단 구간
|
||||
assert lane["same"]["writes"] == 1 # 같은 구간 · 관만 알림 = 안 씀
|
||||
assert lane["moved"]["writes"] == 2
|
||||
assert lane["moved"]["copy"][0]["start_m"] == 5.0 and lane["moved"]["copy"][0]["end_m"] == 105.0
|
||||
assert lane["removed"] == {
|
||||
"copy": [],
|
||||
"writes": 3,
|
||||
} # 소단 지움 = 빈 사본(저장분 소단으로 안 물러섬)
|
||||
|
||||
|
||||
def test_다시_셈_B05만_B06_저장_같은_값(out, tmp_path):
|
||||
r = out["refresh"]
|
||||
no_copy, same, empty = r["noCopy"], r["copySame"], r["copyEmpty"]
|
||||
assert no_copy["fill"] == same["fill"] and no_copy["cut"] == same["cut"] # B05 만 = B06 연 뒤
|
||||
assert empty["fill"] != no_copy["fill"] # 빈 사본 = 소단 없음(저장분으로 안 물러섬)
|
||||
# [저장] = 서버가 구조물 정본으로 다시 셈
|
||||
root = _project(tmp_path / "save", SAVED)
|
||||
design = {"ground_type": "soil", "section_mode": "both_fill", "ditch_type": "standard"}
|
||||
sections = [{"chainage_m": 40.0, "samples": GROUND, "design": design}]
|
||||
assert enforce_design_lines(LONG, sections, root) == 1
|
||||
assert abs(sections[0]["design"]["fill_area_m2"] - same["fill"]) < 1e-3
|
||||
bare = [{"chainage_m": 40.0, "samples": GROUND, "design": dict(design)}]
|
||||
enforce_design_lines(LONG, bare, _project(tmp_path / "bare", []))
|
||||
assert abs(bare[0]["design"]["fill_area_m2"] - empty["fill"]) < 1e-3
|
||||
|
||||
|
||||
def test_쓰는_자리_하나():
|
||||
sync = (ROOT / "B06_Section" / "B06_Section_UI_Page_Design_Sync.ts").read_text(encoding="utf-8")
|
||||
assert "writeBermSpans" not in sync and "useStructureIds(projectId, structures)" in sync
|
||||
lane = (ROOT / "A00_Common" / "design" / "design_facility_lane.ts").read_text(encoding="utf-8")
|
||||
assert "writeBermSpans(projectId, routeId, next)" in lane
|
||||
@@ -0,0 +1,111 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""467 (요구 272 · 분석 4장 (B1)) — 노선 초안 없는 차례의 갈아끼움이 정본 횡단을 지킴.
|
||||
|
||||
못박는 것
|
||||
- 관만 옮김(노선 초안 없음) — 같은 열쇠 · 누가거리 0.01 m 안 측점은 앞 횡단(서버 정본)
|
||||
기하 · 표본 · 중심고 그대로(R 12 곡선 축 차 3.3e-4 · 중심 0.5 mm 차여도) ·
|
||||
옮긴 관 측점만 브라우저 표본.
|
||||
- 되돌림(관 제자리) — 관 측점 밖 모든 횡단이 정본과 바이트 같음(관 측점 = 브라우저 표본).
|
||||
- 노선 초안 차례 = 옛 규칙(축 허용 1e-4 · 넘으면 브라우저 표본).
|
||||
- 가게 길(`swapSectionStations`) = 가게 `routeDraft` 로 가름 — 없음 · 있음 ·
|
||||
초안 버린 직후(초안 표본이 안 남음).
|
||||
|
||||
Node 헬퍼 `helper_272_swap_canon.mjs` 가 vite ssr 로 묶은 진짜 모듈을 부름.
|
||||
"""
|
||||
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
ROOT = HERE.parents[1]
|
||||
CURVES = ("27.50", "33.20", "38.90")
|
||||
STRAIGHT = ("0.00", "20.00", "40.00", "60.00", "70.00")
|
||||
STILL = (*STRAIGHT, *CURVES)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def out(tmp_path_factory):
|
||||
work = tmp_path_factory.mktemp("b272swap")
|
||||
build = subprocess.run( # noqa: S603 — 고정 실행 파일
|
||||
[
|
||||
"node",
|
||||
str(ROOT / "config" / "node_modules" / "vite" / "bin" / "vite.js"),
|
||||
"build",
|
||||
"--configLoader",
|
||||
"runner",
|
||||
"--ssr",
|
||||
"../resources/tester/helper_272_swap_canon_entry.ts",
|
||||
"--outDir",
|
||||
str(work),
|
||||
"--logLevel",
|
||||
"error",
|
||||
],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=300,
|
||||
)
|
||||
assert build.returncode == 0, build.stderr
|
||||
bundle = work / "bundle.mjs"
|
||||
shutil.copy(work / "helper_272_swap_canon_entry.js", bundle)
|
||||
proc = subprocess.run( # noqa: S603
|
||||
["node", str(HERE / "helper_272_swap_canon.mjs"), str(bundle)],
|
||||
cwd=ROOT,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=120,
|
||||
)
|
||||
assert proc.returncode == 0, proc.stderr
|
||||
return json.loads(proc.stdout)
|
||||
|
||||
|
||||
def test_관만_옮김_정본_기하_표본_그대로(out):
|
||||
keep = out["pure"]["keep"]
|
||||
for at in STILL:
|
||||
assert keep[at]["same"], at # 곡선 축 차 3.3e-4 여도 서버 표본 · 기하
|
||||
assert keep[at]["mark"] == f"canon@{float(at):g}"
|
||||
assert keep["55.00"]["browser"] and not keep["55.00"]["same"] # 옮긴 관 = 새 자리 표본
|
||||
assert out["pure"]["keepMoved"] is False # 「노선 밖 고침」 셈 그대로(0.01 m)
|
||||
assert out["pure"]["defaultIsKeep"] # 기본 = 노선 초안 없음
|
||||
|
||||
|
||||
def test_되돌림_정본과_바이트_같음(out):
|
||||
back = out["pure"]["back"]
|
||||
assert all(back[at]["same"] for at in STILL)
|
||||
assert out["pure"]["backBytes"] # 관 측점 밖 횡단 = 정본 바이트
|
||||
assert back["45.00"]["browser"] # 관 측점 = 브라우저 표본(정본은 저장 뒤 서버 값)
|
||||
|
||||
|
||||
def test_노선_초안_차례는_옛_규칙(out):
|
||||
draft = out["pure"]["draft"]
|
||||
for at in CURVES: # 축 차 > 1e-4 = 새 표본
|
||||
assert draft[at]["browser"] and not draft[at]["same"], at
|
||||
for at in STRAIGHT: # 축 차 1e-5 · 자리 같음 = 앞 표본(기하는 새 틀)
|
||||
assert not draft[at]["browser"] and not draft[at]["same"], at
|
||||
|
||||
|
||||
def test_가게_길_초안_없음(out):
|
||||
s = out["storeNoDraft"]
|
||||
assert s["moved"] and s["back"]
|
||||
assert all(s["moved"][at]["same"] for at in STILL)
|
||||
assert all(s["back"][at]["same"] for at in STILL) and s["backBytes"]
|
||||
|
||||
|
||||
def test_가게_길_초안_있음_버린_직후(out):
|
||||
s = out["storeDraft"]
|
||||
assert s["routeDraftSet"]
|
||||
for at in CURVES: # 초안이 옮긴 곡선 = 새 표본
|
||||
assert s["draft"][at]["browser"], at
|
||||
for at in STRAIGHT: # 초안 차례 = 옛 규칙(기하 새 틀 · 표본 앞 값)
|
||||
assert not s["draft"][at]["same"] and not s["draft"][at]["browser"], at
|
||||
dropped = s["dropped"]
|
||||
for at in CURVES: # 버린 뒤 = 저장 노선 자리 표본(초안 3 cm 자리 표본이 안 남음)
|
||||
assert dropped[at]["browser"], at
|
||||
for at in STRAIGHT: # 초안이 안 옮긴 측점 = 앞 횡단 표본(서버) 그대로
|
||||
assert not dropped[at]["browser"], at
|
||||
Reference in New Issue
Block a user