Skip to content

Commit

Permalink
Merge pull request #417 from wearepal/wdc-layer
Browse files Browse the repository at this point in the history
District councils & WDC only layer
  • Loading branch information
paulthatjazz authored Sep 4, 2024
2 parents e04ab1e + e718cdb commit b8b0fa8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 8 additions & 0 deletions app/javascript/projects/layer_palette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) =>
<AddLayerButton
Expand Down
10 changes: 6 additions & 4 deletions app/javascript/projects/reify_layer/boundary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,20 @@ const getSource = memoize((id: string) => {
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({
Expand All @@ -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
Expand Down

0 comments on commit b8b0fa8

Please sign in to comment.