mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 09:12:52 +00:00
corner destroying resampling for oneway markers
This commit is contained in:
@@ -823,11 +823,8 @@ marker#oneway-marker path {
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
text.tag-oneway {
|
||||
fill:#91CFFF;
|
||||
stroke:#2C6B9B;
|
||||
stroke-width:1;
|
||||
pointer-events:none;
|
||||
path.oneway {
|
||||
stroke-width: 6px;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
41
js/id/svg.js
41
js/id/svg.js
@@ -24,6 +24,7 @@ iD.svg = {
|
||||
var last,
|
||||
next,
|
||||
started = false,
|
||||
offset = 0,
|
||||
d = '';
|
||||
|
||||
d3.geo.stream({
|
||||
@@ -32,29 +33,45 @@ iD.svg = {
|
||||
return n.loc;
|
||||
})
|
||||
}, projection.stream({
|
||||
lineStart: function() { last = null; started = false; },
|
||||
lineStart: function() { last = null; started = false; offset = 0; },
|
||||
lineEnd: function() { },
|
||||
point: function(x, y) {
|
||||
if (!started) d += 'M';
|
||||
|
||||
next = [Math.floor(x), Math.floor(y)];
|
||||
if (dx && last && iD.geo.dist(last, next) > dx) {
|
||||
|
||||
if (!started) {
|
||||
d += 'M';
|
||||
d += next[0] + ',' + next[1];
|
||||
offset = dx;
|
||||
|
||||
} else if (!dx) {
|
||||
d += 'L';
|
||||
d += next[0] + ',' + next[1];
|
||||
}
|
||||
|
||||
|
||||
// Resample
|
||||
if (dx && last) {
|
||||
|
||||
var span = iD.geo.dist(last, next),
|
||||
angle = Math.atan2(next[1] - last[1], next[0] - last[0]),
|
||||
to = last.slice();
|
||||
to[0] += Math.cos(angle) * dx;
|
||||
to[1] += Math.sin(angle) * dx;
|
||||
while (iD.geo.dist(last, to) < (span)) {
|
||||
|
||||
to[0] += Math.cos(angle) * offset;
|
||||
to[1] += Math.sin(angle) * offset;
|
||||
|
||||
while (iD.geo.dist(last, to) < span) {
|
||||
|
||||
// a dx-length line segment in that angle
|
||||
if (started) d += 'L';
|
||||
d += Math.floor(to[0]) + ',' + Math.floor(to[1]);
|
||||
started = started || true;
|
||||
d += 'L' + Math.floor(to[0]) + ',' + Math.floor(to[1]);
|
||||
to[0] += Math.cos(angle) * dx;
|
||||
to[1] += Math.sin(angle) * dx;
|
||||
}
|
||||
|
||||
offset = iD.geo.dist(last, to) - span;
|
||||
}
|
||||
if (started) d += 'L';
|
||||
d += next[0] + ',' + next[1];
|
||||
started = started || true;
|
||||
|
||||
started = true;
|
||||
last = next;
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -112,14 +112,16 @@ iD.svg.Lines = function(projection) {
|
||||
casing = surface.select('.layer-casing'),
|
||||
stroke = surface.select('.layer-stroke'),
|
||||
defs = surface.select('defs'),
|
||||
text = surface.select('.layer-text'),
|
||||
oneway = surface.select('.layer-oneway'),
|
||||
shadows = drawPaths(shadow, lines, filter, 'shadow', lineString),
|
||||
casings = drawPaths(casing, lines, filter, 'casing', lineString),
|
||||
strokes = drawPaths(stroke, lines, filter, 'stroke', lineString);
|
||||
strokes = drawPaths(stroke, lines, filter, 'stroke', lineString),
|
||||
oneways = drawPaths(oneway, lines, filter, 'oneway', lineStringOneway);
|
||||
|
||||
strokes
|
||||
.filter(function(d) { return d.isOneWay(); })
|
||||
.attr('marker-mid', 'url(#oneway-marker)')
|
||||
.attr('d', lineStringResampled);
|
||||
oneways.attr('marker-mid', 'url(#oneway-marker)');
|
||||
|
||||
function lineStringOneway(d) {
|
||||
return d.isOneWay() && lineStringResampled(d);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
@@ -34,12 +34,13 @@ iD.svg.Surface = function(context) {
|
||||
id: 'oneway-marker',
|
||||
viewBox: '0 0 10 10',
|
||||
refY: 2.5,
|
||||
refX: 5,
|
||||
markerWidth: 2,
|
||||
markerHeight: 2,
|
||||
orient: 'auto'
|
||||
})
|
||||
.append('path')
|
||||
.attr('d', 'M 0 0 L 5 2.5 L 0 5 z');
|
||||
.attr('d', 'M 5 3 L 0 3 L 0 2 L 5 2 L 5 0 L 10 2.5 L 5 5 z');
|
||||
|
||||
var patterns = defs.selectAll('pattern')
|
||||
.data([
|
||||
@@ -109,7 +110,7 @@ iD.svg.Surface = function(context) {
|
||||
maki));
|
||||
|
||||
var layers = selection.selectAll('.layer')
|
||||
.data(['fill', 'shadow', 'casing', 'stroke', 'text', 'hit', 'halo', 'label']);
|
||||
.data(['fill', 'shadow', 'casing', 'stroke', 'oneway', 'hit', 'halo', 'label']);
|
||||
|
||||
layers.enter().append('g')
|
||||
.attr('class', function(d) { return 'layer layer-' + d; });
|
||||
|
||||
Reference in New Issue
Block a user