mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-14 05:12:13 +02:00
Fix extent and difference rendering for multi polygons
This commit is contained in:
@@ -2,8 +2,14 @@ iD.Relation = iD.Entity.extend({
|
||||
type: "relation",
|
||||
members: [],
|
||||
|
||||
extent: function() {
|
||||
return [[NaN, NaN], [NaN, NaN]];
|
||||
extent: function(resolver) {
|
||||
return resolver.transient(this, 'extent', function() {
|
||||
var extent = iD.geo.Extent();
|
||||
for (var i = 0, l = this.members.length; i < l; i++) {
|
||||
extent = extent.extend(resolver.entity(this.members[i].id).extent(resolver));
|
||||
}
|
||||
return extent;
|
||||
});
|
||||
},
|
||||
|
||||
geometry: function() {
|
||||
|
||||
@@ -69,8 +69,7 @@ iD.Map = function() {
|
||||
all = graph.intersects(extent);
|
||||
filter = d3.functor(true);
|
||||
} else {
|
||||
var only = {},
|
||||
filterOnly = {};
|
||||
var only = {};
|
||||
for (var j = 0; j < difference.length; j++) {
|
||||
var id = difference[j],
|
||||
entity = graph.fetch(id);
|
||||
@@ -86,6 +85,13 @@ iD.Map = function() {
|
||||
only[parents[k].id] = graph.fetch(parents[k].id);
|
||||
}
|
||||
}
|
||||
parents = graph.parentRelations(only[id]);
|
||||
for (k = 0; k < parents.length; k++) {
|
||||
// Don't re-fetch parents
|
||||
if (only[parents[k].id] === undefined) {
|
||||
only[parents[k].id] = parents[k].id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,14 @@ describe('iD.Relation', function () {
|
||||
});
|
||||
|
||||
describe("#extent", function () {
|
||||
it("returns the minimal extent containing the extents of all members");
|
||||
it("returns the minimal extent containing the extents of all members", function () {
|
||||
var a = iD.Node({loc: [0, 0]}),
|
||||
b = iD.Node({loc: [5, 10]}),
|
||||
r = iD.Relation({members: [{id: a.id}, {id: b.id}]}),
|
||||
graph = iD.Graph([a, b, r]);
|
||||
|
||||
expect(r.extent(graph)).to.eql([[0, 0], [5, 10]])
|
||||
});
|
||||
});
|
||||
|
||||
describe("#multipolygon", function () {
|
||||
|
||||
Reference in New Issue
Block a user