Skip to content

Commit

Permalink
Add dog and atv trails modes
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Nov 3, 2023
1 parent e22ee4b commit 0ca85cf
Showing 1 changed file with 63 additions and 10 deletions.
73 changes: 63 additions & 10 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@ <h1>OpenTrailMap</h1>
<div id="controls">
<select id="travel-mode">
<option value="foot" selected>Hiking & Walking Trails</option>
<option value="dog">Dog Walking Trails</option>
<option value="bicycle">Biking Trails</option>
<option value="horse">Horseback Riding Trails</option>
<option value="atv">ATV Trails</option>
</select>
</div>
<script type="text/javascript">
Expand Down Expand Up @@ -81,6 +83,8 @@ <h1>OpenTrailMap</h1>
["!=", ["get", "highway"], "bridleway"],
["!=", ["get", "highway"], "track"]
],
// dog only allowed if explicit
dog: [],
bicycle: [
["!=", ["get", "highway"], "path"],
["!=", ["get", "highway"], "cycleway"],
Expand All @@ -90,14 +94,17 @@ <h1>OpenTrailMap</h1>
horse: [
["!=", ["get", "highway"], "bridleway"],
["!=", ["get", "highway"], "track"]
],
atv: [
["!=", ["get", "highway"], "track"]
]
};

function updateLayers() {

var allFilter;

if (mode === "bicycle" || mode === "horse") {
if (mode === "bicycle" || mode === "horse" || mode === "atv") {
allFilter =
["any",
["all",
Expand All @@ -106,26 +113,38 @@ <h1>OpenTrailMap</h1>
["!=", "highway", "steps"],
],
["has", "foot"],
["has", "atv"],
["has", "bicycle"],
["has", "horse"]
["has", "horse"],
["has", "dog"],
["has", "wheelchair"]
];
} else {
allFilter =
["any",
["!=", "highway", "track"],
["has", "foot"],
["has", "atv"],
["has", "bicycle"],
["has", "horse"]
["has", "horse"],
["has", "dog"],
["has", "wheelchair"]
];
}

var unspecifiedExpression = ["any",
[
"all",
["!", ["has", mode]],
...impliedYesHighways[mode]
]
];
var unspecifiedExpression = [
"any",
[
"all",
["!", ["has", mode]],
["!=", ["get", "access"], "no"],
["!=", ["get", "access"], "private"],
["!=", ["get", "access"], "discouraged"],
...impliedYesHighways[mode]
],
// if mode is explicitly unknown then mark as unknown
["==", ["get", mode], "unknown"]
];

var allowedExpression = ["any",
[
Expand All @@ -144,6 +163,40 @@ <h1>OpenTrailMap</h1>
]
];

if (mode === "atv") {
allowedExpression = [
"all",
allowedExpression,
[
"all",
["!=", ["get", "motor_vehicle"], "no"],
["!=", ["get", "motor_vehicle"], "private"],
["!=", ["get", "motor_vehicle"], "discouraged"]
]
];
unspecifiedExpression[1] = unspecifiedExpression[1].concat(
[["!=", ["get", "motor_vehicle"], "no"],
["!=", ["get", "motor_vehicle"], "private"],
["!=", ["get", "motor_vehicle"], "discouraged"]]
)
} else if (mode === "dog") {
allowedExpression = [
"all",
allowedExpression,
[
"all",
["!=", ["get", "foot"], "no"],
["!=", ["get", "foot"], "private"],
["!=", ["get", "foot"], "discouraged"]
]
];
unspecifiedExpression[1] = unspecifiedExpression[1].concat(
[["!=", ["get", "foot"], "no"],
["!=", ["get", "foot"], "private"],
["!=", ["get", "foot"], "discouraged"]]
)
}

var lineColors = [
"case",
["all", unspecifiedExpression, allowedExpression], "#ff3a00",
Expand Down

0 comments on commit 0ca85cf

Please sign in to comment.