mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-24 09:04:02 +02:00
render triangular midpoints to show direction of way #1085
This commit is contained in:
+13
-7
@@ -75,19 +75,25 @@ iD.svg.Midpoints = function(projection, context) {
|
||||
.insert('g', ':first-child')
|
||||
.attr('class', 'midpoint');
|
||||
|
||||
group.append('circle')
|
||||
.attr('r', 7)
|
||||
group.append('polygon')
|
||||
.attr('points', '-6,8 8,0 -6,-8')
|
||||
.attr('class', 'shadow');
|
||||
|
||||
group.append('circle')
|
||||
.attr('r', 3)
|
||||
group.append('polygon')
|
||||
.attr('points', '-3,4 4,0 -3,-4')
|
||||
.attr('class', 'fill');
|
||||
|
||||
groups.attr('transform', iD.svg.PointTransform(projection));
|
||||
groups.attr('transform', function(d) {
|
||||
var translate = iD.svg.PointTransform(projection),
|
||||
a = context.entity(d.edge[0]),
|
||||
b = context.entity(d.edge[1]),
|
||||
angle = iD.geo.angle(a, b, projection) * (180 / Math.PI);
|
||||
return translate(d) + ' rotate(' + angle + ')';
|
||||
});
|
||||
|
||||
// Propagate data bindings.
|
||||
groups.select('circle.shadow');
|
||||
groups.select('circle.fill');
|
||||
groups.select('polygon.shadow');
|
||||
groups.select('polygon.fill');
|
||||
|
||||
groups.exit()
|
||||
.remove();
|
||||
|
||||
@@ -18,6 +18,7 @@ describe("iD.svg.Midpoints", function () {
|
||||
extent = iD.geo.Extent([0, 0], [100, 100]);
|
||||
|
||||
context.selectedIDs = function() { return [line.id]; };
|
||||
context.entity = function(id) { return graph.entity(id); };
|
||||
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
|
||||
|
||||
expect(surface.select('.midpoint').datum().loc).to.eql([25, 0]);
|
||||
@@ -57,6 +58,7 @@ describe("iD.svg.Midpoints", function () {
|
||||
extent = iD.geo.Extent([0, 0], [100, 100]);
|
||||
|
||||
context.selectedIDs = function() { return [line.id]; };
|
||||
context.entity = function(id) { return graph.entity(id); };
|
||||
surface.call(iD.svg.Midpoints(projection, context), graph, [line], filter, extent);
|
||||
|
||||
expect(surface.select('.midpoint').datum().loc).to.eql([100, 0]);
|
||||
|
||||
Reference in New Issue
Block a user