mirror of
https://github.com/FoggedLens/iD.git
synced 2026-05-16 13:59:27 +02:00
Merge pull request #2292 from bhousel/directional-midpoints
Render triangular midpoints to show direction of any selected way #1448 #1085
This commit is contained in:
+4
-4
@@ -90,10 +90,10 @@ g.vertex.shared .stroke {
|
||||
}
|
||||
|
||||
g.midpoint .fill {
|
||||
fill: #ddd;
|
||||
stroke: black;
|
||||
stroke-opacity: .5;
|
||||
opacity: .5;
|
||||
fill: #fff;
|
||||
stroke: #333;
|
||||
stroke-opacity: .8;
|
||||
opacity: .8;
|
||||
}
|
||||
|
||||
g.vertex .shadow,
|
||||
|
||||
+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 10,0 -6,-8')
|
||||
.attr('class', 'shadow');
|
||||
|
||||
group.append('circle')
|
||||
.attr('r', 3)
|
||||
group.append('polygon')
|
||||
.attr('points', '-3,4 5,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 = Math.round(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