Wipe out some tags entirely, refs #585

This commit is contained in:
Tom MacWright
2013-02-04 17:20:06 -05:00
parent dbb4615918
commit 3e71dd56cd
3 changed files with 19 additions and 4 deletions

View File

@@ -108,5 +108,13 @@ iD.data.deprecated = [
shop: 'supermarket',
organic: 'only'
}
}
},
// entirely discarded tags
{ old: { 'tiger:upload_uuid': '*' } },
{ old: { 'tiger:tlid': '*' } },
{ old: { 'tiger:source': '*' } },
{ old: { 'tiger:separated': '*' } },
{ old: { 'geobase:datasetName': '*' } },
{ old: { 'geobase:uuid': '*' } },
{ old: { 'sub_sea:type': '*' } }
];

View File

@@ -10,19 +10,19 @@ iD.actions.DeprecateTags = function(entityId) {
rule = iD.data.deprecated[i];
var match = _.pairs(rule.old)[0],
replacements = _.pairs(rule.replace);
replacements = rule.replace ? _.pairs(rule.replace) : null;
if (entity.tags[match[0]] && match[1] === '*') {
var value = entity.tags[match[0]];
if (!newtags[replacements[0][0]]) {
if (replacements && !newtags[replacements[0][0]]) {
newtags[replacements[0][0]] = value;
}
delete newtags[match[0]];
change = true;
} else if (entity.tags[match[0]] === match[1]) {
newtags = _.assign({}, rule.replace, _.omit(newtags, match[0]));
newtags = _.assign({}, rule.replace || {}, _.omit(newtags, match[0]));
change = true;
}
}

View File

@@ -29,6 +29,13 @@ describe('iD.actions.DeprecateTags', function () {
expect(graph.entity(entity.id).tags).to.eql(undeprecated);
});
it('wipes out tags that should be entirely removed', function () {
var entity = iD.Entity({ tags: { 'tiger:source': 'foo' } }),
graph = iD.actions.DeprecateTags(entity.id)(iD.Graph([entity])),
undeprecated = { };
expect(graph.entity(entity.id).tags).to.eql(undeprecated);
});
it('replaces keys', function () {
var entity = iD.Entity({ tags: { power_rating: '1 billion volts' } }),
graph = iD.actions.DeprecateTags(entity.id)(iD.Graph([entity])),