fix: hide unavailable GeoServer layers
This commit is contained in:
@@ -39,6 +39,7 @@ export type SupplyLayerCatalogItem = {
|
||||
sourceLayer?: (typeof SOURCE_LAYERS)[keyof typeof SOURCE_LAYERS];
|
||||
geometry: "line" | "point";
|
||||
available: boolean;
|
||||
availability: "required" | "probe";
|
||||
label: string;
|
||||
icon: string;
|
||||
};
|
||||
@@ -49,6 +50,7 @@ export const SUPPLY_LAYER_CATALOG = [
|
||||
sourceLayer: SOURCE_LAYERS.pipes,
|
||||
geometry: "line",
|
||||
available: true,
|
||||
availability: "required",
|
||||
label: "管线",
|
||||
icon: "pipe"
|
||||
},
|
||||
@@ -57,6 +59,7 @@ export const SUPPLY_LAYER_CATALOG = [
|
||||
sourceLayer: SOURCE_LAYERS.junctions,
|
||||
geometry: "point",
|
||||
available: true,
|
||||
availability: "required",
|
||||
label: "节点",
|
||||
icon: "junction"
|
||||
},
|
||||
@@ -65,6 +68,7 @@ export const SUPPLY_LAYER_CATALOG = [
|
||||
sourceLayer: SOURCE_LAYERS.valves,
|
||||
geometry: "point",
|
||||
available: true,
|
||||
availability: "required",
|
||||
label: "阀门",
|
||||
icon: "valve"
|
||||
},
|
||||
@@ -73,6 +77,7 @@ export const SUPPLY_LAYER_CATALOG = [
|
||||
sourceLayer: SOURCE_LAYERS.reservoirs,
|
||||
geometry: "point",
|
||||
available: true,
|
||||
availability: "required",
|
||||
label: "水库",
|
||||
icon: "reservoir"
|
||||
},
|
||||
@@ -81,6 +86,7 @@ export const SUPPLY_LAYER_CATALOG = [
|
||||
sourceLayer: undefined,
|
||||
geometry: "point",
|
||||
available: true,
|
||||
availability: "required",
|
||||
label: "SCADA",
|
||||
icon: "scada-pressure"
|
||||
},
|
||||
@@ -89,6 +95,7 @@ export const SUPPLY_LAYER_CATALOG = [
|
||||
sourceLayer: SOURCE_LAYERS.pumps,
|
||||
geometry: "point",
|
||||
available: true,
|
||||
availability: "probe",
|
||||
label: "水泵",
|
||||
icon: "pump"
|
||||
},
|
||||
@@ -97,6 +104,7 @@ export const SUPPLY_LAYER_CATALOG = [
|
||||
sourceLayer: SOURCE_LAYERS.tanks,
|
||||
geometry: "point",
|
||||
available: true,
|
||||
availability: "probe",
|
||||
label: "水箱",
|
||||
icon: "tank"
|
||||
}
|
||||
@@ -119,14 +127,22 @@ export function isAvailableWaterNetworkSourceId(
|
||||
return (AVAILABLE_WATER_NETWORK_SOURCE_IDS as readonly string[]).includes(value);
|
||||
}
|
||||
|
||||
export function createWaterNetworkSources() {
|
||||
export function createWaterNetworkSources(): Record<GeoServerWaterNetworkSourceId, VectorSourceSpecification>;
|
||||
export function createWaterNetworkSources(
|
||||
sourceIds: readonly GeoServerWaterNetworkSourceId[]
|
||||
): Partial<Record<GeoServerWaterNetworkSourceId, VectorSourceSpecification>>;
|
||||
export function createWaterNetworkSources(
|
||||
sourceIds: readonly GeoServerWaterNetworkSourceId[] = GEOSERVER_WATER_NETWORK_SOURCE_IDS
|
||||
) {
|
||||
return Object.fromEntries(
|
||||
SUPPLY_LAYER_CATALOG.flatMap((layer) =>
|
||||
layer.available && layer.sourceLayer !== undefined
|
||||
layer.available &&
|
||||
layer.sourceLayer !== undefined &&
|
||||
sourceIds.includes(layer.id as GeoServerWaterNetworkSourceId)
|
||||
? [[layer.id, createGeoServerVectorSource(layer.sourceLayer)] as const]
|
||||
: []
|
||||
)
|
||||
) as Record<GeoServerWaterNetworkSourceId, VectorSourceSpecification>;
|
||||
) as Partial<Record<GeoServerWaterNetworkSourceId, VectorSourceSpecification>>;
|
||||
}
|
||||
|
||||
function createGeoServerVectorSource(
|
||||
|
||||
Reference in New Issue
Block a user