Files
iD/js/id/svg/vertices.js
T
John Firebaugh e95d163dbc Apply tag classes to vertices and points
While here, introduce a `classed` matcher for Chai.
2013-01-11 12:22:23 -08:00

41 lines
1.2 KiB
JavaScript

iD.svg.Vertices = function() {
return function(surface, graph, entities, filter, projection) {
var vertices = [];
for (var i = 0; i < entities.length; i++) {
var entity = entities[i];
if (entity.geometry() === 'vertex') {
vertices.push(entity);
}
}
var groups = surface.select('.layer-hit').selectAll('g.vertex')
.filter(filter)
.data(vertices, iD.Entity.key);
var group = groups.enter()
.insert('g', ':first-child')
.attr('class', 'node vertex');
group.append('circle')
.attr('class', 'stroke')
.attr('r', 6);
group.append('circle')
.attr('class', 'fill')
.attr('r', 4);
groups.attr('transform', iD.svg.PointTransform(projection))
.call(iD.svg.TagClasses())
.classed('shared', function(entity) { return graph.parentWays(entity).length > 1; });
// Selecting the following implicitly
// sets the data (vertix entity) on the elements
groups.select('circle.fill');
groups.select('circle.stroke');
groups.exit()
.remove();
};
};