Skip to content

Commit

Permalink
Support highlighting missing highway attributes on portages
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Jul 11, 2024
1 parent 17d82de commit 36d86b7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 36 deletions.
39 changes: 9 additions & 30 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,24 @@ const landTrailLenses = [
"surface",
"smoothness",
"trail_visibility",
"width",
"incline",
"width",
"fixme",
"check_date"
];
const waterTrailLenses = [
"",
"access",
"name",
const highwayOnlyLenses = [
"operator",
"surface",
"smoothness",
"trail_visibility",
"incline",
];
const waterwayOnlyLenses = [
"tidal",
"intermittent",
"rapids",
"open_water",
"oneway",
"width",
"fixme",
"check_date"
];
const defaultTravelMode = "foot";
const defaultLens= "";
Expand Down Expand Up @@ -110,7 +111,6 @@ function setTravelMode(value) {
}
function setLens(value) {
if (value === null) value = defaultLens;
if (travelMode === 'canoe' && !waterTrailLenses.includes(value)) value = waterTrailLenses[0];
if (travelMode !== 'canoe' && !landTrailLenses.includes(value)) value = landTrailLenses[0];

if (lens === value) return;
Expand All @@ -122,27 +122,6 @@ function setLens(value) {
setHashParameters({ lens: lens === defaultLens ? null : value });
}

/*
function setMapStyle(newMapStyle) {
//if (newMapStyle === null) newMapStyle = defaultMapStyle;
//if (newMapStyle === 'all') newMapStyle = lastAdvancedStyle;
//if (!mapStyle.startsWith('canoe') && newMapStyle === 'canoe') newMapStyle = lastCanoeStyle;
//if (advancedMapStyles.includes(mapStyle)) lastAdvancedStyle = mapStyle;
//if (mapStyle.startsWith('canoe')) lastCanoeStyle = mapStyle;
//document.getElementById("map-style").value = mapStyle.startsWith('canoe') ? 'canoe' : basicMapStyles.includes(mapStyle) ? mapStyle : 'all';
//document.getElementById("advanced-style").value = mapStyle;
//document.getElementById("canoe-style").value = mapStyle;
//document.getElementById("advanced-style").style.display = advancedMapStyles.includes(mapStyle) ? 'block' : 'none';
//document.getElementById("canoe-style").style.display = mapStyle.startsWith('canoe') ? 'block' : 'none';
updateTrailLayers();
setHashParameters({ style: mapStyle === defaultMapStyle ? null : mapStyle });
}
*/
window.onload = (event) => {

window.addEventListener("hashchange", updateForHash);
Expand Down
21 changes: 15 additions & 6 deletions js/mapController.js
Original file line number Diff line number Diff line change
Expand Up @@ -658,12 +658,21 @@ function updateTrailLayers() {
]),
];
if (isWaterTrails) {
// don't expect waterway attributes on portage segments
specifiedAttributeExpression = [
"any",
specifiedAttributeExpression,
["has", "highway"],
];
if (waterwayOnlyLenses.includes(lens)) {
// don't expect waterway-only attributes on highways
specifiedAttributeExpression = [
"any",
specifiedAttributeExpression,
["has", "highway"],
];
} else if (highwayOnlyLenses.includes(lens)) {
// don't expect highway-only attributes on waterways
specifiedAttributeExpression = [
"any",
specifiedAttributeExpression,
["!has", "highway"],
];
}
}
if (lens === 'tidal') {
// assume tidal channels are always tidal=yes
Expand Down

0 comments on commit 36d86b7

Please sign in to comment.