(stream)
| 3352 | function d3_geo_resample(project) { |
| 3353 | var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16; |
| 3354 | function resample(stream) { |
| 3355 | var λ00, φ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0; |
| 3356 | var resample = { |
| 3357 | point: point, |
| 3358 | lineStart: lineStart, |
| 3359 | lineEnd: lineEnd, |
| 3360 | polygonStart: function() { |
| 3361 | stream.polygonStart(); |
| 3362 | resample.lineStart = ringStart; |
| 3363 | }, |
| 3364 | polygonEnd: function() { |
| 3365 | stream.polygonEnd(); |
| 3366 | resample.lineStart = lineStart; |
| 3367 | } |
| 3368 | }; |
| 3369 | function point(x, y) { |
| 3370 | x = project(x, y); |
| 3371 | stream.point(x[0], x[1]); |
| 3372 | } |
| 3373 | function lineStart() { |
| 3374 | x0 = NaN; |
| 3375 | resample.point = linePoint; |
| 3376 | stream.lineStart(); |
| 3377 | } |
| 3378 | function linePoint(λ, φ) { |
| 3379 | var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ); |
| 3380 | 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); |
| 3381 | stream.point(x0, y0); |
| 3382 | } |
| 3383 | function lineEnd() { |
| 3384 | resample.point = point; |
| 3385 | stream.lineEnd(); |
| 3386 | } |
| 3387 | function ringStart() { |
| 3388 | lineStart(); |
| 3389 | resample.point = ringPoint; |
| 3390 | resample.lineEnd = ringEnd; |
| 3391 | } |
| 3392 | function ringPoint(λ, φ) { |
| 3393 | linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; |
| 3394 | resample.point = linePoint; |
| 3395 | } |
| 3396 | function ringEnd() { |
| 3397 | resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream); |
| 3398 | resample.lineEnd = lineEnd; |
| 3399 | lineEnd(); |
| 3400 | } |
| 3401 | return resample; |
| 3402 | } |
| 3403 | function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) { |
| 3404 | var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy; |
| 3405 | if (d2 > 4 * δ2 && depth--) { |
no outgoing calls
no test coverage detected