UNPKG

d3-geo-polygon

Version:

Clipping and geometric operations for spherical polygons.

3 lines (2 loc) 37.3 kB
// https://github.com/d3/d3-geo-polygon v2.0.1 Copyright 2017-2024 Mike Bostock !function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-array"),require("d3-geo"),require("d3-geo-projection")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-geo","d3-geo-projection"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{},t.d3,t.d3,t.d3)}(this,(function(t,n,e,o){"use strict";function r(){}function i(t,n){return t&&n&&t[0]===n[0]&&t[1]===n[1]}function l(t,n,e,o){this.x=t,this.z=n,this.o=e,this.e=o,this.v=!1,this.n=this.p=null}function c(t){const n=t.length;if(!n)return;let e,o=0,r=t[0];for(;++o<n;)r.n=e=t[o],e.p=r,r=e;r.n=e=t[0],e.p=r}const u=Math.abs,a=Math.atan,s=Math.atan2,f=Math.cos,p=Math.exp,h=Math.floor,g=Math.hypot,d=Math.log,m=Math.max,y=Math.min,M=Math.pow,P=Math.sign||function(t){return t>0?1:t<0?-1:0},A=Math.sin,E=Math.tan,G=1e-6,v=1e-12,w=Math.PI,x=w/2,S=w/4,C=Math.SQRT1_2,I=N(w),B=2*w,j=180/w,F=w/180;function D(t){return t>1?x:t<-1?-x:Math.asin(t)}function b(t){return t>1?0:t<-1?w:Math.acos(t)}function N(t){return t>0?Math.sqrt(t):0}function R(t){return[s(t[1],t[0]),D(t[2])]}function T(t){const n=R(t);return[n[0]*j,n[1]*j]}function q(t){const n=t[0],e=t[1],o=f(e);return[o*f(n),o*A(n),A(e)]}function H(t){return q([t[0]*F,t[1]*F])}function k(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function z(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 L(t){const n=g(t[0],t[1],t[2]);return[t[0]/n,t[1]/n,t[2]/n]}function O(t,n){const e=n[0]-t[0],o=n[1]-t[1],r=n[2]-t[2];return e*e+o*o+r*r<1e-24}function K(t,e){const o=e[0],r=e[1],i=[A(o),-f(o),0];let l=0,c=0;const u=new n.Adder;for(let n=0,e=t.length;n<e;++n)if(p=(a=t[n]).length){var a,p,h=a[p-1],g=h[0],d=h[1]/2+S,m=A(d),y=f(d);for(let t=0;t<p;++t,g=P,m=v,y=x,h=M){var M=a[t],P=M[0],E=M[1]/2+S,v=A(E),x=f(E),C=P-g,I=C>=0?1:-1,j=I*C,F=j>w,b=m*v;if(u.add(s(b*I*A(j),y*x+b*f(j))),l+=F?C+I*B:C,F^g>=o^P>=o){const t=L(z(q(h),q(M))),n=(F^C>=0?-1:1)*D(L(z(i,t))[2]);(r>n||r===n&&(t[0]||t[1]))&&(c+=F^C>=0?1:-1)}}}return(l<-G||l<G&&+u<-G)^1&c}function Q(t,e,o,u,a,{clipPoint:s=!1}={}){return void 0===a&&(a=U),function(f){const p=e(f),h=function(){let t,n=[];return{point:function(n,e,o,r){const i=[n,e];arguments.length>2&&(i.index=o,i.t=r),t.push(i)},lineStart:function(){n.push(t=[])},lineEnd:r,rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))},result:function(){const e=n;return n=[],t=null,e}}}(),g=e(h);let d,m,y,M=!1;const P={point:A,lineStart:G,lineEnd:v,polygonStart:function(){P.point=w,P.lineStart=x,P.lineEnd=S,m=[],d=[]},polygonEnd:function(){P.point=A,P.lineStart=G,P.lineEnd=v,m=n.merge(m);const t=K(d,u);m.length?(M||(f.polygonStart(),M=!0),function(t,n,e,o,r){const u=[],a=[];if(t.forEach((t=>{let n;if((n=t.length-1)<=0)return;let e=t[0];const o=t[n];if(i(e,o)){r.lineStart();for(let o=0;o<n;++o)r.point((e=t[o])[0],e[1]);return void r.lineEnd()}let c;u.push(c=new l(e,t,null,!0)),a.push(c.o=new l(e,null,c,!1)),u.push(c=new l(o,t,null,!1)),a.push(c.o=new l(o,null,c,!0))})),!u.length)return;a.sort(n),c(u),c(a);for(let t=0,n=a.length;t<n;++t)a[t].e=e=!e;let s,f,p=u[0];for(;;){let t=p,n=!0;for(;t.v;)if((t=t.n)===p)return;s=t.z,r.lineStart();do{if(t.v=t.o.v=!0,t.e){if(n)for(let t=0,n=s.length;t<n;++t)r.point((f=s[t])[0],f[1]);else o(t.x,t.n.x,1,r);t=t.n}else{if(n){s=t.p.z;for(let t=s.length-1;t>=0;--t)r.point((f=s[t])[0],f[1])}else o(t.x,t.p.x,-1,r);t=t.p}t=t.o,s=t.z,n=!n}while(!t.v);r.lineEnd()}}(m,a,t,o,f)):t&&(M||(f.polygonStart(),M=!0),o(null,null,1,f)),M&&(f.polygonEnd(),M=!1),m=d=null},sphere:()=>o(null,null,1,f)};function A(n,e){(!s&&!y||t(n,e))&&f.point(n,e)}function E(t,n){p.point(t,n)}function G(){P.point=E,p.lineStart()}function v(){P.point=A,p.lineEnd()}function w(t,n,e){y.push([t,n]),g.point(t,n,e)}function x(){g.lineStart(),y=[]}function S(){w(y[0][0],y[0][1],!0),g.lineEnd();const t=g.clean(),n=h.result(),e=n.length;let o,r,i;if(y.pop(),d.push(y),y=null,e)if(1&t){if(r=n[0],(o=r.length-1)>0){M||(f.polygonStart(),M=!0),f.lineStart();for(let t=0;t<o;++t)f.point((i=r[t])[0],i[1]);f.lineEnd()}}else e>1&&2&t&&n.push(n.pop().concat(n.shift())),m.push(n.filter(_))}return P}}function _(t){return t.length>1}function U(t,n){return((t=t.x)[0]<0?t[1]-x-G:x-t[1])-((n=n.x)[0]<0?n[1]-x-G:x-n[1])}class V{constructor(t,n){this.from=t,this.to=n,this.normal=z(t,n),this.fromNormal=z(this.normal,t),this.toNormal=z(this.normal,n),this.l=b(k(t,n))}}function W(t,n){if(O(t.from,n.from)||O(t.from,n.to))return t.from;if(O(t.to,n.from)||O(t.to,n.to))return t.to;const e=t.l+n.l<w?f(t.l+n.l)-G:-1;if(k(t.from,n.from)<e||k(t.from,n.to)<e||k(t.to,n.from)<e||k(t.to,n.to)<e)return;const o=L(z(t.normal,n.normal)),r=k(o,t.fromNormal),i=k(o,t.toNormal),l=k(o,n.fromNormal),c=k(o,n.toNormal);return r>=0&&i<=0&&l>=0&&c<=0?o:r<=0&&i>=0&&l<=0&&c>=0?o.map((t=>-t)):void 0}function J(t,n){const e=k(t,n.fromNormal),o=k(t,n.toNormal);return t=k(t,n.normal),u(t)<v&&(e>-1e-12&&o<v||e<v&&o>-1e-12)}const X={};const Y=t=>t;function Z(t){let n=!0;return function t(e){if("Polygon"===e.type&&(e={type:"MultiPolygon",coordinates:[e.coordinates]}),"MultiPolygon"!==e.type)return Y;const o=e.coordinates.map((t=>{const e=function(t){return(n,e)=>K(t,[n,e])}(t=t.map($)),o=function(t){const n=[];let e;return t.forEach(((t,o)=>{const r=q(t);return o&&n.push(new V(e,r)),e=r,t})),n}(t[0]);return Q(e,function(t,n){return function(e){let o,r,i,l,c,u,a,s=[];return{lineStart(){o=null,u=1,a=[]},lineEnd(){c&&s.push(a),s.forEach((t=>{e.lineStart(),t.forEach((t=>e.point(...t))),e.lineEnd()})),s=[]},point(e,p,h){-1==f(e)&&(e-=1e-5*P(A(e))),h&&(e=r,p=i);let g=q([.9999999999*e,p+1e-14]),d=c;if(o){const n=[];let r=new V(o,g);for(let i=0,l=100;i<t.length&&l>0;++i){const c=t[i],u=W(r,c);if(u){if(u===X||O(u,o)||O(u,g)||O(u,c.from)||O(u,c.to)){const t=1e-4;e=(e+3*w+et(i,l)*t)%(2*w)-w,p=y(w/2-t,m(t-w/2,p+et(i,l)*t)),r=new V(o,g=q([e,p])),i=-1,--l,n.length=0;continue}const t=R(u);u.distance=nt(o,u),u.index=i,u.t=nt(c.from,u),u[0]=t[0],u[1]=t[1],delete u[2],n.push(u)}}if(n.length){u=0,n.sort(((t,n)=>t.distance-n.distance));for(let t=0;t<n.length;++t){const e=n[t];d=!d,d?(a=[],a.push([e[0],e[1],e.index,e.t])):(a.push([e[0],e[1],e.index,e.t]),s.push(a))}}d&&a.push([e,p])}else{for(let n=0,o=100;n<t.length&&o>0;++n){if(J(g,t[n])){const t=1e-4;g=q([e=(e+3*w+et(n,o)*t)%(2*w)-w,p=y(w/2-1e-4,m(1e-4-w/2,p+et(n,o)*t))]),n=-1,--o}}l=d=n(r=e,i=p),d&&(a=[],a.push([e,p]))}o=g,c=d},clean:()=>u|(l&&c)<<1}}}(o,e),function(t,n){return(e,o,r,i)=>{if(null==e)i.polygonStart(),n.forEach((t=>{i.lineStart(),t.forEach((t=>i.point(t[0],t[1]))),i.lineEnd()})),i.polygonEnd();else if(e.index!==o.index&&null!=e.index&&null!=o.index)for(let n=e.index;n!==o.index;n=(n+r+t.length)%t.length){const e=t[n],o=R(r>0?e.to:e.from);i.point(o[0],o[1])}else if(e.index===o.index&&e.t>o.t&&null!=e.index&&null!=o.index)for(let n=0;n<t.length;++n){const o=t[(e.index+n*r+t.length)%t.length],l=R(r>0?o.to:o.from);i.point(l[0],l[1])}}}(o,t),t[0][0],tt,{clipPoint:n})}));function r(t){const n=o.map((n=>n(t)));return{point(t,e){n.forEach((n=>n.point(t,e)))},lineStart(){n.forEach((t=>t.lineStart()))},lineEnd(){n.forEach((t=>t.lineEnd()))},polygonStart(){n.forEach((t=>t.polygonStart()))},polygonEnd(){n.forEach((t=>t.polygonEnd()))},sphere(){n.forEach((t=>t.sphere()))}}}return r.polygon=n=>void 0!==n?t(e=n):e,r.clipPoint=o=>void 0!==o?(n=!!o,t(e)):n,r}(t)}function $(t){return t.map((t=>[t[0]*F,t[1]*F]))}function tt(t,n){return t=t.x,n=n.x,t.index-n.index||t.t-n.t}function nt(t,n){const e=z(t,n);return s(N(k(e,e)),k(t,n))}function et(t,n){return P(A(100*t+n))}function ot(t,n){const e=it(t[1],t[0]),o=it(n[1],n[0]),r=function(t,n){return s(t[0]*n[1]-t[1]*n[0],t[0]*n[0]+t[1]*n[1])}(e,o),i=lt(e)/lt(o);return rt([1,0,t[0][0],0,1,t[0][1]],rt([i,0,0,0,i,0],rt([f(r),A(r),0,-A(r),f(r),0],[1,0,-n[0][0],0,1,-n[0][1]])))}function rt(t,n){return[t[0]*n[0]+t[1]*n[3],t[0]*n[1]+t[1]*n[4],t[0]*n[2]+t[1]*n[5]+t[2],t[3]*n[0]+t[4]*n[3],t[3]*n[1]+t[4]*n[4],t[3]*n[2]+t[4]*n[5]+t[5]]}function it(t,n){return[t[0]-n[0],t[1]-n[1]]}function lt(t){return N(t[0]*t[0]+t[1]*t[1])}function ct(t,n){function o(t,e){const o=n(t,e),r=o.project([t*j,e*j]),i=o.transform;return i?[i[0]*r[0]+i[1]*r[1]+i[2],-(i[3]*r[0]+i[4]*r[1]+i[5])]:[r[0],-r[1]]}function r(t,e){const o=t.project.invert;let i,l=e,c=t.transform;if(c&&(c=function(t){const n=1/(t[0]*t[4]-t[1]*t[3]);return[n*t[4],-n*t[1],n*(t[1]*t[5]-t[2]*t[4]),-n*t[3],n*t[0],n*(t[2]*t[3]-t[0]*t[5])]}(c),l=[c[0]*l[0]+c[1]*l[1]+c[2],c[3]*l[0]+c[4]*l[1]+c[5]]),o&&t===function(t){return n(t[0]*F,t[1]*F)}(i=o(l)))return i;const u=t.children;for(let t=0,n=u&&u.length;t<n;++t)if(i=r(u[t],e),i)return i}!function t(n,e){if(n.edges=function(t){const n=t.length,e=[];for(let o=0,r=t[n-1];o<n;++o)e.push([r,r=t[o]]);return e}(n.face),e.face){const t=n.shared=function(t,n){const e=t.length;let o,r,i=null;for(let l=0;l<e;++l){o=t[l];for(let t=n.length;--t>=0;)if(r=n[t],o[0]===r[0]&&o[1]===r[1]){if(i)return[i,o];i=o}}}(n.face,e.face),o=ot(t.map(e.project),t.map(n.project));n.transform=e.transform?rt(e.transform,o):o;let r=e.edges;for(let e=0,o=r.length;e<o;++e)i(t[0],r[e][1])&&i(t[1],r[e][0])&&(r[e]=n),i(t[0],r[e][0])&&i(t[1],r[e][1])&&(r[e]=n);r=n.edges;for(let n=0,o=r.length;n<o;++n)i(t[0],r[n][0])&&i(t[1],r[n][1])&&(r[n]=e),i(t[0],r[n][1])&&i(t[1],r[n][0])&&(r[n]=e)}else n.transform=e.transform;n.children&&n.children.forEach((e=>t(e,n)));return n}(t,{transform:null}),at(t)&&(o.invert=function(n,e){const o=r(t,[n,-e]);return o&&(o[0]*=F,o[1]*=F,o)});const l=e.geoProjection(o),c=[],u={type:"MultiPolygon",coordinates:[[c]]};return ut({point:(t,n)=>c.push([t,n])},t),c.push(c[0]),l.preclip(Z(u).clipPoint(e.geoArea(u)<4*Math.PI-.1)),l.tree=function(){return t},l}function ut(t,n,o){let r,i,l=n.edges,c=l.length,a={type:"MultiPoint",coordinates:n.face},s=n.face.filter((function(t){return 90!==u(t[1])})),f=e.geoBounds({type:"MultiPoint",coordinates:s}),p=!1,h=-1,g=f[1][0]-f[0][0];if(n.centroid=180===g||360===g?[(f[0][0]+f[1][0])/2,(f[0][1]+f[1][1])/2]:e.geoCentroid(a),o)for(;++h<c&&l[h]!==o;);++h;for(let u=0;u<c;++u)i=l[(u+h)%c],Array.isArray(i)?(p||(t.point((r=e.geoInterpolate(i[0],n.centroid)(G))[0],r[1]),p=!0),t.point((r=e.geoInterpolate(i[1],n.centroid)(G))[0],r[1])):(p=!1,i!==o&&ut(t,i,n))}function at(t){return t.project.invert||t.children&&t.children.some(at)}const st=[[0,90],[-90,0],[0,0],[90,0],[180,0],[0,-90]];var ft=[[0,2,1],[0,3,2],[5,1,2],[5,2,3],[0,1,4],[0,4,3],[5,4,1],[5,3,4]].map((t=>t.map((t=>st[t]))));function pt(t,n){const e=N(1-A(n));return[2/I*t*e,I*(1-e)]}pt.invert=function(t,n){const e=n/I-1;return[e?t*N(w)/e/2:0,D(1-e**2)]};const ht=2/N(3);function gt(t,n){const e=pt(t,n);return[e[0]*ht,e[1]]}function dt(t,n){let e=0;for(let o=0;o<t.length;++o)e+=t[o]*n[o];return e}function mt(t){return[s(t[1],t[0])*j,D(m(-1,y(1,t[2])))*j]}function yt(t){const n=t[0]*F,e=t[1]*F,o=f(e);return[o*f(n),o*A(n),A(e)]}gt.invert=(t,n)=>pt.invert(t/ht,n);const Mt=t=>e.geoGnomonic().scale(1).translate([0,0]).rotate([Math.abs(t.site[1])>89.99999999?0:-t.site[0],-t.site[1]]);function Pt(t=[],n={features:[]},o=Mt,r){void 0===r&&(r=function(t,n){let o=1/0,r=-1;for(let l=0;l<i.length;l++){const c=e.geoDistance(i[l].site,[t,n]);c<o&&(o=c,r=l)}return r});let i=[];function l(){i=n.features.map(((t,n)=>{const r=t.geometry.coordinates[0].slice(0,-1);return r.site=t.properties&&t.properties.sitecoordinates?t.properties.sitecoordinates:e.geoCentroid(t.geometry),{face:r,site:r.site,id:n,project:o(r)}})),t.forEach(((t,n)=>{const e=i[t];e&&(e.children||(e.children=[])).push(i[n])}))}function c(t,n){return i[r(t*j,n*j)]}let u=e.geoGnomonic();return l(),function e(){let a=u.rotate(),s=u.translate(),f=u.center(),p=u.scale(),h=u.angle();return i.length&&(u=ct(i.find(((n,e)=>n&&!i[t[e]])),c)),u.parents=function(n){return arguments.length?(t=n,l(),e()):t},u.polygons=function(t){return arguments.length?(n=t,l(),e()):n},u.faceProjection=function(t){return arguments.length?(o=t,l(),e()):o},u.faceFind=function(t){return arguments.length?(r=t,e()):r},u.rotate(a).translate(s).center(f).scale(p).angle(h)}()}function At(t){function n(n,e){if(u(u(e)-x)<G)return[0,e<0?-2:2];const o=A(e),r=M((1+o)/(1-o),t/2),i=.5*(r+1/r)+f(n*=t);return[2*A(n)/i,(r-1/r)/i]}return n.invert=(n,e)=>{const o=u(e);if(u(o-2)<G)return n?null:[0,P(e)*x];if(o>2)return null;const r=(n/=2)*n,i=(e/=2)*e;let l=2*e/(1+r+i);return l=M((1+l)/(1-l),1/t),[s(2*n,1-r-i)/t,D((l-1)/(l+1))]},n}function Et(t,n){return[t[0]*n[0]-t[1]*n[1],t[1]*n[0]+t[0]*n[1]]}function Gt(t,n){return[t[0]+n[0],t[1]+n[1]]}function vt(t,n){return[t[0]-n[0],t[1]-n[1]]}function wt(t){return t[0]*t[0]+t[1]*t[1]}function xt(t,n){const e=u(t),o=u(n);return 0===t?d(o):0===n?d(e):e<3e3&&o<3e3?.5*d(t*t+n*n):d(t/f(s(n,t)))}function St(t,n){let e,o,r=t[1];if(0===(t=t[0])&&0===r)return[0,0];if("number"==typeof n&&(n=[n,0]),!n[1]){if(0===r&&t>=0)return[M(t,n[0]),0];if(0===t)switch((n[1]%4+4)%4){case 0:return[M(r,n[0]),0];case 1:return[0,M(r,n[0])];case 2:return[-M(r,n[0]),0];case 3:return[0,-M(r,n[0])]}}return e=s(r,t),o=xt(t,r),t=p(n[0]*o-n[1]*e),r=n[1]*o+n[0]*e,[t*f(r),t*A(r)]}const Ct=[-.5,N(3)/2],It=[1.7666387502854533,0],Bt=.09;const jt=At?At(.5):null;function Ft(t,e){const o=jt(t,e),r=function(t){const e=St(Ct,n.scan([0,1,2].map((function(n){return-Et(t,St(Ct,[n,0]))[0]}))));let o=Et(e,t);o=[1-o[0],-o[1]];const r=[1.44224957030741,.240374928384568,.0686785509670194,.0178055502507087,.00228276285265497,-.00148379585422573,-.00164287728109203,-.00102583417082273,-.000483607537673571,-.000167030822094781,-245024395166263e-19,214092375450951e-19,255897270486771e-19,173086854400834e-19,872756299984649e-20,318304486798473e-20,4.79323894565283e-7,-4.58968389565456e-7,-5.62970586787826e-7,-3.92135372833465e-7];let i=[0,0];for(let t=r.length;t--;)i=Gt([r[t],0],Et(i,o));let l=Et(Gt(It,Et([-i[0],-i[1]],St(o,1-2/3))),Et(e,e));const c=wt(t);if(c<Bt){const n=[1,1/3,5/27,10/81,22/243],e=St(t,[3,0]);let o=[0,0];for(let t=n.length;t--;)o=Gt([n[t],0],Et(o,e));o=Et(o,t),l=Gt(Et(l,[c/Bt,0]),Et(o,[1-c/Bt,0]))}return l}([o[1]/2,o[0]/2]);return[r[1],r[0]]}function Dt(t,n=40,e=1e-12){return(o,r,i=0,l=0)=>{let c,a,s;for(let f=0;f<n;++f){const n=t(i,l),f=n[0]-o,p=n[1]-r;if(u(f)<e&&u(p)<e)break;const h=f*f+p*p;if(h>c){i-=a/=2,l-=s/=2;continue}c=h;const g=(i>0?-1:1)*e,d=(l>0?-1:1)*e,m=t(i+g,l),y=t(i,l+d),M=(m[0]-n[0])/g,P=(m[1]-n[1])/g,A=(y[0]-n[0])/d,E=(y[1]-n[1])/d,G=E*M-P*A,v=(u(G)<.5?.5:1)/G;if(a=(p*A-f*E)*v,s=(f*P-p*M)*v,i+=a,l+=s,u(a)<e&&u(s)<e)break}return[i,l]}}function bt(t,o){const r=[-.5,N(3)/2];let i=[0,0],l=[0,0],c=Et(e.geoStereographicRaw(t,o),[N(2),0]);const u=n.greatest([0,1,2],(t=>Et(c,St(r,[t,0]))[0])),a=St(r,[u,0]),s=N(wt(c));if(s>.3){const t=vt([1,0],Et(a,c)),n=1.4021821053254548,e=[1.15470053837925,.192450089729875,.0481125224324687,.010309826235529,.000334114739114366,-.00150351632601465,-.0012304417796231,-.000675190201960282,-.000284084537293856,-821205120500051e-19,-159257630018706e-20,191691805888369e-19,173095888028726e-19,103865580818367e-19,470614523937179e-20,14413500104181e-19,1.92757960170179e-8,-3.82869799649063e-7,-3.57526015225576e-7,-2.2175964844211e-7];let o=[0,0];for(let n=e.length;n--;)o=Gt([e[n],0],Et(o,t));i=vt([n,0],Et(St(t,.5),o)),i=Et(i,a),i=Et(i,a)}if(s<.5){const t=[1,1/8,3/56,1/32,35/1664,63/4096,231/19456],n=St(c,[3,0]);for(let e=t.length;e--;)l=Gt([t[e],0],Et(l,n));l=Et(l,c)}if(s<.3)return l;if(s>.5)return i;const f=(s-.3)/.2;return Gt(Et(i,[f,0]),Et(l,[1-f,0]))}const Nt=Dt(bt);bt.invert=function(t,n){if(t>1.5)return!1;const e=Nt(t,n,t,.5*n),o=bt(e[0],e[1]);return o[0]-=t,o[1]-=n,o[0]*o[0]+o[1]*o[1]<1e-8?e:[-10,0]};const Rt=D(1/3),Tt=[[0,90],[-180,-Rt*j],[-60,-Rt*j],[60,-Rt*j]],qt=[[1,2,3],[0,2,1],[0,3,2],[0,1,3]].map((t=>t.map((t=>Tt[t]))));function Ht(){const t=N(3),n=N(5+2*N(5))/N(15),o=N(8)/N(5+N(5)),r=N(3+N(5))/N(5+N(5)),i=function(e,i){const l=f(i),c=n/(l*f(e)),u=l*A(e)*c,a=A(i)*c,p=s(2*a/t+o/3-o/2,r),h=s(u-a/t+o/3-o/2,r),g=s(o/3-u-a/t-o/2,r);return[t*(h-g),2*p-h-g]};return i.invert=function(t,n){if(t*t+n*n>5)return[0,3];const o=2.9309936378128416,r=e.geoGnomonicRaw.invert(t/o,n/o);let l,c,a=0;do{const e=i(r[0],r[1]);l=t-e[0],c=n-e[1],r[0]+=.2*l,r[1]+=.2*c}while(a++<30&&u(l)+u(c)>G);return r},i}const kt=D(1/3),zt=[[x,0,0,-x,0,N(3)],[-kt,0,w,x,0,-N(3)],[-kt,2*w/3,w,5*w/6,3,0],[-kt,-2*w/3,w,w/6,-3,0]],Lt={sphereSym:3,planarSym:6,width:6,height:2*N(3),centrums:zt,rotateOOB:function(t,n,e,o){return u(t)>this.width/2?[2*e-t,-n]:[-t,this.height*P(n)-n]},inBounds:()=>!0};function Ot(t){function n(n,e){const o=function(t,n,e){let o,r,i,l=100;e=void 0===e?0:+e,n=+n;do{r=t(e),i=t(e+G),r===i&&(i=r+G),e-=o=-1e-6*(r-n)/(r-i)}while(l-- >0&&u(o)>G);return l<0?NaN:e}((t=>a((t-D(A(t)/N(3)))/w*N(12))),e,e/2),r=n/(N(3)/f(e));return[x-M(r,1/t)*a(N(2)/f(o)),o]}function e(t,n,e){if(null==e)return[t,n];const o=e[0],r=e[1],i=e[2];let l,c;return l=o==x?t:D(A(o)*A(t)+f(o)*f(t)*f(r-n)),o==x?c=n-r:o==-x?c=r-n-w:(c=b((f(o)*A(t)-A(o)*f(t)*f(r-n))/f(l))-w,isNaN(c)?c=f(r-n)>=0&&t<o||f(r-n)<0&&t<-o?0:-w:A(n-r)>0&&(c=-c)),c-=i,[l,c]}function o(n,o){const r=Lt.width,i=Lt.height,l=Lt.sphereSym;let c=-1/0,s=-1/0,p=null;for(const t of zt){const r=e(o,n,t);r[0]>c&&(c=r[0],s=r[1],p=t)}const g=h((s+w/l)/(2*w/l))*(2*w/l),d=function(n,e){const o=a((n-D(A(n)/N(3)))/w*N(12)),r=(x-e)/a(N(2)/f(n));return[M(r,t)*N(3)/f(o),o]}(s-g,c),m=d[0],y=d[1]+p[3]+g*l/Lt.planarSym,P=p[4],E=p[5];let G=[m*f(y)+P,m*A(y)+E];return(u(G[0])>r/2||u(G[1])>i/2)&&(G=Lt.rotateOOB(G[0],G[1],P,E)),G}return o.invert=function(t,e){if(isNaN(t)||isNaN(e))return null;const o=Lt.planarSym;let r=1/0,i=null;for(const n of zt){const o=g(t-n[4],e-n[5]);o<r&&(r=o,i=n)}const l=i[3],c=i[4],a=i[5],p=g(t-c,e-a),d=s(e-a,t-c)-l,m=h((d+w/o)/(2*w/o))*(2*w/o);let y=n(p,d-m);if(null==y)return null;y[1]=m*o/Lt.sphereSym+y[1];let M=function(t,n){if(null==n)return t;let e=t[0],o=t[1];const r=n[0],i=n[1];o+=n[2];let l,c=D(A(r)*A(e)-f(r)*f(o)*f(e)),a=A(e)/f(r)/f(c)-E(r)*E(c);return l=r==x?o+i:r==-x?-o+i+w:u(a)>1?0==o&&e<-r||0!=o&&e<r?i+w:i:A(o)>0?i+b(a):i-b(a),[c,l,n[2]]}(y,i);return[M[1],M[0]]},o}function Kt(t,n){const e=Ot(t),o=Lt.height;function r(t,r){const i=e(t,r),l=[i[1],-i[0]];return l[1]>0&&(l[0]=o-l[0],l[1]*=-1),l[0]+=n,l[0]<0&&(l[0]+=2*o),l}return r.invert=function(t,r){return(t=(t-n)/o)>1.5&&(t-=2),t>.5&&(t=1-t,r*=-1),e.invert(-r,t*o)},r}const Qt=a(C)*j,_t=[[0,Qt],[90,Qt],[180,Qt],[-90,Qt],[0,-Qt],[90,-Qt],[180,-Qt],[-90,-Qt]],Ut=[[0,3,2,1],[0,1,5,4],[1,2,6,5],[2,3,7,6],[3,0,4,7],[4,5,6,7]].map((t=>t.map((t=>_t[t]))));function Vt(t){const n={lengthMG:t};function e(t,n){return Math.hypot(t[0]-n[0],t[1]-n[1])}function o(t,n,e,o){return[e[0]+(o[0]-e[0])*t/n,e[1]+(o[1]-e[1])*t/n]}function r(t,n,e,o){const r=E(n*F),i=E(o*F),l=(r*t[0]-i*e[0]-t[1]+e[1])/(r-i);return[l,r*(l-t[0])+t[1]]}function i(t,n,e,o){let r=e[0],i=e[1],l=o[0],c=o[1],u=t[0],a=t[1],s=(l-r)*(l-r)+(c-i)*(c-i),f=2*((l-r)*(r-u)+(c-i)*(i-a)),p=f*f-4*s*(u*u+a*a+r*r+i*i-2*(u*r+a*i)-n*n),h=0,g=0,d=0,m=0;return 0===s||p<0?[0,[0,0]]:(h=(-f+N(p))/(2*s),g=(-f-N(p))/(2*s),0<=h&&h<=1?(d=r+h*(l-r),m=i+h*(c-i),[1,[d,m]]):0<=g&&g<=1?(d=r+g*(l-r),m=i+g*(c-i),[1,[d,m]]):[0,[0,0]])}function l(t,e){const o=[0,0];return-60===e?(o[0]=t[0]*n.cos60+t[1]*n.sin60,o[1]=-t[0]*n.sin60+t[1]*n.cos60):-120===e?(o[0]=-t[0]*n.cos60+t[1]*n.sin60,o[1]=-t[0]*n.sin60-t[1]*n.cos60):(o[0]=t[0]*f(e*F)-t[1]*A(e*F),o[1]=t[0]*A(e*F)+t[1]*f(e*F)),o}function c(t){const e=n.deltaMEq*t;return e<=n.lengthGF?[n.pointG[0],e]:o(e-n.lengthGF,n.lengthAB,n.pointF,n.pointE)}function a(t){return c(t)}function s(t){return r(n.pointM,2*t/3,a(t),t/3)}function p(t){return 0===t?[n.pointA+n.lengthAB,0]:r(n.pointA,t,n.pointM,2*t/3)}function h(t){return e(a(t),s(t))}function g(t){return e(s(t),p(t))}function d(t){let o=[0,0],i=p(t),l=0,c=[0,0];return t<=30?(o[0]=n.pointA[0]+n.lengthAP73*f(t*F),o[1]=n.pointA[1]+n.lengthAP73*A(t*F),l=e(i,o)):(o=r(n.pointT,-60,i,t),l=e(i,o),t>44&&(c=r(n.pointT,-60,i,2/3*t),c[0]>o[0]&&(o=c,l=-e(i,o)))),{parallel73:o,lengthParallel73:l}}function m(t){return[n.pointA[0]+n.lengthAP75*f(t*F),n.pointA[1]+n.lengthAP75*A(t*F)]}function y(t,n){let e=(o=(t+180)/90+1,Math[o>0?"floor":"ceil"](o));var o;let r=(t+720)%90-45;const i=P(r);return r=u(r),5===e&&(e=1),n<0&&(e=[0,6,7,8,5][e]),[r,u(n),i,e]}function M(t,r){if(0===t)return r>=75?function(t,e){return[n.pointA[0]+104*(90-e),0]}(0,r):function(t,e){return[n.pointG[0]-100*e,0]}(0,r);if(r>=75)return function(t,e){const o=104*(90-e);return[n.pointA[0]+o*f(t*F),n.pointA[1]+o*A(t*F)]}(t,r);if(0===r)return function(t){return c(t)}(t);if(r>=73&&t<=30)return function(t,e){const o=1560+100*(75-e);return[n.pointA[0]+o*f(t*F),n.pointA[1]+o*A(t*F)]}(t,r);if(45===t)return r<=15?function(t,e){return o(e,15,n.pointE,n.pointD)}(0,r):r<=73?function(t,e){return o(e-15,58,n.pointD,n.pointT)}(0,r):function(t,r){const i=m(45),l=d(t).parallel73,c=e(n.pointT,n.pointB),u=e(n.pointB,i),a=(75-r)*(u+c)/2;return a<=u?o(a,u,i,n.pointB):o(a-u,c,n.pointB,l)}(t,r);if(t<=29)return function(t,n){const e=d(t),r=h(t),i=g(t),l=n*(r+i+e.lengthParallel73)/73;return l<=r?o(l,r,a(t),s(t)):l<=r+i?o(l-r,i,s(t),p(t)):o(l-r-i,e.lengthParallel73,p(t),e.parallel73)}(t,r);if(r>=73)return function(t,n){const r=m(t),i=e(p(t),r),l=d(t),c=l.parallel73,u=l.lengthParallel73,a=(75-n)*(i-u)/2;return a<=i?o(a,i,r,p(t)):o(a-i,-u,p(t),c)}(t,r);{const l=h(t);let c,u=i(n.pointC,n.radius,s(t),p(t)),f=u[0],m=u[1];return 1===f?c=l+e(s(t),m):(u=i(n.pointC,n.radius,a(t),s(t)),f=u[0],m=u[1],c=l-e(s(t),m)),r<=15?function(t,n,e){const r=n*e/15,i=h(t),l=g(t);return r<=i?o(r,i,a(t),s(t)):o(r-i,l,s(t),p(t))}(t,r,c):function(t,n,e){const r=d(t),i=r.parallel73,l=h(t),c=g(t),u=r.lengthParallel73,f=e+(n-15)*(l+c+u-e)/58;return f<=l?o(f,l,a(t),p(t)):f<=l+c?o(f-l,c,s(t),p(t)):o(f-l-c,u,p(t),i)}(t,r,c)}}function G(t,e){const o=y(t*j,e*j),r=o[0],i=o[1],c=o[2],u=o[3],a=M(r,i);return function(t,e){let o;return 0===e?o=l(t,-60):1===e?(o=l(t,-120),o[0]-=n.lengthMG):2===e?(o=l(t,-60),o[0]-=n.lengthMG):3===e?(o=l(t,-120),o[0]+=n.lengthMG):4===e?(o=l(t,-60),o[0]+=n.lengthMG):5===e?(o=l([2*n.lengthMG-t[0],t[1]],-60),o[0]+=n.lengthMG):6===e?(o=l([2*n.lengthMG-t[0],t[1]],-120),o[0]-=n.lengthMG):7===e?(o=l([2*n.lengthMG-t[0],t[1]],-60),o[0]-=n.lengthMG):8===e&&(o=l([2*n.lengthMG-t[0],t[1]],-120),o[0]+=n.lengthMG),o}([a[0],c*a[1]],u)}return function(){let t,i,l,c,u,a,m,y,M,P,G,v=N(3);n.lengthMA=.094*n.lengthMG,n.lengthParallel0to73At0=n.lengthMG/100,n.lengthParallel73to90At0=(n.lengthMG-n.lengthMA-73*n.lengthParallel0to73At0)/17,n.sin60=v/2,n.cos60=.5,n.pointM=[0,0],n.pointG=[n.lengthMG,0],t=[n.lengthMG,n.lengthMG*E(30*F)],n.pointA=[n.lengthMA,0],n.pointB=r(n.pointM,30,n.pointA,45),n.lengthAG=e(n.pointA,n.pointG),n.lengthAB=e(n.pointA,n.pointB),i=e(n.pointM,n.pointB),l=e(n.pointM,t),c=e(t,n.pointG),n.pointD=o(i,l,t,n.pointM),n.pointF=[n.lengthMG,c-i],n.pointE=[t[0]-n.lengthMA*A(30*F),t[1]-n.lengthMA*f(30*F)],n.lengthGF=e(n.pointG,n.pointF),n.lengthBD=e(n.pointB,n.pointD),n.lengthBDE=n.lengthBD+n.lengthAB,n.lengthGFE=n.lengthGF+n.lengthAB,n.deltaMEq=n.lengthGFE/45,n.lengthAP75=15*n.lengthParallel73to90At0,n.lengthAP73=n.lengthMG-n.lengthMA-73*n.lengthParallel0to73At0,u=[n.pointA[0]+n.lengthAP73*f(30*F),n.pointA[1]+n.lengthAP73*A(30*F)],n.pointT=r(u,-60,n.pointB,30),a=d(29),m=a.lengthParallel73,y=h(29),M=g(29),P=15*(y+M+m)/73,G=[0,0],n.pointC=[0,0],n.radius=0,P-=y,G=o(P,M,s(29),p(29)),n.pointC[1]=(G[0]*G[0]+G[1]*G[1]-n.pointD[0]*n.pointD[0]-n.pointD[1]*n.pointD[1])/(2*(v*G[0]+G[1]-v*n.pointD[0]-n.pointD[1])),n.pointC[0]=v*n.pointC[1],n.radius=e(n.pointC,n.pointD)}(),G.invert=Dt(G),G}const Wt=e.geoAzimuthalEqualAreaRaw,Jt=-.05,Xt=90,Yt=[0,5.022570623227068],Zt=79.92959180396787,$t=[479.9999905630355,250.35977064160338],tn=[[-180,-1e-4],[180,-1e-4],[1e-4,Jt],[-1e-4,Jt]];function nn(t=Wt){function n(n,e){const o=Et(t(n,e),[f(-w/2),A(-w/2)]);return 0==o[0]&&0==o[1]&&(o[0]+=1e-10,o[1]+=1e-10),[xt(o[0],o[1]),s(o[1],o[0])]}return n.invert=function(n,e){const o=Et([p(n)*f(e),p(n)*A(e)],[f(w/2),A(w/2)]);return t.invert(o[0],o[1])},n}function en(){return ln.apply(this,arguments)}function on(t,n=!1){const{lobes:e}=t;return function t(o){const r=o.rotate(),i=o.scale(),l=o.translate();o.rotate([0,0]).translate([0,0]),o.lobes=function(n){return arguments.length?t(e(n)):e()},o.preclip((t=>t));const c=1-1e-7,u=n?1:c;let a=[];return o.stream({point(t,n){a.push([t*u,n*c])},lineStart(){},lineEnd(){},polygonStart(){},polygonEnd(){},sphere(){}}).sphere(),o.scale(i),a=a.map(o.invert),a.push(a[0]),o.rotate(r).translate(l).preclip(Z({type:"Polygon",coordinates:[a]}))}(t)}function rn(t){const{lobes:o}=t;return function t(r){const i=o?.(),l=n.merge(Array.from(i,((t,n)=>{const o=t.flatMap((t=>Array.from(t,(n=>e.geoInterpolate(n,[t[1][0],0])(1e-9)))));return 0===n?o:[...o].reverse()})));return r.lobes=function(n){return arguments.length?t(o(n)):o()},r.preclip(Z({type:"Polygon",coordinates:[[...l,l[0]]]}))}(t)}function ln(t,n){const r=.001,i=90*e.geoDistance(t,n)/Math.PI+r,l={type:"Polygon",coordinates:[[[180-i,r],[180-i,-.001],[-180+i,-.001],[-180+i,r],[180-i,r]]]};return o.geoTwoPointEquidistant(t,n).preclip(Z(l).clipPoint(!1))}t.geoAirocean=function(){return function(t){const o=a(.5)*j,r=[[0,90],[0,-90]].concat(n.range(10).map((t=>[(36*t+180)%360-180,1&t?o:-o]))),i=[[0,3,11],[0,5,3],[0,7,5],[0,9,7],[0,11,9],[2,11,3],[3,4,2],[4,3,5],[5,6,4],[6,5,7],[7,8,6],[8,7,9],[9,10,8],[10,9,11],[11,2,10],[1,2,4],[1,4,6],[1,6,8],[1,8,10],[1,10,2]].map((t=>t.map((t=>r[t]))));return i.forEach((t=>t.centroid=e.geoCentroid({type:"MultiPoint",coordinates:t}))),function(){let t,n,o,r;t=i[15],r=t.centroid,n=t.slice(),t[0]=r,t=[n[0],r,n[2]],t.centroid=r,i.push(t),t=[n[0],n[1],r],t.centroid=r,i.push(t),t=i[14],r=t.centroid,n=t.slice();const l=e.geoGnomonic().scale(1).translate([0,0]).rotate([-r[0],-r[1]]),c=l(t[1]),u=l(t[2]);o=l.invert([(c[0]+u[0])/2,(c[1]+u[1])/2]),t[1]=o,t=[n[0],n[1],o],t.centroid=r,i.push(t),t=i[19],r=t.centroid,n=t.slice(),t[1]=o,t=[o,n[0],n[1]],t.centroid=r,i.push(t)}(),function(t){t=t||(t=>e.geoGnomonic().scale(1).translate([0,0]).rotate([-t.centroid[0],-t.centroid[1]]));const n=i.map(((n,o)=>{const r=n.slice();return r.push(r[0]),{face:n,site:n.centroid,id:o,contains:function(t,n){return e.geoContains({type:"Polygon",coordinates:[r]},[t*j,n*j])},project:t(n)}}));[-1,0,1,11,13,6,7,1,7,8,9,10,11,12,13,6,8,10,17,21,16,15,19,19].forEach(((t,e)=>{const o=n[t];o&&(o.children||(o.children=[])).push(n[e])}));const o=ct(n[0],(function(t,e){for(let o=0;o<n.length;++o)if(n[o].contains(t,e))return n[o]}));return o.faces=n,o}(t)}((t=>{const n=t.centroid;return t.direction=Math.abs(n[1]-52.62)<1||Math.abs(n[1]+10.81)<1?0:60,e.geoProjection(Ht()).scale(1).translate([0,0]).rotate([-n[0],-n[1],t.direction||0])})).rotate([-83.65929,25.44458,-87.45184]).angle(-60).scale(45.4631).center([126,0])},t.geoBerghaus=function(){return on(o.geoBerghaus.apply(this,arguments))},t.geoCahillKeyes=function(t){t=t||(()=>function(){const t=1e4,n=e.geoProjectionMutator(Vt);return n(t)}().scale(1));const n=[[0,90],[-90,0],[0,0],[90,0],[180,0],[0,-90]],o=[[0,2,1],[0,3,2],[5,1,2],[5,2,3],[0,1,4],[0,4,3],[5,4,1],[5,3,4]].map((t=>t.map((t=>n[t])))),r=o.map((t=>{const n=t.map(H),e=n.length,o=17*F,r=f(o),i=A(o),l=[];let c,u=n[e-1];for(let t=0;t<e;++t)c=n[t],l.push(T([u[0]*r+c[0]*i,u[1]*r+c[1]*i,u[2]*r+c[2]*i]),T([c[0]*r+u[0]*i,c[1]*r+u[1]*i,c[2]*r+u[2]*i])),u=c;return l})),i=[],l=[-1,3,0,2,0,1,4,5];r.forEach(((t,n)=>{const e=o[n],c=e.length,u=i[n]=[];for(let o=0;o<c;++o)r.push([e[o],t[(2*o+2)%(2*c)],t[(2*o+1)%(2*c)]]),l.push(n),u.push(z(H(t[(2*o+2)%(2*c)]),H(t[(2*o+1)%(2*c)])))}));const c=r.map((n=>({project:t(n),face:n})));return l.forEach(((t,n)=>{const e=c[t];e&&(e.children||(e.children=[])).push(c[n])})),ct(c[0],(function(t,n){const e=f(n),o=[e*f(t),e*A(t),A(n)],r=t<-w/2?n<0?6:4:t<0?n<0?2:0:t<w/2?n<0?3:1:n<0?7:5,l=i[r];return c[k(l[0],o)<0?8+3*r:k(l[1],o)<0?8+3*r+1:k(l[2],o)<0?8+3*r+2:r]})).scale(.023975).rotate([20,0]).center([0,-17])},t.geoCahillKeyesRaw=Vt,t.geoClipPolygon=Z,t.geoComplexLog=function(t=Wt,n=-.05){const o=e.geoProjectionMutator(nn),r=o(t);function i(t){const e=t.angle(),o=t.scale(),r=t.center(),i=t.translate(),l=t.rotate();t.angle(Xt).scale(1).center([0,0]).rotate([0,0]).translate([0,0]).preclip();const c=t(tn[0]),a=t(tn[1]),s=t([tn[2][0],n]),f=t([tn[3][0],n]),p=u(a[0]-c[0]),h=u(s[1]-a[1]),g={type:"Polygon",coordinates:[[c,...Array.from({length:5},((t,n)=>[s[0],s[1]-h*(5-n)/5])),...Array.from({length:50},((t,n)=>[s[0]-p*n/50,s[1]])),...Array.from({length:5},((t,n)=>[f[0],f[1]-h*n/5])),c].map((n=>t.invert(n)))]};return t.angle(e).scale(o).center(r).translate(i).rotate(l).preclip(Z(g))}return r.planarProjectionRaw=function(n){return arguments.length?i(o(t=n)):t},r.cutoffLatitude=function(e){return arguments.length?(n=e,i(o(t))):n},i(r).angle(Xt).center(Yt).scale(Zt).translate($t)},t.geoComplexLogRaw=nn,t.geoCox=function(){const t=e.geoProjection(Ft),n=t.stream;return t.stream=function(o){const r=t.rotate(),i=n(o),l=(t.rotate([0,0]),n(o));return t.rotate(r),i.sphere=function(){e.geoStream(function(){const t=2*D(1/N(5))*j;return{type:"Polygon",coordinates:[[[0,90],[-180,-t+G],[0,-90],[180,-t+G],[0,90]]]}}(),l)},i},t.scale(188.305).translate([480,333.167])},t.geoCoxRaw=Ft,t.geoCubic=function(){const t={type:"FeatureCollection",features:Ut.map((t=>({type:"Feature",geometry:{type:"Polygon",coordinates:[[...t,t[0]]]}})))};return Pt().polygons(t).parents([-1,0,1,5,3,2]).scale(96.8737).center([135,-45]).rotate([120,0])},t.geoDeltoidal=function(){const t=a(.5)*j,n=[[0,90],[0,-90]].concat([0,1,2,3,4,5,6,7,8,9].map((n=>[(36*n+180)%360-180,1&n?t:-t]))),o={type:"FeatureCollection",features:[[0,3,11],[0,5,3],[0,7,5],[0,9,7],[0,11,9],[2,11,3],[3,4,2],[4,3,5],[5,6,4],[6,5,7],[7,8,6],[8,7,9],[9,10,8],[10,9,11],[11,2,10],[1,2,4],[1,4,6],[1,6,8],[1,8,10],[1,10,2]].map((t=>{const o=t.map((t=>n[t])),r=e.geoInterpolate(o[1],o[2])(.5),i=e.geoInterpolate(o[0],o[2])(.5),l=e.geoInterpolate(o[0],o[1])(.5),c=e.geoCentroid({type:"MultiPoint",coordinates:o});return[[o[0],l,c,i],[o[1],r,c,l],[o[2],i,c,r]]})).flat().map((t=>({type:"Feature",properties:{sitecoordinates:e.geoCentroid({type:"MultiPoint",coordinates:t})},geometry:{type:"Polygon",coordinates:[[...t,t[0]]]}})))};return Pt().parents([-1,2,0,5,5,22,8,8,28,11,11,34,14,14,40,16,2,16,17,18,18,19,21,21,23,24,24,25,27,27,29,30,30,31,33,33,35,36,36,37,39,39,41,42,42,46,20,46,49,26,49,52,32,52,55,38,55,58,44,58]).polygons(o).angle(3).rotate([108,0]).translate([72,252]).scale(136.67)},t.geoDodecahedral=function(){const t=D(1/N(3))*j,n=b((N(5)-1)/N(3)/2)*j,e=90-n,o=b(-(1+N(5))/N(3)/2)*j,r={type:"FeatureCollection",features:[[[45,t],[0,n],[180,n],[135,t],[90,e]],[[45,t],[e,0],[-e,0],[-45,t],[0,n]],[[45,t],[90,e],[90,-e],[45,-t],[e,0]],[[0,n],[-45,t],[-90,e],[-135,t],[180,n]],[[e,0],[45,-t],[0,-n],[-45,-t],[-e,0]],[[90,e],[135,t],[o,0],[135,-t],[90,-e]],[[45,-t],[90,-e],[135,-t],[180,-n],[0,-n]],[[135,t],[180,n],[-135,t],[-o,0],[o,0]],[[-45,t],[-e,0],[-45,-t],[-90,-e],[-90,e]],[[-45,-t],[0,-n],[180,-n],[-135,-t],[-90,-e]],[[135,-t],[o,0],[-o,0],[-135,-t],[180,-n]],[[-135,t],[-90,e],[-90,-e],[-135,-t],[-o,0]]].map((t=>({type:"Feature",geometry:{type:"Polygon",coordinates:[[...t,t[0]]]}})))};return Pt().parents([-1,0,4,8,1,2,2,3,1,8,6,3]).angle(108).polygons(r).scale(99.8).rotate([-8,0,-32])},t.geoGingery=function(){return on(o.geoGingery.apply(this,arguments))},t.geoGrayFullerRaw=Ht,t.geoHealpix=function(){return on(o.geoHealpix.apply(this,arguments),!0)},t.geoIcosahedral=function(){const t=a(.5)*j,n=[[0,90],[0,-90]].concat([0,1,2,3,4,5,6,7,8,9].map((n=>[(36*n+180)%360-180,1&n?t:-t]))),e={type:"FeatureCollection",features:[[0,3,11],[0,5,3],[0,7,5],[0,9,7],[0,11,9],[2,11,3],[3,4,2],[4,3,5],[5,6,4],[6,5,7],[7,8,6],[8,7,9],[9,10,8],[10,9,11],[11,2,10],[1,2,4],[1,4,6],[1,6,8],[1,8,10],[1,10,2]].map((t=>t.map((t=>n[t])))).map((t=>({type:"Feature",geometry:{type:"Polygon",coordinates:[[...t,t[0]]]}})))};return Pt().parents([-1,7,9,11,13,0,5,6,7,8,9,10,11,12,13,6,8,10,12,14]).polygons(e).rotate([108,0]).scale(131.777).center([162,0])},t.geoImago=function(){let t=.59,n=1.16;const o=e.geoProjectionMutator(Kt),r=o(t,n);function i(t){const e=100.000002,o=[],r=t.scale(),i=t.center(),l=t.translate(),c=t.rotate();t.scale(1).center([0,90]).rotate([0,0]).translate([n,0]);for(let n=e-G;n>0;n--)o.unshift(t.invert([1.5*Lt.height-.003,Lt.width/2*n/e])),o.push(t.invert([-.5*Lt.height+.003,Lt.width/2*n/e]));return o.push(o[0]),t.scale(r).center(i).translate(l).rotate(c).preclip(Z({type:"Polygon",coordinates:[o]}))}return r.shift=function(e){return arguments.length?i(o(t,n=+e)):n},r.k=function(e){return arguments.length?i(o(t=+e,n)):t},i(r).rotate([18,-12.5,3.5]).scale(138.42).translate([480,250]).center([-139.405,40.5844])},t.geoImagoBlock=function(){let t=.68;const n=e.geoProjectionMutator(Ot),o=n(t);o.k=function(e){return arguments.length?n(t=+e):t};const r=-a(1/N(2))*j,i=[[-179.999999,r+G],[0,90],[179.999999,r+G],[179.999999,r-G],[-179.999999,r-G],[-179.999999,r+G]];return o.preclip(Z({type:"Polygon",coordinates:[i]})).scale(144.04).rotate([18,-12.5,3.5]).center([0,35.2644])},t.geoImagoRaw=Ot,t.geoInterrupt=function(){return rn(o.geoInterrupt.apply(this,arguments))},t.geoInterruptedBoggs=function(){return rn(o.geoInterruptedBoggs.apply(this,arguments))},t.geoInterruptedHomolosine=function(){return rn(o.geoInterruptedHomolosine.apply(this,arguments))},t.geoInterruptedMollweide=function(){return rn(o.geoInterruptedMollweide.apply(this,arguments))},t.geoInterruptedMollweideHemispheres=function(){return rn(o.geoInterruptedMollweideHemispheres.apply(this,arguments))},t.geoInterruptedSinuMollweide=function(){return rn(o.geoInterruptedSinuMollweide.apply(this,arguments))},t.geoInterruptedSinusoidal=function(){return rn(o.geoInterruptedSinusoidal.apply(this,arguments))},t.geoIntersectArc=function(t,n){const e=t.map((t=>q(t.map((t=>t*F))))),o=n.map((t=>q(t.map((t=>t*F))))),r=W(new V(e[0],e[1]),new V(o[0],o[1]));return r?R(r).map((t=>t*j)):null},t.geoLeeRaw=bt,t.geoPolyhedral=ct,t.geoPolyhedralButterfly=function(t=t=>{const n=e.geoCentroid({type:"MultiPoint",coordinates:t});return e.geoGnomonic().scale(1).translate([0,0]).rotate([-n[0],-n[1]])}){const n=ft.map((n=>({face:n,project:t(n)})));return[-1,0,0,1,0,1,4,5].forEach(((t,e)=>{const o=n[t];o&&(o.children||(o.children=[])).push(n[e])})),ct(n[0],((t,e)=>n[t<-w/2?e<0?6:4:t<0?e<0?2:0:t<w/2?e<0?3:1:e<0?7:5])).angle(-30).scale(101.858).center([0,45])},t.geoPolyhedralCollignon=function(t=t=>{const n=e.geoCentroid({type:"MultiPoint",coordinates:t});return e.geoProjection(gt).translate([0,0]).scale(1).rotate(n[1]>0?[-n[0],0]:[180-n[0],180])}){const n=ft.map((n=>({face:n,project:t(n)})));return[-1,0,0,1,0,1,4,5].forEach(((t,e)=>{const o=n[t];o&&(o.children||(o.children=[])).push(n[e])})),ct(n[0],((t,e)=>n[t<-w/2?e<0?6:4:t<0?e<0?2:0:t<w/2?e<0?3:1:e<0?7:5])).angle(-30).scale(121.906).center([0,48.5904])},t.geoPolyhedralVoronoi=Pt,t.geoPolyhedralWaterman=function(t=t=>{const n=6===t.length?e.geoCentroid({type:"MultiPoint",coordinates:t}):t[0];return e.geoGnomonic().scale(1).translate([0,0]).rotate([-n[0],-n[1]])}){const n=ft.map((t=>{const n=t.map(yt),e=n.length,o=[];let r,i=n[e-1];for(let t=0;t<e;++t)r=n[t],o.push(mt([.9486832980505138*i[0]+.31622776601683794*r[0],.9486832980505138*i[1]+.31622776601683794*r[1],.9486832980505138*i[2]+.31622776601683794*r[2]]),mt([.9486832980505138*r[0]+.31622776601683794*i[0],.9486832980505138*r[1]+.31622776601683794*i[1],.9486832980505138*r[2]+.31622776601683794*i[2]])),i=r;return o})),o=[],r=[-1,0,0,1,0,1,4,5];n.forEach(((t,e)=>{const i=ft[e],l=i.length,c=o[e]=[];for(let o=0;o<l;++o)n.push([i[o],t[(2*o+2)%(2*l)],t[(2*o+1)%(2*l)]]),r.push(e),c.push((u=yt(t[(2*o+2)%(2*l)]),a=yt(t[(2*o+1)%(2*l)]),[u[1]*a[2]-u[2]*a[1],u[2]*a[0]-u[0]*a[2],u[0]*a[1]-u[1]*a[0]]));var u,a}));const i=n.map((n=>({project:t(n),face:n})));return r.forEach(((t,n)=>{const e=i[t];e&&(e.children||(e.children=[])).push(i[n])})),ct(i[0],(function(t,n){const e=f(n),r=[e*f(t),e*A(t),A(n)],l=t<-w/2?n<0?6:4:t<0?n<0?2:0:t<w/2?n<0?3:1:n<0?7:5,c=o[l];return i[dt(c[0],r)<0?8+3*l:dt(c[1],r)<0?8+3*l+1:dt(c[2],r)<0?8+3*l+2:l]})).angle(-30).scale(110.625).center([0,45])},t.geoRhombic=function(){const t=a(Math.SQRT1_2)*j,n=[[0,90],[0,t],[90,t],[180,t],[-90,t],[45,0],[135,0],[-135,0],[-45,0],[0,-t],[90,-t],[180,-t],[-90,-t],[0,-90]],o={type:"FeatureCollection",features:[[0,1,8,4],[0,2,5,1],[0,3,6,2],[0,4,7,3],[1,5,9,8],[2,6,10,5],[3,7,11,6],[4,8,12,7],[8,9,13,12],[5,10,13,9],[6,11,13,10],[7,12,13,11]].map((t=>t.map((t=>n[t])))).map((t=>({type:"Feature",properties:{sitecoordinates:e.geoCentroid({type:"MultiPoint",coordinates:t})},geometry:{type:"Polygon",coordinates:[[...t,t[0]]]}})))};return Pt().polygons(o).parents([-1,0,6,2,1,9,11,3,4,8,5,10]).angle(20).rotate([80,0,90*-Math.asin(Math.sqrt(3)/3)]).translate([213,252]).scale(106.48)},t.geoTetrahedralLee=function(t=t=>{const n=e.geoCentroid({type:"MultiPoint",coordinates:t}),o=90==u(n[1])?[0,-n[1],-30]:[-n[0],-n[1],30];return e.geoProjection(bt).scale(1).translate([0,0]).rotate(o)}){return Pt([-1,0,0,0],{features:qt.map((t=>({type:"Feature",geometry:{type:"Polygon",coordinates:[[...t,t[0]]]}})))},t).rotate([30,180]).angle(30).scale(118.662).translate([480,195.47])},t.geoTwoPointEquidistant=en,t.geoTwoPointEquidistantUsa=function(){return en([-158,21.5],[-77,39])}}));