Highlight route segments for parts with normalized surface and smoothness values

This commit ensures that all matching route segments are highlighted when hovering over a surface or smoothness line in the analysis tables.
This commit is contained in:
Marcus Jaschen 2021-11-20 14:17:20 +01:00
parent 9ca93e4c03
commit d9699127f9

View file

@ -500,22 +500,31 @@ BR.TrackAnalysis = L.Class.extend({
return parsed.highway === dataName;
case 'surface':
if (dataName === 'internal-unknown' && typeof parsed.surface !== 'string') {
return true;
}
return typeof parsed.surface === 'string' && parsed.surface === dataName;
return this.singleWayTagMatchesData('surface', parsed, dataName);
case 'smoothness':
if (dataName === 'internal-unknown' && typeof parsed.smoothness !== 'string') {
return true;
}
return typeof parsed.smoothness === 'string' && parsed.smoothness === dataName;
return this.singleWayTagMatchesData('smoothness', parsed, dataName);
}
return false;
},
singleWayTagMatchesData: function (category, parsedData, lookupValue) {
var foundValue = null;
for (var iterationKey in parsedData) {
if (iterationKey.indexOf(category) !== -1) {
foundValue = parsedData[iterationKey];
break;
}
}
if (lookupValue === 'internal-unknown' && foundValue === null) {
return true;
}
return foundValue === lookupValue;
},
/**
* Transform a way tags string into an object, for example:
*