(stream)
| 2807 | function d3_geo_resample(project) { |
| 2808 | var δ2 = .5, maxDepth = 16; |
| 2809 | function resample(stream) { |
| 2810 | var λ0, x0, y0, a0, b0, c0; |
| 2811 | var resample = { |
| 2812 | point: point, |
| 2813 | lineStart: lineStart, |
| 2814 | lineEnd: lineEnd, |
| 2815 | polygonStart: function() { |
| 2816 | stream.polygonStart(); |
| 2817 | resample.lineStart = polygonLineStart; |
| 2818 | }, |
| 2819 | polygonEnd: function() { |
| 2820 | stream.polygonEnd(); |
| 2821 | resample.lineStart = lineStart; |
| 2822 | } |
| 2823 | }; |
| 2824 | function point(x, y) { |
| 2825 | x = project(x, y); |
| 2826 | stream.point(x[0], x[1]); |
| 2827 | } |
| 2828 | function lineStart() { |
| 2829 | x0 = NaN; |
| 2830 | resample.point = linePoint; |
| 2831 | stream.lineStart(); |
| 2832 | } |
| 2833 | function linePoint(λ, φ) { |
| 2834 | var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ); |
| 2835 | resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream); |
| 2836 | stream.point(x0, y0); |
| 2837 | } |
| 2838 | function lineEnd() { |
| 2839 | resample.point = point; |
| 2840 | stream.lineEnd(); |
| 2841 | } |
| 2842 | function polygonLineStart() { |
| 2843 | var λ00, φ00, x00, y00, a00, b00, c00; |
| 2844 | lineStart(); |
| 2845 | resample.point = function(λ, φ) { |
| 2846 | linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; |
| 2847 | resample.point = linePoint; |
| 2848 | }; |
| 2849 | resample.lineEnd = function() { |
| 2850 | resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream); |
| 2851 | resample.lineEnd = lineEnd; |
| 2852 | lineEnd(); |
| 2853 | }; |
| 2854 | } |
| 2855 | return resample; |
| 2856 | } |
| 2857 | function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) { |
| 2858 | var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy; |
| 2859 | if (d2 > 4 * δ2 && depth--) { |
no outgoing calls
no test coverage detected