From 10bd86cb452331e0c5ffc706f4176533ed16cc4a Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Fri, 23 May 2014 17:07:11 -0400 Subject: [PATCH] Check single source for implied onewayness #2220 --- index.html | 1 + js/id/core/oneway_tags.js | 32 ++++++++++++++++++++++++++++++++ js/id/core/way.js | 10 +++++----- js/id/ui/preset/check.js | 14 ++++++++++---- test/index.html | 1 + 5 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 js/id/core/oneway_tags.js diff --git a/index.html b/index.html index fec78cf5c..786668e8f 100644 --- a/index.html +++ b/index.html @@ -204,6 +204,7 @@ + diff --git a/js/id/core/oneway_tags.js b/js/id/core/oneway_tags.js new file mode 100644 index 000000000..0e8f7db35 --- /dev/null +++ b/js/id/core/oneway_tags.js @@ -0,0 +1,32 @@ +iD.oneWayTags = { + 'aerialway': { + 'chair_lift': true, + 'mixed_lift': true, + 't-bar': true, + 'j-bar': true, + 'platter': true, + 'rope_tow': true, + 'magic_carpet': true, + 'yes': true + }, + 'highway': { + 'motorway': true, + 'motorway_link': true + }, + 'junction': { + 'roundabout': true + }, + 'man_made': { + 'piste:halfpipe': true, + 'pipeline': true + }, + 'piste:type': { + 'downhill': true, + 'sled': true, + 'yes': true + }, + 'waterway': { + 'river': true, + 'stream': true + } +}; diff --git a/js/id/core/way.js b/js/id/core/way.js index 530185fc9..3a6e6d6ec 100644 --- a/js/id/core/way.js +++ b/js/id/core/way.js @@ -48,11 +48,11 @@ _.extend(iD.Way.prototype, { if (['no', '0'].indexOf(this.tags.oneway) !== -1) { return false; } // implied oneway tag.. - return this.tags.waterway === 'river' || - this.tags.waterway === 'stream' || - this.tags.highway === 'motorway' || - this.tags.highway === 'motorway_link' || - this.tags.junction === 'roundabout'; + for (var key in this.tags) { + if (key in iD.oneWayTags && (this.tags[key] in iD.oneWayTags[key])) + return true; + } + return false; }, isClosed: function() { diff --git a/js/id/ui/preset/check.js b/js/id/ui/preset/check.js index 5bfeb4625..a8c145944 100644 --- a/js/id/ui/preset/check.js +++ b/js/id/ui/preset/check.js @@ -21,10 +21,16 @@ iD.ui.preset.defaultcheck = function(field) { } var check = function(selection) { - // hack: pretend oneway field is a oneway_yes field if `junction=roundabout` is set. #2220, #1841 - if (field.id === 'oneway' && entity.tags.junction === 'roundabout') { - texts.shift(); - texts.unshift(t('presets.fields.oneway_yes.check.undefined', { 'default': 'Assumed to be Yes' })); + // hack: pretend oneway field is a oneway_yes field + // where implied oneway tag exists (e.g. `junction=roundabout`) #2220, #1841 + if (field.id === 'oneway') { + for (var key in entity.tags) { + if (key in iD.oneWayTags && (entity.tags[key] in iD.oneWayTags[key])) { + texts.shift(); + texts.unshift(t('presets.fields.oneway_yes.check.undefined', { 'default': 'Assumed to be Yes' })); + break; + } + } } selection.classed('checkselect', 'true'); diff --git a/test/index.html b/test/index.html index 8fe2bc698..ef3b0ae22 100644 --- a/test/index.html +++ b/test/index.html @@ -185,6 +185,7 @@ +