- 초안 상세(카드)도 캐시와 같은 attachShapes 를 follow 뒤 현황으로 부름 · atChainage 지움 · 이름 = 측점 계획 제목 - cross 입력 넘김 = 사용자 칸 · 카드 번호만 · 포장 · 기울임 · 하강 = 새 자리 그림에서(crossWithShapes · 점 창도) - 초안 자리 시설 측점 짝 = 등록 열쇠(B06 측점 열쇠 목록 · 처음 본 열쇠) · 차례 짝 지움 - writeFacilities = 지금 가게 값과 견줌(되돌리기 뒤 같은 조작도 씀) - 시험 test_457_draft_card(재현 E · F · G · H) · 365 · 433 · 440 도우미 새 규칙으로 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
137 lines
4.8 KiB
JavaScript
137 lines
4.8 KiB
JavaScript
// 440 — 노선 초안 동안 B06 카드(묶음 새 상세) 번호가 찾기 상세(갈아끼운 캐시)에 있음.
|
|
// 저장 상세 → cross 입력 모음(`pipelineCrossSource` · 진짜) → 새 상세(`draftSectionDetail` · 진짜) 대 갈아끼움(`swapCrossSections` · 진짜).
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const ROOT = path.resolve(__dirname, "..", "..");
|
|
const ts = require(path.join(ROOT, "config", "node_modules", "typescript"));
|
|
const idOf = (m) => `station_${String(Math.round(m * 1000)).padStart(12, "0")}`;
|
|
const REAL =
|
|
/(B05_Profile_Pipeline_Detail|B06_Section_Station_Swap|design_pipeline_cross|common_util_\w+)$/;
|
|
const CATALOG = require("./helper_322_catalog_module.cjs");
|
|
const STUBS = {
|
|
B05_Profile_Pipeline_Grade: { stationIdOf: idOf },
|
|
common_util_station: { stationLabel: (m) => String(m) },
|
|
B05_Profile_UI_Profile_Data: { toDesignProfile: () => ({}) },
|
|
b_page_state: { readState: () => null },
|
|
B06_Section_Section_Canon: { savedDesigns: () => null },
|
|
B06_Section_UI_Standard_Panel: {
|
|
effectiveStandardCross: () => ({ road_width_m: 3 }),
|
|
readRockBoundaryDefault: () => null,
|
|
},
|
|
};
|
|
const cache = new Map();
|
|
function load(full) {
|
|
if (cache.has(full)) return cache.get(full).exports;
|
|
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);
|
|
const req = (r) => {
|
|
if (CATALOG.isCatalogRequest(r)) return CATALOG;
|
|
if (r.endsWith(".json"))
|
|
return JSON.parse(fs.readFileSync(path.resolve(path.dirname(full), r)));
|
|
const name = r.split("/").pop();
|
|
if (STUBS[name]) return STUBS[name];
|
|
if (REAL.test(r)) return load(path.resolve(path.dirname(full), r + ".ts"));
|
|
throw new Error(`stub 없음: ${r}`);
|
|
};
|
|
new Function("exports", "module", "require", js)(box.exports, box, req);
|
|
return box.exports;
|
|
}
|
|
const detailMod = load(path.join(ROOT, "B05_Profile/logic/B05_Profile_Pipeline_Detail.ts"));
|
|
const swapMod = load(path.join(ROOT, "B06_Section/logic/B06_Section_Station_Swap.ts"));
|
|
const crossMod = load(path.join(ROOT, "A00_Common/design/design_pipeline_cross.ts"));
|
|
|
|
const sec = (m, kind, extra = {}) => ({
|
|
station_id: idOf(m),
|
|
chainage_m: m,
|
|
label: "",
|
|
kind,
|
|
center_x: m,
|
|
center_y: 0,
|
|
samples: [],
|
|
design: { design_elevation_m: 100 },
|
|
...extra,
|
|
});
|
|
// 저장 상세: 일반 340 · 관 351(배수관) · 일반 360
|
|
const saved = {
|
|
longitudinal: { stations: [], design_profiles: [], length_m: 400, samples: [] },
|
|
cross_sections: [
|
|
sec(340, "regular"),
|
|
sec(351, "irregular", { culvert: { chainage_m: 351, diameter_m: 0.8 } }),
|
|
sec(360, "regular"),
|
|
],
|
|
};
|
|
const st = (key, m, kind) => ({
|
|
key,
|
|
chainageM: m,
|
|
kind,
|
|
x: m + 0.5,
|
|
y: 3,
|
|
left: [0, 1],
|
|
azimuthDeg: 0,
|
|
ground: null,
|
|
});
|
|
const savedStations = [
|
|
st("grid:340", 340, "grid"),
|
|
st("pipe:p35100", 351, "pipe"),
|
|
st("grid:360", 360, "grid"),
|
|
];
|
|
// 노선 초안: 교점 끌기 → 관이 좌표 따라 354 로(410) · 일반 측점은 같은 m
|
|
const draftStations = [
|
|
st("grid:340", 340, "grid"),
|
|
st("pipe:p35100", 354, "pipe"),
|
|
st("grid:360", 360, "grid"),
|
|
];
|
|
const oldKeys = savedStations.map((s) => s.key);
|
|
|
|
const source = crossMod.pipelineCrossSource("p1", saved, savedStations, null);
|
|
// 그림 자료 = 지금 현황(따라간 관 · 457) — 관 p35100 이 354 로
|
|
const types = [{ type_id: "pipe", name: "배수관", options: [] }];
|
|
const status = detailMod.shapeStatus(
|
|
[{ id: "p35100", facility: "pipe", chainage_m: 354, options: { pipe_diameter_mm: "800" } }],
|
|
[],
|
|
types,
|
|
);
|
|
const draft = detailMod.draftSectionDetail(
|
|
saved,
|
|
{ stations: draftStations, longitudinal: { chainageM: [0, 400], z: [0, 0] } },
|
|
{},
|
|
null,
|
|
source.specs,
|
|
20,
|
|
status,
|
|
);
|
|
const swapped = swapMod.swapCrossSections(saved, draftStations, oldKeys, 20).detail;
|
|
const ids = (detail) => detail.cross_sections.map((s) => s.station_id);
|
|
const swappedIds = new Set(ids(swapped));
|
|
const pipeCard = draft.cross_sections[1];
|
|
// 새 측점(초안에서 처음 생긴 일반 측점) = 누가거리 번호
|
|
const added = detailMod.draftSectionDetail(
|
|
saved,
|
|
{
|
|
stations: [...draftStations, st("grid:380", 380, "grid")],
|
|
longitudinal: { chainageM: [0, 400], z: [0, 0] },
|
|
},
|
|
{},
|
|
null,
|
|
source.specs,
|
|
20,
|
|
status,
|
|
);
|
|
console.log(
|
|
JSON.stringify({
|
|
draftIds: ids(draft),
|
|
allFoundInSwapped: ids(draft).every((id) => swappedIds.has(id)),
|
|
sameOrder: JSON.stringify(ids(draft)) === JSON.stringify(ids(swapped)),
|
|
pipeCard: [
|
|
pipeCard.station_id,
|
|
pipeCard.chainage_m,
|
|
pipeCard.culvert && pipeCard.culvert.chainage_m,
|
|
],
|
|
longIds: draft.longitudinal.stations.map((s) => s.station_id),
|
|
addedId: added.cross_sections[3].station_id,
|
|
}),
|
|
);
|