Make handles connected to more than one way cyan. Fixes #205

This commit is contained in:
Tom MacWright
2012-12-17 14:06:27 -05:00
parent 79a1887d6b
commit e8a14f8b5b
3 changed files with 22 additions and 2 deletions
+4
View File
@@ -32,6 +32,10 @@ circle.handle {
stroke-opacity: 1;
}
circle.handle.two-parents {
fill:#aff;
}
circle.handle.hover {
}
+11
View File
@@ -21,6 +21,17 @@ iD.Graph.prototype = {
return this.entities[id];
},
parentStructure: function(ways) {
var nodes = {};
ways.forEach(function(w) {
_.uniq(w.nodes).forEach(function(n) {
if (typeof nodes[n.id] === 'undefined') nodes[n.id] = 0;
nodes[n.id]++;
});
});
return nodes;
},
parentWays: function(id) {
// This is slow and a bad hack.
return _.filter(this.entities, function(e) {
+7 -2
View File
@@ -96,6 +96,7 @@ iD.Map = function() {
filter = function(d) { return d.accuracy ? d.way in only : d.id in only; };
}
if (all.length > 10000) return editOff();
else editOn();
@@ -112,10 +113,11 @@ iD.Map = function() {
waynodes.push(a);
}
}
var parentStructure = graph.parentStructure(ways);
var wayAccuracyHandles = ways.reduce(function(mem, w) {
return mem.concat(accuracyHandles(w));
}, []);
drawHandles(waynodes, filter);
drawHandles(waynodes, parentStructure, filter);
drawAccuracyHandles(wayAccuracyHandles, filter);
drawCasings(lines, filter);
drawFills(areas, filter);
@@ -138,7 +140,7 @@ iD.Map = function() {
return handles;
}
function drawHandles(waynodes, filter) {
function drawHandles(waynodes, parentStructure, filter) {
var handles = g.hit.selectAll('circle.handle')
.filter(filter)
.data(waynodes, key);
@@ -160,6 +162,9 @@ iD.Map = function() {
return d.id === hover ? 8: 4;
})
.classed('active', classActive)
.classed('two-parents', function(d) {
return parentStructure[d.id] > 1;
})
.classed('hover', classHover);
}