Run intersection on difference changes, do not use compact. Fixes #334

This commit is contained in:
Tom MacWright
2013-01-16 14:06:11 -05:00
parent 0e9e14102e
commit 6407fa464c
2 changed files with 13 additions and 9 deletions
+2 -1
View File
@@ -6,7 +6,8 @@ iD.Way = iD.Entity.extend({
return resolver.transient(this, 'extent', function() {
var extent = [[-Infinity, Infinity], [Infinity, -Infinity]];
for (var i = 0, l = this.nodes.length; i < l; i++) {
var node = resolver.entity(this.nodes[i]);
var node = this.nodes[i];
if (node.loc === undefined) node = resolver.entity(node);
if (node.loc[0] > extent[0][0]) extent[0][0] = node.loc[0];
if (node.loc[0] < extent[1][0]) extent[1][0] = node.loc[0];
if (node.loc[1] < extent[0][1]) extent[0][1] = node.loc[1];
+11 -8
View File
@@ -65,18 +65,21 @@ iD.Map = function() {
var only = {};
for (var j = 0; j < difference.length; j++) {
var id = difference[j];
only[id] = graph.fetch(id);
if (only[id] && only[id].type === 'node') {
var parents = graph.parentWays(only[id]);
for (var k = 0; k < parents.length; k++) {
// Don't re-fetch parents
if (only[parents[k].id] === undefined) {
only[parents[k].id] = graph.fetch(parents[k].id);
var entity = graph.fetch(id);
if (entity && entity.intersects(extent, graph)) {
only[id] = entity;
if (only[id].type === 'node') {
var parents = graph.parentWays(only[id]);
for (var k = 0; k < parents.length; k++) {
// Don't re-fetch parents
if (only[parents[k].id] === undefined) {
only[parents[k].id] = graph.fetch(parents[k].id);
}
}
}
}
}
all = _.compact(_.values(only));
all = _.values(only);
filter = function(d) { return d.midpoint ? d.way in only : d.id in only; };
}