in modules/svg/tag_classes.js [44:148]
tagClasses.getClassesString = function(t, value, entity) {
var primary, status;
var i, k, v;
// in some situations we want to render perimeter strokes a certain way
var overrideGeometry;
if (/\bstroke\b/.test(value)) {
if (!!t.barrier && t.barrier !== 'no') {
overrideGeometry = 'line';
} else if (t.type === 'multipolygon' && !entity.hasInterestingTags()) {
overrideGeometry = 'area';
}
}
// preserve base classes (nothing with `tag-`)
var classes = value.trim().split(/\s+/)
.filter(function(klass) {
return klass.length && !/^tag-/.test(klass);
})
.map(function(klass) { // special overrides for some perimeter strokes
return (klass === 'line' || klass === 'area') ? (overrideGeometry || klass) : klass;
});
// pick at most one primary classification tag..
for (i = 0; i < primaries.length; i++) {
k = primaries[i];
v = t[k];
if (!v || v === 'no') continue;
if (k === 'piste:type') { // avoid a ':' in the class name
k = 'piste';
} else if (k === 'building:part') { // avoid a ':' in the class name
k = 'building_part';
}
primary = k;
if (statuses.indexOf(v) !== -1) { // e.g. `railway=abandoned`
status = v;
classes.push('tag-' + k);
} else {
classes.push('tag-' + k);
classes.push('tag-' + k + '-' + v);
}
break;
}
// add at most one status tag, only if relates to primary tag..
if (!status) {
for (i = 0; i < statuses.length; i++) {
k = statuses[i];
v = t[k];
if (!v || v === 'no') continue;
if (v === 'yes') { // e.g. `railway=rail + abandoned=yes`
status = k;
}
else if (primary && primary === v) { // e.g. `railway=rail + abandoned=railway`
status = k;
} else if (!primary && primaries.indexOf(v) !== -1) { // e.g. `abandoned=railway`
status = k;
primary = v;
classes.push('tag-' + v);
} // else ignore e.g. `highway=path + abandoned=railway`
if (status) break;
}
}
if (status) {
classes.push('tag-status');
classes.push('tag-status-' + status);
}
// add any secondary tags
for (i = 0; i < secondaries.length; i++) {
k = secondaries[i];
v = t[k];
if (!v || v === 'no' || k === primary) continue;
classes.push('tag-' + k);
classes.push('tag-' + k + '-' + v);
}
// For highways, look for surface tagging..
if (primary === 'highway' || primary === 'aeroway') {
var paved = (t.highway !== 'track');
for (k in t) {
v = t[k];
if (k in osmPavedTags) {
paved = !!osmPavedTags[k][v];
break;
}
}
if (!paved) {
classes.push('tag-unpaved');
}
}
// If this is a wikidata-tagged item, add a class for that..
if (t.wikidata || t['brand:wikidata']) {
classes.push('tag-wikidata');
}
return classes.join(' ').trim();
};