From f109efda7ba6dc6fed81966871c2de5cebf9d5ac Mon Sep 17 00:00:00 2001 From: Bryan Housel Date: Thu, 12 Jan 2017 15:56:46 +0530 Subject: [PATCH] Fix close() for single node ways --- modules/osm/way.js | 2 +- test/spec/osm/way.js | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/modules/osm/way.js b/modules/osm/way.js index bd7a28b8c..99ccc3716 100644 --- a/modules/osm/way.js +++ b/modules/osm/way.js @@ -193,8 +193,8 @@ _.extend(osmWay.prototype, { if (this.isClosed() || !this.nodes.length) return this; var nodes = this.nodes.slice(); - nodes.push(nodes[0]); nodes = nodes.filter(noRepeatNodes); + nodes.push(nodes[0]); return this.update({ nodes: nodes }); }, diff --git a/test/spec/osm/way.js b/test/spec/osm/way.js index 8c41b76f8..f45a98ae1 100644 --- a/test/spec/osm/way.js +++ b/test/spec/osm/way.js @@ -431,8 +431,10 @@ describe('iD.osmWay', function() { }); it('closes a way', function () { - var w = iD.Way({ nodes: 'ab'.split('') }); - expect(w.close().nodes.join('')).to.eql('aba'); + var w1 = iD.Way({ nodes: 'ab'.split('') }); + expect(w1.close().nodes.join('')).to.eql('aba', 'multiple'); + var w2 = iD.Way({ nodes: 'a'.split('') }); + expect(w2.close().nodes.join('')).to.eql('aa', 'single'); }); it('eliminates duplicate consecutive nodes when closing a linear way', function () { @@ -461,8 +463,10 @@ describe('iD.osmWay', function() { }); it('uncloses a circular way', function () { - var w = iD.Way({ nodes: 'aba'.split('') }); - expect(w.unclose().nodes.join('')).to.eql('ab'); + var w1 = iD.Way({ nodes: 'aba'.split('') }); + expect(w1.unclose().nodes.join('')).to.eql('ab', 'multiple'); + var w2 = iD.Way({ nodes: 'aa'.split('') }); + expect(w2.unclose().nodes.join('')).to.eql('a', 'single'); }); it('eliminates duplicate consecutive nodes when unclosing a circular way', function () {