Skip to content

Commit

Permalink
Add nordic ski trail layer (close #34)
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Aug 15, 2024
1 parent d2fac25 commit 8689e0b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ The following styles show allowed trail access for different travel modes. Dark
- Bicycle Trails ([`bicycle`](https://wiki.openstreetmap.org/wiki/Key:bicycle) access)
- Horseback Riding Trails ([`horse`](https://wiki.openstreetmap.org/wiki/Key:horse) access)
- ATV Trails ([`atv`](https://wiki.openstreetmap.org/wiki/Key:atv) access)
- Cross-Country Ski Trails ([`ski:nordic`](https://wiki.openstreetmap.org/wiki/Key:ski:nordic) access)
- Snowmobile Trails ([`snowmobile`](https://wiki.openstreetmap.org/wiki/Key:snowmobile) access)

The following styles highlight the presence and values of trail attribute tags. Purple lines mean an attribute is missing, incomplete, or needs review, while teal lines indicate the attribute is good to go.
Expand Down
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ <h1 style="display:flex;"><span style="flex-basis: 100%;"><span class="swatch"><
<option value="bicycle">Biking Trails</option>
<option value="horse">Horseback Riding Trails</option>
<option value="atv">ATV Trails</option>
</optgroup>
<optgroup label="Snow Trails">
<option value="ski:nordic">Cross-Country Ski Trails</option>
<option value="snowmobile">Snowmobile Trails</option>
</optgroup>
<optgroup label="Water Trails">
Expand Down
17 changes: 4 additions & 13 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,16 +65,6 @@ let lensStrings = {
label: "Hand Cart"
},
}

const travelModes = [
"foot",
"wheelchair",
"bicycle",
"horse",
"atv",
"canoe",
"snowmobile",
];
const metadataLenses = {
label: "Metadata",
subitems: [
Expand Down Expand Up @@ -114,7 +104,7 @@ const allLensOptions = [
},
metadataLenses,
];
const wheelchairLensOptions = [
const basicLensOptions = [
{
label: "Attributes",
subitems: [
Expand All @@ -128,7 +118,7 @@ const wheelchairLensOptions = [
"smoothness",
"surface",
"trail_visibility",
"width",
"width",
]
},
metadataLenses,
Expand Down Expand Up @@ -215,7 +205,8 @@ const lensOptionsByMode = {
"foot": hikingLensOptions,
"horse": vehicleLensOptions,
"snowmobile": vehicleLensOptions,
"wheelchair": wheelchairLensOptions,
"ski:nordic": basicLensOptions,
"wheelchair": basicLensOptions,
};
function lensesForMode(travelMode) {
return lensOptionsByMode[travelMode].flatMap(function(item) {
Expand Down
42 changes: 28 additions & 14 deletions js/mapController.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ const impliedYesExpressions = {
wheelchair: [],
canoe: [],
portage: [],
'ski:nordic': [],
snowmobile: [],
};

Expand All @@ -104,15 +105,6 @@ const impliedNoExpressions = {
isNotHighwayExpression,
]
],
snowmobile: [
[
"any",
["in", "highway", "footway", "steps"],
["in", "vehicle", "no", "private", "discouraged"],
["in", "motor_vehicle", "no", "private", "discouraged"],
isNotHighwayExpression,
]
],
bicycle: [
[
"any",
Expand All @@ -125,14 +117,11 @@ const impliedNoExpressions = {
isNotHighwayExpression,
]
],
foot: [
isNotHighwayExpression,
],
canoe: [
["!has", "canoe"],
],
portage: [
["!has", "portage"],
foot: [
isNotHighwayExpression,
],
horse: [
[
Expand All @@ -141,6 +130,25 @@ const impliedNoExpressions = {
isNotHighwayExpression,
],
],
portage: [
["!has", "portage"],
],
'ski:nordic': [
[
"any",
["in", "ski", "no", "private", "discouraged"],
isNotHighwayExpression,
]
],
snowmobile: [
[
"any",
["in", "highway", "footway", "steps"],
["in", "vehicle", "no", "private", "discouraged"],
["in", "motor_vehicle", "no", "private", "discouraged"],
isNotHighwayExpression,
]
],
wheelchair: [
[
"any",
Expand Down Expand Up @@ -821,6 +829,7 @@ let accessHierarchy = {
horse: ['horse'],
mtb: ['vehicle', 'bicycle', 'mtb'],
portage: ['foot', 'portage'],
'ski:nordic': ['foot', 'ski', 'ski:nordic'],
snowmobile: ['vehicle', 'motor_vehicle', 'snowmobile'],
wheelchair: ['foot', 'wheelchair'],
};
Expand Down Expand Up @@ -1223,6 +1232,8 @@ function updateTrailLayers() {
modeIsAllowedExpression("bicycle"),
modeIsAllowedExpression("horse"),
modeIsAllowedExpression("atv"),
modeIsAllowedExpression("snowmobile"),
modeIsAllowedExpression("ski:nordic"),
modeIsAllowedExpression("canoe"),
];
} else {
Expand All @@ -1248,6 +1259,9 @@ function updateTrailLayers() {
["!=", "bicycle", "unknown"],
["!=", "horse", "unknown"],
["!=", "atv", "unknown"],
["!=", "portage", "unknown"],
["!=", "snowmobile", "unknown"],
["!=", "ski:nordic", "unknown"],
];
}

Expand Down

0 comments on commit 8689e0b

Please sign in to comment.