Skip to content

Commit 97e8de6

Browse files
committed
Add railroad bridge casing
1 parent e2b8098 commit 97e8de6

File tree

2 files changed

+84
-24
lines changed

2 files changed

+84
-24
lines changed

src/americana.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,18 @@ americanaLayers.push(
289289
americanaLayers.push(lyrBuilding.building);
290290

291291
var bridgeLayers = [
292+
lyrRail.railBridge.bridgeCasing(),
293+
lyrRail.railServiceBridge.bridgeCasing(),
294+
295+
lyrRail.narrowGaugeBridge.bridgeCasing(),
296+
lyrRail.narrowGaugeServiceBridge.bridgeCasing(),
297+
298+
lyrRail.railBridge.bridgeFill(),
299+
lyrRail.railServiceBridge.bridgeFill(),
300+
301+
lyrRail.narrowGaugeBridge.bridgeFill(),
302+
lyrRail.narrowGaugeServiceBridge.bridgeFill(),
303+
292304
lyrRoad.tertiaryLinkBridge.casing(),
293305
lyrRoad.secondaryLinkBridge.casing(),
294306
lyrRoad.primaryLinkBridge.casing(),

src/layer/rail.js

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,58 @@ class Railway {
5454
constructor() {
5555
this.hue = 35;
5656
}
57+
bridgeCasing = function () {
58+
var layer = baseRailLayer(
59+
this.railClass,
60+
"bridgeCasing",
61+
this.brunnel,
62+
this.minZoomBridge,
63+
this.service,
64+
this.constraints
65+
);
66+
layer.layout = {
67+
"line-cap": "butt",
68+
"line-join": "bevel",
69+
visibility: "visible",
70+
};
71+
layer.paint = {
72+
"line-color": "hsl(0, 0%, 50%)",
73+
"line-width": {
74+
base: railExp,
75+
stops: this.bridgeCasingWidth,
76+
},
77+
};
78+
if (this.constraints != null) {
79+
layer.filter.push(this.constraints);
80+
}
81+
return layer;
82+
};
83+
bridgeFill = function () {
84+
var layer = baseRailLayer(
85+
this.railClass,
86+
"bridgeFill",
87+
this.brunnel,
88+
this.minZoomBridge,
89+
this.service,
90+
this.constraints
91+
);
92+
layer.layout = {
93+
"line-cap": "butt",
94+
"line-join": "bevel",
95+
visibility: "visible",
96+
};
97+
layer.paint = {
98+
"line-color": "white",
99+
"line-width": {
100+
base: railExp,
101+
stops: this.bridgeFillWidth,
102+
},
103+
};
104+
if (this.constraints != null) {
105+
layer.filter.push(this.constraints);
106+
}
107+
return layer;
108+
};
57109
fill = function () {
58110
var layer = baseRailLayer(
59111
this.railClass,
@@ -119,19 +171,19 @@ class Rail extends Railway {
119171
this.service = false;
120172

121173
this.minZoom = 10;
174+
this.minZoomBridge = 13;
175+
this.lineWeight = 0.4;
122176

123-
this.fillWidth = [
124-
[8, 0.4],
125-
[12, 1.2],
126-
[20, 5],
127-
];
128177
this.dashWidth = [
129178
[8, 1.6],
130179
[12, 4.8],
131180
[20, 20],
132181
];
182+
this.fillWidth = Util.zoomMultiply(this.dashWidth, this.lineWeight);
183+
this.bridgeFillWidth = Util.zoomMultiply(this.dashWidth, 1.1);
184+
this.bridgeCasingWidth = Util.zoomMultiply(this.dashWidth, 1.3);
133185

134-
this.dashArray = [0.2, 4];
186+
this.dashArray = [this.lineWeight / 2, 4];
135187

136188
this.fillColor = [
137189
"interpolate",
@@ -150,13 +202,11 @@ class RailService extends Rail {
150202
super();
151203
this.service = true;
152204

153-
this.fillWidth = [
154-
[8, 0.2],
155-
[12, 0.6],
156-
[20, 2.5],
157-
];
205+
this.lineWeight = 0.2;
206+
207+
this.fillWidth = Util.zoomMultiply(this.dashWidth, this.lineWeight);
158208

159-
this.dashArray = [0.1, 4];
209+
this.dashArray = [this.lineWeight / 2, 4];
160210

161211
this.constraints = null;
162212
}
@@ -170,19 +220,19 @@ class NarrowGauge extends Railway {
170220
this.service = false;
171221

172222
this.minZoom = 10;
223+
this.minZoomBridge = 13;
224+
this.lineWeight = 0.4;
173225

174-
this.fillWidth = [
175-
[8, 0.3],
176-
[12, 0.9],
177-
[20, 3.8],
178-
];
179226
this.dashWidth = [
180227
[8, 1.2],
181228
[12, 3.6],
182229
[20, 15],
183230
];
231+
this.fillWidth = Util.zoomMultiply(this.dashWidth, this.lineWeight);
232+
this.bridgeFillWidth = Util.zoomMultiply(this.dashWidth, 1.1);
233+
this.bridgeCasingWidth = Util.zoomMultiply(this.dashWidth, 1.3);
184234

185-
this.dashArray = [0.15, 4];
235+
this.dashArray = [this.lineWeight / 2, 4];
186236

187237
this.fillColor = [
188238
"interpolate",
@@ -201,13 +251,11 @@ class NarrowGaugeService extends NarrowGauge {
201251
super();
202252
this.service = true;
203253

204-
this.fillWidth = [
205-
[8, 0.15],
206-
[12, 0.5],
207-
[20, 1.9],
208-
];
254+
this.lineWeight = 0.2;
255+
256+
this.fillWidth = Util.zoomMultiply(this.dashWidth, this.lineWeight);
209257

210-
this.dashArray = [0.1, 4];
258+
this.dashArray = [this.lineWeight / 2, 4];
211259

212260
this.constraints = null;
213261
}

0 commit comments

Comments
 (0)