diff --git a/src/js/util.js b/src/js/util.js index bce6d34aa..5db0f3069 100644 --- a/src/js/util.js +++ b/src/js/util.js @@ -32,7 +32,11 @@ export function filteredClone(def, filterStep, idSuffix) { case "interpolate-hcl": case "interpolate-lab": case "step": - clone.filter = mapRampExpression(clone.filter, (input, output) => ["all", output, filterStep]); + clone.filter = mapRampExpression(clone.filter, (input, output) => [ + "all", + output, + filterStep, + ]); break; default: throw new TypeError("Unlikely filter"); diff --git a/src/layer/construction.js b/src/layer/construction.js index d1b9c800f..b715c2ed4 100644 --- a/src/layer/construction.js +++ b/src/layer/construction.js @@ -1,11 +1,7 @@ "use strict"; const motorwayHue = 218; -const majorConstruction = [ - "match", - ["get", "class"], - "motorway_construction", -]; +const majorConstruction = ["match", ["get", "class"], "motorway_construction"]; export const road = { id: "highway-construction", @@ -37,7 +33,11 @@ export const road = { 10, [...majorConstruction, `hsl(${motorwayHue}, 60%, 70%)`, "lightslategray"], 13, - [...majorConstruction, `hsl(${motorwayHue}, 100%, 45%)`, "lightslategray"], + [ + ...majorConstruction, + `hsl(${motorwayHue}, 100%, 45%)`, + "lightslategray", + ], 15, [...majorConstruction, `hsl(${motorwayHue}, 100%, 35%)`, "slategray"], ], diff --git a/src/layer/road.js b/src/layer/road.js index d26ae59b4..eebd1487b 100644 --- a/src/layer/road.js +++ b/src/layer/road.js @@ -11,7 +11,17 @@ const tollRoadHue = 100; const isRoad = [ "match", ["get", "class"], - ["motorway", "trunk", "primary", "secondary", "tertiary", "minor", "service", "busway", "bus_guideway"], + [ + "motorway", + "trunk", + "primary", + "secondary", + "tertiary", + "minor", + "service", + "busway", + "bus_guideway", + ], true, false, ]; @@ -21,7 +31,13 @@ const isToll = ["==", ["get", "toll"], 1]; const isNotToll = ["!", isToll]; const isMotorway = ["all", ["==", ["get", "class"], "motorway"], isNotRamp]; const isNotMotorway = ["!=", ["get", "class"], "motorway"]; -const isState = ["match", ["get", "network"], ["us-highway", "us-state"], isNotRamp, false]; +const isState = [ + "match", + ["get", "network"], + ["us-highway", "us-state"], + isNotRamp, + false, +]; const isNotState = ["!", isState]; const isExpressway = ["==", ["get", "expressway"], 1]; const isNotExpressway = ["!", isExpressway]; @@ -31,7 +47,8 @@ const isMinorService = [ "match", ["get", "service"], ["parking_aisle", "driveway"], - true, false, + true, + false, ]; const isConstruction = ["in", "_construction", ["get", "class"]]; const isNotConstruction = ["!", isConstruction]; @@ -41,13 +58,32 @@ const roadFilter = [ "step", ["zoom"], false, - 4, ["all", ["==", ["get", "network"], "us-interstate"], isNotConstruction], - 5, ["match", ["get", "class"], ["motorway", "trunk"], isNotRamp, false], - 7, ["match", ["get", "class"], ["motorway", "trunk", "primary"], isNotRamp, false], - 9, ["match", ["get", "class"], ["motorway", "trunk", "primary", "secondary"], true, false], - 11, ["all", isRoad, isNotService, isNotConstruction], - 12, ["all", isRoad, ["!", isMinorService], isNotConstruction], - 13, ["all", isRoad, isNotConstruction], + 4, + ["all", ["==", ["get", "network"], "us-interstate"], isNotConstruction], + 5, + ["match", ["get", "class"], ["motorway", "trunk"], isNotRamp, false], + 7, + [ + "match", + ["get", "class"], + ["motorway", "trunk", "primary"], + isNotRamp, + false, + ], + 9, + [ + "match", + ["get", "class"], + ["motorway", "trunk", "primary", "secondary"], + true, + false, + ], + 11, + ["all", isRoad, isNotService, isNotConstruction], + 12, + ["all", isRoad, ["!", isMinorService], isNotConstruction], + 13, + ["all", isRoad, isNotConstruction], ]; export const road = { @@ -55,7 +91,11 @@ export const road = { type: "line", source: "openmaptiles", "source-layer": "transportation", - filter: Util.mapRampExpression(roadFilter, (input, output) => ["all", output, ["!=", ["get", "brunnel"], "tunnel"]]), + filter: Util.mapRampExpression(roadFilter, (input, output) => [ + "all", + output, + ["!=", ["get", "brunnel"], "tunnel"], + ]), layout: { "line-cap": "butt", "line-join": "round", @@ -74,26 +114,36 @@ export const road = { 4, [ "case", - isToll, `hsl(${tollRoadHue}, 60%, 70%)`, - isMotorway, `hsl(${motorwayHue}, 60%, 70%)`, - isState, `hsl(${stateHue}, 77%, 50%)`, + isToll, + `hsl(${tollRoadHue}, 60%, 70%)`, + isMotorway, + `hsl(${motorwayHue}, 60%, 70%)`, + isState, + `hsl(${stateHue}, 77%, 50%)`, "#9c9c9c", ], 8, [ "case", - isToll, `hsl(${tollRoadHue}, 100%, 40%)`, - isMotorway, `hsl(${motorwayHue}, 100%, 45%)`, - isState, `hsl(${stateHue}, 77%, 50%)`, + isToll, + `hsl(${tollRoadHue}, 100%, 40%)`, + isMotorway, + `hsl(${motorwayHue}, 100%, 45%)`, + isState, + `hsl(${stateHue}, 77%, 50%)`, "#9c9c9c", ], 14, [ "case", - isToll, `hsl(${tollRoadHue}, 100%, 35%)`, - isMotorway, `hsl(${motorwayHue}, 100%, 35%)`, - isState, `hsl(${stateHue}, 77%, 50%)`, - ["all", ["==", ["get", "class"], "motorway"], isRamp], "#000", + isToll, + `hsl(${tollRoadHue}, 100%, 35%)`, + isMotorway, + `hsl(${motorwayHue}, 100%, 35%)`, + isState, + `hsl(${stateHue}, 77%, 50%)`, + ["all", ["==", ["get", "class"], "motorway"], isRamp], + "#000", "#9c9c9c", ], ], @@ -106,28 +156,52 @@ export const road = { 8, [ "case", - isMotorway, 3, - isExpressway, 1, - isState, 2, - ["match", ["get", "class"], ["trunk", "primary"], isNotRamp, false], 2, + isMotorway, + 3, + isExpressway, + 1, + isState, + 2, + ["match", ["get", "class"], ["trunk", "primary"], isNotRamp, false], + 2, 0.25, ], 18, [ "case", - isMotorway, 6, - ["all", isState, isNotExpressway], 4, - ["match", ["get", "class"], ["trunk", "primary", "secondary", "tertiary"], isNotRamp, false], 4, - isService, 1, + isMotorway, + 6, + ["all", isState, isNotExpressway], + 4, + [ + "match", + ["get", "class"], + ["trunk", "primary", "secondary", "tertiary"], + isNotRamp, + false, + ], + 4, + isService, + 1, 3, ], 20, [ "case", - isMotorway, 10, - ["all", isState, isNotExpressway], 8, - ["match", ["get", "class"], ["trunk", "primary", "secondary", "tertiary"], isNotRamp, false], 8, - isService, 1, + isMotorway, + 10, + ["all", isState, isNotExpressway], + 8, + [ + "match", + ["get", "class"], + ["trunk", "primary", "secondary", "tertiary"], + isNotRamp, + false, + ], + 8, + isService, + 1, 6, ], ], @@ -154,18 +228,25 @@ export const road = { ["case", isUnpaved, 3, 0], 20, ["case", isUnpaved, 6, 0], - ] + ], }, }; export const roadTunnel = { ...road, id: "road-tunnel", - filter: Util.mapRampExpression(roadFilter, (input, output) => ["all", output, ["==", ["get", "brunnel"], "tunnel"]]), + filter: Util.mapRampExpression(roadFilter, (input, output) => [ + "all", + output, + ["==", ["get", "brunnel"], "tunnel"], + ]), paint: { ...road.paint, "line-width": 1, - "line-gap-width": Util.mapRampExpression(road.paint["line-width"], (input, output) => ["-", output, 1]), + "line-gap-width": Util.mapRampExpression( + road.paint["line-width"], + (input, output) => ["-", output, 1] + ), "line-dasharray": [5, 5], }, }; @@ -173,25 +254,36 @@ export const roadTunnel = { export const roadBridgeKnockout = { ...road, id: "road-bridge-knockout", - filter: Util.mapRampExpression(roadFilter, (input, output) => ["all", output, ["==", ["get", "brunnel"], "bridge"]]), + filter: Util.mapRampExpression(roadFilter, (input, output) => [ + "all", + output, + ["==", ["get", "brunnel"], "bridge"], + ]), paint: { "line-color": Color.backgroundFill, - "line-width": Util.mapRampExpression(road.paint["line-width"], (input, output) => ["*", output, 2]), + "line-width": Util.mapRampExpression( + road.paint["line-width"], + (input, output) => ["*", output, 2] + ), "line-gap-width": 0, "line-blur": 0, - } + }, }; export const roadBridgeCasing = { ...road, id: "road-bridge-casing", - filter: Util.mapRampExpression(roadFilter, (input, output) => ["all", output, ["==", ["get", "brunnel"], "bridge"]]), + filter: Util.mapRampExpression(roadFilter, (input, output) => [ + "all", + output, + ["==", ["get", "brunnel"], "bridge"], + ]), paint: { "line-color": "#9c9c9c", "line-width": 0.5, "line-gap-width": roadBridgeKnockout.paint["line-width"], "line-blur": 0, - } + }, }; export const legendEntries = [ @@ -213,7 +305,15 @@ export const legendEntries = [ { description: "Local road", layers: [road.id], - filter: ["all", isNotMotorway, isNotState, isNotToll, isNotExpressway, isNotRamp, isNotService], + filter: [ + "all", + isNotMotorway, + isNotState, + isNotToll, + isNotExpressway, + isNotRamp, + isNotService, + ], }, { description: "Service road",