mirror of
https://github.com/FoggedLens/iD.git
synced 2026-04-21 11:16:36 +02:00
Don't close unclosed multipolygon parts with fewer than three nodes when generating geojson
Update multipolygon geojson code tests
This commit is contained in:
@@ -308,8 +308,9 @@ Object.assign(osmRelation.prototype, {
|
||||
inners = osmJoinWays(inners, resolver);
|
||||
|
||||
var sequenceToLineString = function(sequence) {
|
||||
if (sequence.nodes[0] !== sequence.nodes[sequence.nodes.length - 1]) {
|
||||
// treat all parts as closed even if they aren't
|
||||
if (sequence.nodes.length > 2 &&
|
||||
sequence.nodes[0] !== sequence.nodes[sequence.nodes.length - 1]) {
|
||||
// close unclosed parts to ensure correct area rendering - #2945
|
||||
sequence.nodes.push(sequence.nodes[0]);
|
||||
}
|
||||
return sequence.nodes.map(function(node) { return node.loc; });
|
||||
|
||||
@@ -647,7 +647,7 @@ describe('iD.osmRelation', function () {
|
||||
var r = iD.osmRelation({members: [{id: w.id, type: 'way'}]});
|
||||
var g = iD.coreGraph([a, b, c, w, r]);
|
||||
|
||||
expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc]]]);
|
||||
expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc, a.loc]]]);
|
||||
});
|
||||
|
||||
specify('invalid geometry: unclosed ring consisting of multiple ways', function () {
|
||||
@@ -659,7 +659,7 @@ describe('iD.osmRelation', function () {
|
||||
var r = iD.osmRelation({members: [{id: w1.id, type: 'way'}, {id: w2.id, type: 'way'}]});
|
||||
var g = iD.coreGraph([a, b, c, w1, w2, r]);
|
||||
|
||||
expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc]]]);
|
||||
expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc, a.loc]]]);
|
||||
});
|
||||
|
||||
specify('invalid geometry: unclosed ring consisting of multiple ways, alternate order', function () {
|
||||
@@ -672,7 +672,7 @@ describe('iD.osmRelation', function () {
|
||||
var r = iD.osmRelation({members: [{id: w1.id, type: 'way'}, {id: w2.id, type: 'way'}]});
|
||||
var g = iD.coreGraph([a, b, c, d, w1, w2, r]);
|
||||
|
||||
expect(r.multipolygon(g)).to.eql([[[d.loc, c.loc, b.loc, a.loc]]]);
|
||||
expect(r.multipolygon(g)).to.eql([[[d.loc, c.loc, b.loc, a.loc, d.loc]]]);
|
||||
});
|
||||
|
||||
specify('invalid geometry: unclosed ring consisting of multiple ways, one needing reversal', function () {
|
||||
@@ -685,7 +685,7 @@ describe('iD.osmRelation', function () {
|
||||
var r = iD.osmRelation({members: [{id: w1.id, type: 'way'}, {id: w2.id, type: 'way'}]});
|
||||
var g = iD.coreGraph([a, b, c, d, w1, w2, r]);
|
||||
|
||||
expect(r.multipolygon(g)).to.eql([[[d.loc, c.loc, b.loc, a.loc]]]);
|
||||
expect(r.multipolygon(g)).to.eql([[[a.loc, d.loc, c.loc, b.loc, a.loc]]]);
|
||||
});
|
||||
|
||||
specify('invalid geometry: unclosed ring consisting of multiple ways, one needing reversal, alternate order', function () {
|
||||
@@ -698,7 +698,7 @@ describe('iD.osmRelation', function () {
|
||||
var r = iD.osmRelation({members: [{id: w1.id, type: 'way'}, {id: w2.id, type: 'way'}]});
|
||||
var g = iD.coreGraph([a, b, c, d, w1, w2, r]);
|
||||
|
||||
expect(r.multipolygon(g)).to.eql([[[d.loc, c.loc, b.loc, a.loc]]]);
|
||||
expect(r.multipolygon(g)).to.eql([[[d.loc, c.loc, b.loc, a.loc, d.loc]]]);
|
||||
});
|
||||
|
||||
specify('single polygon with single single-way inner', function () {
|
||||
@@ -805,7 +805,7 @@ describe('iD.osmRelation', function () {
|
||||
var r = iD.osmRelation({members: [{id: w2.id, type: 'way'}, {id: w1.id, type: 'way'}]});
|
||||
var g = iD.coreGraph([a, b, c, w1, r]);
|
||||
|
||||
expect(r.multipolygon(g)).to.eql([[[a.loc, b.loc, c.loc]]]);
|
||||
expect(r.multipolygon(g)).to.eql([[[a.loc, c.loc, b.loc, a.loc]]]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user