import{m as n}from"./d3-array-d83825ab.js"; // Adds floating point numbers with twice the normal precision. // Reference: J. R. Shewchuk, Adaptive Precision Floating-Point Arithmetic and // Fast Robust Geometric Predicates, Discrete & Computational Geometry 18(3) // 305–363 (1997). // Code adapted from GeographicLib by Charles F. F. Karney, // http://geographiclib.sourceforge.net/ function t(){return new i}function i(){this.reset()}i.prototype={constructor:i,reset:function(){this.s=// rounded value this.t=0;// exact error },add:function(n){o(r,n,this.t),o(this,r.s,this.s),this.s?this.t+=r.t:this.s=r.t},valueOf:function(){return this.s}};var r=new i;function o(n,t,i){var r=n.s=t+i,o=r-t,e=r-o;n.t=t-e+(i-o)}var e=1e-6,u=Math.PI,f=u/2,l=u/4,a=2*u,c=180/u,p=u/180,s=Math.abs,v=Math.atan,h=Math.atan2,g=Math.cos,d=Math.sin,E=Math.sqrt;function S(n){return n>1?0:n<-1?u:Math.acos(n)}function y(n){return n>1?f:n<-1?-f:Math.asin(n)}function m(){}function M(n,t){n&&N.hasOwnProperty(n.type)&&N[n.type](n,t)}var x={Feature:function(n,t){M(n.geometry,t)},FeatureCollection:function(n,t){for(var i=n.features,r=-1,o=i.length;++ru?n-a:n<-u?n+a:n,t]}function q(n){return function(t,i){return[(t+=n)>u?t-a:t<-u?t+a:t,i]}}function G(n){var t=q(n);return t.invert=q(-n),t}function k(n,t){var i=g(n),r=d(n),o=g(t),e=d(t);function u(n,t){var u=g(t),f=g(n)*u,l=d(n)*u,a=d(t),c=a*i+f*r;return[h(l*o-c*e,f*i-a*r),y(c*o+l*e)]}return u.invert=function(n,t){var u=g(t),f=g(n)*u,l=d(n)*u,a=d(t),c=a*o-l*e;return[h(l*o+a*e,f*i+c*r),y(c*i-f*r)]},u} // Generates a circle centered at [0°, 0°], with a given radius and precision. // Returns the signed angle of a cartesian point relative to [cosRadius, 0, 0]. function B(n,t){(t=j(t))[0]-=n,F(t);var i=S(-t[1]);return((-t[2]<0?-i:i)+a-e)%a}function D(){var n,t=[];return{point:function(t,i){n.push([t,i])},lineStart:function(){t.push(n=[])},lineEnd:m,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var i=t;return t=[],n=null,i}}}function H(n,t){return s(n[0]-t[0])=0;--e)o.point((c=a[e])[0],c[1]);else r(s.x,s.p.x,-1,o);s=s.p}a=(s=s.o).z,v=!v}while(!s.v);o.lineEnd()}}}function Q(n){if(t=n.length){for(var t,i,r=0,o=n[0];++r0)do{f.point(0===a||3===a?t:r,a>1?o:i)}while((a=(a+u+4)%4)!==p);else f.point(e[0],e[1])}function l(n,o){return s(n[0]-t)0?0:3:s(n[0]-r)0?2:1:s(n[1]-i)0?1:0:o>0?3:2;// abs(p[1] - y1) < epsilon }function a(n,t){return c(n.x,t.x)}function c(n,t){var i=l(n,1),r=l(t,1);return i!==r?i-r:0===i?t[1]-n[1]:1===i?n[0]-t[0]:2===i?n[1]-t[1]:t[0]-n[0]}return function(e){var l,c,p,s,v,h,// first point g,d,E,// previous point S,y,m=e,M=D(),x={point:N,lineStart:function(){x.point=w,c&&c.push(p=[]);S=!0,E=!1,g=d=NaN} // TODO rather than special-case polygons, simply handle them separately. // Ideally, coincident intersection points should be jittered to avoid // clipping issues. ,lineEnd:function(){l&&(w(s,v),h&&E&&M.rejoin(),l.push(M.result()));x.point=N,E&&m.lineEnd()},polygonStart: // Buffer geometry within a polygon and then clip it en masse. function(){m=M,l=[],c=[],y=!0},polygonEnd:function(){var i=function(){for(var n=0,i=0,r=c.length;io&&(s-e)*(o-u)>(v-u)*(t-e)&&++n:v<=o&&(s-e)*(o-u)<(v-u)*(t-e)&&--n;return n}(),r=y&&i,u=(l=n(l)).length;(r||u)&&(e.polygonStart(),r&&(e.lineStart(),f(null,null,1,e),e.lineEnd()),u&&K(l,a,i,f,e),e.polygonEnd());m=e,l=c=p=null}};function N(n,t){u(n,t)&&m.point(n,t)}function w(n,e){var f=u(n,e);if(c&&p.push([n,e]),S)s=n,v=e,h=f,S=!1,f&&(m.lineStart(),m.point(n,e));else if(f&&E)m.point(n,e);else{var l=[g=Math.max(T,Math.min(R,g)),d=Math.max(T,Math.min(R,d))],a=[n=Math.max(T,Math.min(R,n)),e=Math.max(T,Math.min(R,e))];!function(n,t,i,r,o,e){var u,f=n[0],l=n[1],a=0,c=1,p=t[0]-f,s=t[1]-l;if(u=i-f,p||!(u>0)){if(u/=p,p<0){if(u0){if(u>c)return;u>a&&(a=u)}if(u=o-f,p||!(u<0)){if(u/=p,p<0){if(u>c)return;u>a&&(a=u)}else if(p>0){if(u0)){if(u/=s,s<0){if(u0){if(u>c)return;u>a&&(a=u)}if(u=e-l,s||!(u<0)){if(u/=s,s<0){if(u>c)return;u>a&&(a=u)}else if(s>0){if(u0&&(n[0]=f+a*p,n[1]=l+a*s),c<1&&(t[0]=f+c*p,t[1]=l+c*s),!0}}}}}(l,a,t,i,r,o)?f&&(m.lineStart(),m.point(n,e),y=!1):(E||(m.lineStart(),m.point(l[0],l[1])),m.point(a[0],a[1]),f||m.lineEnd(),y=!1)}g=n,d=e,E=f}return x}}var V=t();function W(n){return n}t(),t(),t();var X=Infinity,Y=X,Z=-X,$=Z,_={point:function(n,t){nZ&&(Z=n);t$&&($=t)},lineStart:m,lineEnd:m,polygonStart:m,polygonEnd:m,result:function(){var n=[[X,Y],[Z,$]];return Z=$=-(Y=X=Infinity),n}};function nn(t,i,r,o){return function(f,c){var p,s,v,E=i(c),S=f.invert(o[0],o[1]),m=D(),M=i(m),x=!1,N={point:w,lineStart:z,lineEnd:I,polygonStart:function(){N.point=A,N.lineStart=C,N.lineEnd=L,s=[],p=[]},polygonEnd:function(){N.point=w,N.lineStart=z,N.lineEnd=I,s=n(s);var t=function(n,t){var i=t[0],r=t[1],o=[d(i),-g(i),0],f=0,c=0;V.reset();for(var p=0,s=n.length;p=0?1:-1,q=b*L,G=q>u,k=x*A; // Are the longitudes either side of the point’s meridian (lambda), // and are the latitudes smaller than the parallel (phi)? if(V.add(h(k*b*d(q),N*C+k*g(q))),f+=G?L+b*a:L,G^m>=i^z>=i){var B=O(j(S),j(P));F(B);var D=O(o,B);F(D);var H=(G^L>=0?-1:1)*y(D[2]);(r>H||r===H&&(B[0]||B[1]))&&(c+=G^L>=0?1:-1)}} // First, determine whether the South pole is inside or outside: // It is inside if: // * the polygon winds around it in a clockwise direction. // * the polygon does not (cumulatively) wind around it, but has a negative // (counter-clockwise) area. // Second, count the (signed) number of times a segment crosses a lambda // from the point to the South pole. If it is zero, then the point is the // same side as the South pole. return(f<-e||f0){for(x||(c.polygonStart(),x=!0),c.lineStart(),n=0;n1&&2&o&&e.push(e.pop().concat(e.shift())),s.push(e.filter(tn))}return N}}function tn(n){return n.length>1} // Intersections are sorted along the clip edge. For both antimeridian cutting // and circle clipping, the same comparison is used. function rn(n,t){return((n=n.x)[0]<0?n[1]-f-e:f-n[1])-((t=t.x)[0]<0?t[1]-f-e:f-t[1])}t();const on=nn((function(){return!0}),( // Takes a line and cuts into visible segments. Return values: 0 - there were // intersections or the line was empty; 1 - no intersections; 2 - there were // intersections, and the first and last segments should be rejoined. function(n){var t,i=NaN,r=NaN,o=NaN;// no intersections return{lineStart:function(){n.lineStart(),t=1},point:function(l,a){var c=l>0?u:-u,p=s(l-i);s(p-u)0?f:-f),n.point(o,r),n.lineEnd(),n.lineStart(),n.point(c,r),n.point(l,r),t=0):o!==c&&p>=u&&(// line crosses antimeridian s(i-o)e?v((d(t)*(u=g(r))*d(i)-d(r)*(o=g(t))*d(n))/(o*u*f)):(t+r)/2}(i,r,l,a),n.point(o,r),n.lineEnd(),n.lineStart(),n.point(c,r),t=0),n.point(i=l,r=a),o=c},lineEnd:function(){n.lineEnd(),i=r=NaN},clean:function(){return 2-t;// if intersections, rejoin first and last segments }}}),(function(n,t,i,r){var o;if(null==n)o=i*f,r.point(-u,o),r.point(0,o),r.point(u,o),r.point(u,0),r.point(u,-o),r.point(0,-o),r.point(-u,-o),r.point(-u,0),r.point(-u,o);else if(s(n[0]-t[0])>e){var l=n[0]0,o=s(i)>e;// TODO optimise for this common case function f(n,t){return g(n)*g(t)>i} // Takes a line and cuts into visible segments. Return values used for polygon // clipping: 0 - there were intersections or the line was empty; 1 - no // intersections 2 - there were intersections, and the first and last segments // should be rejoined. // Intersects the great circle between a and b with the clip circle. function l(n,t,r){var o=[1,0,0],// normal f=O(j(n),j(t)),l=I(f,f),a=f[0],// cartesianDot(n1, n2), c=l-a*a; // We have two planes, n1.p = d1 and n2.p = d2. // Find intersection line p(t) = c1 n1 + c2 n2 + t (n1 ⨯ n2). // Two polar points. if(!c)return!r&&n;var p=i*l/c,v=-i*a/c,h=O(o,f),g=C(o,p);A(g,C(f,v)); // Solve |p(t)|^2 = 1. var d=h,S=I(g,d),y=I(d,d),m=S*S-y*(I(g,g)-1);if(!(m<0)){var M=E(m),x=C(d,(-S-M)/y);if(A(x,g),x=z(x),!r)return x; // Two intersection points. var N,w=n[0],P=t[0],F=n[1],L=t[1];P0^x[1]<(s(x[0]-w)u^(w<=x[0]&&x[0]<=P)){var G=C(d,(-S+M)/y);return A(G,g),[x,z(G)]}}} // Generates a 4-bit vector representing the location of a point relative to // the small circle's bounding box. function c(t,i){var o=r?n:u-n,e=0;// above return t<-o?e|=1:t>o&&(e|=2),// right i<-o?e|=4:i>o&&(e|=8),e}return nn(f,(function(n){var t,// previous point i,// code for previous point a,// visibility of previous point p,// visibility of first point s;// no intersections return{lineStart:function(){p=a=!1,s=1},point:function(v,h){var g,d=[v,h],E=f(v,h),S=r?E?0:c(v,h):E?c(v+(v<0?u:-u),h):0;if(!t&&(p=a=E)&&n.lineStart(), // Handle degeneracies. // TODO ignore if not clipping polygons. E!==a&&(!(g=l(t,d))||H(t,g)||H(d,g))&&(d[0]+=e,d[1]+=e,E=f(d[0],d[1])),E!==a)s=0,E?( // outside going in n.lineStart(),g=l(d,t),n.point(g[0],g[1])):( // inside going out g=l(t,d),n.point(g[0],g[1]),n.lineEnd()),t=g;else if(o&&t&&r^E){var y; // If the codes for two points are different, or are both zero, // and there this segment intersects with the small circle. S&i||!(y=l(d,t,!0))||(s=0,r?(n.lineStart(),n.point(y[0][0],y[0][1]),n.point(y[1][0],y[1][1]),n.lineEnd()):(n.point(y[1][0],y[1][1]),n.lineEnd(),n.lineStart(),n.point(y[0][0],y[0][1])))}!E||t&&H(t,d)||n.point(d[0],d[1]),t=d,a=E,i=S},lineEnd:function(){a&&n.lineEnd(),t=null}, // Rejoin first and last segments if there were intersections and the first // and last points were visible. clean:function(){return s|(p&&a)<<1}}}),(function(i,r,o,e){!function(n,t,i,r,o,e){if(i){var u=g(t),f=d(t),l=r*i;null==o?(o=t+r*a,e=t-l/2):(o=B(u,o),e=B(u,e),(r>0?oe)&&(o+=r*a));for(var c,p=o;r>0?p>e:p4*t&&m--){var P=f+g,z=l+d,j=a+S,I=E(P*P+z*z+j*j),O=y(j/=I),A=s(s(j)-1)t||s((x*b+N*q)/w-.5)>.3||f*g+l*d+a*S2?n[2]%360*p:0,F()):[m*c,M*c,x*c]},O.precision=function(n){return arguments.length?(I=cn(C,j=n*n),q()):E(j)},O.fitExtent=function(n,t){return ln(O,n,t)},O.fitSize=function(n,t){return function(n,t,i){return ln(n,[[0,0],t],i)}(O,n,t)},function(){return t=n.apply(this,arguments),O.invert=t.invert&&A,F()}}((function(){return n}))()}function vn(n){return function(t,i){var r=g(t),o=g(i),e=n(r*o);return[e*o*d(t),e*d(i)]}}function hn(n){return function(t,i){var r=E(t*t+i*i),o=n(r),e=d(o),u=g(o);return[h(t*e,r*u),y(r&&i*e/r)]}}vn((function(n){return E(2/(1+n))})).invert=hn((function(n){return 2*y(n/2)}));var gn=vn((function(n){return(n=S(n))&&n/d(n)}));function dn(){return sn(gn).scale(79.4188).clipAngle(179.999)}function En(n,t){return[n,t]}gn.invert=hn((function(n){return n})),En.invert=En;export{dn as g}; //# sourceMappingURL=d3-geo-106fc929.js.map