Skip to content

Commit

Permalink
Fix display of waterways for lenses on all mode
Browse files Browse the repository at this point in the history
  • Loading branch information
quincylvania committed Aug 1, 2024
1 parent 636a7b2 commit a2a2162
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 70 deletions.
12 changes: 11 additions & 1 deletion js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ const allLensOptions = [
"maxspeed",
"surface",
"trail_visibility",
"width",
"width",
],
},
{
label: "Waterway Attributes",
subitems: [
"intermittent",
"open_water",
"rapids",
"tidal",
]
},
metadataLenses,
Expand Down Expand Up @@ -216,6 +225,7 @@ function lensesForMode(travelMode) {
const highwayOnlyLenses = [
"hand_cart",
"incline",
"maxspeed",
"operator",
"sac_scale",
"smoothness",
Expand Down
137 changes: 68 additions & 69 deletions js/mapController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = [
Expand All @@ -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`
Expand All @@ -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") {
Expand Down

0 comments on commit a2a2162

Please sign in to comment.