Fix Relation#multipolygon for unmatched inner rings (fixes #461)

This commit is contained in:
John Firebaugh
2013-01-22 17:54:57 -05:00
parent d74bf1e39a
commit 381794e7a1
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -140,7 +140,7 @@ _.extend(iD.Relation.prototype, {
if (o !== undefined)
result[o].push(inners[i]);
else
result.push(inners[i]); // Invalid geometry
result.push([inners[i]]); // Invalid geometry
}
return result;
+11
View File
@@ -298,6 +298,17 @@ describe('iD.Relation', function () {
expect(r.multipolygon(graph)).to.eql([[[a, b, c, a], [d, e, f, d]], [[g, h, i, g]]]);
});
specify("invalid geometry: unmatched inner", function () {
var a = iD.Node(),
b = iD.Node(),
c = iD.Node(),
w = iD.Way({nodes: [a.id, b.id, c.id, a.id]}),
r = iD.Relation({members: [{id: w.id, role: 'inner', type: 'way'}]}),
g = iD.Graph([a, b, c, w, r]);
expect(r.multipolygon(g)).to.eql([[[a, b, c, a]]]);
});
specify("incomplete relation", function () {
var a = iD.Node(),
b = iD.Node(),