Skip to content

Commit 594d4a5

Browse files
committed
Formatted code
1 parent 1a0c975 commit 594d4a5

3 files changed

Lines changed: 153 additions & 49 deletions

File tree

src/js/util.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ export function filteredClone(def, filterStep, idSuffix) {
3232
case "interpolate-hcl":
3333
case "interpolate-lab":
3434
case "step":
35-
clone.filter = mapRampExpression(clone.filter, (input, output) => ["all", output, filterStep]);
35+
clone.filter = mapRampExpression(clone.filter, (input, output) => [
36+
"all",
37+
output,
38+
filterStep,
39+
]);
3640
break;
3741
default:
3842
throw new TypeError("Unlikely filter");

src/layer/construction.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
"use strict";
22

33
const motorwayHue = 218;
4-
const majorConstruction = [
5-
"match",
6-
["get", "class"],
7-
"motorway_construction",
8-
];
4+
const majorConstruction = ["match", ["get", "class"], "motorway_construction"];
95

106
export const road = {
117
id: "highway-construction",
@@ -37,7 +33,11 @@ export const road = {
3733
10,
3834
[...majorConstruction, `hsl(${motorwayHue}, 60%, 70%)`, "lightslategray"],
3935
13,
40-
[...majorConstruction, `hsl(${motorwayHue}, 100%, 45%)`, "lightslategray"],
36+
[
37+
...majorConstruction,
38+
`hsl(${motorwayHue}, 100%, 45%)`,
39+
"lightslategray",
40+
],
4141
15,
4242
[...majorConstruction, `hsl(${motorwayHue}, 100%, 35%)`, "slategray"],
4343
],

src/layer/road.js

Lines changed: 142 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,17 @@ const tollRoadHue = 100;
1111
const isRoad = [
1212
"match",
1313
["get", "class"],
14-
["motorway", "trunk", "primary", "secondary", "tertiary", "minor", "service", "busway", "bus_guideway"],
14+
[
15+
"motorway",
16+
"trunk",
17+
"primary",
18+
"secondary",
19+
"tertiary",
20+
"minor",
21+
"service",
22+
"busway",
23+
"bus_guideway",
24+
],
1525
true,
1626
false,
1727
];
@@ -21,7 +31,13 @@ const isToll = ["==", ["get", "toll"], 1];
2131
const isNotToll = ["!", isToll];
2232
const isMotorway = ["all", ["==", ["get", "class"], "motorway"], isNotRamp];
2333
const isNotMotorway = ["!=", ["get", "class"], "motorway"];
24-
const isState = ["match", ["get", "network"], ["us-highway", "us-state"], isNotRamp, false];
34+
const isState = [
35+
"match",
36+
["get", "network"],
37+
["us-highway", "us-state"],
38+
isNotRamp,
39+
false,
40+
];
2541
const isNotState = ["!", isState];
2642
const isExpressway = ["==", ["get", "expressway"], 1];
2743
const isNotExpressway = ["!", isExpressway];
@@ -31,7 +47,8 @@ const isMinorService = [
3147
"match",
3248
["get", "service"],
3349
["parking_aisle", "driveway"],
34-
true, false,
50+
true,
51+
false,
3552
];
3653
const isConstruction = ["in", "_construction", ["get", "class"]];
3754
const isNotConstruction = ["!", isConstruction];
@@ -41,21 +58,44 @@ const roadFilter = [
4158
"step",
4259
["zoom"],
4360
false,
44-
4, ["all", ["==", ["get", "network"], "us-interstate"], isNotConstruction],
45-
5, ["match", ["get", "class"], ["motorway", "trunk"], isNotRamp, false],
46-
7, ["match", ["get", "class"], ["motorway", "trunk", "primary"], isNotRamp, false],
47-
9, ["match", ["get", "class"], ["motorway", "trunk", "primary", "secondary"], true, false],
48-
11, ["all", isRoad, isNotService, isNotConstruction],
49-
12, ["all", isRoad, ["!", isMinorService], isNotConstruction],
50-
13, ["all", isRoad, isNotConstruction],
61+
4,
62+
["all", ["==", ["get", "network"], "us-interstate"], isNotConstruction],
63+
5,
64+
["match", ["get", "class"], ["motorway", "trunk"], isNotRamp, false],
65+
7,
66+
[
67+
"match",
68+
["get", "class"],
69+
["motorway", "trunk", "primary"],
70+
isNotRamp,
71+
false,
72+
],
73+
9,
74+
[
75+
"match",
76+
["get", "class"],
77+
["motorway", "trunk", "primary", "secondary"],
78+
true,
79+
false,
80+
],
81+
11,
82+
["all", isRoad, isNotService, isNotConstruction],
83+
12,
84+
["all", isRoad, ["!", isMinorService], isNotConstruction],
85+
13,
86+
["all", isRoad, isNotConstruction],
5187
];
5288

5389
export const road = {
5490
id: "road",
5591
type: "line",
5692
source: "openmaptiles",
5793
"source-layer": "transportation",
58-
filter: Util.mapRampExpression(roadFilter, (input, output) => ["all", output, ["!=", ["get", "brunnel"], "tunnel"]]),
94+
filter: Util.mapRampExpression(roadFilter, (input, output) => [
95+
"all",
96+
output,
97+
["!=", ["get", "brunnel"], "tunnel"],
98+
]),
5999
layout: {
60100
"line-cap": "butt",
61101
"line-join": "round",
@@ -74,26 +114,36 @@ export const road = {
74114
4,
75115
[
76116
"case",
77-
isToll, `hsl(${tollRoadHue}, 60%, 70%)`,
78-
isMotorway, `hsl(${motorwayHue}, 60%, 70%)`,
79-
isState, `hsl(${stateHue}, 77%, 50%)`,
117+
isToll,
118+
`hsl(${tollRoadHue}, 60%, 70%)`,
119+
isMotorway,
120+
`hsl(${motorwayHue}, 60%, 70%)`,
121+
isState,
122+
`hsl(${stateHue}, 77%, 50%)`,
80123
"#9c9c9c",
81124
],
82125
8,
83126
[
84127
"case",
85-
isToll, `hsl(${tollRoadHue}, 100%, 40%)`,
86-
isMotorway, `hsl(${motorwayHue}, 100%, 45%)`,
87-
isState, `hsl(${stateHue}, 77%, 50%)`,
128+
isToll,
129+
`hsl(${tollRoadHue}, 100%, 40%)`,
130+
isMotorway,
131+
`hsl(${motorwayHue}, 100%, 45%)`,
132+
isState,
133+
`hsl(${stateHue}, 77%, 50%)`,
88134
"#9c9c9c",
89135
],
90136
14,
91137
[
92138
"case",
93-
isToll, `hsl(${tollRoadHue}, 100%, 35%)`,
94-
isMotorway, `hsl(${motorwayHue}, 100%, 35%)`,
95-
isState, `hsl(${stateHue}, 77%, 50%)`,
96-
["all", ["==", ["get", "class"], "motorway"], isRamp], "#000",
139+
isToll,
140+
`hsl(${tollRoadHue}, 100%, 35%)`,
141+
isMotorway,
142+
`hsl(${motorwayHue}, 100%, 35%)`,
143+
isState,
144+
`hsl(${stateHue}, 77%, 50%)`,
145+
["all", ["==", ["get", "class"], "motorway"], isRamp],
146+
"#000",
97147
"#9c9c9c",
98148
],
99149
],
@@ -106,28 +156,52 @@ export const road = {
106156
8,
107157
[
108158
"case",
109-
isMotorway, 3,
110-
isExpressway, 1,
111-
isState, 2,
112-
["match", ["get", "class"], ["trunk", "primary"], isNotRamp, false], 2,
159+
isMotorway,
160+
3,
161+
isExpressway,
162+
1,
163+
isState,
164+
2,
165+
["match", ["get", "class"], ["trunk", "primary"], isNotRamp, false],
166+
2,
113167
0.25,
114168
],
115169
18,
116170
[
117171
"case",
118-
isMotorway, 6,
119-
["all", isState, isNotExpressway], 4,
120-
["match", ["get", "class"], ["trunk", "primary", "secondary", "tertiary"], isNotRamp, false], 4,
121-
isService, 1,
172+
isMotorway,
173+
6,
174+
["all", isState, isNotExpressway],
175+
4,
176+
[
177+
"match",
178+
["get", "class"],
179+
["trunk", "primary", "secondary", "tertiary"],
180+
isNotRamp,
181+
false,
182+
],
183+
4,
184+
isService,
185+
1,
122186
3,
123187
],
124188
20,
125189
[
126190
"case",
127-
isMotorway, 10,
128-
["all", isState, isNotExpressway], 8,
129-
["match", ["get", "class"], ["trunk", "primary", "secondary", "tertiary"], isNotRamp, false], 8,
130-
isService, 1,
191+
isMotorway,
192+
10,
193+
["all", isState, isNotExpressway],
194+
8,
195+
[
196+
"match",
197+
["get", "class"],
198+
["trunk", "primary", "secondary", "tertiary"],
199+
isNotRamp,
200+
false,
201+
],
202+
8,
203+
isService,
204+
1,
131205
6,
132206
],
133207
],
@@ -154,44 +228,62 @@ export const road = {
154228
["case", isUnpaved, 3, 0],
155229
20,
156230
["case", isUnpaved, 6, 0],
157-
]
231+
],
158232
},
159233
};
160234

161235
export const roadTunnel = {
162236
...road,
163237
id: "road-tunnel",
164-
filter: Util.mapRampExpression(roadFilter, (input, output) => ["all", output, ["==", ["get", "brunnel"], "tunnel"]]),
238+
filter: Util.mapRampExpression(roadFilter, (input, output) => [
239+
"all",
240+
output,
241+
["==", ["get", "brunnel"], "tunnel"],
242+
]),
165243
paint: {
166244
...road.paint,
167245
"line-width": 1,
168-
"line-gap-width": Util.mapRampExpression(road.paint["line-width"], (input, output) => ["-", output, 1]),
246+
"line-gap-width": Util.mapRampExpression(
247+
road.paint["line-width"],
248+
(input, output) => ["-", output, 1]
249+
),
169250
"line-dasharray": [5, 5],
170251
},
171252
};
172253

173254
export const roadBridgeKnockout = {
174255
...road,
175256
id: "road-bridge-knockout",
176-
filter: Util.mapRampExpression(roadFilter, (input, output) => ["all", output, ["==", ["get", "brunnel"], "bridge"]]),
257+
filter: Util.mapRampExpression(roadFilter, (input, output) => [
258+
"all",
259+
output,
260+
["==", ["get", "brunnel"], "bridge"],
261+
]),
177262
paint: {
178263
"line-color": Color.backgroundFill,
179-
"line-width": Util.mapRampExpression(road.paint["line-width"], (input, output) => ["*", output, 2]),
264+
"line-width": Util.mapRampExpression(
265+
road.paint["line-width"],
266+
(input, output) => ["*", output, 2]
267+
),
180268
"line-gap-width": 0,
181269
"line-blur": 0,
182-
}
270+
},
183271
};
184272

185273
export const roadBridgeCasing = {
186274
...road,
187275
id: "road-bridge-casing",
188-
filter: Util.mapRampExpression(roadFilter, (input, output) => ["all", output, ["==", ["get", "brunnel"], "bridge"]]),
276+
filter: Util.mapRampExpression(roadFilter, (input, output) => [
277+
"all",
278+
output,
279+
["==", ["get", "brunnel"], "bridge"],
280+
]),
189281
paint: {
190282
"line-color": "#9c9c9c",
191283
"line-width": 0.5,
192284
"line-gap-width": roadBridgeKnockout.paint["line-width"],
193285
"line-blur": 0,
194-
}
286+
},
195287
};
196288

197289
export const legendEntries = [
@@ -213,7 +305,15 @@ export const legendEntries = [
213305
{
214306
description: "Local road",
215307
layers: [road.id],
216-
filter: ["all", isNotMotorway, isNotState, isNotToll, isNotExpressway, isNotRamp, isNotService],
308+
filter: [
309+
"all",
310+
isNotMotorway,
311+
isNotState,
312+
isNotToll,
313+
isNotExpressway,
314+
isNotRamp,
315+
isNotService,
316+
],
217317
},
218318
{
219319
description: "Service road",

0 commit comments

Comments
 (0)