From e718cdbd00fd8e7af354da629b426cecbbd3c1d6 Mon Sep 17 00:00:00 2001 From: Paul Crossley Date: Wed, 4 Sep 2024 11:31:10 +0100 Subject: [PATCH] District councils & WDC only layer --- app/javascript/projects/layer_palette.tsx | 8 ++++++++ app/javascript/projects/reify_layer/boundary.ts | 10 ++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/javascript/projects/layer_palette.tsx b/app/javascript/projects/layer_palette.tsx index 1833c18a..fa1129e5 100644 --- a/app/javascript/projects/layer_palette.tsx +++ b/app/javascript/projects/layer_palette.tsx @@ -244,6 +244,14 @@ export const LayerPalette = ({ addLayer, hide, dbModels, getTeamDatasets, teamNa { name: "Polling Districts", identifier: "shapefiles:polling_districts_england" + }, + { + name: "District Councils", + identifier: "shapefiles:district_borough_unitary" + }, + { + name: "District Councils - Wealden District Council", + identifier: "shapefiles:district_borough_unitary" } ).sort((a, b) => (a.name < b.name) ? -1 : 1).map(({ name, identifier }) => { return source }) -const getStyle = (layer: BoundaryLayer, zoom: number | undefined) => ( +const getStyle = (layer: BoundaryLayer, zoom: number | undefined, name: string) => ( (feature) => { const properties = feature.getProperties() const id = properties.geometry?.ol_uid ?? properties.Admin_Unit_ID const col = boundaryColourMap.get(id) || [Math.random() * 255, Math.random() * 255, Math.random() * 255, 1] boundaryColourMap.set(id, col) + + const wealdenOnly = (properties.Name === "Wealden District" && name == "District Councils - Wealden District Council") return new Style({ fill : new Fill({ - color: `rgba(${col[0]}, ${col[1]}, ${col[2]}, ${col[3]})` + color: `rgba(${col[0]}, ${col[1]}, ${col[2]}, ${!wealdenOnly && name == "District Councils - Wealden District Council" ? 0 : col[3]})` }), stroke: new Stroke({ - color: `rgba(0, 0, 122, 1)`, + color: `rgba(0, 0, 122, ${!wealdenOnly && name == "District Councils - Wealden District Council" ? 0 : 1})`, width: 2 }), text: new Text({ @@ -59,7 +61,7 @@ export function reifyBoundaryLayer (layer: BoundaryLayer, existingLayer: BaseLay const vectLayer = new VectorLayer({ source: getSource(layer.identifier), - style: getStyle(layer, map.getView().getZoom()) + style: getStyle(layer, map.getView().getZoom(), layer.name) }) return vectLayer