Skip to content

Commit

Permalink
Merge pull request #350 from wearepal/designations-component
Browse files Browse the repository at this point in the history
Add Ancient Woodland to Designations
  • Loading branch information
paulthatjazz authored Feb 22, 2024
2 parents 6b3bc6d + ebf7a28 commit 2333748
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/javascript/projects/layer_palette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ export const LayerPalette = ({ addLayer, hide, dbModels, getTeamDatasets, teamNa
</Section>
<Section title="Designations">
{
designations.sort((a, b) => (a.name < b.name) ? -1 : 1).map(({ name, identifier, stroke, fill }) =>
designations.sort((a, b) => (a.name < b.name) ? -1 : 1).map(({ name, identifier, stroke, fill, attribution }) =>
<AddLayerButton
addLayer={addLayer}
prototype={{
Expand All @@ -215,6 +215,7 @@ export const LayerPalette = ({ addLayer, hide, dbModels, getTeamDatasets, teamNa
identifier,
visible: true,
opacity: 1,
attribution
}}
/>
)
Expand Down
11 changes: 11 additions & 0 deletions app/javascript/projects/modelling/designations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface Designation {
identifier: string
fill: [number, number, number, number]
stroke: [number, number, number, number]
attribution?: string
}

// Designations available from both the Model and Map view, add new designations here to make them available in both views
Expand Down Expand Up @@ -78,5 +79,15 @@ export const designations : Designation[] = [
identifier: "shapefiles:ramsar_eng",
fill: [0, 60, 110, 1],
stroke: [0, 0, 0, 1]
},
{
id: 8,
value: "AW",
socket: booleanDataSocket,
name: "Ancient Woodland",
identifier: "shapefiles:aw_eng",
fill: [252, 186, 3, 1],
stroke: [0, 0, 0, 1],
attribution: '&copy; <a href="https://naturalengland-defra.opendata.arcgis.com/datasets/Defra::ancient-woodland-england/about">Natural England</a>'
}
]
5 changes: 3 additions & 2 deletions app/javascript/projects/reify_layer/shapefile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { memoize } from "lodash"
import { Map } from "ol"


const getSource = memoize((id: string) => {
const getSource = memoize((id: string, attribution: undefined | string) => {

const store = id.split(":")[0]

Expand All @@ -19,6 +19,7 @@ const getSource = memoize((id: string) => {
extractGeometryName: true
}),
strategy: bbox,
attributions: attribution
})

return source
Expand All @@ -41,7 +42,7 @@ const getStyle = (layer: ShapeLayer, zoom: number | undefined) => (
export function reifyShapeFileLayer (layer: ShapeLayer, existingLayer: BaseLayer | null, map: Map) {

const vectLayer = new VectorLayer({
source: getSource(layer.identifier),
source: getSource(layer.identifier, layer.attribution),
style: getStyle(layer, map.getView().getZoom()),
minZoom: layer.minZoom,
})
Expand Down
1 change: 1 addition & 0 deletions app/javascript/projects/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export interface ShapeLayer extends BaseLayer {
identifier: string
colors: StrokeFill
minZoom?: number
attribution?: string
}

export interface BoundaryLayer extends BaseLayer {
Expand Down

0 comments on commit 2333748

Please sign in to comment.