feat: initialize drainage network frontend

This commit is contained in:
2026-07-10 16:16:17 +08:00
commit 66de96d9e4
133 changed files with 33057 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
import type { MapGeoJSONFeature } from "maplibre-gl";
import type { DetailFeature } from "../types";
import { formatValue } from "../utils/format-value";
import { SOURCE_LAYERS } from "./sources";
export function getFeatureId(feature: MapGeoJSONFeature) {
const raw = feature.properties?.id ?? feature.id;
return raw === undefined || raw === null ? "" : String(raw);
}
export function toDetailFeature(feature: MapGeoJSONFeature): DetailFeature {
const isPipe = feature.sourceLayer === SOURCE_LAYERS.pipes;
const id = getFeatureId(feature);
const diameter = feature.properties?.diameter;
const length = feature.properties?.length;
const demand = feature.properties?.demand;
return {
id,
layer: isPipe ? "pipes" : "junctions",
title: isPipe ? `管线 ${id || "未命名"}` : `节点 ${id || "未命名"}`,
subtitle: isPipe
? `DN${formatValue(diameter)} · ${formatValue(length)} m`
: `需水量 ${formatValue(demand)} · 高程 ${formatValue(feature.properties?.elevation)} m`,
properties: feature.properties ?? {}
};
}