diff --git a/assets/chevron.png b/assets/chevron.png new file mode 100644 index 000000000..c6087b94e Binary files /dev/null and b/assets/chevron.png differ diff --git a/src/lib/browse/LayerControls.svelte b/src/lib/browse/LayerControls.svelte index 09775f4d8..2df857cb6 100644 --- a/src/lib/browse/LayerControls.svelte +++ b/src/lib/browse/LayerControls.svelte @@ -29,6 +29,7 @@ import BusStopsLayerControl from "./layers/points/BusStops.svelte"; import CriticalIssuesLayerControl from "./layers/points/CriticalIssues.svelte"; import CrossingsLayerControl from "./layers/points/Crossings.svelte"; + import GradientsLayerControl from "./layers/lines/Gradients.svelte"; import CycleParkingLayerControl from "./layers/points/CycleParking.svelte"; import EducationLayerControl from "./layers/points/Education.svelte"; import HospitalsLayerControl from "./layers/points/Hospitals.svelte"; @@ -107,6 +108,7 @@ + {#if appVersion() == "Private (development)"} diff --git a/src/lib/browse/colors.ts b/src/lib/browse/colors.ts index 105f1d2b2..bf9199ade 100644 --- a/src/lib/browse/colors.ts +++ b/src/lib/browse/colors.ts @@ -65,6 +65,16 @@ export const colors = { "#76c384", "#488f31", ], + + // Thanks to https://ropensci.github.io/slopes/articles/roadnetworkcycling.html + gradient_flat_to_steep: [ + "#267300", + "#70A800", + "#FFAA00", + "#E60000", + "#A80000", + "#730000", + ], }; // For dense line layers, make individual lines easily distinguished when diff --git a/src/lib/browse/layers/lines/Gradients.svelte b/src/lib/browse/layers/lines/Gradients.svelte new file mode 100644 index 000000000..261e4b5fd --- /dev/null +++ b/src/lib/browse/layers/lines/Gradients.svelte @@ -0,0 +1,101 @@ + + + + Gradients + + +

+ This layer shows the steepness of roads, with the arrows pointing + uphill. You have to zoom in to see all roads. +

+

+ Note the gradient may be incorrect near bridges and tunnels, depending + on the underlying Digital Elevation Model used. +

+

+ This layer is built from + OS Terrain 50 + and roads from OpenStreetMap. The data is valid as of 18 + February 2024. +

+ + +
+
+
+{#if show} + +{/if} + + + + +

+ Gradient: {Math.abs(props.gradient) / 100} + % +

+
+
+ + ", ["abs", ["get", "gradient"]], 300]} + layout={{ + "icon-image": "chevron", + "icon-size": 1.0, + "symbol-placement": "line", + "symbol-spacing": 50, + "icon-allow-overlap": true, + "icon-rotate": ["case", ["<", ["get", "gradient"], 0], 180, 0], + visibility: show ? "visible" : "none", + }} + /> +
diff --git a/src/lib/common/MapLibreMap.svelte b/src/lib/common/MapLibreMap.svelte index 9792c133a..175c48d8e 100644 --- a/src/lib/common/MapLibreMap.svelte +++ b/src/lib/common/MapLibreMap.svelte @@ -1,4 +1,5 @@