mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
Fix close() for single node ways
This commit is contained in:
@@ -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 });
|
||||
},
|
||||
|
||||
|
||||
@@ -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 () {
|
||||
|
||||
Reference in New Issue
Block a user