From 3449a680a75cea1ea45e360a4bb61d97926b1379 Mon Sep 17 00:00:00 2001 From: Tom MacWright Date: Mon, 4 Feb 2013 16:02:34 -0500 Subject: [PATCH] Add tag deprecation action and data, not yet integrated. --- data/data.js | 1 + data/deprecated.js | 112 ++++++++++++++++++++++++++++ index.html | 3 + js/id/actions/deprecate_tags.js | 36 +++++++++ test/index.html | 5 ++ test/spec/actions/deprecate_tags.js | 40 ++++++++++ 6 files changed, 197 insertions(+) create mode 100644 data/data.js create mode 100644 data/deprecated.js create mode 100644 js/id/actions/deprecate_tags.js create mode 100644 test/spec/actions/deprecate_tags.js diff --git a/data/data.js b/data/data.js new file mode 100644 index 000000000..279b1ea86 --- /dev/null +++ b/data/data.js @@ -0,0 +1 @@ +iD.data = {}; diff --git a/data/deprecated.js b/data/deprecated.js new file mode 100644 index 000000000..53457c9f3 --- /dev/null +++ b/data/deprecated.js @@ -0,0 +1,112 @@ +// from http://wiki.openstreetmap.org/wiki/Deprecated_features +// TODO: deal with deprecated 'class' tag +// does not deal with landuse=wood because of indecision +// we will not care about http://taginfo.openstreetmap.org/tags/bicycle_parking=sheffield +iD.data.deprecated = [ + { + old: { barrier: 'wire_fence' }, + replace: { + barrier: 'fence', + fence_type: 'chain' + } + }, + { + old: { barrier: 'wood_fence' }, + replace: { + barrier: 'fence', + fence_type: 'wood' + } + }, + { + old: { highway: 'ford' }, + replace: { + ford: 'yes' + } + }, + { + old: { highway: 'ford' }, + replace: { + ford: 'yes' + } + }, + { + old: { highway: 'ford' }, + replace: { + ford: 'yes' + } + }, + { + old: { highway: 'stile' }, + replace: { + barrier: 'stile' + } + }, + { + old: { highway: 'incline' }, + replace: { + highway: 'road', + incline: 'up' + } + }, + { + old: { highway: 'incline_steep' }, + replace: { + highway: 'road', + incline: 'up' + } + }, + { + old: { highway: 'unsurfaced' }, + replace: { + highway: 'road', + incline: 'unpaved' + } + }, + { + old: { highway: 'unsurfaced' }, + replace: { + highway: 'road', + incline: 'unpaved' + } + }, + { + old: { landuse: 'wood' }, + replace: { + highway: 'road', + incline: 'unpaved' + } + }, + { + old: { natural: 'marsh' }, + replace: { + natural: 'wetland', + wetland: 'marsh' + } + }, + { + old: { shop: 'organic' }, + replace: { + shop: 'supermarket', + organic: 'only' + } + }, + { + old: { power_source: '*' }, + replace: { + 'generator:source': '$1' + } + }, + { + old: { power_rating: '*' }, + replace: { + 'generator:output': '$1' + } + }, + { + old: { bicycle_parking: 'organic' }, + replace: { + shop: 'supermarket', + organic: 'only' + } + } +]; diff --git a/index.html b/index.html index 83ae066eb..c03ac29ae 100644 --- a/index.html +++ b/index.html @@ -134,6 +134,9 @@ + + +
+ @@ -130,6 +131,9 @@ + + + + diff --git a/test/spec/actions/deprecate_tags.js b/test/spec/actions/deprecate_tags.js new file mode 100644 index 000000000..4f202e97f --- /dev/null +++ b/test/spec/actions/deprecate_tags.js @@ -0,0 +1,40 @@ +describe('iD.actions.DeprecateTags', function () { + it('deprecates tags', function () { + var entity = iD.Entity({ tags: { barrier: 'wire_fence' } }), + graph = iD.actions.DeprecateTags(entity.id)(iD.Graph([entity])), + undeprecated = { + barrier: 'fence', + fence_type: 'chain' + }; + expect(graph.entity(entity.id).tags).to.eql(undeprecated); + }); + + it('does not overwrite explicit tags', function () { + var entity = iD.Entity({ tags: { barrier: 'wire_fence', fence_type: 'foo' } }), + graph = iD.actions.DeprecateTags(entity.id)(iD.Graph([entity])), + undeprecated = { + barrier: 'fence', + fence_type: 'foo' + }; + expect(graph.entity(entity.id).tags).to.eql(undeprecated); + }); + + it('leaves other tags alone', function () { + var entity = iD.Entity({ tags: { highway: 'ford', name: 'Foo' } }), + graph = iD.actions.DeprecateTags(entity.id)(iD.Graph([entity])), + undeprecated = { + ford: 'yes', + name: 'Foo' + }; + 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])), + undeprecated = { + 'generator:output': '1 billion volts' + }; + expect(graph.entity(entity.id).tags).to.eql(undeprecated); + }); +});