feat(workbench): integrate runtime data and map tooling
This commit is contained in:
@@ -3,6 +3,8 @@ import type { DetailFeature } from "../types";
|
||||
import { formatValue } from "../utils/format-value";
|
||||
import {
|
||||
SOURCE_LAYERS,
|
||||
WATER_NETWORK_SOURCE_IDS,
|
||||
isSourceGisSourceId,
|
||||
type GeoServerWaterNetworkSourceId,
|
||||
type WaterNetworkSourceId
|
||||
} from "./sources";
|
||||
@@ -13,8 +15,12 @@ export function getFeatureId(feature: MapGeoJSONFeature) {
|
||||
}
|
||||
|
||||
export function getWaterNetworkSourceId(feature: MapGeoJSONFeature): WaterNetworkSourceId | null {
|
||||
if ((WATER_NETWORK_SOURCE_IDS as readonly string[]).includes(feature.source)) {
|
||||
return feature.source as WaterNetworkSourceId;
|
||||
}
|
||||
|
||||
for (const [sourceId, sourceLayer] of Object.entries(SOURCE_LAYERS) as [GeoServerWaterNetworkSourceId, string][]) {
|
||||
if (feature.source === sourceId || feature.sourceLayer === sourceLayer) {
|
||||
if (feature.sourceLayer === sourceLayer) {
|
||||
return sourceId;
|
||||
}
|
||||
}
|
||||
@@ -37,6 +43,24 @@ export function toDetailFeature(feature: MapGeoJSONFeature): DetailFeature {
|
||||
}
|
||||
|
||||
function getFeatureLabels(sourceId: WaterNetworkSourceId, id: string, properties: Record<string, unknown>) {
|
||||
if (sourceId === "water_quality_monitoring_points") {
|
||||
return {
|
||||
title: `水质监测点 ${formatValue(properties.monitoring_point_no)}`,
|
||||
subtitle: `节点 ${formatValue(properties.node_id ?? id)} · 灵敏度分析选点`
|
||||
};
|
||||
}
|
||||
|
||||
if (isSourceGisSourceId(sourceId)) {
|
||||
const sourceName = formatValue(properties.source_layer_name);
|
||||
const sourceIdLabel = formatValue(properties.source_object_id ?? properties.source_fid ?? id);
|
||||
return {
|
||||
title: `${sourceName} ${sourceIdLabel}`,
|
||||
subtitle: sourceId === "fx_20200423_pipes" || sourceId === "fx_20200811_dn100_pipes"
|
||||
? `管径 ${formatValue(properties.diameter)} · 长度 ${formatValue(properties.length)} m`
|
||||
: `${formatValue(properties.dataset_title)} · 源要素 ${formatValue(properties.source_fid)}`
|
||||
};
|
||||
}
|
||||
|
||||
if (sourceId === "pipes") {
|
||||
return {
|
||||
title: `管线 ${id || "未命名"}`,
|
||||
|
||||
Reference in New Issue
Block a user