Skip to content

Commit a33da7b

Browse files
committed
prevent degenerate ways caused by deleting a corner of a triangle
1 parent ac172a2 commit a33da7b

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

modules/osm/way.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Object.assign(osmWay.prototype, {
242242

243243

244244
isDegenerate: function() {
245-
return (new Set(this.nodes).size < (this.isArea() ? 3 : 2));
245+
return (new Set(this.nodes).size < (this.isClosed() ? 3 : 2));
246246
},
247247

248248

test/spec/osm/way.js

+4
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,10 @@ describe('iD.osmWay', function() {
473473
expect(iD.osmWay({nodes: ['a', 'b']}).isDegenerate()).to.equal(false);
474474
});
475475

476+
it('returns true for a linear way that doubles back on itself', function () {
477+
expect(iD.osmWay({nodes: ['a', 'b', 'a']}).isDegenerate()).to.equal(true);
478+
});
479+
476480
it('returns true for an area with zero, one, or two unique nodes', function () {
477481
expect(iD.osmWay({tags: {area: 'yes'}, nodes: []}).isDegenerate()).to.equal(true);
478482
expect(iD.osmWay({tags: {area: 'yes'}, nodes: ['a', 'a']}).isDegenerate()).to.equal(true);

0 commit comments

Comments
 (0)