Skip to content

Commit a2e347a

Browse files
authored
prevent degenerate ways caused by deleting a corner of a triangle (#10003)
1 parent ce0eca3 commit a2e347a

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,15 @@ _Breaking developer changes, which may affect downstream projects or sites that
4242
#### :camera: Street-Level
4343
#### :white_check_mark: Validation
4444
#### :bug: Bugfixes
45+
* Prevent degenerate ways caused by deleting a corner of a triangle ([#10003], thanks [@k-yle])
4546
#### :earth_asia: Localization
4647
#### :hourglass: Performance
4748
#### :mortar_board: Walkthrough / Help
4849
#### :rocket: Presets
4950
#### :hammer: Development
5051

52+
[#10003]: https://github.com/openstreetmap/iD/pull/10003
53+
5154

5255
# 2.31.0
5356
##### 2025-Feb-05

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/actions/circularize.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,11 @@ describe('iD.actionCircularize', function () {
278278
var graph = iD.coreGraph([
279279
iD.osmNode({id: 'a', loc: [0, 0]}),
280280
iD.osmNode({id: 'b', loc: [0, 2]}),
281-
iD.osmWay({id: '-', nodes: ['a', 'b', 'a']})
281+
iD.osmNode({id: 'c', loc: [2, 0]}),
282+
iD.osmWay({id: '-', nodes: ['a', 'b', 'c', 'a']})
282283
]);
283284

284-
expect(area('-', graph)).to.eql(0);
285+
expect(area('-', graph)).to.eql(2);
285286

286287
graph = iD.actionCircularize('-', projection)(graph);
287288

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)