diff --git a/scripts/taginfo_template.json b/scripts/taginfo_template.json index 67da7cfa6..e3fca4349 100644 --- a/scripts/taginfo_template.json +++ b/scripts/taginfo_template.json @@ -104,6 +104,13 @@ "description": "Unpaved roads have an alternating dash pattern.", "doc_url": "https://openmaptiles.org/schema/#surface" }, + { + "key": "surface", + "value": "track", + "object_types": ["way"], + "description": "Track roads have a two-track line pattern that is dashed if unpaved and solid if paved.", + "doc_url": "https://openmaptiles.org/schema/#transportation" + }, { "key": "iata", "object_types": ["node", "area"], @@ -222,6 +229,20 @@ "description": "Major roads under construction have a dotted line pattern and a more prominent color.", "doc_url": "https://openmaptiles.org/schema/#transportation" }, + { + "key": "highway", + "value": "track", + "object_types": ["way"], + "description": "Track roads have a two-track line pattern that is dashed if unpaved and solid if paved.", + "doc_url": "https://openmaptiles.org/schema/#transportation" + }, + { + "key": "ford", + "value": "yes", + "object_types": ["way"], + "description": "The color of track roads changes from brown to blue for ways tagged as fords.", + "doc_url": "https://openmaptiles.org/schema/#transportation" + }, { "key": "railway", "value": "rail", diff --git a/src/js/legend_config.js b/src/js/legend_config.js index 02e9170e3..80ce22c06 100644 --- a/src/js/legend_config.js +++ b/src/js/legend_config.js @@ -4,6 +4,7 @@ import * as PlaceLayers from "../layer/place.js"; import * as LanduseLayers from "../layer/landuse.js"; import * as BoundaryLayers from "../layer/boundary.js"; import * as RoadLayers from "../layer/road.js"; +import * as TrackLayers from "../layer/track.js"; import * as ConstructionLayers from "../layer/construction.js"; import * as HighwayExitLayers from "../layer/highway_exit.js"; import * as RailLayers from "../layer/rail.js"; @@ -27,6 +28,7 @@ export const sections = [ name: "Roads", entries: [ ...RoadLayers.legendEntries, + ...TrackLayers.legendEntries, ...ConstructionLayers.legendEntries, ...HighwayExitLayers.legendEntries, ], diff --git a/src/layer/index.js b/src/layer/index.js index 2cbd84e06..73b01f45a 100644 --- a/src/layer/index.js +++ b/src/layer/index.js @@ -14,6 +14,7 @@ import * as lyrPlace from "./place.js"; import * as lyrPoi from "./poi.js"; import * as lyrRail from "./rail.js"; import * as lyrRoad from "./road.js"; +import * as lyrTrack from "./track.js"; import * as lyrTransportationLabel from "./transportation_label.js"; import * as lyrWater from "./water.js"; import * as lyrBuilding from "./building.js"; @@ -86,6 +87,9 @@ export function build(locales) { lyrAeroway.taxiway, lyrAeroway.taxiwayArea, + lyrTrack.track, + lyrTrack.pavedTrack, + lyrRoad.motorwayLink.casing(), lyrRoad.trunkLink.casing(), @@ -143,6 +147,9 @@ export function build(locales) { var bridgeLayers = [ lyrRail.bridgeCasing, + lyrTrack.bridgeCasing, + lyrTrack.bridgeFill, + lyrRoad.trunkLinkBridge.casing(), lyrRoad.motorwayLinkBridge.casing(), @@ -178,6 +185,9 @@ export function build(locales) { lyrRoad.roadBridge.surface(), + lyrTrack.trackBridge, + lyrTrack.pavedTrackBridge, + lyrRail.railBridge.dashes(), lyrRail.railServiceBridge.dashes(), diff --git a/src/layer/track.js b/src/layer/track.js new file mode 100644 index 000000000..f536a11d8 --- /dev/null +++ b/src/layer/track.js @@ -0,0 +1,147 @@ +"use strict"; + +import * as Color from "../constants/color.js"; + +const trackSelect = ["==", ["get", "class"], "track"]; +const unpavedSelect = ["!=", ["get", "surface"], "paved"]; +const pavedSelect = ["==", ["get", "surface"], "paved"]; +const bridgeSelect = ["==", ["get", "brunnel"], "bridge"]; +const fordSelect = ["==", ["get", "brunnel"], "ford"]; +const notFordSelect = ["!=", ["get", "brunnel"], "ford"]; +const opacity = ["interpolate", ["exponential", 1.2], ["zoom"], 12, 0, 13, 1]; +const getBrunnel = ["get", "brunnel"]; + +export const track = { + id: "highway-track", + type: "line", + source: "openmaptiles", + "source-layer": "transportation", + filter: ["all", trackSelect, unpavedSelect], + minzoom: 12, + paint: { + "line-color": ["match", getBrunnel, "ford", Color.waterLine, "#d4b791"], + "line-opacity": opacity, + "line-blur": 0.75, + "line-width": 0.5, + "line-dasharray": [12, 3], + "line-offset": 0, + "line-gap-width": [ + "interpolate", + ["exponential", 1.2], + ["zoom"], + 13, + 0.7, + 20, + 6, + ], + }, +}; + +export const pavedTrack = { + id: "highway-track-paved", + type: "line", + source: "openmaptiles", + "source-layer": "transportation", + filter: ["all", trackSelect, pavedSelect], + minzoom: 12, + paint: { ...track.paint }, +}; +pavedTrack["paint"]["line-dasharray"] = [1, 0]; + +export const trackBridge = { + id: "highway-track-bridge", + type: "line", + source: "openmaptiles", + "source-layer": "transportation", + filter: ["all", trackSelect, unpavedSelect, bridgeSelect], + minzoom: 12, + paint: { ...track.paint }, +}; + +export const pavedTrackBridge = { + id: "highway-track-paved-bridge", + type: "line", + source: "openmaptiles", + "source-layer": "transportation", + filter: ["all", trackSelect, pavedSelect, bridgeSelect], + minzoom: 12, + paint: { ...pavedTrack.paint }, +}; + +// Bridge casing layers +export const bridgeCasing = { + id: "track-bridge-casing", + type: "line", + source: "openmaptiles", + "source-layer": "transportation", + filter: ["all", bridgeSelect, trackSelect], + minzoom: 13, + layout: { + "line-cap": "butt", + "line-join": "bevel", + visibility: "visible", + }, + paint: { + "line-color": "black", + "line-opacity": opacity, + "line-width": [ + "interpolate", + ["exponential", 1.2], + ["zoom"], + 13, + 1.1, + 20, + 11, + ], + }, +}; +// Bridge casing layers +export const bridgeFill = { + id: "track-bridge-fill", + type: "line", + source: "openmaptiles", + "source-layer": "transportation", + filter: ["all", bridgeSelect, trackSelect], + minzoom: 13, + layout: { + "line-cap": "butt", + "line-join": "bevel", + visibility: "visible", + }, + paint: { + "line-color": Color.backgroundFill, + "line-opacity": opacity, + "line-width": [ + "interpolate", + ["exponential", 1.2], + ["zoom"], + 13, + 1.0, + 20, + 10, + ], + }, +}; + +export const legendEntries = [ + { + description: "Unpaved track", + layers: [track.id], + filter: notFordSelect, + }, + { + description: "Unpaved track - ford", + layers: [track.id], + filter: fordSelect, + }, + { + description: "Paved track", + layers: [pavedTrack.id], + filter: notFordSelect, + }, + { + description: "Paved track - ford", + layers: [pavedTrack.id], + filter: fordSelect, + }, +]; diff --git a/src/layer/transportation_label.js b/src/layer/transportation_label.js index e3f45f4a1..9556ce783 100644 --- a/src/layer/transportation_label.js +++ b/src/layer/transportation_label.js @@ -8,7 +8,7 @@ const highwaySelector = ["match", ["get", "class"]]; const motorwayToTrunk = ["motorway", "trunk"]; const motorwayToPrimary = [...motorwayToTrunk, "primary"]; const motorwayToSecondary = [...motorwayToPrimary, "secondary"]; -const motorwayToMinor = [...motorwayToSecondary, "tertiary", "minor"]; +const motorwayToMinor = [...motorwayToSecondary, "tertiary", "minor", "track"]; const motorwayToService = [...motorwayToMinor, "service"]; const majorConstruction = ["motorway_construction", "trunk_construction"];