Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a RUC layer #564

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/lib/browse/LayerControls.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import CensusOutputAreaLayerControl from "./layers/areas/CensusOutputAreas.svelte";
import CombinedAuthoritiesLayerControl from "./layers/areas/CombinedAuthorities.svelte";
import ImdLayerControl from "./layers/areas/IMD.svelte";
import RuralUrbanLayerControl from "./layers/areas/RuralUrban.svelte";
import LocalAuthorityDistrictsLayerControl from "./layers/areas/LocalAuthorityDistricts.svelte";
import LocalPlanningAuthoritiesLayerControl from "./layers/areas/LocalPlanningAuthorities.svelte";
import ParliamentaryConstituenciesLayerControl from "./layers/areas/ParliamentaryConstituencies.svelte";
Expand Down Expand Up @@ -120,6 +121,7 @@
<CheckboxGroup small>
<CensusOutputAreaLayerControl />
<ImdLayerControl />
<RuralUrbanLayerControl />
</CheckboxGroup>
</CollapsibleCard>

Expand Down
90 changes: 90 additions & 0 deletions src/lib/browse/layers/areas/RuralUrban.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<script lang="ts">
import LayerControl from "../LayerControl.svelte";
import {
ExternalLink,
Popup,
publicResourceBaseUrl,
Legend,
} from "lib/common";
import { layerId, constructMatchExpression } from "lib/maplibre";
import {
FillLayer,
hoverStateFilter,
LineLayer,
VectorTileSource,
} from "svelte-maplibre";
import OsOglLicense from "../OsOglLicense.svelte";
import { showHideLayer } from "../url";

let name = "ruc";
let longName = "rural_urban_classification";
let title = "Rural Urban Classification";

let show = showHideLayer(name);

let colors = {
"Urban major conurbation": "#fe2200",
"Urban minor conurbation": "#ff6f00",
"Urban city and town": "#ffa602",
"Urban city and town in a sparse setting": "#ffe400",
"Rural hamlets and isolated dwellings": "#e5f5e0",
"Rural hamlets and isolated dwellings in a sparse setting": "#a1d99b",
"Rural town and fringe": "#d6e601",
"Rural town and fringe in a sparse setting": "#8cb503",
"Rural village": "#4a8a02",
"Rural village in a sparse setting": "#006100",
};
</script>

<LayerControl {name} {title} bind:show={$show}>
<span slot="help">
<p>
The 2011 Rural Urban Classification distinguishes four urban and six rural
categories. The data comes from <ExternalLink
href="https://www.gov.uk/government/collections/rural-urban-classification"
>
DEFRA
</ExternalLink>. Note this is data from 2011.
</p>
<OsOglLicense />
</span>
<span slot="controls">
<Legend rows={Object.entries(colors)} />
</span>
</LayerControl>

<VectorTileSource
url={`pmtiles://${publicResourceBaseUrl()}/v1/${longName}.pmtiles`}
>
<FillLayer
{...layerId(name)}
sourceLayer={longName}
paint={{
"fill-color": constructMatchExpression(["get", "RUC11"], colors, "cyan"),
"fill-opacity": hoverStateFilter(0.5, 0.7),
}}
layout={{
visibility: $show ? "visible" : "none",
}}
manageHoverState
eventsIfTopMost
>
<Popup let:props>
<p>
{props.OA11CD} is {props.RUC11.startsWith("U") ? "an" : "a"}
<b>{props.RUC11}</b>
</p>
</Popup>
</FillLayer>
<LineLayer
{...layerId(`${name}-outline`)}
sourceLayer={longName}
paint={{
"line-color": "black",
"line-width": 0.5,
}}
layout={{
visibility: $show ? "visible" : "none",
}}
/>
</VectorTileSource>
2 changes: 2 additions & 0 deletions src/lib/maplibre/zorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ export let layerZorder = [
browse("census_output_areas-outline"),
browse("imd"),
browse("imd-outline"),
browse("ruc"),
browse("ruc-outline"),
browse("pollution"),
browse("road_noise"),
browse("user_data_polygons"),
Expand Down
Loading