Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prevent degenerate ways caused by deleting a corner of a triangle #10003

Merged
merged 2 commits into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -42,12 +42,15 @@ _Breaking developer changes, which may affect downstream projects or sites that
#### :camera: Street-Level
#### :white_check_mark: Validation
#### :bug: Bugfixes
* Prevent degenerate ways caused by deleting a corner of a triangle ([#10003], thanks [@k-yle])
#### :earth_asia: Localization
#### :hourglass: Performance
#### :mortar_board: Walkthrough / Help
#### :rocket: Presets
#### :hammer: Development

[#10003]: https://github.com/openstreetmap/iD/pull/10003


# 2.31.0
##### 2025-Feb-05
2 changes: 1 addition & 1 deletion modules/osm/way.js
Original file line number Diff line number Diff line change
@@ -242,7 +242,7 @@ Object.assign(osmWay.prototype, {


isDegenerate: function() {
return (new Set(this.nodes).size < (this.isArea() ? 3 : 2));
return (new Set(this.nodes).size < (this.isClosed() ? 3 : 2));
},


5 changes: 3 additions & 2 deletions test/spec/actions/circularize.js
Original file line number Diff line number Diff line change
@@ -278,10 +278,11 @@ describe('iD.actionCircularize', function () {
var graph = iD.coreGraph([
iD.osmNode({id: 'a', loc: [0, 0]}),
iD.osmNode({id: 'b', loc: [0, 2]}),
iD.osmWay({id: '-', nodes: ['a', 'b', 'a']})
iD.osmNode({id: 'c', loc: [2, 0]}),
iD.osmWay({id: '-', nodes: ['a', 'b', 'c', 'a']})
]);

expect(area('-', graph)).to.eql(0);
expect(area('-', graph)).to.eql(2);

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

4 changes: 4 additions & 0 deletions test/spec/osm/way.js
Original file line number Diff line number Diff line change
@@ -473,6 +473,10 @@ describe('iD.osmWay', function() {
expect(iD.osmWay({nodes: ['a', 'b']}).isDegenerate()).to.equal(false);
});

it('returns true for a linear way that doubles back on itself', function () {
expect(iD.osmWay({nodes: ['a', 'b', 'a']}).isDegenerate()).to.equal(true);
});

it('returns true for an area with zero, one, or two unique nodes', function () {
expect(iD.osmWay({tags: {area: 'yes'}, nodes: []}).isDegenerate()).to.equal(true);
expect(iD.osmWay({tags: {area: 'yes'}, nodes: ['a', 'a']}).isDegenerate()).to.equal(true);