Support special styling for wikidata-tagged features

This commit is contained in:
Bryan Housel
2019-05-18 23:57:23 -04:00
parent 901e808c76
commit 344aec206c
7 changed files with 143 additions and 82 deletions
+3
View File
@@ -174,6 +174,9 @@ osmEntity.prototype = {
return Object.keys(this.tags).some(osmIsInterestingTag);
},
hasWikidata: function() {
return !!this.tags.wikidata || !!this.tags['brand:wikidata'];
},
isHighwayIntersection: function() {
return false;
+6 -2
View File
@@ -156,7 +156,8 @@ export function svgLabels(projection, context) {
texts.enter()
.append('text')
.attr('class', function(d, i) {
return classes + ' ' + labels[i].classes + ' ' + d.id;
var hasWd = d.hasWikidata() ? ' tag-wikidata' : '';
return classes + ' ' + labels[i].classes + hasWd + ' ' + d.id;
})
.merge(texts)
.attr('x', get(labels, 'x'))
@@ -192,7 +193,10 @@ export function svgLabels(projection, context) {
// enter/update
icons.enter()
.append('use')
.attr('class', 'icon ' + classes)
.attr('class', function(d) {
var hasWd = d.hasWikidata() ? ' tag-wikidata' : '';
return 'icon ' + classes + hasWd;
})
.attr('width', '17px')
.attr('height', '17px')
.merge(icons)
+3 -5
View File
@@ -127,11 +127,9 @@ export function svgPoints(projection, context) {
.attr('transform', svgPointTransform(projection))
.call(svgTagClasses());
// Selecting the following implicitly
// sets the data (point entity) on the element
groups.select('.shadow');
groups.select('.stroke');
groups.select('.icon')
groups.select('.shadow'); // propagate bound data
groups.select('.stroke'); // propagate bound data
groups.select('.icon') // propagate bound data
.attr('xlink:href', function(entity) {
var preset = context.presets().match(entity, graph);
var picon = preset && preset.icon;
+5
View File
@@ -139,6 +139,11 @@ export function svgTagClasses() {
}
}
// 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();
};