Swap wikidata/wikipedia for brand: tags if possible

(closes #6416)

This also ignores any features with an office tag, to avoid
changing a wikipedia/wikidata tag on a corporate office.
This commit is contained in:
Bryan Housel
2019-05-24 14:22:46 -04:00
parent 839d922ea6
commit 44349c8015
3 changed files with 39 additions and 3 deletions
+1 -1
View File
@@ -3511,7 +3511,7 @@ li.issue-fix-item:not(.actionable) .fix-icon {
border: 1px solid #ccc;
}
.issue-info .tagDiff-cell {
padding: 2px 5px;
padding: 2px 10px;
font-family: monospace;
font-size: 10px;
border: 1px solid #ccc;
+4 -1
View File
@@ -156,7 +156,10 @@ export function uiEntityIssues(context) {
.transition()
.duration(200)
.style('max-height', '200px')
.style('opacity', '1');
.style('opacity', '1')
.on('end', function () {
info.style('max-height', null);
});
}
});
+34 -1
View File
@@ -17,6 +17,16 @@ export function validationOutdatedTags() {
nsiMatcher.buildMatchIndex(brands.brands);
var nsiKeys = ['amenity', 'shop', 'tourism', 'leisure', 'office'];
var allWD = {};
var allWP = {};
Object.keys(brands.brands).forEach(function(kvnd) {
var brand = brands.brands[kvnd];
var wd = brand.tags['brand:wikidata'];
var wp = brand.tags['brand:wikipedia'];
if (wd) { allWD[wd] = kvnd; }
if (wp) { allWP[wp] = kvnd; }
});
function oldTagIssues(entity, context) {
var graph = context.graph();
@@ -55,7 +65,30 @@ export function validationOutdatedTags() {
});
}
// search name-suggestion-index
// Do `wikidata` or `wikipedia` identify this entity as a brand? #6416
// If so, these tags can be swapped to `brand:wikidata`/`brand:wikipedia`
var isBrand;
if (newTags.wikidata) { // try matching `wikidata`
isBrand = allWD[newTags.wikidata];
}
if (!isBrand && newTags.wikipedia) { // fallback to `wikipedia`
isBrand = allWP[newTags.wikipedia];
}
if (isBrand && !newTags.office) { // but avoid doing this for corporate offices
if (newTags.wikidata) {
newTags['brand:wikidata'] = newTags.wikidata;
delete newTags.wikidata;
}
if (newTags.wikipedia) {
newTags['brand:wikipedia'] = newTags.wikipedia;
delete newTags.wikipedia;
}
// I considered setting `name` and other tags here, but they aren't unique per wikidata
// (Q2759586 -> in USA "Papa John's", in Russia "Папа Джонс")
// So users will really need to use a preset or assign `name` themselves.
}
// try key/value|name match against name-suggestion-index
if (newTags.name) {
for (var i = 0; i < nsiKeys.length; i++) {
var k = nsiKeys[i];