From 10659505e2a4d131cf01fe1a1cade4c170118afa Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Sun, 6 Aug 2017 23:39:58 -0400 Subject: [PATCH] Add code to treat a few special tags as areas instead of lines even in the absense of a proper `area=yes` or `areaKeys` tag. (closes #4194) --- modules/osm/way.js | 20 ++++++++++++++++++++ test/spec/osm/way.js | 10 ++++++++++ 2 files changed, 30 insertions(+) diff --git a/modules/osm/way.js b/modules/osm/way.js index 99ccc3716..bf026c3a2 100644 --- a/modules/osm/way.js +++ b/modules/osm/way.js @@ -152,6 +152,23 @@ _.extend(osmWay.prototype, { isArea: function() { + // `highway` and `railway` are typically linear features, but there + // are a few exceptions that should be treated as areas, even in the + // absense of a proper `area=yes` or `areaKeys` tag.. see #4194 + var lineKeys = { + highway: { + rest_area: true, + services: true + }, + railway: { + roundhouse: true, + station: true, + traverser: true, + turntable: true, + wash: true + } + }; + if (this.tags.area === 'yes') return true; if (!this.isClosed() || this.tags.area === 'no') @@ -160,6 +177,9 @@ _.extend(osmWay.prototype, { if (key in areaKeys && !(this.tags[key] in areaKeys[key])) { return true; } + if (key in lineKeys && this.tags[key] in lineKeys[key]) { + return true; + } } return false; }, diff --git a/test/spec/osm/way.js b/test/spec/osm/way.js index f45a98ae1..3881358e9 100644 --- a/test/spec/osm/way.js +++ b/test/spec/osm/way.js @@ -345,6 +345,16 @@ describe('iD.osmWay', function() { expect(iD.Way({nodes: ['n1', 'n1'], tags: {building: 'yes'}}).isArea()).to.equal(true); }); + it('returns true for some highway and railway exceptions', function() { + expect(iD.Way({nodes: ['n1', 'n1'], tags: { highway: 'services' }}).isArea(), 'highway=services').to.equal(true); + expect(iD.Way({nodes: ['n1', 'n1'], tags: { highway: 'rest_area' }}).isArea(), 'highway=rest_area').to.equal(true); + expect(iD.Way({nodes: ['n1', 'n1'], tags: { railway: 'roundhouse' }}).isArea(), 'railway=roundhouse').to.equal(true); + expect(iD.Way({nodes: ['n1', 'n1'], tags: { railway: 'station' }}).isArea(), 'railway=station').to.equal(true); + expect(iD.Way({nodes: ['n1', 'n1'], tags: { railway: 'traverser' }}).isArea(), 'railway=traverser').to.equal(true); + expect(iD.Way({nodes: ['n1', 'n1'], tags: { railway: 'turntable' }}).isArea(), 'railway=turntable').to.equal(true); + expect(iD.Way({nodes: ['n1', 'n1'], tags: { railway: 'wash' }}).isArea(), 'railway=wash').to.equal(true); + }); + it('returns false if the way is closed and has no keys in iD.areaKeys', function() { expect(iD.Way({nodes: ['n1', 'n1'], tags: {a: 'b'}}).isArea()).to.equal(false); });