Reinsert parentRelations of modified parentWays

(closes #3008)
This commit is contained in:
Bryan Housel
2016-02-29 23:09:24 -05:00
parent a85361545d
commit c79c65fb39
2 changed files with 25 additions and 9 deletions
+10 -9
View File
@@ -10,21 +10,22 @@ iD.Tree = function(head) {
}
function updateParents(entity, insertions, memo) {
head.parentWays(entity).forEach(function(parent) {
if (rectangles[parent.id]) {
rtree.remove(rectangles[parent.id]);
insertions[parent.id] = parent;
head.parentWays(entity).forEach(function(way) {
if (rectangles[way.id]) {
rtree.remove(rectangles[way.id]);
insertions[way.id] = way;
}
updateParents(way, insertions, memo);
});
head.parentRelations(entity).forEach(function(parent) {
head.parentRelations(entity).forEach(function(relation) {
if (memo[entity.id]) return;
memo[entity.id] = true;
if (rectangles[parent.id]) {
rtree.remove(rectangles[parent.id]);
insertions[parent.id] = parent;
if (rectangles[relation.id]) {
rtree.remove(rectangles[relation.id]);
insertions[relation.id] = relation;
}
updateParents(parent, insertions, memo);
updateParents(relation, insertions, memo);
});
}
+15
View File
@@ -146,6 +146,21 @@ describe("iD.Tree", function() {
expect(tree.intersects(extent, graph)).to.eql([]);
});
it("adjusts parent relations of parent ways when a member node is moved", function() {
var graph = iD.Graph(),
tree = iD.Tree(graph),
node = iD.Node({id: 'n', loc: [1, 1]}),
way = iD.Way({id: 'w', nodes: ['n']}),
relation = iD.Relation({members: [{type: 'multipolygon', id: 'w'}]}),
extent = iD.geo.Extent([0, 0], [2, 2]);
graph = graph.replace(node).replace(way).replace(relation);
expect(tree.intersects(extent, graph)).to.eql([node, way, relation]);
graph = graph.replace(node.move([3, 3]));
expect(tree.intersects(extent, graph)).to.eql([]);
});
it("adjusts parent ways when a member node is removed", function() {
var graph = iD.Graph(),
tree = iD.Tree(graph),