Skip to content

Commit

Permalink
Merge pull request #339 from wearepal/kew-data
Browse files Browse the repository at this point in the history
Woody linear ukceh map layer
  • Loading branch information
paulthatjazz authored Feb 16, 2024
2 parents 8cd4eb4 + dfe1405 commit b6d8136
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
16 changes: 16 additions & 0 deletions app/javascript/projects/layer_palette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,22 @@ export const LayerPalette = ({ addLayer, hide, dbModels, getTeamDatasets, teamNa
year: 2021,
}}
/>
<AddLayerButton
addLayer={addLayer}
prototype={{
type: "ShapeLayer",
name: "UKCEH Woody Linear Features",
identifier: "ukceh:linearwoody2",
colors: {
stroke: [0, 255, 0, 1],
fill: [0, 255, 0, 1],
strokeWidth: 3
},
visible: true,
opacity: 1,
minZoom: 15
}}
/>
</Section>
<Section title="Crop Map of England">
{
Expand Down
9 changes: 6 additions & 3 deletions app/javascript/projects/reify_layer/shapefile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ import { Map } from "ol"

const getSource = memoize((id: string) => {

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

const source = new VectorSource({
url: extent => `https://landscapes.wearepal.ai/geoserver/shapefiles/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=${id}&outputFormat=application/json&bbox=${extent.join(',')},EPSG:3857&crs=EPSG:3857`,
url: extent => `https://landscapes.wearepal.ai/geoserver/${store}/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=${id}&outputFormat=application/json&bbox=${extent.join(',')},EPSG:3857&crs=EPSG:3857`,
format: new GeoJSON({
extractGeometryName: true
}),
Expand All @@ -30,7 +32,7 @@ const getStyle = (layer: ShapeLayer, zoom: number | undefined) => (
}),
stroke: new Stroke({
color: `rgba(${layer.colors.stroke[0]}, ${layer.colors.stroke[1]}, ${layer.colors.stroke[2]}, ${layer.colors.stroke[3]})`,
width: 1
width: layer.colors.strokeWidth || 1
})
})
}
Expand All @@ -40,7 +42,8 @@ export function reifyShapeFileLayer (layer: ShapeLayer, existingLayer: BaseLayer

const vectLayer = new VectorLayer({
source: getSource(layer.identifier),
style: getStyle(layer, map.getView().getZoom())
style: getStyle(layer, map.getView().getZoom()),
minZoom: layer.minZoom,
})

return vectLayer
Expand Down
2 changes: 2 additions & 0 deletions app/javascript/projects/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface ColourMapATI {
export interface StrokeFill {
stroke: [r: number, g: number, b: number, a: number]
fill: [r: number, g: number, b: number, a: number]
strokeWidth?: number
}

export interface KewOption {
Expand Down Expand Up @@ -55,6 +56,7 @@ export interface ShapeLayer extends BaseLayer {
type: "ShapeLayer"
identifier: string
colors: StrokeFill
minZoom?: number
}

export interface BoundaryLayer extends BaseLayer {
Expand Down

0 comments on commit b6d8136

Please sign in to comment.