From e9b2563ad8a649dc22e5cb43c19985d8e3b8802f Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Tue, 5 Mar 2013 17:39:05 -0800 Subject: [PATCH] Force natural=coastline not to be an area (fixes #900) --- js/id/core/way.js | 23 +++++++++++++++++++---- test/spec/core/way.js | 4 ++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/js/id/core/way.js b/js/id/core/way.js index a44ed6545..65dfb5a2e 100644 --- a/js/id/core/way.js +++ b/js/id/core/way.js @@ -52,7 +52,7 @@ _.extend(iD.Way.prototype, { if (!this.isClosed() || this.tags.area === 'no') return false; for (var key in this.tags) - if (key in iD.Way.areaKeys) + if (key in iD.Way.areaKeys && !(this.tags[key] in iD.Way.areaKeys[key])) return true; return false; }, @@ -149,6 +149,21 @@ _.extend(iD.Way.prototype, { } }); -iD.Way.areaKeys = iD.util.trueObj(['area', 'building', 'leisure', 'tourism', 'ruins', - 'historic', 'landuse', 'military', 'natural', 'amenity', 'shop', 'man_made', - 'public_transport']); +// A closed way is considered to be an area if it has a tag with one +// of the following keys, and the value is _not_ one of the associated +// values for the respective key. +iD.Way.areaKeys = { + area: {}, + building: {}, + leisure: {}, + tourism: {}, + ruins: {}, + historic: {}, + landuse: {}, + military: {}, + natural: iD.util.trueObj(['coastline']), + amenity: {}, + shop: {}, + man_made: {}, + public_transport: {} +}; diff --git a/test/spec/core/way.js b/test/spec/core/way.js index 2201b7fc4..00f33b4df 100644 --- a/test/spec/core/way.js +++ b/test/spec/core/way.js @@ -110,6 +110,10 @@ describe('iD.Way', function() { it('returns false if the way is closed and has tag area=no', function() { expect(iD.Way({nodes: ['n1', 'n1'], tags: {area: 'no', building: 'yes'}}).isArea()).to.equal(false); }); + + it('returns false for coastline', function() { + expect(iD.Way({nodes: ['n1', 'n1'], tags: {natural: 'coastline'}}).isArea()).to.equal(false); + }); }); describe("#isDegenerate", function() {