fix(계산묶음): 349-0l 되돌리면 종단도도 저장 기준 그대로 — 전 측점 다시 셈 예약 없앰 · 되돌림 길 기록
- 종단도 adoptPipeline(초안 버림) = 열 때처럼 그리기만 — 편집 때 쓰던 전 측점 다시 셈 예약(rebuild → crossPreview) 안 함 · 낡음은 그리기가 잼 - 계산 묶음 — 상세를 초안 전 상세로 되돌린 뒤에 종단도를 저장 기준으로(그 전엔 초안 상세를 낡음으로 봄) - 묶음 기록 restored · restoreWhy(saved · unchanged · stations · no-saved) - cross 단계에 지형 격자(미교차 넓힘 · 349-0j 짝) · test_346_2 서버 대조도 넓힘 포함 - 시험 test_349_0l_undo_draw 4건 — 진짜 종단도 낡음 판정 · crossPreview 를 거침(옛 코드 되돌린 뒤 7822 대 열기 3911 재현) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TteK8mfYZetk5P3bEZkyVZ
This commit is contained in:
@@ -27,6 +27,7 @@ import type {
|
||||
FollowPatch,
|
||||
PipelineInputs,
|
||||
PipelineOutputs,
|
||||
PipelineRunRecord,
|
||||
PipelineStation,
|
||||
RouteDraft,
|
||||
StageFn,
|
||||
@@ -122,12 +123,13 @@ export interface PagePipelineOptions {
|
||||
/** 노선 조작 뒤 follow 가 가게 관 · 구조물을 다시 씀(목록 · 알약 다시) — `far` = 새 노선에서
|
||||
* `STRUCTURE_ROUTE_DRIFT_MAX_M` 넘게 먼 구조물 수(초안을 버려 되돌렸으면 0). */
|
||||
onFacilitiesFollowed?: (far: number) => void;
|
||||
/** 노선 초안을 버림(349-0k) — 초안 전 상세(`saved` · 없으면 null)로 되돌림 · `stations` = 저장 노선 측점. */
|
||||
/** 노선 초안을 버림(349-0k) — 초안 전 상세(`saved` · 없으면 null)로 되돌림 · `stations` = 저장 노선 측점 ·
|
||||
* 돌려주는 값 = 되돌림 길 한 단어(묶음 기록 `restoreWhy`). 끝난 뒤 종단도가 저장 기준으로 돌아옴. */
|
||||
onDraftDropped?: (
|
||||
routeId: number,
|
||||
saved: SectionDetailResponse | null,
|
||||
stations: PipelineStation[],
|
||||
) => void;
|
||||
) => Promise<string>;
|
||||
}
|
||||
|
||||
interface PagePipeline {
|
||||
@@ -225,6 +227,9 @@ function createPagePipeline(
|
||||
/** 노선 초안 전 상세(종단도가 그리던 것) — 초안을 버리면 이것으로(다시 셈 없음 · 349-0k). */
|
||||
let restoreTo: SectionDetailResponse | null = null;
|
||||
let restoring = false;
|
||||
/** 초안을 버린 차례 기록 · 되돌림이 끝나는 약속(종단도는 그 뒤 저장 기준으로 — 349-0l). */
|
||||
let dropRun: Promise<PipelineRunRecord> | null = null;
|
||||
let dropping: Promise<string> | null = null;
|
||||
/** 노선 초안 전 가게 관 · 구조물 — 초안 동안 follow 가 새 측점을 가게에 씀 · 초안을 버리면 이것으로. */
|
||||
let beforeDraft: Facilities | null = null;
|
||||
/** 묶음이 가게에 마지막으로 쓴 관 · 구조물 · 쓰는 동안(메아리 — 다시 입력으로 안 받음). */
|
||||
@@ -260,7 +265,8 @@ function createPagePipeline(
|
||||
crossSource = { detail, source: pipelineCrossSource(projectId, detail, savedStations) };
|
||||
return crossSource.source;
|
||||
};
|
||||
const crossStage = createCrossStage();
|
||||
const groundDeps = groundStageDeps(projectId);
|
||||
const crossStage = createCrossStage({ grid: groundDeps.grid }); // 미교차 넓힘 = 같은 지형 격자(349-0j)
|
||||
const haulStage = createHaulStage(projectId, () => savedSource().routeId ?? undefined);
|
||||
const pipe = createDesignPipeline({
|
||||
stages: {
|
||||
@@ -280,7 +286,7 @@ function createPagePipeline(
|
||||
},
|
||||
}),
|
||||
stations: createStationsStage({ intervalM: options.stationIntervalM, types: () => types }),
|
||||
ground: createGroundStage(groundStageDeps(projectId)),
|
||||
ground: createGroundStage(groundDeps),
|
||||
planline: createPlanlineStage({ savedBase: () => savedSource().base, savedLine }),
|
||||
profile: profileStage,
|
||||
// 단면 유형 기본값 = 새 지형 상단측(서버 노선 저장 규칙) — 단계 본문은 그대로 부름
|
||||
@@ -319,8 +325,19 @@ function createPagePipeline(
|
||||
const stations = (event.value as PipelineOutputs["ground"] | null)?.stations ?? [];
|
||||
const saved = restoreTo;
|
||||
restoreTo = null;
|
||||
if (typeof routeId === "number" && stations.length)
|
||||
queueMicrotask(() => options.onDraftDropped?.(routeId, saved, stations));
|
||||
if (typeof routeId !== "number" || !stations.length || !options.onDraftDropped) return;
|
||||
const drop = options.onDraftDropped;
|
||||
const record = dropRun;
|
||||
dropping = new Promise<string>((resolve) =>
|
||||
queueMicrotask(
|
||||
() => void drop(routeId, saved, stations).then(resolve, () => resolve("error")),
|
||||
),
|
||||
);
|
||||
void dropping.then((why) =>
|
||||
record?.then((run) =>
|
||||
Object.assign(run, { restored: why === "saved" || why === "unchanged", restoreWhy: why }),
|
||||
),
|
||||
);
|
||||
});
|
||||
// 사용자 노선 조작 뒤 follow 가 다시 매긴 관 · 구조물 = 가게(목록 · 알약 · 횡단 보기가 바로 새 측점) ·
|
||||
// 초안을 버리면 초안 전 값 · 열 때(start 차례)는 안 씀 — 알림 밖(틱 뒤)에서 씀(쓰기 고리 막음과 안 부딪힘)
|
||||
@@ -375,7 +392,15 @@ function createPagePipeline(
|
||||
const edits = (pipe.input("alignment") as AlignmentEdits | null) ?? emptyEdits();
|
||||
if (draft) draftAlignment.set("alignmentDraft", edits);
|
||||
else if (drawnDraft) markAlignmentSaved(DRAFT_ROUTE_ID); // 초안을 버림 — 노선 0 칸도 비움
|
||||
if ((draft || drawnDraft) && base) link.adoptPipeline(base, edits, draft);
|
||||
// 초안을 버린 차례 — 상세를 되돌린 뒤 저장 기준으로(그 전에 그리면 초안 상세를 낡음으로 봄 · 349-0l)
|
||||
const after = !draft && event.generation === quietGeneration ? dropping : null;
|
||||
if ((draft || drawnDraft) && base) {
|
||||
if (after)
|
||||
void after.then(
|
||||
() => void (!pipe.input("route") && link.adoptPipeline(base, edits, false)),
|
||||
);
|
||||
else link.adoptPipeline(base, edits, draft);
|
||||
}
|
||||
drawnDraft = draft;
|
||||
});
|
||||
|
||||
@@ -473,9 +498,9 @@ function createPagePipeline(
|
||||
const before = pipe.output("route")?.line ?? null;
|
||||
const after = draft ? draftLine(draft, plan?.min_radius_m ?? 0).line : savedLine();
|
||||
const generation = pipe.generation;
|
||||
void pipe.update("route", draft, routeRange(before, after));
|
||||
const run = pipe.update("route", draft, routeRange(before, after));
|
||||
restoring = !draft && !!stored && pipe.generation !== generation;
|
||||
if (restoring) quietGeneration = pipe.generation;
|
||||
if (restoring) [quietGeneration, dropRun, dropping] = [pipe.generation, run, null];
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
@@ -638,11 +638,11 @@ export function createDesignProfile(ctx: DesignProfileContext) {
|
||||
store = preview = createProfileEditStore(pagePipeline.DRAFT_ROUTE_ID, edits, () =>
|
||||
rebuild(),
|
||||
);
|
||||
if (!draft && store === preview)
|
||||
store = createProfileEditStore(routeId, savedEdits, () => rebuild());
|
||||
if (!draft) preview = null;
|
||||
base = draft ? nextBase : listed();
|
||||
rebuild();
|
||||
if (draft) return void ((base = nextBase), rebuild());
|
||||
if (store === preview) store = createProfileEditStore(routeId, savedEdits, () => rebuild());
|
||||
[preview, base] = [null, listed()];
|
||||
alignment = base && buildAlignment(base, store.edits()); // 그리기만 · 다시 셈 예약 없음(349-0l)
|
||||
draw();
|
||||
},
|
||||
/** [확정] 직전에 호출한다. 편집이 없으면 아무 것도 하지 않는다. */
|
||||
async save(): Promise<void> {
|
||||
|
||||
@@ -529,13 +529,14 @@ export async function mountProfileView(
|
||||
onCorridorStale: () => sections.setCorridorPending(true),
|
||||
onFacilitiesFollowed: followFacilities,
|
||||
// 초안을 버림 — 초안 전 상세 그대로(349-0k) · 그 상세가 없거나(초안 둔 채 새로고침) 측점이 다르면 갈아끼움
|
||||
onDraftDropped: (routeId, saved, stations) =>
|
||||
void (async () => {
|
||||
const back =
|
||||
saved && (await restoreSectionDetail(activeProjectId, routeId, saved, stations));
|
||||
if (!saved || (back && !back.same))
|
||||
await swapSectionStations(activeProjectId, routeId, stations);
|
||||
})(),
|
||||
onDraftDropped: async (routeId, saved, stations) => {
|
||||
const back =
|
||||
saved && (await restoreSectionDetail(activeProjectId, routeId, saved, stations));
|
||||
if (saved && !back) return "unchanged";
|
||||
if (back?.same) return "saved";
|
||||
await swapSectionStations(activeProjectId, routeId, stations);
|
||||
return saved ? "stations" : "no-saved";
|
||||
},
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -278,4 +278,8 @@ export interface PipelineRunRecord {
|
||||
totalMs: number;
|
||||
/** done = 브라우저 단계 끝 · dropped = 새 조작에 밀려 버림 · error = 단계가 던짐. */
|
||||
outcome: "running" | "done" | "dropped" | "error";
|
||||
/** 노선 초안을 버린 차례(349-0l) — 초안 전 상세로 되돌렸나 · 까닭 한 단어(saved · unchanged · stations ·
|
||||
* no-saved · none). */
|
||||
restored?: boolean;
|
||||
restoreWhy?: string;
|
||||
}
|
||||
|
||||
@@ -192,14 +192,14 @@ async function run() {
|
||||
pageMod.routeDraftBridge(P, link, {
|
||||
stationIntervalM: job.interval,
|
||||
// `design_view_profile` 의 onDraftDropped 그대로
|
||||
onDraftDropped: (routeId, saved, stations) =>
|
||||
void (async () => {
|
||||
const back =
|
||||
saved && (await sectionStore.restoreSectionDetail(P, routeId, saved, stations));
|
||||
restores.push({ saved: !!saved, back: back ? { same: back.same } : null });
|
||||
if (!saved || (back && !back.same))
|
||||
await sectionStore.swapSectionStations(P, routeId, stations);
|
||||
})(),
|
||||
onDraftDropped: async (routeId, saved, stations) => {
|
||||
const back = saved && (await sectionStore.restoreSectionDetail(P, routeId, saved, stations));
|
||||
restores.push({ saved: !!saved, back: back ? { same: back.same } : null });
|
||||
if (saved && !back) return "unchanged";
|
||||
if (back?.same) return "saved";
|
||||
await sectionStore.swapSectionStations(P, routeId, stations);
|
||||
return saved ? "stations" : "no-saved";
|
||||
},
|
||||
});
|
||||
// followSwap — 새 상세 → 종단도 render(처음부터 다시 · 비정규 측점) · 가게 stations → 갈아끼움
|
||||
const stopListen = sectionStore.subscribeSectionDetail(P, R, (next) => {
|
||||
|
||||
@@ -0,0 +1,373 @@
|
||||
/* PLAN 349-0l sub7 헬퍼 — 열기 → 노선 꼭짓점 끌기 → 되돌리기 → 횡단 보기 → 종단 보기, 누가토량 · 측점 · 횡단이
|
||||
* 열 때와 같음 · 다시 셈 0. 진짜 TS — 종단도(`design_profile` · 낡음 판정 → crossPreview 예약) · 계산 묶음 ·
|
||||
* 상세 가게(`B06_Section_Section_Store`). 화면 부품(DOM · SVG · 오버레이 · 도구줄)과 서버 창구만 가짜 ·
|
||||
* 그리기는 진짜 `renderProfile` 의 낡음 판정 줄만 · 다시 셈 창구(`refreshCrossDesigns`)는 부른 수를 세고 면적을
|
||||
* 바꿈(서버와 다른 값 흉내). 검증_sub7 노선(관 11 · 구조물 1 은 시험이 관 자리에 놓음).
|
||||
* 입력 argv[2] JSON · argv[3] 격자 이진. 결과 = 표준출력 JSON. 짝 = `test_349_0l_undo_draw.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;
|
||||
},
|
||||
};
|
||||
}
|
||||
const windowBase = {
|
||||
sessionStorage: memoryStorage(),
|
||||
localStorage: memoryStorage(),
|
||||
setTimeout,
|
||||
clearTimeout,
|
||||
addEventListener: () => undefined,
|
||||
removeEventListener: () => undefined,
|
||||
};
|
||||
globalThis.window = new Proxy(windowBase, {
|
||||
get: (t, key) => (key in t ? t[key] : undefined),
|
||||
set: (t, key, value) => ((t[key] = value), true),
|
||||
});
|
||||
|
||||
// 흙 배분 서버 — 늦게 답함 · 끊기면 버림
|
||||
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("@ui/")) return anyModule();
|
||||
if (request.endsWith(".css")) return {};
|
||||
if (request.endsWith(".json")) return require(path.join(path.dirname(full), request));
|
||||
if (request.startsWith("@util/"))
|
||||
return loadTs(path.join(ROOT, "common_util", `${request.slice(6)}.ts`));
|
||||
if (request.startsWith(".")) return loadTs(path.join(path.dirname(full), `${request}.ts`));
|
||||
return require(request);
|
||||
};
|
||||
new Function("exports", "module", "require", js)(box.exports, box, localRequire);
|
||||
return box.exports;
|
||||
}
|
||||
const 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" };
|
||||
|
||||
/** 아무 화면 부품 — 무엇을 읽든 · 부르든 또 그것(DOM · 오버레이 · 도구줄 흉내). */
|
||||
function anyNode() {
|
||||
const box = { dataset: {}, style: {}, classList: { add() {}, remove() {}, toggle() {} } };
|
||||
return new Proxy(function node() {}, {
|
||||
get: (_t, key) => {
|
||||
if (key in box) return box[key];
|
||||
if (key === "then" || typeof key === "symbol") return undefined;
|
||||
return (box[key] = anyNode());
|
||||
},
|
||||
set: (_t, key, value) => ((box[key] = value), true),
|
||||
apply: () => anyNode(),
|
||||
});
|
||||
}
|
||||
const anyModule = (own = {}) =>
|
||||
new Proxy(own, {
|
||||
get: (t, key) =>
|
||||
key in t
|
||||
? t[key]
|
||||
: key === "__esModule"
|
||||
? true
|
||||
: typeof key === "symbol"
|
||||
? undefined
|
||||
: anyNode(),
|
||||
});
|
||||
globalThis.document = anyNode();
|
||||
globalThis.HTMLElement = function HTMLElement() {};
|
||||
|
||||
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"] = anyModule({
|
||||
fetchStructures: async () => ({ structures: job.structures }),
|
||||
fetchStructureTypes: async () => job.types,
|
||||
readPendingStructures: () => null,
|
||||
});
|
||||
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 };
|
||||
// 구조물 초안 얹기(측점 계획 · 형상) — 이 시험 밖 · 아무 일 없음
|
||||
STUBS["B06_Section_Section_Drafts"] = {
|
||||
withDraftStations: async () => undefined,
|
||||
withDraftShapes: async () => undefined,
|
||||
forgetDraftStations: () => undefined,
|
||||
};
|
||||
STUBS["B06_Section_Api_Fetch"] = {
|
||||
fetchSectionDetail: async () => JSON.parse(JSON.stringify(job.detail)),
|
||||
saveSections: async () => undefined,
|
||||
};
|
||||
// 횡단 다시 셈(브라우저 · B05 crossPreview · B06 카드 같은 창구) — 부른 횟수 · 면적은 서버와 달라짐(두 배)
|
||||
let refreshCalls = 0;
|
||||
const doubled = (detail) =>
|
||||
detail.cross_sections.forEach((section) => {
|
||||
if (!section.design) return;
|
||||
const design = { ...section.design };
|
||||
for (const [key, value] of Object.entries(design))
|
||||
if (key.endsWith("_m2") && typeof value === "number") design[key] = value * 2;
|
||||
section.design = design;
|
||||
});
|
||||
STUBS["B06_Section_Cross_Refresh"] = {
|
||||
refreshCrossDesigns: async ({ detail }) => {
|
||||
refreshCalls += 1;
|
||||
doubled(detail);
|
||||
return detail.cross_sections.map((s) => s.chainage_m);
|
||||
},
|
||||
holdScreenAlignment: () => () => undefined,
|
||||
USER_TOUCHED_KEYS: [],
|
||||
};
|
||||
// 그리기 — 진짜 `renderProfile` 의 낡음 판정 줄만(같은 함수 · 같은 인자) · SVG 는 안 그림
|
||||
const draws = [];
|
||||
let opened = null;
|
||||
STUBS["B05_Profile_UI_Profile_Render"] = {
|
||||
renderProfile: (ctx) => {
|
||||
const detail = ctx.detail();
|
||||
if (!detail) return;
|
||||
const alignment = ctx.alignment();
|
||||
const longitudinal = detail.longitudinal;
|
||||
const designProfiles = alignment
|
||||
? [profileData.toDesignProfile(alignment, longitudinal.design_profiles?.[0])]
|
||||
: (longitudinal.design_profiles ?? []);
|
||||
const key = common.staleKey({
|
||||
longitudinal: { design_profiles: designProfiles },
|
||||
cross_sections: detail.cross_sections,
|
||||
});
|
||||
draws.push({ key, saved: detail === opened });
|
||||
ctx.onStaleDesigns?.(key);
|
||||
},
|
||||
};
|
||||
STUBS["common_util_view_window"] = { frameOf: (_root, fn) => fn() };
|
||||
for (const name of [
|
||||
"B05_Profile_UI_Profile_Balance",
|
||||
"B05_Profile_UI_Profile_Heights",
|
||||
"B05_Profile_UI_Profile_Panel_Tools",
|
||||
"B05_Profile_UI_Profile_Zoom",
|
||||
"B05_Profile_UI_Profile_Drag",
|
||||
"B05_Profile_UI_Profile_MassHaul",
|
||||
"design_profile_overlays",
|
||||
"design_profile_viewport",
|
||||
"design_save",
|
||||
"B05_Profile_Api_Fetch",
|
||||
"common_util_mass_haul_balance_view",
|
||||
])
|
||||
STUBS[name] = anyModule();
|
||||
|
||||
const pageMod = load("A00_Common", "design", "design_pipeline_page.ts");
|
||||
const storeMod = load("A00_Common", "design", "design_store.ts");
|
||||
const sectionStore = load("B06_Section", "B06_Section_Section_Store.ts");
|
||||
const common = load("B06_Section", "B06_Section_UI_Section_Common.ts");
|
||||
const profileData = load("B05_Profile", "logic", "B05_Profile_UI_Profile_Data.ts");
|
||||
const alignmentMod = load("B05_Profile", "logic", "B05_Profile_UI_Profile_Alignment.ts");
|
||||
const baseMod = load("A00_Common", "design", "design_profile_base.ts");
|
||||
const massHaul = load("common_util", "common_util_mass_haul.ts");
|
||||
const profileMod = load("A00_Common", "design", "design_profile.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(30);
|
||||
const last = runs()[runs().length - 1];
|
||||
const count = runs().length + refreshCalls * 1000 + draws.length * 1e6;
|
||||
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 sliceRuns = (mark) =>
|
||||
runs()
|
||||
.slice(mark)
|
||||
.map((r) => ({
|
||||
sources: r.sources,
|
||||
outcome: r.outcome,
|
||||
restored: r.restored ?? null,
|
||||
why: r.restoreWhy ?? null,
|
||||
}));
|
||||
const finalOf = (detail) => {
|
||||
const [series] = massHaul.computeMassHaulSeries(
|
||||
detail.longitudinal,
|
||||
detail.cross_sections,
|
||||
job.conversion,
|
||||
undefined,
|
||||
["cross"],
|
||||
);
|
||||
const points = series?.result.points ?? [];
|
||||
return points.length ? points[points.length - 1].cumulative_volume_m3 : null;
|
||||
};
|
||||
const crossOf = (detail) =>
|
||||
JSON.stringify(detail.cross_sections.map((s) => [s.chainage_m, s.design, s.samples]));
|
||||
/** 서버 정본 흉내 — 저장 횡단 계획고 = 열 때 종단도 계획선(낡음 0 · 서버가 낸 상세와 같음). */
|
||||
function settleDesigns(detail) {
|
||||
const pa = detail.longitudinal.profile_alignment;
|
||||
const base = baseMod.listedBase(alignmentMod.toAlignmentBase(pa), detail, []);
|
||||
const samples = alignmentMod.buildAlignment(base, pa.edits).samples;
|
||||
const at = (c) => {
|
||||
const i = samples.findIndex((s) => s.chainage_m >= c);
|
||||
if (i < 0) return samples[samples.length - 1].elevation_m;
|
||||
if (i === 0) return samples[0].elevation_m;
|
||||
const a = samples[i - 1];
|
||||
const b = samples[i];
|
||||
return (
|
||||
a.elevation_m +
|
||||
((b.elevation_m - a.elevation_m) * (c - a.chainage_m)) / (b.chainage_m - a.chainage_m)
|
||||
);
|
||||
};
|
||||
detail.cross_sections.forEach((s) => (s.design.design_elevation_m = at(s.chainage_m)));
|
||||
}
|
||||
|
||||
async function run() {
|
||||
const P = "proj-349l";
|
||||
const R = 7;
|
||||
window.localStorage.setItem("frd_current_project_id", P);
|
||||
opened = await sectionStore.loadSectionDetail(P, R);
|
||||
settleDesigns(opened);
|
||||
const profile = profileMod.createDesignProfile({
|
||||
projectId: P,
|
||||
view: "profile",
|
||||
onSelectStation: () => undefined,
|
||||
});
|
||||
const live = () => sectionStore.loadSectionDetail(P, R);
|
||||
pageMod.routeDraftBridge(P, profile, {
|
||||
stationIntervalM: job.interval,
|
||||
// `design_view_profile` 의 onDraftDropped 그대로
|
||||
onDraftDropped: async (routeId, saved, stations) => {
|
||||
const back = saved && (await sectionStore.restoreSectionDetail(P, routeId, saved, stations));
|
||||
if (saved && !back) return "unchanged";
|
||||
if (back?.same) return "saved";
|
||||
await sectionStore.swapSectionStations(P, routeId, stations);
|
||||
return saved ? "stations" : "no-saved";
|
||||
},
|
||||
});
|
||||
// 종단 보기 `renderSections` · followSwap 그대로 — 새 상세 → render · 비정규 측점 · 가게 stations → 갈아끼움
|
||||
const show = (detail) => {
|
||||
profile.render(detail, job.interval, R);
|
||||
profile.setIrregularStations([]);
|
||||
};
|
||||
const stopListen = sectionStore.subscribeSectionDetail(P, R, (next) => show(next));
|
||||
const stopStore = storeMod.useDesignStore(P, null).subscribe("stations", (stations) => {
|
||||
if (stations?.length) void sectionStore.swapSectionStations(P, R, stations);
|
||||
});
|
||||
show(opened);
|
||||
profile.setEarthworkContext({ conversion: job.conversion });
|
||||
await quiet();
|
||||
const measure = async (mark, refreshMark) => {
|
||||
const detail = await live();
|
||||
return {
|
||||
runs: sliceRuns(mark),
|
||||
refresh: refreshCalls - refreshMark,
|
||||
lastKey: draws[draws.length - 1]?.key ?? null,
|
||||
drawnSaved: draws[draws.length - 1]?.saved ?? null,
|
||||
sameObject: detail === opened,
|
||||
stations: detail.cross_sections.map((s) => s.chainage_m),
|
||||
final: finalOf(detail),
|
||||
cross: crossOf(detail),
|
||||
edits: JSON.stringify(profile.pipelineSource().edits),
|
||||
pipeEdits: JSON.stringify(pageMod.pagePipeline(P).input("alignment")),
|
||||
};
|
||||
};
|
||||
const open = await measure(0, 0);
|
||||
|
||||
// 노선 꼭짓점 한 번 끌기 — 상세가 새 노선 측점으로 갈아끼워짐 · 그 횡단을 카드가 다시 셈(흉내)
|
||||
let mark = runs().length;
|
||||
let refreshMark = refreshCalls;
|
||||
const bridge = pageMod.routeDraftBridge(P, profile);
|
||||
bridge.edited(draftOf(shift(1, 6, -4)));
|
||||
await quiet();
|
||||
doubled(await live());
|
||||
const drag = await measure(mark, refreshMark);
|
||||
|
||||
// 되돌리기 한 번(초안 버림)
|
||||
mark = runs().length;
|
||||
refreshMark = refreshCalls;
|
||||
bridge.edited(null);
|
||||
await quiet();
|
||||
const undo = await measure(mark, refreshMark);
|
||||
|
||||
// 횡단 보기(B06) 다녀옴 — 종단도는 횡단 보기 자리에서 `shownDetail`(묶음 새 상세 없으면 저장 상세)을 그림
|
||||
mark = runs().length;
|
||||
refreshMark = refreshCalls;
|
||||
profile.setView("cross");
|
||||
show(pageMod.pipelineDetail(P) ?? (await live()));
|
||||
profile.setEarthworkContext({ conversion: job.conversion });
|
||||
await quiet();
|
||||
profile.setView("profile");
|
||||
profile.setActive(true);
|
||||
await quiet();
|
||||
const back = await measure(mark, refreshMark);
|
||||
const blocked = pageMod.pagePipeline(P).blockedWrites;
|
||||
stopListen();
|
||||
stopStore();
|
||||
pageMod.disposePagePipeline(P);
|
||||
return { open, drag, undo, back, 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);
|
||||
});
|
||||
@@ -3,7 +3,7 @@
|
||||
· 열 때 한 번(저장 노선 · 발자국 · 저장 횡단 입력이 측점 열쇠로 모임)
|
||||
초안 없으면 3D 낡음 · 흙 배분 안 함
|
||||
· 노선 점 옮김 한 번에 cross · footprint · masshaul 까지 · 단계 합 0.3 s 안
|
||||
· 누가토량 = 서버 엔진(generate_sections · compute_cross_design)으로
|
||||
· 누가토량 = 서버 엔진(generate_sections · compute_cross_design · 미교차 넓힘 extend_unclosed)으로
|
||||
같은 노선을 셈한 값과 같은 자리수
|
||||
· 상단측(단면 유형 기본값) = 서버 `uphill_side` 짝(거울)
|
||||
· 늦은 응답 버림(흙 배분 끊김 · 옛 차례 haul 안 들어옴)
|
||||
@@ -38,6 +38,7 @@ from B05_Profile.B05_Profile_Engine_Grade_Profile import ( # noqa: E402
|
||||
)
|
||||
from B05_Profile.B05_Profile_Structures_Schema import structure_type_map # noqa: E402
|
||||
from B06_Section.B06_Section_Engine_Design import compute_cross_design # noqa: E402
|
||||
from B06_Section.B06_Section_Engine_SampleExtend import extend_unclosed # noqa: E402
|
||||
from common_util.common_util_drainage_pipes import parse_pipe_points # noqa: E402
|
||||
from common_util.common_util_route_polyline import build_planned_polyline # noqa: E402
|
||||
from common_util.common_util_structure_station import plan_stations # noqa: E402
|
||||
@@ -183,10 +184,12 @@ def _run(case) -> dict:
|
||||
"planRadius": s.get("plan_radius_m"),
|
||||
"outer": s.get("curve_outer_side"),
|
||||
"widening": s.get("curve_widening_m"),
|
||||
"frame": s["frame"],
|
||||
}
|
||||
for s in server["cross_sections"]
|
||||
]
|
||||
out["pipes"] = pipes
|
||||
out["sampler"] = sampler
|
||||
return out
|
||||
|
||||
|
||||
@@ -239,15 +242,23 @@ def test_누가토량_서버_엔진과_같은_자리수(r):
|
||||
nets = []
|
||||
for a, b in zip(ts, py):
|
||||
assert abs(a["chainage"] - b["chainage"]) < 1e-3
|
||||
design = compute_cross_design(
|
||||
b["samples"],
|
||||
a["elevation"],
|
||||
ground_type="ripping_rock",
|
||||
section_mode=f"{b['uphill'] or 'left'}_cut",
|
||||
plan_radius_m=b["planRadius"],
|
||||
curve_outer_side=b["outer"],
|
||||
curve_widening_m=b["widening"],
|
||||
)
|
||||
|
||||
def compute(samples, a=a, b=b):
|
||||
return compute_cross_design(
|
||||
samples,
|
||||
a["elevation"],
|
||||
ground_type="ripping_rock",
|
||||
section_mode=f"{b['uphill'] or 'left'}_cut",
|
||||
plan_radius_m=b["planRadius"],
|
||||
curve_outer_side=b["outer"],
|
||||
curve_widening_m=b["widening"],
|
||||
)
|
||||
|
||||
design = compute(b["samples"])
|
||||
# 미교차 넓힘 — 묶음 cross 도 같은 지형 격자로 넓힘(349-0j · [저장] 정본 길)
|
||||
wide = extend_unclosed(b["samples"], b["frame"], compute, r["sampler"])
|
||||
if wide is not None and (wide[1]["left_m"] or wide[1]["right_m"]):
|
||||
design = compute(wide[0])
|
||||
assert abs(design["cut_area_m2"] - a["cut"]) < 0.05 + 0.01 * design["cut_area_m2"]
|
||||
assert abs(design["fill_area_m2"] - a["fill"]) < 0.05 + 0.01 * design["fill_area_m2"]
|
||||
nets.append((b["chainage"], design["cut_area_m2"] - design["fill_area_m2"]))
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
"""PLAN 349-0l sub7 — 되돌리면 종단도 · 상세 · 측점이 열 때와 한 벌(다시 셈 0).
|
||||
|
||||
· 열기 → 노선 꼭짓점 끌기 → 되돌리기 → 횡단 보기 → 종단 보기 — 누가토량 · 측점 · 횡단 = 열기 값
|
||||
· 진짜 종단도 낡음 판정 · crossPreview 예약을 거침 — 되돌린 뒤 다시 셈 0 · 낡음 0
|
||||
· 묶음 기록에 되돌림 길(restored · 까닭) · 되돌리기 = 묶음 한 번
|
||||
짝: `helper_349_0l_undo_draw.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"]
|
||||
# 저장 횡단 면적 = 서버가 상세를 낼 때 셈(파일엔 없음) — 정본 대신 정한 값
|
||||
for i, section in enumerate(sections):
|
||||
section["design"] = {
|
||||
"ground_type": "soil",
|
||||
"design_elevation_m": section["center_z"],
|
||||
"cut_area_m2": 4.0 + (i % 5),
|
||||
"fill_area_m2": 1.5 + (i % 3),
|
||||
}
|
||||
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,
|
||||
# 구조물 하나 — 첫 관 자리(같은 측점을 덮음 · 측점 목록 그대로) · follow 가 함께 옮김
|
||||
"structures": [
|
||||
{
|
||||
"structure_id": "s-349l",
|
||||
"type_id": "cross_drain_exposed",
|
||||
"chainage_m": pipes[0]["chainage_m"],
|
||||
"x": pipes[0]["x"],
|
||||
"y": pipes[0]["y"],
|
||||
}
|
||||
],
|
||||
"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_0l_undo_draw.cjs"), str(path), str(grid)],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
encoding="utf-8",
|
||||
timeout=300,
|
||||
)
|
||||
assert proc.returncode == 0, proc.stderr
|
||||
return json.loads(proc.stdout)
|
||||
|
||||
|
||||
def test_열기_낡음_0_다시_셈_0(r):
|
||||
o = r["open"]
|
||||
assert [x["outcome"] for x in o["runs"]] == ["done"], o["runs"]
|
||||
assert o["lastKey"] == "" and o["drawnSaved"]
|
||||
assert o["refresh"] == 0
|
||||
assert o["sameObject"] and o["final"] is not None
|
||||
|
||||
|
||||
def test_끌기_새_측점(r):
|
||||
d = r["drag"]
|
||||
assert [x["sources"] for x in d["runs"]] == [["route"]], d["runs"]
|
||||
assert not d["sameObject"] # 시험이 갈아끼움 길을 실제로 거침
|
||||
assert d["final"] != r["open"]["final"]
|
||||
|
||||
|
||||
def test_되돌리기_열기_값_다시_셈_0(r):
|
||||
u, o = r["undo"], r["open"]
|
||||
assert [(x["sources"], x["restored"], x["why"]) for x in u["runs"]] == [
|
||||
(["route"], True, "saved")
|
||||
], u["runs"]
|
||||
assert u["refresh"] == 0
|
||||
assert u["lastKey"] == "" and u["drawnSaved"]
|
||||
assert u["sameObject"]
|
||||
assert u["stations"] == o["stations"]
|
||||
assert u["cross"] == o["cross"]
|
||||
assert u["final"] == o["final"]
|
||||
assert u["edits"] == o["edits"] and u["pipeEdits"] == u["edits"]
|
||||
|
||||
|
||||
def test_횡단_보기_다녀와도_같은_값(r):
|
||||
b, o = r["back"], r["open"]
|
||||
assert b["runs"] == [], b["runs"]
|
||||
assert b["refresh"] == 0
|
||||
assert b["lastKey"] == "" and b["drawnSaved"]
|
||||
assert b["final"] == o["final"]
|
||||
assert b["cross"] == o["cross"]
|
||||
assert r["blocked"] == 0
|
||||
Reference in New Issue
Block a user