(listener)
| 2553 | return Math.cos(λ) * Math.cos(φ) > cr; |
| 2554 | } |
| 2555 | function clipLine(listener) { |
| 2556 | var point0, c0, v0, v00, clean; |
| 2557 | return { |
| 2558 | lineStart: function() { |
| 2559 | v00 = v0 = false; |
| 2560 | clean = 1; |
| 2561 | }, |
| 2562 | point: function(λ, φ) { |
| 2563 | var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0; |
| 2564 | if (!point0 && (v00 = v0 = v)) listener.lineStart(); |
| 2565 | if (v !== v0) { |
| 2566 | point2 = intersect(point0, point1); |
| 2567 | if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) { |
| 2568 | point1[0] += ε; |
| 2569 | point1[1] += ε; |
| 2570 | v = visible(point1[0], point1[1]); |
| 2571 | } |
| 2572 | } |
| 2573 | if (v !== v0) { |
| 2574 | clean = 0; |
| 2575 | if (v) { |
| 2576 | listener.lineStart(); |
| 2577 | point2 = intersect(point1, point0); |
| 2578 | listener.point(point2[0], point2[1]); |
| 2579 | } else { |
| 2580 | point2 = intersect(point0, point1); |
| 2581 | listener.point(point2[0], point2[1]); |
| 2582 | listener.lineEnd(); |
| 2583 | } |
| 2584 | point0 = point2; |
| 2585 | } else if (notHemisphere && point0 && smallRadius ^ v) { |
| 2586 | var t; |
| 2587 | if (!(c & c0) && (t = intersect(point1, point0, true))) { |
| 2588 | clean = 0; |
| 2589 | if (smallRadius) { |
| 2590 | listener.lineStart(); |
| 2591 | listener.point(t[0][0], t[0][1]); |
| 2592 | listener.point(t[1][0], t[1][1]); |
| 2593 | listener.lineEnd(); |
| 2594 | } else { |
| 2595 | listener.point(t[1][0], t[1][1]); |
| 2596 | listener.lineEnd(); |
| 2597 | listener.lineStart(); |
| 2598 | listener.point(t[0][0], t[0][1]); |
| 2599 | } |
| 2600 | } |
| 2601 | } |
| 2602 | if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) { |
| 2603 | listener.point(point1[0], point1[1]); |
| 2604 | } |
| 2605 | point0 = point1, v0 = v, c0 = c; |
| 2606 | }, |
| 2607 | lineEnd: function() { |
| 2608 | if (v0) listener.lineEnd(); |
| 2609 | point0 = null; |
| 2610 | }, |
| 2611 | clean: function() { |
| 2612 | return clean | (v00 && v0) << 1; |
no test coverage detected