fix(계산묶음): 349 조작 하나 = 묶음 한 번 · 열기만 하면 저장 정본 그대로
- 고리 끊음: 묶음 측점 → 상세 갈아끼움 → 종단도 render · 비정규 측점 · 유토곡선 설정이 묶음을 처음부터 다시 부르던 것 — 다시 시작은 저장 정본(새로 받은 상세 · 새 노선)이 바뀔 때만 · 횡단 입력도 정본 상세에서만 모음 - 열 때(start 차례)는 측점 · 종단을 가게에 안 냄 — 상세 갈아끼움 없음 · 유토곡선 = 저장값 - 저장 노선(열 때 · 초안 버림)은 관 · 구조물 누가거리 · 계획고를 저장값 그대로(다시 투영 안 함 · 되돌리기 뒤 계획고 한 번 더 셈 없음) - 노선 초안 동안 종단도 render · 비정규 측점이 초안 그림(기준 · 미리보기 가게)을 덮지 않음 - 시험 test_349_pipeline_once 4건(검증_sub7 실제 노선 · 옛 코드에서 4건 실패 재현) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TteK8mfYZetk5P3bEZkyVZ
This commit is contained in:
@@ -43,6 +43,7 @@ import {
|
|||||||
markAlignmentSaved,
|
markAlignmentSaved,
|
||||||
readAlignmentDraft,
|
readAlignmentDraft,
|
||||||
} from "../../B05_Profile/B05_Profile_UI_Profile_Edit";
|
} from "../../B05_Profile/B05_Profile_UI_Profile_Edit";
|
||||||
|
import { readAlignment } from "../../B05_Profile/logic/B05_Profile_UI_Profile_Data";
|
||||||
import {
|
import {
|
||||||
analysisTerrain,
|
analysisTerrain,
|
||||||
fetchRoutePlan,
|
fetchRoutePlan,
|
||||||
@@ -141,7 +142,7 @@ export function routeDraftBridge(
|
|||||||
export const pipelineGrade = (projectId: string, edits: AlignmentEdits): void =>
|
export const pipelineGrade = (projectId: string, edits: AlignmentEdits): void =>
|
||||||
pages.get(projectId)?.grade(edits);
|
pages.get(projectId)?.grade(edits);
|
||||||
|
|
||||||
/** 저장 종단 기준이 바뀜(새 상세 · 구조물 측점) — 처음부터 다시. */
|
/** 저장 정본이 바뀜(새로 받은 상세 · 새 노선) — 처음부터 다시. 갈아끼운 상세 · 같은 상세 다시 그림은 안 셈. */
|
||||||
export const restartPagePipeline = (projectId: string): void => pages.get(projectId)?.restart();
|
export const restartPagePipeline = (projectId: string): void => pages.get(projectId)?.restart();
|
||||||
|
|
||||||
/** 유토곡선 설정(토량환산계수 · 자연방토 경사) — masshaul 단계 재료 · 표준단면이 막 왔으면 횡단 입력도. */
|
/** 유토곡선 설정(토량환산계수 · 자연방토 경사) — masshaul 단계 재료 · 표준단면이 막 왔으면 횡단 입력도. */
|
||||||
@@ -178,19 +179,43 @@ function createPagePipeline(
|
|||||||
let savedStations: PipelineStation[] = [];
|
let savedStations: PipelineStation[] = [];
|
||||||
let crossSource: { detail: SectionDetailResponse; source: PipelineCrossSource | null } | null =
|
let crossSource: { detail: SectionDetailResponse; source: PipelineCrossSource | null } | null =
|
||||||
null;
|
null;
|
||||||
|
/** 저장 정본(서버가 준 상세 · 노선 번호) — 측점 갈아끼움(swap)이 만든 새 상세는 지반 표본 배열을
|
||||||
|
* 그대로 둠 → 정본 아님(묶음 출력 → 상세 → 다시 묶음 고리를 끊음). */
|
||||||
|
let canon: { routeId: unknown; samples: unknown; detail: SectionDetailResponse | null } | null =
|
||||||
|
null;
|
||||||
let shown: SectionDetailResponse | null = null;
|
let shown: SectionDetailResponse | null = null;
|
||||||
let ready = false;
|
let ready = false;
|
||||||
let started = false;
|
let started = false;
|
||||||
/** 앞 종단이 노선 초안으로 셈한 것인가 — 초안을 버리면 저장 기준으로 다시 그림. */
|
/** 앞 종단이 노선 초안으로 셈한 것인가 — 초안을 버리면 저장 기준으로 다시 그림. */
|
||||||
let drawnDraft = false;
|
let drawnDraft = false;
|
||||||
let disposed = false;
|
let disposed = false;
|
||||||
|
/** 열 때 · 정본이 바뀐 차례(start) 번호 — 측점 · 종단을 가게에 안 냄(상세 = 저장 정본 그대로). */
|
||||||
|
let openGeneration = -1;
|
||||||
|
|
||||||
const savedLine = (): Vertex[] | null =>
|
const savedLine = (): Vertex[] | null =>
|
||||||
plan ? plan.planned.map(([x, y]): Vertex => [x, y]) : null;
|
plan ? plan.planned.map(([x, y]): Vertex => [x, y]) : null;
|
||||||
const savedCurves = () =>
|
const savedCurves = () =>
|
||||||
(plan?.curves ?? []).map(({ start, apex, end, radius_m }) => ({ start, apex, end, radius_m }));
|
(plan?.curves ?? []).map(({ start, apex, end, radius_m }) => ({ start, apex, end, radius_m }));
|
||||||
|
/** 저장 정본이 바뀌었나(새로 받은 상세 · 새 노선) — 바뀌었으면 잡아 둠. */
|
||||||
|
const canonChanged = (): boolean => {
|
||||||
|
const { detail = null, routeId } = link.pipelineSource();
|
||||||
|
const samples = detail?.longitudinal.samples;
|
||||||
|
if (canon && canon.routeId === routeId && canon.samples === samples) return false;
|
||||||
|
canon = { routeId, samples, detail };
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
/** 저장 노선 계획고 편집(세션 초안 → 저장분) — 노선 초안을 버리면 이것으로 돌아옴. */
|
||||||
|
const savedEdits = (): AlignmentEdits => {
|
||||||
|
const routeId = canon?.routeId;
|
||||||
|
const longitudinal = canon?.detail?.longitudinal;
|
||||||
|
return (
|
||||||
|
(typeof routeId === "number" ? readAlignmentDraft(routeId) : null) ??
|
||||||
|
(longitudinal && readAlignment(longitudinal)?.edits) ??
|
||||||
|
emptyEdits()
|
||||||
|
);
|
||||||
|
};
|
||||||
const crossNow = (): PipelineCrossSource | null => {
|
const crossNow = (): PipelineCrossSource | null => {
|
||||||
const detail = link.pipelineSource().detail ?? null;
|
const detail = canon?.detail ?? null;
|
||||||
if (!detail) return null;
|
if (!detail) return null;
|
||||||
if (crossSource?.detail !== detail || !crossSource.source)
|
if (crossSource?.detail !== detail || !crossSource.source)
|
||||||
crossSource = { detail, source: pipelineCrossSource(projectId, detail, savedStations) };
|
crossSource = { detail, source: pipelineCrossSource(projectId, detail, savedStations) };
|
||||||
@@ -204,7 +229,14 @@ function createPagePipeline(
|
|||||||
minRadiusM: () => plan?.min_radius_m ?? 0,
|
minRadiusM: () => plan?.min_radius_m ?? 0,
|
||||||
savedLine: () => plan && { line: savedLine()!, curves: savedCurves() },
|
savedLine: () => plan && { line: savedLine()!, curves: savedCurves() },
|
||||||
}),
|
}),
|
||||||
follow: createFollowStage({ savedLine }),
|
follow: createFollowStage({
|
||||||
|
savedLine,
|
||||||
|
saved: () => ({
|
||||||
|
pipes: store.get("pipes") ?? savedPipes,
|
||||||
|
structures: store.get("structures") ?? savedStructures,
|
||||||
|
alignment: savedEdits(),
|
||||||
|
}),
|
||||||
|
}),
|
||||||
stations: createStationsStage({ intervalM: options.stationIntervalM, types: () => types }),
|
stations: createStationsStage({ intervalM: options.stationIntervalM, types: () => types }),
|
||||||
ground: createGroundStage(groundStageDeps(projectId)),
|
ground: createGroundStage(groundStageDeps(projectId)),
|
||||||
planline: createPlanlineStage({ savedBase: () => link.pipelineSource().base, savedLine }),
|
planline: createPlanlineStage({ savedBase: () => link.pipelineSource().base, savedLine }),
|
||||||
@@ -231,7 +263,11 @@ function createPagePipeline(
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
pipe.subscribe(publishToStore(store));
|
const publish = publishToStore(store);
|
||||||
|
pipe.subscribe((event) => {
|
||||||
|
const saved = event.kind === "stage" && (event.stage === "ground" || event.stage === "profile");
|
||||||
|
if (!(saved && event.generation === openGeneration)) publish(event);
|
||||||
|
});
|
||||||
pipe.subscribe((event) => {
|
pipe.subscribe((event) => {
|
||||||
if (event.kind !== "stage" || (event.stage !== "profile" && event.stage !== "cross")) return;
|
if (event.kind !== "stage" || (event.stage !== "profile" && event.stage !== "cross")) return;
|
||||||
const draft = pipe.input("route") !== null;
|
const draft = pipe.input("route") !== null;
|
||||||
@@ -270,8 +306,10 @@ function createPagePipeline(
|
|||||||
};
|
};
|
||||||
const start = (): void => {
|
const start = (): void => {
|
||||||
if (disposed || !ready || !link.pipelineSource().base) return;
|
if (disposed || !ready || !link.pipelineSource().base) return;
|
||||||
|
canonChanged();
|
||||||
started = true;
|
started = true;
|
||||||
void pipe.start(inputsNow());
|
void pipe.start(inputsNow());
|
||||||
|
openGeneration = pipe.generation;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 저장 노선(그린 선 · 곡선표 · 기본 반경) · 그 측점 열쇠 — [저장] 뒤 다시 받음(`restart`). */
|
/** 저장 노선(그린 선 · 곡선표 · 기본 반경) · 그 측점 열쇠 — [저장] 뒤 다시 받음(`restart`). */
|
||||||
@@ -343,7 +381,7 @@ function createPagePipeline(
|
|||||||
},
|
},
|
||||||
restart() {
|
restart() {
|
||||||
if (!started) return start();
|
if (!started) return start();
|
||||||
void loadPlan().then(start);
|
if (canonChanged()) void loadPlan().then(start); // 갈아끼움 · 같은 상세 다시 그림은 안 셈
|
||||||
},
|
},
|
||||||
earthwork(context) {
|
earthwork(context) {
|
||||||
earthwork = context;
|
earthwork = context;
|
||||||
|
|||||||
@@ -494,13 +494,13 @@ export function createDesignProfile(ctx: DesignProfileContext) {
|
|||||||
const routeChanged = nextRouteId !== routeId;
|
const routeChanged = nextRouteId !== routeId;
|
||||||
const carried = routeChanged && store.edited() ? store.edits() : null;
|
const carried = routeChanged && store.edited() ? store.edits() : null;
|
||||||
// 서버 저장분을 기준으로 삼되, 남아 있는 세션 초안이 있으면 그쪽을 우선한다.
|
// 서버 저장분을 기준으로 삼되, 남아 있는 세션 초안이 있으면 그쪽을 우선한다.
|
||||||
if (routeChanged || !store.dirty()) {
|
if (routeChanged || (store !== preview && !store.dirty())) {
|
||||||
routeId = nextRouteId ?? routeId;
|
routeId = nextRouteId ?? routeId;
|
||||||
savedEdits = stored?.edits ?? emptyEdits();
|
savedEdits = stored?.edits ?? emptyEdits();
|
||||||
store = createProfileEditStore(routeId, savedEdits, () => rebuild());
|
store = createProfileEditStore(routeId, savedEdits, () => rebuild());
|
||||||
}
|
}
|
||||||
storedBase = stored ? toAlignmentBase(stored) : null;
|
storedBase = stored ? toAlignmentBase(stored) : null;
|
||||||
base = listed();
|
if (store !== preview) base = listed(); // 노선 초안 그림은 그대로(갈아끼운 상세)
|
||||||
// 이월분은 base 설정 후 미저장 초안으로 커밋한다(확정 시 전송·재탐색 후 새로고침에도 유지).
|
// 이월분은 base 설정 후 미저장 초안으로 커밋한다(확정 시 전송·재탐색 후 새로고침에도 유지).
|
||||||
if (carried) store.replace(carried);
|
if (carried) store.replace(carried);
|
||||||
alignment = base ? buildAlignment(base, store.edits()) : null;
|
alignment = base ? buildAlignment(base, store.edits()) : null;
|
||||||
@@ -580,7 +580,7 @@ export function createDesignProfile(ctx: DesignProfileContext) {
|
|||||||
/** 비정규 측점 목록을 반영해 그래프(세로선+라벨)·테이블(주석)을 다시 그린다. */
|
/** 비정규 측점 목록을 반영해 그래프(세로선+라벨)·테이블(주석)을 다시 그린다. */
|
||||||
setIrregularStations(stations: IrregularStation[]) {
|
setIrregularStations(stations: IrregularStation[]) {
|
||||||
irregularStations = stations;
|
irregularStations = stations;
|
||||||
base = listed();
|
if (store !== preview) base = listed();
|
||||||
if (base) alignment = buildAlignment(base, store.edits());
|
if (base) alignment = buildAlignment(base, store.edits());
|
||||||
pagePipeline.restartPagePipeline(projectId);
|
pagePipeline.restartPagePipeline(projectId);
|
||||||
draw();
|
draw();
|
||||||
|
|||||||
@@ -75,10 +75,15 @@ export function gradeRange(
|
|||||||
/**
|
/**
|
||||||
* follow — 노선이 바뀐 차례에 한 번 · 관 · 구조물 좌표 따라감 · 계획고 편집 옮김. 첫 계산(옛 노선 없음)은
|
* follow — 노선이 바뀐 차례에 한 번 · 관 · 구조물 좌표 따라감 · 계획고 편집 옮김. 첫 계산(옛 노선 없음)은
|
||||||
* 저장 노선(`savedLine`)을 옛 노선으로 보고 좌표만 따라감(투영은 몇 번 해도 같음 · 계획고 옮김은 안 함 —
|
* 저장 노선(`savedLine`)을 옛 노선으로 보고 좌표만 따라감(투영은 몇 번 해도 같음 · 계획고 옮김은 안 함 —
|
||||||
* 열 때의 계획고 초안은 이미 그 노선 기준).
|
* 열 때의 계획고 초안은 이미 그 노선 기준). 노선 초안이 없으면(열 때 · 초안 버림) `saved` 를 그대로 —
|
||||||
|
* 저장 노선의 관 · 구조물 누가거리 · 계획고는 정본이라 다시 투영하지 않음(투영 오차 = 측점 목록 어긋남).
|
||||||
*/
|
*/
|
||||||
export function createFollowStage(deps: { savedLine(): Vertex[] | null }): StageFn<"follow"> {
|
export function createFollowStage(deps: {
|
||||||
|
savedLine(): Vertex[] | null;
|
||||||
|
saved?(): FollowPatch;
|
||||||
|
}): StageFn<"follow"> {
|
||||||
return (ctx) => {
|
return (ctx) => {
|
||||||
|
if (!ctx.inputs.route && deps.saved) return deps.saved();
|
||||||
const before = ctx.before.route?.line ?? deps.savedLine();
|
const before = ctx.before.route?.line ?? deps.savedLine();
|
||||||
const now = ctx.out.route;
|
const now = ctx.out.route;
|
||||||
if (!before || !now) return {};
|
if (!before || !now) return {};
|
||||||
|
|||||||
@@ -0,0 +1,255 @@
|
|||||||
|
/* PLAN 349 sub7 헬퍼 — 페이지 계산 묶음이 조작 하나에 한 번만 도는지 · 열기만 하면 저장 측점 목록 그대로인지.
|
||||||
|
* 진짜 TS(`design_pipeline_page` · 단계 파일 전부)를 트랜스파일해 Node 로 돌림 · 서버 창구만 가짜.
|
||||||
|
* 종단 보기 고리(가게 stations → 상세 갈아끼움 → 종단도 render · 비정규 측점 · 유토곡선 설정)를 흉내 냄 —
|
||||||
|
* `design_view_profile_sections.followSwap` · `design_profile.render` 가 부르는 그대로.
|
||||||
|
* 입력 argv[2] JSON · argv[3] 격자 이진. 결과 = 표준출력 JSON. 짝 = `test_349_pipeline_once.py`. */
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
const ts = require(path.join(__dirname, "..", "..", "config", "node_modules", "typescript"));
|
||||||
|
const CATALOG = require("./helper_322_catalog_module.cjs");
|
||||||
|
|
||||||
|
const ROOT = path.join(__dirname, "..", "..");
|
||||||
|
const job = JSON.parse(fs.readFileSync(process.argv[2], "utf8"));
|
||||||
|
|
||||||
|
function memoryStorage() {
|
||||||
|
const map = new Map();
|
||||||
|
return {
|
||||||
|
getItem: (key) => (map.has(key) ? map.get(key) : null),
|
||||||
|
setItem: (key, value) => map.set(key, String(value)),
|
||||||
|
removeItem: (key) => map.delete(key),
|
||||||
|
key: (index) => [...map.keys()][index] ?? null,
|
||||||
|
get length() {
|
||||||
|
return map.size;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
globalThis.window = {
|
||||||
|
sessionStorage: memoryStorage(),
|
||||||
|
localStorage: memoryStorage(),
|
||||||
|
setTimeout,
|
||||||
|
clearTimeout,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 흙 배분 서버 — 늦게 답함 · 끊기면 버림
|
||||||
|
globalThis.fetch = (url, init) =>
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
const timer = setTimeout(
|
||||||
|
() => resolve({ ok: true, json: async () => ({ haul_plan: { blocks: [], url } }) }),
|
||||||
|
20,
|
||||||
|
);
|
||||||
|
init.signal.addEventListener("abort", () => {
|
||||||
|
clearTimeout(timer);
|
||||||
|
reject(new Error("aborted"));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
const STUBS = {};
|
||||||
|
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 (CATALOG.isCatalogRequest(request)) return CATALOG;
|
||||||
|
const key = Object.keys(STUBS).find((name) => request.endsWith(name));
|
||||||
|
if (key) return STUBS[key];
|
||||||
|
if (request.startsWith("@config/")) return { API_BASE_URL: "http://fake" };
|
||||||
|
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 load = (...parts) => loadTs(path.join(ROOT, ...parts));
|
||||||
|
|
||||||
|
const sampler = load("common_util", "common_util_surface_sampler.ts");
|
||||||
|
const bytes = fs.readFileSync(process.argv[3]);
|
||||||
|
const grid = sampler.parseDtmGrid(
|
||||||
|
bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.length),
|
||||||
|
);
|
||||||
|
const local = { grid, design: "las" };
|
||||||
|
|
||||||
|
STUBS["B05_Profile_Api_Replan"] = {
|
||||||
|
analysisTerrain: () => "las",
|
||||||
|
fetchRoutePlan: async () => ({
|
||||||
|
planned: job.line,
|
||||||
|
curves: job.curves,
|
||||||
|
min_radius_m: job.minRadius,
|
||||||
|
station_snap: job.stationSnap,
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
STUBS["B05_Profile_Api_Structures"] = {
|
||||||
|
fetchStructures: async () => ({ structures: [] }),
|
||||||
|
fetchStructureTypes: async () => job.types,
|
||||||
|
};
|
||||||
|
STUBS["B05_Profile_Api_TerrainGrid"] = {
|
||||||
|
loadDesignTerrainGrid: async () => local,
|
||||||
|
groundStageDeps: () => ({ grid: () => local, remote: async () => [] }),
|
||||||
|
};
|
||||||
|
STUBS["B04_PreProcess_Api_Fetch"] = {
|
||||||
|
fetchDetailPipePoints: async () => ({
|
||||||
|
pipe_points: job.pipes.map((pipe) => ({ ...pipe, lonlat: [0, 0] })),
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
STUBS["B06_Section_UI_Standard_Panel"] = { effectiveStandardCross: () => job.standard };
|
||||||
|
|
||||||
|
const pageMod = load("A00_Common", "design", "design_pipeline_page.ts");
|
||||||
|
const storeMod = load("A00_Common", "design", "design_store.ts");
|
||||||
|
const alignment = load("B05_Profile", "logic", "B05_Profile_UI_Profile_Alignment.ts");
|
||||||
|
const page = load("A00_Common", "b_page_state.ts");
|
||||||
|
|
||||||
|
const tick = (ms = 0) => new Promise((resolve) => setTimeout(resolve, ms));
|
||||||
|
const runs = () => globalThis.__aisloPipeline?.runs ?? [];
|
||||||
|
/** 묶음이 조용해질 때까지 — 마지막 기록이 끝나고 새 기록이 더 안 생김(고리면 계속 생김). */
|
||||||
|
async function quiet() {
|
||||||
|
let seen = -1;
|
||||||
|
for (let i = 0; i < 400; i += 1) {
|
||||||
|
await tick(15);
|
||||||
|
const last = runs()[runs().length - 1];
|
||||||
|
const count = runs().length;
|
||||||
|
if (count === seen && (!last || last.outcome !== "running")) return;
|
||||||
|
seen = count;
|
||||||
|
}
|
||||||
|
throw new Error("묶음이 조용해지지 않음");
|
||||||
|
}
|
||||||
|
const n = job.nodes.length;
|
||||||
|
const draftOf = (nodes) => ({
|
||||||
|
nodes,
|
||||||
|
curveOn: Array(n).fill(true),
|
||||||
|
curveRadius: Array(n).fill(null),
|
||||||
|
curveLock: Array(n).fill(null),
|
||||||
|
curveArc: Array(n).fill(null),
|
||||||
|
stationSnap: job.stationSnap,
|
||||||
|
});
|
||||||
|
const shift = (index, dx, dy) =>
|
||||||
|
job.nodes.map((node, i) => (i === index ? [node[0] + dx, node[1] + dy] : node));
|
||||||
|
const chainagesOf = (stations) => (stations ?? []).map((s) => s.chainageM);
|
||||||
|
|
||||||
|
async function openOnce(P) {
|
||||||
|
window.localStorage.setItem("frd_current_project_id", P);
|
||||||
|
const savedAlignment = job.detail.longitudinal.profile_alignment;
|
||||||
|
const savedBase = alignment.toAlignmentBase(savedAlignment);
|
||||||
|
let detail = job.detail;
|
||||||
|
const swaps = [];
|
||||||
|
const grades = [];
|
||||||
|
const link = {
|
||||||
|
pipelineSource: () => ({ base: savedBase, edits: savedAlignment.edits, detail, routeId: 7 }),
|
||||||
|
// 종단도 adoptPipeline → rebuild → pipelineGrade(지금 가게 편집)
|
||||||
|
adoptPipeline: (base, edits, draft) => {
|
||||||
|
const now = draft ? edits : savedAlignment.edits;
|
||||||
|
grades.push(draft);
|
||||||
|
pageMod.pipelineGrade(P, now);
|
||||||
|
},
|
||||||
|
redraw: () => undefined,
|
||||||
|
side: null,
|
||||||
|
};
|
||||||
|
const before = runs().length;
|
||||||
|
pageMod.routeDraftBridge(P, link, { stationIntervalM: job.interval });
|
||||||
|
// 종단 보기 · 횡단 보기 고리 — 측점 목록이 다르면 상세를 갈아끼우고(지반 표본 배열은 그대로) render
|
||||||
|
const stop = storeMod.useDesignStore(P, null).subscribe("stations", (stations) => {
|
||||||
|
if (!stations?.length) return;
|
||||||
|
const now = detail.cross_sections.map((s) => s.chainage_m);
|
||||||
|
const same =
|
||||||
|
now.length === stations.length &&
|
||||||
|
stations.every((s, i) => Math.abs(s.chainageM - now[i]) < 1e-6);
|
||||||
|
if (same) return;
|
||||||
|
swaps.push(stations.length);
|
||||||
|
void Promise.resolve().then(() => {
|
||||||
|
detail = {
|
||||||
|
...detail,
|
||||||
|
longitudinal: {
|
||||||
|
...detail.longitudinal,
|
||||||
|
stations: stations.map((s) => ({ chainage_m: s.chainageM, kind: s.kind })),
|
||||||
|
},
|
||||||
|
cross_sections: stations.map((s) => ({
|
||||||
|
...(detail.cross_sections.find((c) => Math.abs(c.chainage_m - s.chainageM) < 0.01) ?? {}),
|
||||||
|
chainage_m: s.chainageM,
|
||||||
|
})),
|
||||||
|
};
|
||||||
|
pageMod.restartPagePipeline(P); // profilePanel.render
|
||||||
|
pageMod.restartPagePipeline(P); // setIrregularStations
|
||||||
|
pageMod.pipelineEarthwork(P, { conversion: job.conversion }); // B06 render
|
||||||
|
});
|
||||||
|
});
|
||||||
|
pageMod.pipelineEarthwork(P, { conversion: job.conversion });
|
||||||
|
pageMod.restartPagePipeline(P); // 첫 render(묶음 준비 전)
|
||||||
|
await quiet();
|
||||||
|
const pipe = pageMod.pagePipeline(P);
|
||||||
|
return { link, pipe, before, swaps, grades, stop, savedAlignment };
|
||||||
|
}
|
||||||
|
|
||||||
|
async function run() {
|
||||||
|
const P = "proj-349";
|
||||||
|
const ctx = await openOnce(P);
|
||||||
|
const { pipe, swaps } = ctx;
|
||||||
|
const openRuns = runs().slice(ctx.before);
|
||||||
|
const stations = pipe.output("ground")?.stations ?? [];
|
||||||
|
const open = {
|
||||||
|
runs: openRuns.map((r) => ({ sources: r.sources, outcome: r.outcome })),
|
||||||
|
swaps: swaps.length,
|
||||||
|
stations: chainagesOf(stations),
|
||||||
|
saved: job.detail.cross_sections.map((s) => s.chainage_m),
|
||||||
|
pipeChainages: (pipe.input("pipes") ?? []).map((p) => p.chainage_m),
|
||||||
|
final: pipe.output("masshaul")?.haulInput?.final_cumulative_m3 ?? null,
|
||||||
|
footprint: pipe.output("footprint")?.records.length ?? 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 노선 꼭짓점 한 번 끌어 놓기
|
||||||
|
let mark = runs().length;
|
||||||
|
const dragMark = swaps.length;
|
||||||
|
const bridge = pageMod.routeDraftBridge(P, ctx.link);
|
||||||
|
bridge.edited(draftOf(shift(1, 6, -4)));
|
||||||
|
await quiet();
|
||||||
|
const drag = {
|
||||||
|
runs: runs()
|
||||||
|
.slice(mark)
|
||||||
|
.map((r) => ({ sources: r.sources, outcome: r.outcome })),
|
||||||
|
swaps: swaps.length - dragMark,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 되돌리기 한 번(열 때로)
|
||||||
|
mark = runs().length;
|
||||||
|
const swapMark = swaps.length;
|
||||||
|
bridge.edited(null);
|
||||||
|
await quiet();
|
||||||
|
const undo = {
|
||||||
|
runs: runs()
|
||||||
|
.slice(mark)
|
||||||
|
.map((r) => ({ sources: r.sources, outcome: r.outcome })),
|
||||||
|
pipeChainages: (pipe.input("pipes") ?? []).map((p) => p.chainage_m),
|
||||||
|
alignmentSaved:
|
||||||
|
JSON.stringify(pipe.input("alignment")) === JSON.stringify(ctx.savedAlignment.edits),
|
||||||
|
stations: chainagesOf(pipe.output("ground")?.stations),
|
||||||
|
swapsAfter: swaps.length - swapMark,
|
||||||
|
};
|
||||||
|
const blocked = pipe.blockedWrites;
|
||||||
|
ctx.stop();
|
||||||
|
pageMod.disposePagePipeline(P);
|
||||||
|
page.clearDrafts(P);
|
||||||
|
|
||||||
|
// 다시 열기 — 같은 입력이면 같은 값
|
||||||
|
const again = await openOnce("proj-349b");
|
||||||
|
const reopen = {
|
||||||
|
runs: runs().slice(again.before).length,
|
||||||
|
final: again.pipe.output("masshaul")?.haulInput?.final_cumulative_m3 ?? null,
|
||||||
|
stations: chainagesOf(again.pipe.output("ground")?.stations),
|
||||||
|
};
|
||||||
|
again.stop();
|
||||||
|
pageMod.disposePagePipeline("proj-349b");
|
||||||
|
return { open, drag, undo, reopen, blocked };
|
||||||
|
}
|
||||||
|
|
||||||
|
run()
|
||||||
|
.then((out) => {
|
||||||
|
process.stdout.write(JSON.stringify(out));
|
||||||
|
process.exit(0);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
process.stderr.write(String(error && error.stack ? error.stack : error));
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
"""PLAN 349 sub7 — 조작 하나 = 묶음 한 번 · 열기만 하면 저장 정본 그대로.
|
||||||
|
|
||||||
|
· 열 때 묶음 한 번 · 측점 목록 = 저장 측점(갈아끼움 없음 · 관 누가거리 = 저장값)
|
||||||
|
· 노선 꼭짓점 한 번 끌기 = 한 번(sources [route]) — 갈아끼운 상세 다시 그림이 처음부터 다시 안 부름
|
||||||
|
· 되돌리기 한 번(열 때로) = 한 번 · 관 · 계획고 = 저장값 · 측점 = 저장 측점
|
||||||
|
· 다시 열면 같은 값 · 계산 · 알림 안 입력 쓰기 0
|
||||||
|
짝: `helper_349_pipeline_once.cjs`(실제 TS 를 Node 로 · 서버 창구만 가짜 · 종단 보기 고리 흉내).
|
||||||
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import csv
|
||||||
|
import json
|
||||||
|
import subprocess
|
||||||
|
import sys
|
||||||
|
import tempfile
|
||||||
|
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 B05_Profile.B05_Profile_Structures_Schema import structure_type_map # noqa: E402
|
||||||
|
from common_util.common_util_surface_sampler import dtm_grid_bytes # noqa: E402
|
||||||
|
from config.config_system_design import STANDARD_CROSS_SECTION # noqa: E402
|
||||||
|
|
||||||
|
pytestmark = pytest.mark.skipif(
|
||||||
|
not (ROOT / "config" / "node_modules" / "typescript").is_dir(),
|
||||||
|
reason="프론트엔드 의존성 미설치",
|
||||||
|
)
|
||||||
|
|
||||||
|
PROJECT = ROOT / "storage/1/3/6d3b2812-6d5a-4168-a932-40e4ae303d5a" # 검증_sub7
|
||||||
|
ROUTE = PROJECT / "B05_Profile/route"
|
||||||
|
SECTION = PROJECT / "B06_Section"
|
||||||
|
GRID = PROJECT / "B04_PreProcess/models/dtm_classification_smooth.npz"
|
||||||
|
ONES = {g: {"loose": 1.0, "compacted": 1.0} for g in ("soil", "ripping_rock", "blasting_rock")}
|
||||||
|
|
||||||
|
|
||||||
|
def _csv(path: Path) -> list[list[float]]:
|
||||||
|
with path.open(encoding="utf-8") as handle:
|
||||||
|
return [[float(r["x"]), float(r["y"])] for r in csv.DictReader(handle)]
|
||||||
|
|
||||||
|
|
||||||
|
def _json(path: Path):
|
||||||
|
return json.loads(path.read_text(encoding="utf-8"))
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(scope="module")
|
||||||
|
def r() -> dict:
|
||||||
|
if not (GRID.is_file() and (SECTION / "longitudinal/longitudinal.json").is_file()):
|
||||||
|
pytest.skip("검증_sub7 없음")
|
||||||
|
curves = _json(ROUTE / "planned_route_curves.json")
|
||||||
|
sections = sorted(
|
||||||
|
(_json(p) for p in (SECTION / "cross_sections").glob("cross_*.json")),
|
||||||
|
key=lambda s: s["chainage_m"],
|
||||||
|
)
|
||||||
|
pipes = _json(PROJECT / "B04_PreProcess/drainage/edits/pipe_points.json")["points"]
|
||||||
|
job = {
|
||||||
|
"line": _csv(ROUTE / "planned_route.csv"),
|
||||||
|
"nodes": _csv(ROUTE / "planned_route_nodes.csv"),
|
||||||
|
"curves": [
|
||||||
|
{k: c[k] for k in ("start", "apex", "end", "radius_m")} for c in curves["curves"]
|
||||||
|
],
|
||||||
|
"stationSnap": bool(curves.get("station_snap")),
|
||||||
|
"minRadius": curves["min_radius_m"],
|
||||||
|
"interval": 20.0,
|
||||||
|
"types": [
|
||||||
|
{"type_id": t.type_id, "group": t.group, "placement": t.placement}
|
||||||
|
for t in structure_type_map().values()
|
||||||
|
],
|
||||||
|
"pipes": pipes,
|
||||||
|
"standard": STANDARD_CROSS_SECTION,
|
||||||
|
"conversion": ONES,
|
||||||
|
"detail": {
|
||||||
|
"longitudinal": _json(SECTION / "longitudinal/longitudinal.json"),
|
||||||
|
"cross_sections": sections,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
with tempfile.TemporaryDirectory() as folder:
|
||||||
|
path = Path(folder) / "job.json"
|
||||||
|
path.write_text(json.dumps(job), encoding="utf-8")
|
||||||
|
grid = Path(folder) / "grid.bin"
|
||||||
|
grid.write_bytes(dtm_grid_bytes(GRID))
|
||||||
|
proc = subprocess.run( # noqa: S603 — 고정 실행 파일
|
||||||
|
["node", str(HERE / "helper_349_pipeline_once.cjs"), str(path), str(grid)],
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
encoding="utf-8",
|
||||||
|
timeout=300,
|
||||||
|
)
|
||||||
|
assert proc.returncode == 0, proc.stderr
|
||||||
|
out = json.loads(proc.stdout)
|
||||||
|
out["savedPipes"] = [p["chainage_m"] for p in pipes]
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
def _same(a: list[float], b: list[float]) -> bool:
|
||||||
|
return len(a) == len(b) and all(abs(x - y) < 1e-6 for x, y in zip(a, b))
|
||||||
|
|
||||||
|
|
||||||
|
def test_열_때_한_번_저장_측점_그대로(r):
|
||||||
|
o = r["open"]
|
||||||
|
assert [x["outcome"] for x in o["runs"]] == ["done"], o["runs"]
|
||||||
|
assert o["swaps"] == 0 # 열 때 측점을 가게에 안 냄 — 상세 = 저장 정본 그대로
|
||||||
|
# 묶음 측점 ≈ 저장 측점 — 끝점만 저장 노선 csv 자릿수(0.1 mm)만큼 다를 수 있음(그래서 안 냄)
|
||||||
|
assert len(o["stations"]) == len(o["saved"])
|
||||||
|
assert all(abs(x - y) < 0.001 for x, y in zip(o["stations"], o["saved"]))
|
||||||
|
assert o["pipeChainages"] == r["savedPipes"]
|
||||||
|
assert o["footprint"] > 0
|
||||||
|
|
||||||
|
|
||||||
|
def test_꼭짓점_끌기_한_번(r):
|
||||||
|
d = r["drag"]
|
||||||
|
assert [x["sources"] for x in d["runs"]] == [["route"]], d["runs"]
|
||||||
|
assert d["swaps"] == 1 # 새 노선 측점으로 갈아끼움은 한 번(고리 아님)
|
||||||
|
|
||||||
|
|
||||||
|
def test_되돌리기_한_번_저장값으로(r):
|
||||||
|
u = r["undo"]
|
||||||
|
assert [x["sources"] for x in u["runs"]] == [["route"]], u["runs"]
|
||||||
|
assert u["pipeChainages"] == r["savedPipes"]
|
||||||
|
assert u["alignmentSaved"]
|
||||||
|
assert _same(u["stations"], r["open"]["stations"])
|
||||||
|
|
||||||
|
|
||||||
|
def test_다시_열면_같은_값_고리_없음(r):
|
||||||
|
assert r["reopen"]["runs"] == 1
|
||||||
|
assert r["reopen"]["final"] == r["open"]["final"]
|
||||||
|
assert r["reopen"]["stations"] == r["open"]["stations"]
|
||||||
|
assert r["blocked"] == 0
|
||||||
Reference in New Issue
Block a user