feat(B03): 입력 화면을 계획노선/지형 두 컨테이너로 나누고 파일마다 카드를 준다
노선 파일이 다섯이면 카드도 다섯이어야 어느 것이 왔는지 보인다(사용자 지시). 세트를 슬롯 하나에 몰아 담던 companions 구조를 걷어내고, 슬롯 하나가 파일 하나를 갖는 기존 구조로 되돌렸다 - 업로드 루프도 원래대로다. - 왼쪽 컨테이너 계획노선 자료: csv(.csv/.shp) shx dbf cpg route_prj - 오른쪽 컨테이너 지형 자료(LAS): las_laz prj(지형 좌표계) tfw tif + LAS 없는 설계 토글 - .prj만 확장자로 안 갈린다 - 노선 도형과 basename이 같으면 노선 좌표계 카드, 아니면 지형 카드(planSlotAssignments). 재접속 현황은 저장 경로(input/shp/)로 가른다. - 재접속 현황 응답에 relative_path 추가. - 필수 판정이 노선 PRJ를 route_prj로 따로 센다 - 지형 PRJ 없이 통과하던 구멍을 막았다. - 형제 카드(shx/dbf/route_prj)는 노선 도형이 shapefile일 때만 필수 - 확장자 줄의 "선택" 꼬리표가 실시간으로 붙고 떨어진다. - 카드가 좁아져 한글 제목이 글자 단위로 접히던 것을 word-break: keep-all과 헤더 flex-wrap으로 고쳤다. 화면 검증(공용 브라우저): 실물 7파일을 한 번에 떨어뜨려 배정 실측 - route.prj는 노선 좌표계 카드, terrain.prj는 지형 카드로 갈렸고 카드 제목 9개 모두 한 줄. tmp/tests/test_route_shapefile_input.py 9개 통과, tsc --noEmit 통과. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,45 @@
|
||||
import { ui_locales } from "@ui/ui_template_locale";
|
||||
|
||||
export type FileSlot = "csv" | "las_laz" | "prj" | "tfw" | "tif" | "dxf";
|
||||
/**
|
||||
* 카드 한 장 = 파일 한 개. 계획노선 shapefile은 파일이 다섯이므로 카드도 다섯이다
|
||||
* (2026-08-31 사용자 지시) — 어느 파일이 왔고 어느 것이 비었는지 화면에서 바로 보인다.
|
||||
* `route_prj`(노선 좌표계)와 `prj`(지형 좌표계)는 확장자가 같아 basename으로 가른다.
|
||||
*/
|
||||
export type FileSlot =
|
||||
| "csv"
|
||||
| "shx"
|
||||
| "dbf"
|
||||
| "cpg"
|
||||
| "route_prj"
|
||||
| "las_laz"
|
||||
| "prj"
|
||||
| "tfw"
|
||||
| "tif"
|
||||
| "dxf";
|
||||
|
||||
/** 왼쪽(계획노선) 컨테이너에 놓이는 슬롯. */
|
||||
export const ROUTE_SLOTS: readonly FileSlot[] = [
|
||||
"csv",
|
||||
"shx",
|
||||
"dbf",
|
||||
"cpg",
|
||||
"route_prj",
|
||||
];
|
||||
|
||||
/** 오른쪽(지형·LAS) 컨테이너에 놓이는 슬롯. */
|
||||
export const TERRAIN_SLOTS: readonly FileSlot[] = [
|
||||
"las_laz",
|
||||
"prj",
|
||||
"tfw",
|
||||
"tif",
|
||||
];
|
||||
|
||||
/** 노선 도형이 shapefile일 때 함께 있어야 하는 슬롯(.cpg는 없으면 CP949). */
|
||||
export const SHAPEFILE_DEPENDENT_SLOTS: readonly FileSlot[] = [
|
||||
"shx",
|
||||
"dbf",
|
||||
"route_prj",
|
||||
];
|
||||
export type UploadStatus = "pending" | "uploading" | "completed" | "failed";
|
||||
|
||||
export interface SlotConfig {
|
||||
@@ -13,12 +52,6 @@ export interface SlotConfig {
|
||||
|
||||
export interface FileSlotState extends SlotConfig {
|
||||
file?: File;
|
||||
/**
|
||||
* 계획노선 shapefile의 동반 파일(.shx/.dbf/.cpg/.prj). 슬롯 하나가 파일 한 벌을
|
||||
* 받는 유일한 경우다 — GDAL이 열려면 형제 파일이 같이 있어야 한다(2026-08-31).
|
||||
* 대표 파일(`file`)은 언제나 .shp이고, 동반 파일은 그보다 먼저 전송한다.
|
||||
*/
|
||||
companions?: File[];
|
||||
uploadSessionId?: string;
|
||||
uploadStatus: UploadStatus;
|
||||
progressBytes: number;
|
||||
@@ -54,6 +87,34 @@ const SLOT_CONFIGS: readonly SlotConfig[] = [
|
||||
extensions: [".csv", ".shp"],
|
||||
isRequired: true,
|
||||
},
|
||||
{
|
||||
slot: "shx",
|
||||
labelKey: "B03_File_Slot_RouteIndex",
|
||||
icon: "⋮",
|
||||
extensions: [".shx"],
|
||||
isRequired: false,
|
||||
},
|
||||
{
|
||||
slot: "dbf",
|
||||
labelKey: "B03_File_Slot_RouteAttribute",
|
||||
icon: "▤",
|
||||
extensions: [".dbf"],
|
||||
isRequired: false,
|
||||
},
|
||||
{
|
||||
slot: "cpg",
|
||||
labelKey: "B03_File_Slot_RouteEncoding",
|
||||
icon: "⌨",
|
||||
extensions: [".cpg"],
|
||||
isRequired: false,
|
||||
},
|
||||
{
|
||||
slot: "route_prj",
|
||||
labelKey: "B03_File_Slot_RouteProjection",
|
||||
icon: "◈",
|
||||
extensions: [".prj"],
|
||||
isRequired: false,
|
||||
},
|
||||
{
|
||||
slot: "las_laz",
|
||||
labelKey: "B03_File_Slot_PointCloud",
|
||||
@@ -94,37 +155,41 @@ export function getBaseName(fileName: string): string {
|
||||
return index >= 0 ? fileName.slice(0, index) : fileName;
|
||||
}
|
||||
|
||||
/** shapefile 동반 파일. `.prj`가 여기 들어 있어 지형 PRJ와 basename으로 갈린다. */
|
||||
const SHAPEFILE_COMPANION_EXT = [".shx", ".dbf", ".cpg", ".prj"];
|
||||
|
||||
/**
|
||||
* 고른 파일을 「계획노선 shapefile 한 벌」과 나머지로 가른다.
|
||||
* 고른 파일을 카드(슬롯)에 배정한다.
|
||||
*
|
||||
* 확장자만 보고 슬롯을 찾으면 노선 PRJ와 지형 PRJ가 같은 슬롯을 다툰다. `.shp`와
|
||||
* **basename이 같은** 것만 노선 세트로 묶고, 남은 `.prj`는 지형 슬롯으로 보낸다.
|
||||
* `.prj`만 확장자로 갈리지 않는다 — 노선 좌표계와 지형 좌표계가 같은 확장자다.
|
||||
* **노선 도형(.shp)과 basename이 같은 것**만 노선 좌표계 카드로 보내고, 나머지는
|
||||
* 지형 좌표계 카드로 보낸다. `routeStem`은 이미 골라 둔 노선 도형의 basename으로,
|
||||
* 노선 PRJ를 나중에 따로 추가하는 경우를 받아 준다.
|
||||
*/
|
||||
export function splitShapefileSelection(files: readonly File[]): {
|
||||
shapefile: { primary: File; companions: File[] } | null;
|
||||
rest: File[];
|
||||
} {
|
||||
const primary = files.find((file) => getExtension(file.name) === ".shp");
|
||||
if (!primary) return { shapefile: null, rest: [...files] };
|
||||
const stem = getBaseName(primary.name);
|
||||
const companions: File[] = [];
|
||||
const rest: File[] = [];
|
||||
for (const file of files) {
|
||||
if (file === primary) continue;
|
||||
export function planSlotAssignments(
|
||||
files: readonly File[],
|
||||
slotConfigs: readonly SlotConfig[],
|
||||
routeStem?: string,
|
||||
): { file: File; slot?: FileSlot }[] {
|
||||
const batchStem = files
|
||||
.filter((file) => getExtension(file.name) === ".shp")
|
||||
.map((file) => getBaseName(file.name))[0];
|
||||
const stem = batchStem ?? routeStem;
|
||||
return files.map((file) => {
|
||||
const extension = getExtension(file.name);
|
||||
if (
|
||||
SHAPEFILE_COMPANION_EXT.includes(extension) &&
|
||||
getBaseName(file.name) === stem
|
||||
) {
|
||||
companions.push(file);
|
||||
} else {
|
||||
rest.push(file);
|
||||
if (extension === ".prj") {
|
||||
const isRoute = stem !== undefined && getBaseName(file.name) === stem;
|
||||
return { file, slot: (isRoute ? "route_prj" : "prj") as FileSlot };
|
||||
}
|
||||
}
|
||||
return { shapefile: { primary, companions }, rest };
|
||||
const config = slotConfigs.find(
|
||||
(candidate) =>
|
||||
candidate.slot !== "route_prj" &&
|
||||
candidate.extensions.includes(extension),
|
||||
);
|
||||
return { file, slot: config?.slot };
|
||||
});
|
||||
}
|
||||
|
||||
/** 슬롯 설정 목록 — 배정 규칙이 카드 정의와 같은 것을 쓰도록 밖으로 연다. */
|
||||
export function slotConfigs(): readonly SlotConfig[] {
|
||||
return SLOT_CONFIGS;
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
|
||||
Reference in New Issue
Block a user