(radius)
| 10911 | } |
| 10912 | |
| 10913 | function clipCircle(radius) { |
| 10914 | var cr = cos$1(radius), |
| 10915 | delta = 2 * radians, |
| 10916 | smallRadius = cr > 0, |
| 10917 | notHemisphere = abs$1(cr) > epsilon$1; // TODO optimise for this common case |
| 10918 | |
| 10919 | function interpolate(from, to, direction, stream) { |
| 10920 | circleStream(stream, radius, delta, direction, from, to); |
| 10921 | } |
| 10922 | |
| 10923 | function visible(lambda, phi) { |
| 10924 | return cos$1(lambda) * cos$1(phi) > cr; |
| 10925 | } |
| 10926 | |
| 10927 | // Takes a line and cuts into visible segments. Return values used for polygon |
| 10928 | // clipping: 0 - there were intersections or the line was empty; 1 - no |
| 10929 | // intersections 2 - there were intersections, and the first and last segments |
| 10930 | // should be rejoined. |
| 10931 | function clipLine(stream) { |
| 10932 | var point0, // previous point |
| 10933 | c0, // code for previous point |
| 10934 | v0, // visibility of previous point |
| 10935 | v00, // visibility of first point |
| 10936 | clean; // no intersections |
| 10937 | return { |
| 10938 | lineStart: function() { |
| 10939 | v00 = v0 = false; |
| 10940 | clean = 1; |
| 10941 | }, |
| 10942 | point: function(lambda, phi) { |
| 10943 | var point1 = [lambda, phi], |
| 10944 | point2, |
| 10945 | v = visible(lambda, phi), |
| 10946 | c = smallRadius |
| 10947 | ? v ? 0 : code(lambda, phi) |
| 10948 | : v ? code(lambda + (lambda < 0 ? pi$1 : -pi$1), phi) : 0; |
| 10949 | if (!point0 && (v00 = v0 = v)) stream.lineStart(); |
| 10950 | if (v !== v0) { |
| 10951 | point2 = intersect(point0, point1); |
| 10952 | if (!point2 || pointEqual(point0, point2) || pointEqual(point1, point2)) |
| 10953 | point1[2] = 1; |
| 10954 | } |
| 10955 | if (v !== v0) { |
| 10956 | clean = 0; |
| 10957 | if (v) { |
| 10958 | // outside going in |
| 10959 | stream.lineStart(); |
| 10960 | point2 = intersect(point1, point0); |
| 10961 | stream.point(point2[0], point2[1]); |
| 10962 | } else { |
| 10963 | // inside going out |
| 10964 | point2 = intersect(point0, point1); |
| 10965 | stream.point(point2[0], point2[1], 2); |
| 10966 | stream.lineEnd(); |
| 10967 | } |
| 10968 | point0 = point2; |
| 10969 | } else if (notHemisphere && point0 && smallRadius ^ v) { |
| 10970 | var t; |
no test coverage detected