Merge remote-tracking branch 'origin/dev' into sub_laptop_7
This commit is contained in:
@@ -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,11 @@
|
||||
/* 272 시험 묶음 진입점(468 · 466-C) — 사진첩 빈 칸 · 세션 맵 빈 쓰기 · 숨은 종단도 파생값 · 배지 자릿수(진짜 모듈 · vite ssr). */
|
||||
export { createProfileHistory } from "../../B05_Profile/B05_Profile_UI_Profile_History";
|
||||
export {
|
||||
createSessionMap,
|
||||
moveSessionMaps,
|
||||
} from "../../B06_Section/B06_Section_UI_Page_Link_Session";
|
||||
export { renderProfile } from "../../B05_Profile/B05_Profile_UI_Profile_Render";
|
||||
export { createRouteMassHaulPanel } from "../../B05_Profile/B05_Profile_UI_Profile_MassHaul";
|
||||
export { createMassHaulBadge } from "../../common_util/common_util_mass_haul_badge";
|
||||
export { computeMassHaulSeries } from "../../common_util/common_util_mass_haul";
|
||||
export { staleKey } from "../../B06_Section/B06_Section_UI_Section_Common";
|
||||
@@ -0,0 +1,231 @@
|
||||
/* 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),
|
||||
};
|
||||
}
|
||||
|
||||
/* 1-2. 격자 측점(40 m)에 구조물을 놓고 뺌 — 열쇠가 바뀌어도 같은 자리 = 정본 표본 · 기하 */
|
||||
{
|
||||
const onGrid = stationsAt(45).map((s) =>
|
||||
s.key === "grid:2" ? { ...s, key: "structure:s1", kind: "structure", id: "s1" } : s,
|
||||
);
|
||||
const placed = m.swapCrossSections(canonDetail(), onGrid, KEYS, 20, false);
|
||||
const removed = m.swapCrossSections(placed.detail, stationsAt(45), keysOf(onGrid), 20, false);
|
||||
out.gridStructure = {
|
||||
placed: report(placed.detail)["40.00"],
|
||||
removed: report(removed.detail)["40.00"],
|
||||
removedBytes: bytesSame(removed.detail, [45, 40]),
|
||||
};
|
||||
}
|
||||
|
||||
/* 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,353 @@
|
||||
/* 272 헬퍼(468 · 466-C) — 사진첩 빈 칸 · 세션 맵 빈 쓰기 · 숨은 종단도 파생값 · 배지 자릿수.
|
||||
* node helper_272_value_hold.mjs <묶음.mjs>
|
||||
* vite ssr 로 묶은 진짜 모듈(helper_272_entry.ts) · 표준출력 JSON 한 벌.
|
||||
* 짝 = `test_272_history_empty_cells.py` · `test_272_hidden_summary.py`.
|
||||
*/
|
||||
import { pathToFileURL } from "node:url";
|
||||
|
||||
const store = () => {
|
||||
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(),
|
||||
};
|
||||
};
|
||||
// 손길 듣기(pointerdown · keydown)가 붙는 창 — 사진첩 시험(346-4)과 같은 꼴
|
||||
const win = new EventTarget();
|
||||
win.setTimeout = setTimeout;
|
||||
win.clearTimeout = clearTimeout;
|
||||
win.sessionStorage = store();
|
||||
win.localStorage = store();
|
||||
win.innerHeight = 900;
|
||||
win.matchMedia = () => ({ matches: false, addEventListener: () => undefined });
|
||||
win.requestAnimationFrame = (run) => setTimeout(run, 0);
|
||||
globalThis.window = win;
|
||||
globalThis.screen = {};
|
||||
globalThis.sessionStorage = win.sessionStorage;
|
||||
globalThis.localStorage = win.localStorage;
|
||||
globalThis.requestAnimationFrame = win.requestAnimationFrame;
|
||||
const any = new Proxy(function () {}, {
|
||||
get: (_t, k) => (k === Symbol.toPrimitive ? () => 0 : any),
|
||||
apply: () => any,
|
||||
construct: () => any,
|
||||
});
|
||||
globalThis.document = any;
|
||||
localStorage.setItem("frd_current_project_id", "p1");
|
||||
|
||||
const m = await import(pathToFileURL(process.argv[2]).href);
|
||||
const out = {};
|
||||
const S = sessionStorage;
|
||||
const key = (name) => `aislo:draft:${name}:p1:7`;
|
||||
const SIX = ["basinadjust", "crossw", "extraspan", "extrawall", "inletstruct", "revetx"];
|
||||
const touch = () => win.dispatchEvent(new Event("keydown"));
|
||||
|
||||
/* ── H1 · 되돌린 뒤 빈 칸이 생김(R4) — 「{}」 · 「null」 · 「""」 쓰기는 걸음 아님 · ↷ 남음 ── */
|
||||
{
|
||||
const h = m.createProfileHistory(() => {});
|
||||
touch();
|
||||
S.setItem(key("alignment-draft"), JSON.stringify({ station_offsets: { 100: 1 } }));
|
||||
h.record();
|
||||
const edited = h.canUndo();
|
||||
h.undo();
|
||||
const undone = { undo: h.canUndo(), redo: h.canRedo(), grade: S.getItem(key("alignment-draft")) };
|
||||
// B06 로 넘어가는 누름(손길) 뒤 첫 마운트 · 갈아끼움 이동(moveSessionMaps)이 빈 맵 여섯을 씀 · 다른 칸은 null · 빈 글
|
||||
touch();
|
||||
SIX.forEach((name) => S.setItem(key(name), "{}"));
|
||||
S.setItem(key("rockb"), "null");
|
||||
S.setItem(key("cutslope"), "");
|
||||
h.record();
|
||||
out.h1 = { edited, undone, after: { undo: h.canUndo(), redo: h.canRedo() } };
|
||||
// ↷ = 사용자 조작 그대로 한 걸음
|
||||
out.h1.redone = h.redo();
|
||||
out.h1.redoGrade = S.getItem(key("alignment-draft"));
|
||||
out.h1.final = { undo: h.canUndo(), redo: h.canRedo() };
|
||||
S.clear();
|
||||
localStorage.setItem("frd_current_project_id", "p1");
|
||||
}
|
||||
|
||||
/* ── H2 · 「[]」 = 목록 초안(관 · 구조물 모두 지움) — 걸음 그대로 · 되돌리면 칸 없음 ── */
|
||||
{
|
||||
const h = m.createProfileHistory(() => {});
|
||||
touch();
|
||||
S.setItem("aislo:draft:pipes:p1", "[]");
|
||||
h.record();
|
||||
const step = h.canUndo();
|
||||
h.undo();
|
||||
out.h2 = { step, undonePipes: S.getItem("aislo:draft:pipes:p1") };
|
||||
h.redo();
|
||||
out.h2.redonePipes = S.getItem("aislo:draft:pipes:p1");
|
||||
S.clear();
|
||||
localStorage.setItem("frd_current_project_id", "p1");
|
||||
}
|
||||
|
||||
/* ── H3 · 빈 칸이 있던 걸음으로 되돌림 = 빈 칸(없음과 같음) · 값 칸은 그대로 ── */
|
||||
{
|
||||
S.setItem(key("crossw"), "{}");
|
||||
S.setItem(key("revetx"), JSON.stringify({ "100.00:inlet": { x: 1 } }));
|
||||
const h = m.createProfileHistory(() => {});
|
||||
touch();
|
||||
S.setItem(key("crossw"), JSON.stringify({ "100.00": 6 }));
|
||||
h.record();
|
||||
const step = h.canUndo();
|
||||
h.undo();
|
||||
out.h3 = { step, crossw: S.getItem(key("crossw")), revetx: S.getItem(key("revetx")) };
|
||||
S.clear();
|
||||
localStorage.setItem("frd_current_project_id", "p1");
|
||||
}
|
||||
|
||||
/* ── H4 · 세션 맵 — 빈 맵 쓰기 = 칸 지움 · 값 있으면 씀 · 빈 맵 이동은 칸을 안 만듦 ── */
|
||||
{
|
||||
const width = m.createSessionMap(
|
||||
() => key("crossw"),
|
||||
(v) => (typeof v === "number" ? v : undefined),
|
||||
);
|
||||
width.persist();
|
||||
const emptyWrite = S.getItem(key("crossw"));
|
||||
width.values.set("100.00", 6);
|
||||
width.persist();
|
||||
const filledWrite = S.getItem(key("crossw"));
|
||||
width.values.clear();
|
||||
width.persist();
|
||||
const clearedWrite = S.getItem(key("crossw"));
|
||||
const others = SIX.filter((n) => n !== "crossw").map((n) =>
|
||||
m.createSessionMap(
|
||||
() => key(n),
|
||||
(v) => v,
|
||||
),
|
||||
);
|
||||
m.moveSessionMaps(new Map([["100.00", "120.00"]]));
|
||||
const moved = SIX.map((n) => S.getItem(key(n)));
|
||||
// 값 있는 맵 이동 = 새 자리로 옮겨 씀
|
||||
S.setItem(key("extrawall"), JSON.stringify({ "100.00": 2 }));
|
||||
m.moveSessionMaps(new Map([["100.00", "120.00"]]));
|
||||
out.h4 = {
|
||||
emptyWrite,
|
||||
filledWrite,
|
||||
clearedWrite,
|
||||
moved,
|
||||
movedFilled: S.getItem(key("extrawall")),
|
||||
made: others.length,
|
||||
};
|
||||
S.clear();
|
||||
localStorage.setItem("frd_current_project_id", "p1");
|
||||
}
|
||||
|
||||
/* ── 숨은 종단도(본문 0 크기) — 낡음 예약 · 유토곡선 셈 · 배분 선반입 여전히 · 펼침과 같은 값 ── */
|
||||
const samples = [0, 20, 40, 60, 80, 100].map((c) => ({
|
||||
chainage_m: c,
|
||||
elevation_m: 100 + c * 0.05,
|
||||
valid: true,
|
||||
}));
|
||||
const plan = [0, 20, 40, 60, 80, 100].map((c) => ({ chainage_m: c, elevation_m: 100 + c * 0.04 }));
|
||||
const design = (c, cut, fill, z) => ({
|
||||
station_id: `station_${c}`,
|
||||
chainage_m: c,
|
||||
design: {
|
||||
cut_area_m2: cut,
|
||||
fill_area_m2: fill,
|
||||
ground_type: "soil",
|
||||
design_elevation_m: z,
|
||||
},
|
||||
});
|
||||
const detail = {
|
||||
longitudinal: {
|
||||
length_m: 100,
|
||||
samples,
|
||||
stations: samples.map((s) => ({
|
||||
station_id: `station_${s.chainage_m}`,
|
||||
chainage_m: s.chainage_m,
|
||||
})),
|
||||
design_profiles: [{ id: "design_grade_line", samples: plan }],
|
||||
},
|
||||
cross_sections: [
|
||||
design(0, 2, 0, 100),
|
||||
design(20, 3, 1, 100.8),
|
||||
design(40, 1, 4, 101.6),
|
||||
design(60, 0, 6, 999), // 낡음 — 계획선과 어긋난 측점(다시 셈 예약 대상)
|
||||
design(80, 2, 2, 103.2),
|
||||
design(100, 4, 0, 104),
|
||||
],
|
||||
};
|
||||
const alignment = {
|
||||
samples: plan,
|
||||
edits: { station_offsets: {}, curve_radii: {} },
|
||||
stations: plan.map((p) => ({
|
||||
chainage_m: p.chainage_m,
|
||||
plan_elevation_m: p.elevation_m,
|
||||
kind: "regular",
|
||||
})),
|
||||
curves: [],
|
||||
balance: { cut_area_m2: 0, fill_area_m2: 0, net_area_m2: 0 },
|
||||
policy: { station_interval_m: 20, edit_step_m: 0.1 },
|
||||
};
|
||||
const ONES = {
|
||||
soil: { loose: 1, compacted: 1 },
|
||||
ripping_rock: { loose: 1, compacted: 1 },
|
||||
blasting_rock: { loose: 1, compacted: 1 },
|
||||
};
|
||||
|
||||
function ctxFor(width, rec) {
|
||||
const body = {
|
||||
clientWidth: width,
|
||||
clientHeight: width ? 400 : 0,
|
||||
scrollLeft: 0,
|
||||
parentElement: null,
|
||||
replaceChildren: () => (rec.painted += 1),
|
||||
addEventListener: () => undefined,
|
||||
};
|
||||
return {
|
||||
body,
|
||||
onStaleDesigns: (k) => (rec.stale.push(k), false),
|
||||
callbacks: undefined,
|
||||
massHaul: { draw: (p) => rec.mass.push(p) },
|
||||
tableOverlay: { isOpen: () => false, contentHeight: () => 0, setTable: () => undefined },
|
||||
store: { edits: () => ({}), savedRadii: () => ({}), resetStation: () => undefined },
|
||||
detail: () => detail,
|
||||
alignment: () => alignment,
|
||||
base: () => null,
|
||||
stationInterval: () => 20,
|
||||
irregularStations: () => [],
|
||||
minCoverTargets: () => [],
|
||||
structures: () => [],
|
||||
structureTypes: () => [],
|
||||
selectedStationId: () => null,
|
||||
setSelectedStationId: () => undefined,
|
||||
selectedStructureId: () => null,
|
||||
setSelectedStructureId: () => undefined,
|
||||
stationDisplay: () => ({ station: 0, cumulative: 0 }),
|
||||
setLastSize: () => (rec.sized += 1),
|
||||
renderBalance: () => (rec.balance += 1),
|
||||
applyHeightCascade: () => ({ chartHeight: 300 }),
|
||||
clearMainDragCooldown: () => undefined,
|
||||
selectStation: () => undefined,
|
||||
applyEdits: () => undefined,
|
||||
handleToolPick: () => false,
|
||||
zoom: () => ({ x: 1 }),
|
||||
holdElevationRange: (next) => next ?? undefined,
|
||||
toolActive: () => false,
|
||||
tools: { selectedRuns: () => [], mountOverlay: () => undefined },
|
||||
stationIdAtStructure: () => null,
|
||||
redraw: () => undefined,
|
||||
setElevationWindowUpdater: () => undefined,
|
||||
};
|
||||
}
|
||||
const pick = (p) =>
|
||||
p && {
|
||||
pendingRecalc: p.pendingRecalc,
|
||||
staleChainages: p.staleChainages,
|
||||
crossSections: p.crossSections.length,
|
||||
longitudinal: p.longitudinal,
|
||||
stations: p.stationSource.stations.map((s) => s.chainage_m),
|
||||
maxChainageM: p.axis.maxChainageM,
|
||||
};
|
||||
const hiddenRec = { stale: [], mass: [], painted: 0, sized: 0, balance: 0 };
|
||||
m.renderProfile(ctxFor(0, hiddenRec));
|
||||
const shownRec = { stale: [], mass: [], painted: 0, sized: 0, balance: 0 };
|
||||
let shownError = null;
|
||||
try {
|
||||
m.renderProfile(ctxFor(1200, shownRec));
|
||||
} catch (error) {
|
||||
shownError = String(error?.stack ?? error);
|
||||
}
|
||||
out.hidden = {
|
||||
stale: hiddenRec.stale,
|
||||
mass: pick(hiddenRec.mass[0]),
|
||||
massCount: hiddenRec.mass.length,
|
||||
painted: hiddenRec.painted,
|
||||
sized: hiddenRec.sized,
|
||||
};
|
||||
out.shown = {
|
||||
stale: shownRec.stale,
|
||||
mass: pick(shownRec.mass[0]),
|
||||
massCount: shownRec.mass.length,
|
||||
painted: shownRec.painted,
|
||||
error: shownError,
|
||||
};
|
||||
out.expectedStale = m.staleKey({
|
||||
longitudinal: { design_profiles: [{ samples: plan }] },
|
||||
cross_sections: detail.cross_sections,
|
||||
});
|
||||
|
||||
/* 유토곡선 판(진짜) — 판 접힘 · 펼침인데 본문 숨음(자리 0) = 총괄값 · 배분 선반입만 · 그림 없음 */
|
||||
function massPanel(open) {
|
||||
localStorage.setItem("aislo:pref:masshaul-open", String(open));
|
||||
const rec = { summary: [], scheduled: 0 };
|
||||
const prefetch = {
|
||||
schedule: () => (rec.scheduled += 1),
|
||||
current: () => null,
|
||||
};
|
||||
const panel = m.createRouteMassHaulPanel(
|
||||
() => undefined,
|
||||
(s) => rec.summary.push(s),
|
||||
prefetch,
|
||||
);
|
||||
panel.setContext({ conversion: ONES });
|
||||
return { panel, rec };
|
||||
}
|
||||
const series = m.computeMassHaulSeries(
|
||||
{ length_m: 100, design_profiles: [{ samples: plan }] },
|
||||
detail.cross_sections,
|
||||
ONES,
|
||||
undefined,
|
||||
["cross"],
|
||||
);
|
||||
const finalM3 = series[0]?.result.points.at(-1)?.cumulative_volume_m3 ?? null;
|
||||
const massParams = hiddenRec.mass[0];
|
||||
out.panel = {};
|
||||
for (const open of [false, true]) {
|
||||
const { panel, rec } = massPanel(open);
|
||||
let error = null;
|
||||
try {
|
||||
if (massParams) panel.draw({ ...massParams, pendingRecalc: false });
|
||||
} catch (e) {
|
||||
error = String(e?.stack ?? e);
|
||||
}
|
||||
out.panel[open ? "open" : "closed"] = {
|
||||
summary: rec.summary.map((s) => s?.finalM3 ?? null),
|
||||
scheduled: rec.scheduled,
|
||||
error,
|
||||
};
|
||||
}
|
||||
out.finalM3 = finalM3;
|
||||
|
||||
/* ── 배지 표기 — 소수 한 자리 고정 ── */
|
||||
{
|
||||
const make = () => {
|
||||
const el = {
|
||||
textContent: "",
|
||||
title: "",
|
||||
hidden: false,
|
||||
style: { setProperty: () => undefined },
|
||||
classList: { toggle: () => undefined, add: () => undefined },
|
||||
append: () => undefined,
|
||||
className: "",
|
||||
};
|
||||
return el;
|
||||
};
|
||||
const made = [];
|
||||
globalThis.document = { createElement: () => (made.push(make()), made.at(-1)) };
|
||||
const badge = m.createMassHaulBadge();
|
||||
const texts = [];
|
||||
for (const v of [-17570, -17570.7, 1234.56, 0]) {
|
||||
badge.set({
|
||||
finalM3: v,
|
||||
cutNaturalM3: 0,
|
||||
cutCompactedM3: 0,
|
||||
fillCompactedM3: 0,
|
||||
surplusM3: 0,
|
||||
shortageM3: 0,
|
||||
});
|
||||
texts.push(made[2].textContent);
|
||||
}
|
||||
out.badge = texts;
|
||||
globalThis.document = any;
|
||||
}
|
||||
|
||||
process.stdout.write(JSON.stringify(out));
|
||||
process.exit(0);
|
||||
@@ -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,55 @@
|
||||
"""272 · 468 (C2) 종단 판 접힘(본문 0 크기) 파생값 · (C3) 배지 자릿수.
|
||||
|
||||
R3 — 판 접은 채 교점 ↓ → 배지 옛 값 그대로 → 이제 접힘 동안도 낡음 예약 · 유토 총괄값 · 배분 선반입 · 측점 자료를 셈 ·
|
||||
그리기(본문 갈아 끼움 · 크기 기록)만 건너뜀 · 펼친 그림과 같은 값. 배지 = 소수 한 자리 고정.
|
||||
짝: `helper_272_value_hold.mjs` · 묶음 짓기 = `test_272_history_empty_cells.run_helper`.
|
||||
|
||||
./venv/Scripts/python.exe -m pytest resources/tester/test_272_hidden_summary.py -q
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
from test_272_history_empty_cells import pytestmark, run_helper # noqa: E402, F401
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def out(tmp_path_factory):
|
||||
return run_helper(tmp_path_factory)
|
||||
|
||||
|
||||
def test_숨은_본문도_낡음_예약은_펼침과_같은_열쇠(out):
|
||||
assert out["shown"]["error"] is None
|
||||
assert out["shown"]["stale"] == [out["expectedStale"]]
|
||||
assert out["hidden"]["stale"] == out["shown"]["stale"]
|
||||
|
||||
|
||||
def test_숨은_본문도_유토곡선_입력은_펼침과_같음(out):
|
||||
hidden, shown = out["hidden"], out["shown"]
|
||||
assert hidden["massCount"] == shown["massCount"] == 1
|
||||
assert hidden["mass"] == shown["mass"]
|
||||
assert hidden["mass"]["staleChainages"] == [60]
|
||||
|
||||
|
||||
def test_숨은_본문은_그리기만_건너뜀(out):
|
||||
assert out["hidden"]["painted"] == 0 and out["hidden"]["sized"] == 0
|
||||
assert out["shown"]["painted"] == 1
|
||||
|
||||
|
||||
def test_유토_판_접힘_펼침_모두_총괄값과_배분_선반입(out):
|
||||
final = out["finalM3"]
|
||||
assert final is not None
|
||||
for state in ("closed", "open"):
|
||||
panel = out["panel"][state]
|
||||
assert panel["error"] is None, panel["error"]
|
||||
assert panel["summary"] == [final], state
|
||||
assert panel["scheduled"] == 1, state
|
||||
|
||||
|
||||
def test_배지는_소수_한_자리(out):
|
||||
assert out["badge"] == ["-17,570.0㎥", "-17,570.7㎥", "1,234.6㎥", "0.0㎥"]
|
||||
@@ -0,0 +1,104 @@
|
||||
"""272 · 468 (C1) 되돌리기 빈 칸 — 「{}」 · 「null」 · 「""」 = 칸 없음 · 세션 맵 빈 쓰기 = 칸 지움.
|
||||
|
||||
R4 — 교점 ↓ → ↶ → B06(누름 뒤 첫 마운트가 빈 맵 여섯 「{}」를 씀) → ↶ 켜짐 · ↷ 사라짐 → 이제 ↶ 꺼짐 · ↷ 남음.
|
||||
「[]」 는 목록 초안(관 · 구조물 모두 지움 = 저장분과 다름)이라 걸음 그대로.
|
||||
짝: `helper_272_value_hold.mjs`(vite ssr 로 묶은 진짜 모듈 · `helper_272_entry.ts`).
|
||||
|
||||
./venv/Scripts/python.exe -m pytest resources/tester/test_272_history_empty_cells.py -q
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import shutil
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
ROOT = HERE.parents[1]
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not (ROOT / "config" / "node_modules" / "vite").is_dir(),
|
||||
reason="프론트엔드 의존성 미설치",
|
||||
)
|
||||
|
||||
|
||||
def run_helper(tmp_path_factory: pytest.TempPathFactory) -> dict:
|
||||
work = tmp_path_factory.mktemp("b272")
|
||||
build = subprocess.run(
|
||||
[
|
||||
"node",
|
||||
str(ROOT / "config" / "node_modules" / "vite" / "bin" / "vite.js"),
|
||||
"build",
|
||||
"--configLoader",
|
||||
"runner",
|
||||
"--ssr",
|
||||
"../resources/tester/helper_272_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_entry.js", bundle)
|
||||
proc = subprocess.run(
|
||||
["node", str(HERE / "helper_272_value_hold.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)
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def out(tmp_path_factory):
|
||||
return run_helper(tmp_path_factory)
|
||||
|
||||
|
||||
def test_되돌린_뒤_빈_칸이_생겨도_다시하기_남음(out):
|
||||
h1 = out["h1"]
|
||||
assert h1["edited"] is True
|
||||
assert h1["undone"] == {"undo": False, "redo": True, "grade": None}
|
||||
# 빈 맵 여섯 「{}」 · 「null」 · 「""」 = 걸음 아님
|
||||
assert h1["after"] == {"undo": False, "redo": True}
|
||||
|
||||
|
||||
def test_사용자_조작은_한_걸음_그대로(out):
|
||||
h1 = out["h1"]
|
||||
assert h1["redone"] is True
|
||||
assert h1["redoGrade"] == json.dumps({"station_offsets": {"100": 1}}, separators=(",", ":"))
|
||||
assert h1["final"] == {"undo": True, "redo": False}
|
||||
|
||||
|
||||
def test_빈_목록_초안은_걸음(out):
|
||||
# 관 모두 지움(「[]」) ≠ 칸 없음(저장분 관) — 되돌리기 · 다시하기 그대로
|
||||
assert out["h2"] == {"step": True, "undonePipes": None, "redonePipes": "[]"}
|
||||
|
||||
|
||||
def test_빈_칸_걸음으로_되돌리면_빈_칸(out):
|
||||
h3 = out["h3"]
|
||||
assert h3["step"] is True
|
||||
assert h3["crossw"] in (None, "{}") # 빈 칸 = 칸 없음(읽는 쪽은 빈 맵)
|
||||
assert h3["revetx"] == json.dumps({"100.00:inlet": {"x": 1}}, separators=(",", ":"))
|
||||
|
||||
|
||||
def test_세션_맵_빈_쓰기는_칸_지움(out):
|
||||
h4 = out["h4"]
|
||||
assert h4["emptyWrite"] is None
|
||||
assert h4["filledWrite"] == '{"100.00":6}'
|
||||
assert h4["clearedWrite"] is None
|
||||
# 빈 맵 이동은 칸을 안 만듦 · 값 있는 맵은 새 자리로 옮겨 씀
|
||||
assert h4["moved"] == [None] * 6
|
||||
assert h4["movedFilled"] == '{"120.00":2}'
|
||||
@@ -0,0 +1,118 @@
|
||||
# -*- 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):
|
||||
g = out["gridStructure"]
|
||||
assert g["placed"]["same"] and not g["placed"]["browser"] # 열쇠 바뀜(구조물) · 같은 자리 = 정본
|
||||
assert g["removed"]["same"] and not g["removed"]["browser"] # 다시 격자 = 정본 표본 · 기하
|
||||
assert g["removedBytes"]
|
||||
|
||||
|
||||
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