diff --git a/data/deprecated.json b/data/deprecated.json index affdabd30..81dbf4009 100644 --- a/data/deprecated.json +++ b/data/deprecated.json @@ -1558,6 +1558,10 @@ "old": {"unnamed": "*"}, "replace": {"noname": "$1"} }, + { + "old": {"vending": "parcel_mail_in;parcel_pickup"}, + "replace": {"vending": "parcel_pickup;parcel_mail_in"} + }, { "old": {"vhf_channel": "*"}, "replace": {"vhf": "$1"} diff --git a/data/taginfo.json b/data/taginfo.json index 05ba12294..36d8b4600 100644 --- a/data/taginfo.json +++ b/data/taginfo.json @@ -2366,6 +2366,7 @@ {"key": "type", "value": "shield", "description": "🄳 ➜ volcano:type=shield"}, {"key": "type", "value": "strato", "description": "🄳 ➜ volcano:type=stratovolcano"}, {"key": "unnamed", "description": "🄳 ➜ noname=*"}, + {"key": "vending", "value": "parcel_mail_in;parcel_pickup", "description": "🄳 ➜ vending=parcel_pickup;parcel_mail_in"}, {"key": "vhf_channel", "description": "🄳 ➜ vhf=*"}, {"key": "volcano", "value": "extinct", "description": "🄳 ➜ volcano:status=extinct"}, {"key": "wall_type", "value": "noise_barrier", "description": "🄳 ➜ wall=noise_barrier"}, diff --git a/modules/actions/upgrade_tags.js b/modules/actions/upgrade_tags.js index 92bf48e2e..6dc13cc73 100644 --- a/modules/actions/upgrade_tags.js +++ b/modules/actions/upgrade_tags.js @@ -7,9 +7,15 @@ export function actionUpgradeTags(entityId, oldTags, replaceTags) { var semiIndex; for (var oldTagKey in oldTags) { + // wildcard match if (oldTags[oldTagKey] === '*') { + // note the value since we might need to transfer it transferValue = tags[oldTagKey]; delete tags[oldTagKey]; + // exact match + } else if (oldTags[oldTagKey] === tags[oldTagKey]) { + delete tags[oldTagKey]; + // match is within semicolon-delimited values } else { var vals = tags[oldTagKey].split(';').filter(Boolean); var oldIndex = vals.indexOf(oldTags[oldTagKey]); diff --git a/modules/osm/entity.js b/modules/osm/entity.js index e10eb3784..2714672af 100644 --- a/modules/osm/entity.js +++ b/modules/osm/entity.js @@ -201,6 +201,7 @@ osmEntity.prototype = { var matchesDeprecatedTags = oldKeys.every(function(oldKey) { if (!tags[oldKey]) return false; if (d.old[oldKey] === '*') return true; + if (d.old[oldKey] === tags[oldKey]) return true; var vals = tags[oldKey].split(';').filter(Boolean); if (vals.length === 0) { diff --git a/test/spec/actions/upgrade_tags.js b/test/spec/actions/upgrade_tags.js index 6c07dfbcc..0f35bf1e6 100644 --- a/test/spec/actions/upgrade_tags.js +++ b/test/spec/actions/upgrade_tags.js @@ -96,4 +96,12 @@ describe('iD.actionUpgradeTags', function () { expect(graph.entity(entity.id).tags).to.eql({ leisure: 'ice_rink', sport: 'curling;ice_hockey;multi', name: 'Foo' }); }); + it('upgrades an entire semicolon-delimited tag value', function () { + var oldTags = { vending: 'parcel_mail_in;parcel_pickup' }, + newTags = { vending: 'parcel_pickup;parcel_mail_in' }, + entity = iD.osmEntity({ tags: { vending: 'parcel_mail_in;parcel_pickup', name: 'Foo' }}), + graph = iD.actionUpgradeTags(entity.id, oldTags, newTags)(iD.coreGraph([entity])); + expect(graph.entity(entity.id).tags).to.eql({ vending: 'parcel_pickup;parcel_mail_in', name: 'Foo' }); + }); + });