diff --git a/js/index.js b/js/index.js index f68607f..4e28ffd 100644 --- a/js/index.js +++ b/js/index.js @@ -100,7 +100,16 @@ const allLensOptions = [ "maxspeed", "surface", "trail_visibility", - "width", + "width", + ], + }, + { + label: "Waterway Attributes", + subitems: [ + "intermittent", + "open_water", + "rapids", + "tidal", ] }, metadataLenses, @@ -216,6 +225,7 @@ function lensesForMode(travelMode) { const highwayOnlyLenses = [ "hand_cart", "incline", + "maxspeed", "operator", "sac_scale", "smoothness", diff --git a/js/mapController.js b/js/mapController.js index f2f321f..afa8d92 100644 --- a/js/mapController.js +++ b/js/mapController.js @@ -946,61 +946,60 @@ function isSpecifiedExpressionForLens(lens, travelMode) { ]; } - if (travelMode === "canoe") { - if (lens === 'tidal') { - // assume tidal channels are always tidal=yes - specifiedAttributeExpression = [ - "any", - specifiedAttributeExpression, - ["==", "waterway", "tidal_channel"], - ]; - } - if (lens === 'open_water') { - // only expect open_water tag on certain features - specifiedAttributeExpression = [ - "any", - specifiedAttributeExpression, - ["!in", "waterway", "fairway", "flowline"], - ]; - } - if (lens === 'width') { - // don't expect width tag on links - specifiedAttributeExpression = [ - "any", - specifiedAttributeExpression, - ["==", "waterway", "link"], - ]; - } + if (lens === 'tidal') { + // assume tidal channels are always tidal=yes + specifiedAttributeExpression = [ + "any", + specifiedAttributeExpression, + ["==", "waterway", "tidal_channel"], + ]; + } + if (lens === 'open_water') { + // only expect open_water tag on certain features + specifiedAttributeExpression = [ + "any", + specifiedAttributeExpression, + ["!in", "waterway", "fairway", "flowline"], + ]; + } + if (lens === 'width') { + // don't expect width tag on links + specifiedAttributeExpression = [ + "any", + specifiedAttributeExpression, + ["==", "waterway", "link"], + ]; + } - 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", + 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 === 'oneway' && travelMode === "canoe") { + specifiedAttributeExpression = [ + "any", + [ + "all", specifiedAttributeExpression, - ["!has", "highway"], - ]; - } else if (lens === 'oneway') { - specifiedAttributeExpression = [ - "any", - [ - "all", - specifiedAttributeExpression, - ["has", "waterway"], - ], - [ - "all", - attributeIsSpecifiedExpression(specifyingKeysForLens(lens, 'portage')), - ["!has", "waterway"], - ], - ]; - } + ["has", "waterway"], + ], + [ + "all", + attributeIsSpecifiedExpression(specifyingKeysForLens(lens, 'portage')), + ["!has", "waterway"], + ], + ]; } return specifiedAttributeExpression; @@ -1243,10 +1242,17 @@ function updateTrailLayers() { let pathsColors = colors.trail; let waterwaysColors = colors.water; - if (travelMode !== "all") { - - specifiedAccessExpression = accessIsSpecifiedExpression(travelMode); - + if (travelMode === "all") { + allowedAccessExpression = [ + "any", + modeIsAllowedExpression("foot"), + modeIsAllowedExpression("wheelchair"), + modeIsAllowedExpression("bicycle"), + modeIsAllowedExpression("horse"), + modeIsAllowedExpression("atv"), + modeIsAllowedExpression("canoe"), + ]; + } else { let modes = [travelMode]; if (travelMode == "canoe") modes.push('portage'); allowedAccessExpression = [ @@ -1255,8 +1261,11 @@ function updateTrailLayers() { return modeIsAllowedExpression(mode); }) ]; - } else if (lens === 'access' || lens === '') { + } + if (travelMode !== "all") { + specifiedAccessExpression = accessIsSpecifiedExpression(travelMode); + } else if (lens === 'access' || lens === '') { specifiedAccessExpression = [ "all", // access not fully specified if any access tag is explicitly set to `unknown` @@ -1266,17 +1275,7 @@ function updateTrailLayers() { ["!=", "bicycle", "unknown"], ["!=", "horse", "unknown"], ["!=", "atv", "unknown"], - ]; - - allowedAccessExpression = [ - "any", - modeIsAllowedExpression("foot"), - modeIsAllowedExpression("wheelchair"), - modeIsAllowedExpression("bicycle"), - modeIsAllowedExpression("horse"), - modeIsAllowedExpression("atv"), - modeIsAllowedExpression("canoe"), - ]; + ]; } if (lens !== "" && lens !== "access") {