Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for highway=track #717

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
21 changes: 21 additions & 0 deletions scripts/taginfo_template.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down Expand Up @@ -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"
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add an entry for ford=yes, as well as a second entry for surface that describes the stylistic variation on tracks.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback. Added these taginfo entries in ab1e133.

{
"key": "ford",
"value": "yes",
"object_types": ["way"],
"description": "The color of track roads changes from brown to blue for ways tagged as fords.",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A more direct way of saying this is that the ford blends in with the waterway it crosses.

"doc_url": "https://openmaptiles.org/schema/#transportation"
},
{
"key": "railway",
"value": "rail",
Expand Down
2 changes: 2 additions & 0 deletions src/js/legend_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -27,6 +28,7 @@ export const sections = [
name: "Roads",
entries: [
...RoadLayers.legendEntries,
...TrackLayers.legendEntries,
...ConstructionLayers.legendEntries,
...HighwayExitLayers.legendEntries,
],
Expand Down
10 changes: 10 additions & 0 deletions src/layer/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -86,6 +87,9 @@ export function build(locales) {
lyrAeroway.taxiway,
lyrAeroway.taxiwayArea,

lyrTrack.track,
lyrTrack.pavedTrack,

lyrRoad.motorwayLink.casing(),
lyrRoad.trunkLink.casing(),

Expand Down Expand Up @@ -143,6 +147,9 @@ export function build(locales) {
var bridgeLayers = [
lyrRail.bridgeCasing,

lyrTrack.bridgeCasing,
lyrTrack.bridgeFill,

lyrRoad.trunkLinkBridge.casing(),
lyrRoad.motorwayLinkBridge.casing(),

Expand Down Expand Up @@ -178,6 +185,9 @@ export function build(locales) {

lyrRoad.roadBridge.surface(),

lyrTrack.trackBridge,
lyrTrack.pavedTrackBridge,

lyrRail.railBridge.dashes(),
lyrRail.railServiceBridge.dashes(),

Expand Down
147 changes: 147 additions & 0 deletions src/layer/track.js
Original file line number Diff line number Diff line change
@@ -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,
},
];
2 changes: 1 addition & 1 deletion src/layer/transportation_label.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
Expand Down