Skip to content

Commit

Permalink
Add narrow gauge railways
Browse files Browse the repository at this point in the history
  • Loading branch information
claysmalley committed Jul 15, 2022
1 parent 2a70738 commit 667d89b
Show file tree
Hide file tree
Showing 2 changed files with 111 additions and 6 deletions.
15 changes: 15 additions & 0 deletions src/americana.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,11 @@ americanaLayers.push(
lyrRail.railServiceTunnel.dashes(),
lyrRail.railServiceTunnel.fill(),

lyrRail.narrowGaugeTunnel.dashes(),
lyrRail.narrowGaugeTunnel.fill(),
lyrRail.narrowGaugeServiceTunnel.dashes(),
lyrRail.narrowGaugeServiceTunnel.fill(),

lyrOneway.tunnel,
lyrOneway.tunnelLink,

Expand Down Expand Up @@ -272,6 +277,11 @@ americanaLayers.push(
lyrRail.railService.dashes(),
lyrRail.railService.fill(),

lyrRail.narrowGauge.dashes(),
lyrRail.narrowGauge.fill(),
lyrRail.narrowGaugeService.dashes(),
lyrRail.narrowGaugeService.fill(),

lyrOneway.road,
lyrOneway.link
);
Expand Down Expand Up @@ -386,6 +396,11 @@ var bridgeLayers = [
lyrRail.railServiceBridge.dashes(),
lyrRail.railServiceBridge.fill(),

lyrRail.narrowGaugeBridge.dashes(),
lyrRail.narrowGaugeBridge.fill(),
lyrRail.narrowGaugeServiceBridge.dashes(),
lyrRail.narrowGaugeServiceBridge.fill(),

lyrRoadLabel.bridgeSpacer,

lyrOneway.bridge,
Expand Down
102 changes: 96 additions & 6 deletions src/layer/rail.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,64 @@ class RailService extends Rail {
}
}

class NarrowGauge extends Railway {
constructor() {
super();
this.railClass = "narrow_gauge";
this.brunnel = "surface";
this.service = false;

this.minZoom = 10;

this.fillWidth = [
[8, 0.3],
[12, 0.9],
[20, 3.8],
];
this.dashWidth = [
[8, 1.6],
[12, 4.8],
[20, 20],
];

this.dashArray = [0.15, 3];

this.fillColor = [
"interpolate",
["exponential", railExp],
["zoom"],
this.minZoom,
`hsl(${this.hue}, 0%, 75%)`,
this.minZoom + 2,
`hsl(${this.hue}, 0%, 50%)`,
];
}
}

class NarrowGaugeService extends NarrowGauge {
constructor() {
super();
this.service = true;

this.fillWidth = [
[8, 0.15],
[12, 0.5],
[20, 1.9],
];

this.dashArray = [0.1, 3];

this.constraints = null;
}
}

/*
* TODO:
* subway
* light_rail
* tram
* monorail
* funicular
* narrow_gauge
* subway z14
* light_rail z12
* tram z14
* monorail z14
* funicular z12
* preserved?
*/

Expand All @@ -191,6 +241,22 @@ class RailServiceBridge extends RailService {
}
}

class NarrowGaugeBridge extends NarrowGauge {
constructor() {
super();
// Undifferentiated
this.brunnel = "bridge";
}
}

class NarrowGaugeServiceBridge extends NarrowGaugeService {
constructor() {
super();
// Undifferentiated
this.brunnel = "bridge";
}
}

// Tunnels

class RailTunnel extends Rail {
Expand All @@ -209,10 +275,34 @@ class RailServiceTunnel extends RailService {
}
}

class NarrowGaugeTunnel extends NarrowGauge {
constructor() {
super();
this.brunnel = "tunnel";
this.fillColor = `hsl(${this.hue}, 0%, 90%)`;
}
}

class NarrowGaugeServiceTunnel extends NarrowGaugeService {
constructor() {
super();
this.brunnel = "tunnel";
this.fillColor = `hsl(${this.hue}, 0%, 90%)`;
}
}

export const rail = new Rail();
export const railBridge = new RailBridge();
export const railTunnel = new RailTunnel();

export const railService = new RailService();
export const railServiceBridge = new RailServiceBridge();
export const railServiceTunnel = new RailServiceTunnel();

export const narrowGauge = new NarrowGauge();
export const narrowGaugeBridge = new NarrowGaugeBridge();
export const narrowGaugeTunnel = new NarrowGaugeTunnel();

export const narrowGaugeService = new NarrowGaugeService();
export const narrowGaugeServiceBridge = new NarrowGaugeServiceBridge();
export const narrowGaugeServiceTunnel = new NarrowGaugeServiceTunnel();

0 comments on commit 667d89b

Please sign in to comment.