trekmap-preorder/d3geo.min.js

1 line
22 KiB
JavaScript

(()=>{var B=class{constructor(){this._partials=new Float64Array(32),this._n=0}add(n){let e=this._partials,r=0;for(let o=0;o<this._n&&o<32;o++){let a=e[o],f=n+a,u=Math.abs(n)<Math.abs(a)?n-(f-a):a-(f-n);u&&(e[r++]=u),n=f}return e[r]=n,this._n=r+1,this}valueOf(){let n=this._partials,e=this._n,r,o,a,f=0;if(e>0){for(f=n[--e];e>0&&(r=f,o=n[--e],f=r+o,a=o-(f-r),!a););e>0&&(a<0&&n[e-1]<0||a>0&&n[e-1]>0)&&(o=a*2,r=f+o,o==r-f&&(f=r))}return f}};function*hr(t){for(let n of t)yield*n}function ft(t){return Array.from(hr(t))}function et(t,n,e){t=+t,n=+n,e=(o=arguments.length)<2?(n=t,t=0,1):o<3?1:+e;for(var r=-1,o=Math.max(0,Math.ceil((n-t)/e))|0,a=new Array(o);++r<o;)a[r]=t+r*e;return a}var R=1e-6,In=1e-12,q=Math.PI,H=q/2,Kt=q/4,O=q*2,Q=180/q,F=q/180,I=Math.abs,Nn=Math.atan,U=Math.atan2,A=Math.cos,vt=Math.ceil;var N=Math.sin,Cn=Math.sign||function(t){return t>0?1:t<0?-1:0},Y=Math.sqrt;function zn(t){return t>1?0:t<-1?q:Math.acos(t)}function J(t){return t>1?H:t<-1?-H:Math.asin(t)}function $(){}function Lt(t,n){t&&_n.hasOwnProperty(t.type)&&_n[t.type](t,n)}var Ln={Feature:function(t,n){Lt(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,o=e.length;++r<o;)Lt(e[r].geometry,n)}},_n={Sphere:function(t,n){n.sphere()},Point:function(t,n){t=t.coordinates,n.point(t[0],t[1],t[2])},MultiPoint:function(t,n){for(var e=t.coordinates,r=-1,o=e.length;++r<o;)t=e[r],n.point(t[0],t[1],t[2])},LineString:function(t,n){Qt(t.coordinates,n,0)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,o=e.length;++r<o;)Qt(e[r],n,0)},Polygon:function(t,n){Tn(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,o=e.length;++r<o;)Tn(e[r],n)},GeometryCollection:function(t,n){for(var e=t.geometries,r=-1,o=e.length;++r<o;)Lt(e[r],n)}};function Qt(t,n,e){var r=-1,o=t.length-e,a;for(n.lineStart();++r<o;)a=t[r],n.point(a[0],a[1],a[2]);n.lineEnd()}function Tn(t,n){var e=-1,r=t.length;for(n.polygonStart();++e<r;)Qt(t[e],n,1);n.polygonEnd()}function j(t,n){t&&Ln.hasOwnProperty(t.type)?Ln[t.type](t,n):Lt(t,n)}function xt(t){return[U(t[1],t[0]),J(t[2])]}function k(t){var n=t[0],e=t[1],r=A(e);return[r*A(n),r*N(n),N(e)]}function St(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function lt(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function _t(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Et(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function wt(t){var n=Y(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}function Rt(t,n){function e(r,o){return r=t(r,o),n(r[0],r[1])}return t.invert&&n.invert&&(e.invert=function(r,o){return r=n.invert(r,o),r&&t.invert(r[0],r[1])}),e}function Vt(t,n){return I(t)>q&&(t-=Math.round(t/O)*O),[t,n]}Vt.invert=Vt;function Gn(t,n,e){return(t%=O)?n||e?Rt(Dn(t),Fn(n,e)):Dn(t):n||e?Fn(n,e):Vt}function $n(t){return function(n,e){return n+=t,I(n)>q&&(n-=Math.round(n/O)*O),[n,e]}}function Dn(t){var n=$n(t);return n.invert=$n(-t),n}function Fn(t,n){var e=A(t),r=N(t),o=A(n),a=N(n);function f(u,g){var h=A(g),i=A(u)*h,l=N(u)*h,p=N(g),m=p*e+i*r;return[U(l*o-m*a,i*e-p*r),J(m*o+l*a)]}return f.invert=function(u,g){var h=A(g),i=A(u)*h,l=N(u)*h,p=N(g),m=p*o-l*a;return[U(l*o+p*a,i*e+m*r),J(m*e-i*r)]},f}function Yn(t,n,e,r,o,a){if(e){var f=A(n),u=N(n),g=r*e;o==null?(o=n+r*O,a=n-g/2):(o=Xn(f,o),a=Xn(f,a),(r>0?o<a:o>a)&&(o+=r*O));for(var h,i=o;r>0?i>a:i<a;i-=g)h=xt([f,-u*A(i),-u*N(i)]),t.point(h[0],h[1])}}function Xn(t,n){n=k(n),n[0]-=t,wt(n);var e=zn(-n[1]);return((-n[2]<0?-e:e)+O-R)%O}function Tt(){var t=[],n;return{point:function(e,r,o){n.push([e,r,o])},lineStart:function(){t.push(n=[])},lineEnd:$,rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))},result:function(){var e=t;return t=[],n=null,e}}}function pt(t,n){return I(t[0]-n[0])<R&&I(t[1]-n[1])<R}function $t(t,n,e,r){this.x=t,this.z=n,this.o=e,this.e=r,this.v=!1,this.n=this.p=null}function Dt(t,n,e,r,o){var a=[],f=[],u,g;if(t.forEach(function(c){if(!((w=c.length-1)<=0)){var w,v=c[0],x=c[w],E;if(pt(v,x)){if(!v[2]&&!x[2]){for(o.lineStart(),u=0;u<w;++u)o.point((v=c[u])[0],v[1]);o.lineEnd();return}x[0]+=2*R}a.push(E=new $t(v,c,null,!0)),f.push(E.o=new $t(v,null,E,!1)),a.push(E=new $t(x,c,null,!1)),f.push(E.o=new $t(x,null,E,!0))}}),!!a.length){for(f.sort(n),On(a),On(f),u=0,g=f.length;u<g;++u)f[u].e=e=!e;for(var h=a[0],i,l;;){for(var p=h,m=!0;p.v;)if((p=p.n)===h)return;i=p.z,o.lineStart();do{if(p.v=p.o.v=!0,p.e){if(m)for(u=0,g=i.length;u<g;++u)o.point((l=i[u])[0],l[1]);else r(p.x,p.n.x,1,o);p=p.n}else{if(m)for(i=p.p.z,u=i.length-1;u>=0;--u)o.point((l=i[u])[0],l[1]);else r(p.x,p.p.x,-1,o);p=p.p}p=p.o,i=p.z,m=!m}while(!p.v);o.lineEnd()}}}function On(t){if(n=t.length){for(var n,e=0,r=t[0],o;++e<n;)r.n=o=t[e],o.p=r,r=o;r.n=o=t[0],o.p=r}}function jt(t){return I(t[0])<=q?t[0]:Cn(t[0])*((I(t[0])+q)%O-q)}function Bn(t,n){var e=jt(n),r=n[1],o=N(r),a=[N(e),-A(e),0],f=0,u=0,g=new B;o===1?r=H+R:o===-1&&(r=-H-R);for(var h=0,i=t.length;h<i;++h)if(p=(l=t[h]).length)for(var l,p,m=l[p-1],c=jt(m),w=m[1]/2+Kt,v=N(w),x=A(w),E=0;E<p;++E,c=S,v=P,x=_,m=d){var d=l[E],S=jt(d),y=d[1]/2+Kt,P=N(y),_=A(y),z=S-c,L=z>=0?1:-1,D=L*z,M=D>q,Z=v*P;if(g.add(U(Z*L*N(D),x*_+Z*A(D))),f+=M?z+L*O:z,M^c>=e^S>=e){var G=lt(k(m),k(d));wt(G);var T=lt(a,G);wt(T);var s=(M^z>=0?-1:1)*J(T[2]);(r>s||r===s&&(G[0]||G[1]))&&(u+=M^z>=0?1:-1)}}return(f<-R||f<R&&g<-In)^u&1}function Ft(t,n,e,r){return function(o){var a=n(o),f=Tt(),u=n(f),g=!1,h,i,l,p={point:m,lineStart:w,lineEnd:v,polygonStart:function(){p.point=x,p.lineStart=E,p.lineEnd=d,i=[],h=[]},polygonEnd:function(){p.point=m,p.lineStart=w,p.lineEnd=v,i=ft(i);var S=Bn(h,r);i.length?(g||(o.polygonStart(),g=!0),Dt(i,vr,S,e,o)):S&&(g||(o.polygonStart(),g=!0),o.lineStart(),e(null,null,1,o),o.lineEnd()),g&&(o.polygonEnd(),g=!1),i=h=null},sphere:function(){o.polygonStart(),o.lineStart(),e(null,null,1,o),o.lineEnd(),o.polygonEnd()}};function m(S,y){t(S,y)&&o.point(S,y)}function c(S,y){a.point(S,y)}function w(){p.point=c,a.lineStart()}function v(){p.point=m,a.lineEnd()}function x(S,y){l.push([S,y]),u.point(S,y)}function E(){u.lineStart(),l=[]}function d(){x(l[0][0],l[0][1]),u.lineEnd();var S=u.clean(),y=f.result(),P,_=y.length,z,L,D;if(l.pop(),h.push(l),l=null,!!_){if(S&1){if(L=y[0],(z=L.length-1)>0){for(g||(o.polygonStart(),g=!0),o.lineStart(),P=0;P<z;++P)o.point((D=L[P])[0],D[1]);o.lineEnd()}return}_>1&&S&2&&y.push(y.pop().concat(y.shift())),i.push(y.filter(gr))}}return p}}function gr(t){return t.length>1}function vr(t,n){return((t=t.x)[0]<0?t[1]-H-R:H-t[1])-((n=n.x)[0]<0?n[1]-H-R:H-n[1])}var kt=Ft(function(){return!0},xr,Er,[-q,-H]);function xr(t){var n=NaN,e=NaN,r=NaN,o;return{lineStart:function(){t.lineStart(),o=1},point:function(a,f){var u=a>0?q:-q,g=I(a-n);I(g-q)<R?(t.point(n,e=(e+f)/2>0?H:-H),t.point(r,e),t.lineEnd(),t.lineStart(),t.point(u,e),t.point(a,e),o=0):r!==u&&g>=q&&(I(n-r)<R&&(n-=r*R),I(a-u)<R&&(a-=u*R),e=Sr(n,e,a,f),t.point(r,e),t.lineEnd(),t.lineStart(),t.point(u,e),o=0),t.point(n=a,e=f),r=u},lineEnd:function(){t.lineEnd(),n=e=NaN},clean:function(){return 2-o}}}function Sr(t,n,e,r){var o,a,f=N(t-e);return I(f)>R?Nn((N(n)*(a=A(r))*N(e)-N(r)*(o=A(n))*N(t))/(o*a*f)):(n+r)/2}function Er(t,n,e,r){var o;if(t==null)o=e*H,r.point(-q,o),r.point(0,o),r.point(q,o),r.point(q,0),r.point(q,-o),r.point(0,-o),r.point(-q,-o),r.point(-q,0),r.point(-q,o);else if(I(t[0]-n[0])>R){var a=t[0]<n[0]?q:-q;o=e*a/2,r.point(-a,o),r.point(0,o),r.point(a,o)}else r.point(n[0],n[1])}function Hn(t){var n=A(t),e=2*F,r=n>0,o=I(n)>R;function a(i,l,p,m){Yn(m,t,e,p,i,l)}function f(i,l){return A(i)*A(l)>n}function u(i){var l,p,m,c,w;return{lineStart:function(){c=m=!1,w=1},point:function(v,x){var E=[v,x],d,S=f(v,x),y=r?S?0:h(v,x):S?h(v+(v<0?q:-q),x):0;if(!l&&(c=m=S)&&i.lineStart(),S!==m&&(d=g(l,E),(!d||pt(l,d)||pt(E,d))&&(E[2]=1)),S!==m)w=0,S?(i.lineStart(),d=g(E,l),i.point(d[0],d[1])):(d=g(l,E),i.point(d[0],d[1],2),i.lineEnd()),l=d;else if(o&&l&&r^S){var P;!(y&p)&&(P=g(E,l,!0))&&(w=0,r?(i.lineStart(),i.point(P[0][0],P[0][1]),i.point(P[1][0],P[1][1]),i.lineEnd()):(i.point(P[1][0],P[1][1]),i.lineEnd(),i.lineStart(),i.point(P[0][0],P[0][1],3)))}S&&(!l||!pt(l,E))&&i.point(E[0],E[1]),l=E,m=S,p=y},lineEnd:function(){m&&i.lineEnd(),l=null},clean:function(){return w|(c&&m)<<1}}}function g(i,l,p){var m=k(i),c=k(l),w=[1,0,0],v=lt(m,c),x=St(v,v),E=v[0],d=x-E*E;if(!d)return!p&&i;var S=n*x/d,y=-n*E/d,P=lt(w,v),_=Et(w,S),z=Et(v,y);_t(_,z);var L=P,D=St(_,L),M=St(L,L),Z=D*D-M*(St(_,_)-1);if(!(Z<0)){var G=Y(Z),T=Et(L,(-D-G)/M);if(_t(T,_),T=xt(T),!p)return T;var s=i[0],C=l[0],X=i[1],W=l[1],K;C<s&&(K=s,s=C,C=K);var gt=C-s,nt=I(gt-q)<R,it=nt||gt<R;if(!nt&&W<X&&(K=X,X=W,W=K),it?nt?X+W>0^T[1]<(I(T[0]-s)<R?X:W):X<=T[1]&&T[1]<=W:gt>q^(s<=T[0]&&T[0]<=C)){var rt=Et(L,(-D+G)/M);return _t(rt,_),[T,xt(rt)]}}}function h(i,l){var p=r?t:q-t,m=0;return i<-p?m|=1:i>p&&(m|=2),l<-p?m|=4:l>p&&(m|=8),m}return Ft(f,u,a,r?[0,-t]:[-q,t-q])}function Zn(t,n,e,r,o,a){var f=t[0],u=t[1],g=n[0],h=n[1],i=0,l=1,p=g-f,m=h-u,c;if(c=e-f,!(!p&&c>0)){if(c/=p,p<0){if(c<i)return;c<l&&(l=c)}else if(p>0){if(c>l)return;c>i&&(i=c)}if(c=o-f,!(!p&&c<0)){if(c/=p,p<0){if(c>l)return;c>i&&(i=c)}else if(p>0){if(c<i)return;c<l&&(l=c)}if(c=r-u,!(!m&&c>0)){if(c/=m,m<0){if(c<i)return;c<l&&(l=c)}else if(m>0){if(c>l)return;c>i&&(i=c)}if(c=a-u,!(!m&&c<0)){if(c/=m,m<0){if(c>l)return;c>i&&(i=c)}else if(m>0){if(c<i)return;c<l&&(l=c)}return i>0&&(t[0]=f+i*p,t[1]=u+i*m),l<1&&(n[0]=f+l*p,n[1]=u+l*m),!0}}}}}var Mt=1e9,Gt=-Mt;function bt(t,n,e,r){function o(h,i){return t<=h&&h<=e&&n<=i&&i<=r}function a(h,i,l,p){var m=0,c=0;if(h==null||(m=f(h,l))!==(c=f(i,l))||g(h,i)<0^l>0)do p.point(m===0||m===3?t:e,m>1?r:n);while((m=(m+l+4)%4)!==c);else p.point(i[0],i[1])}function f(h,i){return I(h[0]-t)<R?i>0?0:3:I(h[0]-e)<R?i>0?2:1:I(h[1]-n)<R?i>0?1:0:i>0?3:2}function u(h,i){return g(h.x,i.x)}function g(h,i){var l=f(h,1),p=f(i,1);return l!==p?l-p:l===0?i[1]-h[1]:l===1?h[0]-i[0]:l===2?h[1]-i[1]:i[0]-h[0]}return function(h){var i=h,l=Tt(),p,m,c,w,v,x,E,d,S,y,P,_={point:z,lineStart:Z,lineEnd:G,polygonStart:D,polygonEnd:M};function z(s,C){o(s,C)&&i.point(s,C)}function L(){for(var s=0,C=0,X=m.length;C<X;++C)for(var W=m[C],K=1,gt=W.length,nt=W[0],it,rt,zt=nt[0],ut=nt[1];K<gt;++K)it=zt,rt=ut,nt=W[K],zt=nt[0],ut=nt[1],rt<=r?ut>r&&(zt-it)*(r-rt)>(ut-rt)*(t-it)&&++s:ut<=r&&(zt-it)*(r-rt)<(ut-rt)*(t-it)&&--s;return s}function D(){i=l,p=[],m=[],P=!0}function M(){var s=L(),C=P&&s,X=(p=ft(p)).length;(C||X)&&(h.polygonStart(),C&&(h.lineStart(),a(null,null,1,h),h.lineEnd()),X&&Dt(p,u,s,a,h),h.polygonEnd()),i=h,p=m=c=null}function Z(){_.point=T,m&&m.push(c=[]),y=!0,S=!1,E=d=NaN}function G(){p&&(T(w,v),x&&S&&l.rejoin(),p.push(l.result())),_.point=z,S&&i.lineEnd()}function T(s,C){var X=o(s,C);if(m&&c.push([s,C]),y)w=s,v=C,x=X,y=!1,X&&(i.lineStart(),i.point(s,C));else if(X&&S)i.point(s,C);else{var W=[E=Math.max(Gt,Math.min(Mt,E)),d=Math.max(Gt,Math.min(Mt,d))],K=[s=Math.max(Gt,Math.min(Mt,s)),C=Math.max(Gt,Math.min(Mt,C))];Zn(W,K,t,n,e,r)?(S||(i.lineStart(),i.point(W[0],W[1])),i.point(K[0],K[1]),X||i.lineEnd(),P=!1):X&&(i.lineStart(),i.point(s,C),P=!1)}E=s,d=C,S=X}return _}}var tn,nn,Xt,Yt,st={sphere:$,point:$,lineStart:wr,lineEnd:$,polygonStart:$,polygonEnd:$};function wr(){st.point=Mr,st.lineEnd=Rr}function Rr(){st.point=st.lineEnd=$}function Mr(t,n){t*=F,n*=F,nn=t,Xt=N(n),Yt=A(n),st.point=yr}function yr(t,n){t*=F,n*=F;var e=N(n),r=A(n),o=I(t-nn),a=A(o),f=N(o),u=r*f,g=Yt*e-Xt*r*a,h=Xt*e+Yt*r*a;tn.add(U(Y(u*u+g*g),h)),nn=t,Xt=e,Yt=r}function Wn(t){return tn=new B,j(t,st),+tn}var rn=[null,null],Pr={type:"LineString",coordinates:rn};function en(t,n){return rn[0]=t,rn[1]=n,Wn(Pr)}function Un(t,n,e){var r=et(t,n-R,e).concat(n);return function(o){return r.map(function(a){return[o,a]})}}function Jn(t,n,e){var r=et(t,n-R,e).concat(n);return function(o){return r.map(function(a){return[a,o]})}}function on(){var t,n,e,r,o,a,f,u,g=10,h=g,i=90,l=360,p,m,c,w,v=2.5;function x(){return{type:"MultiLineString",coordinates:E()}}function E(){return et(vt(r/i)*i,e,i).map(c).concat(et(vt(u/l)*l,f,l).map(w)).concat(et(vt(n/g)*g,t,g).filter(function(d){return I(d%i)>R}).map(p)).concat(et(vt(a/h)*h,o,h).filter(function(d){return I(d%l)>R}).map(m))}return x.lines=function(){return E().map(function(d){return{type:"LineString",coordinates:d}})},x.outline=function(){return{type:"Polygon",coordinates:[c(r).concat(w(f).slice(1),c(e).reverse().slice(1),w(u).reverse().slice(1))]}},x.extent=function(d){return arguments.length?x.extentMajor(d).extentMinor(d):x.extentMinor()},x.extentMajor=function(d){return arguments.length?(r=+d[0][0],e=+d[1][0],u=+d[0][1],f=+d[1][1],r>e&&(d=r,r=e,e=d),u>f&&(d=u,u=f,f=d),x.precision(v)):[[r,u],[e,f]]},x.extentMinor=function(d){return arguments.length?(n=+d[0][0],t=+d[1][0],a=+d[0][1],o=+d[1][1],n>t&&(d=n,n=t,t=d),a>o&&(d=a,a=o,o=d),x.precision(v)):[[n,a],[t,o]]},x.step=function(d){return arguments.length?x.stepMajor(d).stepMinor(d):x.stepMinor()},x.stepMajor=function(d){return arguments.length?(i=+d[0],l=+d[1],x):[i,l]},x.stepMinor=function(d){return arguments.length?(g=+d[0],h=+d[1],x):[g,h]},x.precision=function(d){return arguments.length?(v=+d,p=Un(a,o,90),m=Jn(n,t,v),c=Un(u,f,90),w=Jn(r,e,v),x):v},x.extentMajor([[-180,-90+R],[180,90-R]]).extentMinor([[-180,-80-R],[180,80+R]])}function an(){return on()()}var yt=t=>t;var un=new B,fn=new B,Kn,Qn,ln,pn,ot={point:$,lineStart:$,lineEnd:$,polygonStart:function(){ot.lineStart=qr,ot.lineEnd=Ir},polygonEnd:function(){ot.lineStart=ot.lineEnd=ot.point=$,un.add(I(fn)),fn=new B},result:function(){var t=un/2;return un=new B,t}};function qr(){ot.point=Ar}function Ar(t,n){ot.point=Vn,Kn=ln=t,Qn=pn=n}function Vn(t,n){fn.add(pn*t-ln*n),ln=t,pn=n}function Ir(){Vn(Kn,Qn)}var sn=ot;var ct=1/0,Ot=ct,Pt=-ct,Bt=Pt,Nr={point:Cr,lineStart:$,lineEnd:$,polygonStart:$,polygonEnd:$,result:function(){var t=[[ct,Ot],[Pt,Bt]];return Pt=Bt=-(Ot=ct=1/0),t}};function Cr(t,n){t<ct&&(ct=t),t>Pt&&(Pt=t),n<Ot&&(Ot=n),n>Bt&&(Bt=n)}var mt=Nr;var cn=0,mn=0,qt=0,Ht=0,Zt=0,dt=0,dn=0,hn=0,At=0,bn,tr,b,tt,V={point:at,lineStart:jn,lineEnd:kn,polygonStart:function(){V.lineStart=_r,V.lineEnd=Tr},polygonEnd:function(){V.point=at,V.lineStart=jn,V.lineEnd=kn},result:function(){var t=At?[dn/At,hn/At]:dt?[Ht/dt,Zt/dt]:qt?[cn/qt,mn/qt]:[NaN,NaN];return cn=mn=qt=Ht=Zt=dt=dn=hn=At=0,t}};function at(t,n){cn+=t,mn+=n,++qt}function jn(){V.point=zr}function zr(t,n){V.point=Lr,at(b=t,tt=n)}function Lr(t,n){var e=t-b,r=n-tt,o=Y(e*e+r*r);Ht+=o*(b+t)/2,Zt+=o*(tt+n)/2,dt+=o,at(b=t,tt=n)}function kn(){V.point=at}function _r(){V.point=$r}function Tr(){nr(bn,tr)}function $r(t,n){V.point=nr,at(bn=b=t,tr=tt=n)}function nr(t,n){var e=t-b,r=n-tt,o=Y(e*e+r*r);Ht+=o*(b+t)/2,Zt+=o*(tt+n)/2,dt+=o,o=tt*t-b*n,dn+=o*(b+t),hn+=o*(tt+n),At+=o*3,at(b=t,tt=n)}var gn=V;function Wt(t){this._context=t}Wt.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){this._line===0&&this._context.closePath(),this._point=NaN},point:function(t,n){switch(this._point){case 0:{this._context.moveTo(t,n),this._point=1;break}case 1:{this._context.lineTo(t,n);break}default:{this._context.moveTo(t+this._radius,n),this._context.arc(t,n,this._radius,0,O);break}}},result:$};var xn=new B,vn,rr,er,It,Nt,Ut={point:$,lineStart:function(){Ut.point=Dr},lineEnd:function(){vn&&or(rr,er),Ut.point=$},polygonStart:function(){vn=!0},polygonEnd:function(){vn=null},result:function(){var t=+xn;return xn=new B,t}};function Dr(t,n){Ut.point=or,rr=It=t,er=Nt=n}function or(t,n){It-=t,Nt-=n,xn.add(Y(It*It+Nt*Nt)),It=t,Nt=n}var Sn=Ut;var ir,Jt,ar,ur,ht=class{constructor(n){this._append=n==null?fr:Fr(n),this._radius=4.5,this._=""}pointRadius(n){return this._radius=+n,this}polygonStart(){this._line=0}polygonEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){this._line===0&&(this._+="Z"),this._point=NaN}point(n,e){switch(this._point){case 0:{this._append`M${n},${e}`,this._point=1;break}case 1:{this._append`L${n},${e}`;break}default:{if(this._append`M${n},${e}`,this._radius!==ar||this._append!==Jt){let r=this._radius,o=this._;this._="",this._append`m0,${r}a${r},${r} 0 1,1 0,${-2*r}a${r},${r} 0 1,1 0,${2*r}z`,ar=r,Jt=this._append,ur=this._,this._=o}this._+=ur;break}}}result(){let n=this._;return this._="",n.length?n:null}};function fr(t){let n=1;this._+=t[0];for(let e=t.length;n<e;++n)this._+=arguments[n]+t[n]}function Fr(t){let n=Math.floor(t);if(!(n>=0))throw new RangeError(`invalid digits: ${t}`);if(n>15)return fr;if(n!==ir){let e=10**n;ir=n,Jt=function(o){let a=1;this._+=o[0];for(let f=o.length;a<f;++a)this._+=Math.round(arguments[a]*e)/e+o[a]}}return Jt}function En(t,n){let e=3,r=4.5,o,a;function f(u){return u&&(typeof r=="function"&&a.pointRadius(+r.apply(this,arguments)),j(u,o(a))),a.result()}return f.area=function(u){return j(u,o(sn)),sn.result()},f.measure=function(u){return j(u,o(Sn)),Sn.result()},f.bounds=function(u){return j(u,o(mt)),mt.result()},f.centroid=function(u){return j(u,o(gn)),gn.result()},f.projection=function(u){return arguments.length?(o=u==null?(t=null,yt):(t=u).stream,f):t},f.context=function(u){return arguments.length?(a=u==null?(n=null,new ht(e)):new Wt(n=u),typeof r!="function"&&a.pointRadius(r),f):n},f.pointRadius=function(u){return arguments.length?(r=typeof u=="function"?u:(a.pointRadius(+u),+u),f):r},f.digits=function(u){if(!arguments.length)return e;if(u==null)e=null;else{let g=Math.floor(u);if(!(g>=0))throw new RangeError(`invalid digits: ${u}`);e=g}return n===null&&(a=new ht(e)),f},f.projection(t).digits(e).context(n)}function Ct(t){return function(n){var e=new wn;for(var r in t)e[r]=t[r];return e.stream=n,e}}function wn(){}wn.prototype={constructor:wn,point:function(t,n){this.stream.point(t,n)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};function Rn(t,n,e){var r=t.clipExtent&&t.clipExtent();return t.scale(150).translate([0,0]),r!=null&&t.clipExtent(null),j(e,t.stream(mt)),n(mt.result()),r!=null&&t.clipExtent(r),t}function Mn(t,n,e){return Rn(t,function(r){var o=n[1][0]-n[0][0],a=n[1][1]-n[0][1],f=Math.min(o/(r[1][0]-r[0][0]),a/(r[1][1]-r[0][1])),u=+n[0][0]+(o-f*(r[1][0]+r[0][0]))/2,g=+n[0][1]+(a-f*(r[1][1]+r[0][1]))/2;t.scale(150*f).translate([u,g])},e)}function lr(t,n,e){return Mn(t,[[0,0],n],e)}function pr(t,n,e){return Rn(t,function(r){var o=+n,a=o/(r[1][0]-r[0][0]),f=(o-a*(r[1][0]+r[0][0]))/2,u=-a*r[0][1];t.scale(150*a).translate([f,u])},e)}function sr(t,n,e){return Rn(t,function(r){var o=+n,a=o/(r[1][1]-r[0][1]),f=-a*r[0][0],u=(o-a*(r[1][1]+r[0][1]))/2;t.scale(150*a).translate([f,u])},e)}var cr=16,Gr=A(30*F);function yn(t,n){return+n?Yr(t,n):Xr(t)}function Xr(t){return Ct({point:function(n,e){n=t(n,e),this.stream.point(n[0],n[1])}})}function Yr(t,n){function e(r,o,a,f,u,g,h,i,l,p,m,c,w,v){var x=h-r,E=i-o,d=x*x+E*E;if(d>4*n&&w--){var S=f+p,y=u+m,P=g+c,_=Y(S*S+y*y+P*P),z=J(P/=_),L=I(I(P)-1)<R||I(a-l)<R?(a+l)/2:U(y,S),D=t(L,z),M=D[0],Z=D[1],G=M-r,T=Z-o,s=E*G-x*T;(s*s/d>n||I((x*G+E*T)/d-.5)>.3||f*p+u*m+g*c<Gr)&&(e(r,o,a,f,u,g,M,Z,L,S/=_,y/=_,P,w,v),v.point(M,Z),e(M,Z,L,S,y,P,h,i,l,p,m,c,w,v))}}return function(r){var o,a,f,u,g,h,i,l,p,m,c,w,v={point:x,lineStart:E,lineEnd:S,polygonStart:function(){r.polygonStart(),v.lineStart=y},polygonEnd:function(){r.polygonEnd(),v.lineStart=E}};function x(z,L){z=t(z,L),r.point(z[0],z[1])}function E(){l=NaN,v.point=d,r.lineStart()}function d(z,L){var D=k([z,L]),M=t(z,L);e(l,p,i,m,c,w,l=M[0],p=M[1],i=z,m=D[0],c=D[1],w=D[2],cr,r),r.point(l,p)}function S(){v.point=x,r.lineEnd()}function y(){E(),v.point=P,v.lineEnd=_}function P(z,L){d(o=z,L),a=l,f=p,u=m,g=c,h=w,v.point=d}function _(){e(l,p,i,m,c,w,a,f,o,u,g,h,cr,r),v.lineEnd=S,S()}return v}}var Or=Ct({point:function(t,n){this.stream.point(t*F,n*F)}});function Br(t){return Ct({point:function(n,e){var r=t(n,e);return this.stream.point(r[0],r[1])}})}function Hr(t,n,e,r,o){function a(f,u){return f*=r,u*=o,[n+t*f,e-t*u]}return a.invert=function(f,u){return[(f-n)/t*r,(e-u)/t*o]},a}function mr(t,n,e,r,o,a){if(!a)return Hr(t,n,e,r,o);var f=A(a),u=N(a),g=f*t,h=u*t,i=f/t,l=u/t,p=(u*e-f*n)/t,m=(u*n+f*e)/t;function c(w,v){return w*=r,v*=o,[g*w-h*v+n,e-h*w-g*v]}return c.invert=function(w,v){return[r*(i*w-l*v+p),o*(m-l*w-i*v)]},c}function Pn(t){return Zr(function(){return t})()}function Zr(t){var n,e=150,r=480,o=250,a=0,f=0,u=0,g=0,h=0,i,l=0,p=1,m=1,c=null,w=kt,v=null,x,E,d,S=yt,y=.5,P,_,z,L,D;function M(s){return z(s[0]*F,s[1]*F)}function Z(s){return s=z.invert(s[0],s[1]),s&&[s[0]*Q,s[1]*Q]}M.stream=function(s){return L&&D===s?L:L=Or(Br(i)(w(P(S(D=s)))))},M.preclip=function(s){return arguments.length?(w=s,c=void 0,T()):w},M.postclip=function(s){return arguments.length?(S=s,v=x=E=d=null,T()):S},M.clipAngle=function(s){return arguments.length?(w=+s?Hn(c=s*F):(c=null,kt),T()):c*Q},M.clipExtent=function(s){return arguments.length?(S=s==null?(v=x=E=d=null,yt):bt(v=+s[0][0],x=+s[0][1],E=+s[1][0],d=+s[1][1]),T()):v==null?null:[[v,x],[E,d]]},M.scale=function(s){return arguments.length?(e=+s,G()):e},M.translate=function(s){return arguments.length?(r=+s[0],o=+s[1],G()):[r,o]},M.center=function(s){return arguments.length?(a=s[0]%360*F,f=s[1]%360*F,G()):[a*Q,f*Q]},M.rotate=function(s){return arguments.length?(u=s[0]%360*F,g=s[1]%360*F,h=s.length>2?s[2]%360*F:0,G()):[u*Q,g*Q,h*Q]},M.angle=function(s){return arguments.length?(l=s%360*F,G()):l*Q},M.reflectX=function(s){return arguments.length?(p=s?-1:1,G()):p<0},M.reflectY=function(s){return arguments.length?(m=s?-1:1,G()):m<0},M.precision=function(s){return arguments.length?(P=yn(_,y=s*s),T()):Y(y)},M.fitExtent=function(s,C){return Mn(M,s,C)},M.fitSize=function(s,C){return lr(M,s,C)},M.fitWidth=function(s,C){return pr(M,s,C)},M.fitHeight=function(s,C){return sr(M,s,C)};function G(){var s=mr(e,0,0,p,m,l).apply(null,n(a,f)),C=mr(e,r-s[0],o-s[1],p,m,l);return i=Gn(u,g,h),_=Rt(n,C),z=Rt(i,_),P=yn(_,y),T()}function T(){return L=D=null,M}return function(){return n=t.apply(this,arguments),M.invert=n.invert&&Z,G()}}function dr(t){return function(n,e){var r=Y(n*n+e*e),o=t(r),a=N(o),f=A(o);return[U(n*a,r*f),J(r&&e*a/r)]}}function qn(t,n){return[A(n)*N(t),N(n)]}qn.invert=dr(J);function An(){return Pn(qn).scale(249.5).clipAngle(90+R)}window.TG={geoOrthographic:An,geoPath:En,geoGraticule10:an,geoDistance:en};})();