From 97e8de609510ac9b29b4c91985ac6e7f11e02a0d Mon Sep 17 00:00:00 2001 From: Clay Smalley Date: Sat, 16 Jul 2022 15:57:24 -0400 Subject: [PATCH] Add railroad bridge casing --- src/americana.js | 12 ++++++ src/layer/rail.js | 96 +++++++++++++++++++++++++++++++++++------------ 2 files changed, 84 insertions(+), 24 deletions(-) diff --git a/src/americana.js b/src/americana.js index 9d66c0eee..8bb204f3d 100644 --- a/src/americana.js +++ b/src/americana.js @@ -289,6 +289,18 @@ americanaLayers.push( americanaLayers.push(lyrBuilding.building); var bridgeLayers = [ + lyrRail.railBridge.bridgeCasing(), + lyrRail.railServiceBridge.bridgeCasing(), + + lyrRail.narrowGaugeBridge.bridgeCasing(), + lyrRail.narrowGaugeServiceBridge.bridgeCasing(), + + lyrRail.railBridge.bridgeFill(), + lyrRail.railServiceBridge.bridgeFill(), + + lyrRail.narrowGaugeBridge.bridgeFill(), + lyrRail.narrowGaugeServiceBridge.bridgeFill(), + lyrRoad.tertiaryLinkBridge.casing(), lyrRoad.secondaryLinkBridge.casing(), lyrRoad.primaryLinkBridge.casing(), diff --git a/src/layer/rail.js b/src/layer/rail.js index 204194ec5..aa44634eb 100644 --- a/src/layer/rail.js +++ b/src/layer/rail.js @@ -54,6 +54,58 @@ class Railway { constructor() { this.hue = 35; } + bridgeCasing = function () { + var layer = baseRailLayer( + this.railClass, + "bridgeCasing", + this.brunnel, + this.minZoomBridge, + this.service, + this.constraints + ); + layer.layout = { + "line-cap": "butt", + "line-join": "bevel", + visibility: "visible", + }; + layer.paint = { + "line-color": "hsl(0, 0%, 50%)", + "line-width": { + base: railExp, + stops: this.bridgeCasingWidth, + }, + }; + if (this.constraints != null) { + layer.filter.push(this.constraints); + } + return layer; + }; + bridgeFill = function () { + var layer = baseRailLayer( + this.railClass, + "bridgeFill", + this.brunnel, + this.minZoomBridge, + this.service, + this.constraints + ); + layer.layout = { + "line-cap": "butt", + "line-join": "bevel", + visibility: "visible", + }; + layer.paint = { + "line-color": "white", + "line-width": { + base: railExp, + stops: this.bridgeFillWidth, + }, + }; + if (this.constraints != null) { + layer.filter.push(this.constraints); + } + return layer; + }; fill = function () { var layer = baseRailLayer( this.railClass, @@ -119,19 +171,19 @@ class Rail extends Railway { this.service = false; this.minZoom = 10; + this.minZoomBridge = 13; + this.lineWeight = 0.4; - this.fillWidth = [ - [8, 0.4], - [12, 1.2], - [20, 5], - ]; this.dashWidth = [ [8, 1.6], [12, 4.8], [20, 20], ]; + this.fillWidth = Util.zoomMultiply(this.dashWidth, this.lineWeight); + this.bridgeFillWidth = Util.zoomMultiply(this.dashWidth, 1.1); + this.bridgeCasingWidth = Util.zoomMultiply(this.dashWidth, 1.3); - this.dashArray = [0.2, 4]; + this.dashArray = [this.lineWeight / 2, 4]; this.fillColor = [ "interpolate", @@ -150,13 +202,11 @@ class RailService extends Rail { super(); this.service = true; - this.fillWidth = [ - [8, 0.2], - [12, 0.6], - [20, 2.5], - ]; + this.lineWeight = 0.2; + + this.fillWidth = Util.zoomMultiply(this.dashWidth, this.lineWeight); - this.dashArray = [0.1, 4]; + this.dashArray = [this.lineWeight / 2, 4]; this.constraints = null; } @@ -170,19 +220,19 @@ class NarrowGauge extends Railway { this.service = false; this.minZoom = 10; + this.minZoomBridge = 13; + this.lineWeight = 0.4; - this.fillWidth = [ - [8, 0.3], - [12, 0.9], - [20, 3.8], - ]; this.dashWidth = [ [8, 1.2], [12, 3.6], [20, 15], ]; + this.fillWidth = Util.zoomMultiply(this.dashWidth, this.lineWeight); + this.bridgeFillWidth = Util.zoomMultiply(this.dashWidth, 1.1); + this.bridgeCasingWidth = Util.zoomMultiply(this.dashWidth, 1.3); - this.dashArray = [0.15, 4]; + this.dashArray = [this.lineWeight / 2, 4]; this.fillColor = [ "interpolate", @@ -201,13 +251,11 @@ class NarrowGaugeService extends NarrowGauge { super(); this.service = true; - this.fillWidth = [ - [8, 0.15], - [12, 0.5], - [20, 1.9], - ]; + this.lineWeight = 0.2; + + this.fillWidth = Util.zoomMultiply(this.dashWidth, this.lineWeight); - this.dashArray = [0.1, 4]; + this.dashArray = [this.lineWeight / 2, 4]; this.constraints = null; }