fix midpoint redrawing

Midpoints weren't being redrawn when the way was deleted
but both edge nodes still existed in other ways.
This commit is contained in:
Ansis Brammanis
2013-03-28 18:30:10 -04:00
parent dbbca3608b
commit e9244159dc
2 changed files with 20 additions and 6 deletions
+18 -5
View File
@@ -71,11 +71,24 @@ iD.Map = function(context) {
all = _.compact(_.values(complete));
filter = function(d) {
if (d.type === 'midpoint') {
var a = graph.entity(d.edge[0]),
b = graph.entity(d.edge[1]);
return !a || !b ||
_.intersection(graph.parentWays(a), all).length ||
_.intersection(graph.parentWays(b), all).length;
var a = d.edge[0],
b = d.edge[1];
// redraw a midpoint if it needs to be
// - moved (either edge node moved)
// - deleted (edge nodes not consecutive in any parent way)
if (a in complete || b in complete) return true;
var parentsWays = graph.parentWays({ id: a });
for (var i = 0; i < parentsWays.length; i++) {
var nodes = parentsWays[i].nodes;
for (var n = 0; n < nodes.length; n++) {
if (nodes[n] === a && (nodes[n - 1] === b || nodes[n + 1] === b)) return false;
}
}
return true;
} else {
return d.id in complete;
}
+2 -1
View File
@@ -19,7 +19,8 @@ iD.svg.Midpoints = function(projection) {
b = nodes[j + 1],
id = [a.id, b.id].sort().join('-');
if (!midpoints[id]) {
// If neither of the nodes changed, no need to redraw midpoint
if (!midpoints[id] && (filter(a) || filter(b))) {
var loc = iD.geo.interp(a.loc, b.loc, 0.5);
if (extent.intersects(loc) && iD.geo.dist(projection(a.loc), projection(b.loc)) > 40) {
midpoints[id] = {