mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-17 22:24:49 +02:00
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:
+18
-5
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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] = {
|
||||
|
||||
Reference in New Issue
Block a user