import{a as Ft,b as Lt}from"./chunk-FNJ2A2P5.js";import{a as Pt}from"./chunk-6MN6BBPN.js";import{a as tt}from"./chunk-NJVIDNJ6.js";import"./chunk-EZRSLM27.js";import{a as Ht}from"./chunk-LSAUAD4X.js";import{a as rt}from"./chunk-563CJZT3.js";import"./chunk-ZPW6H6BB.js";import{b as $,g as Gt,i as St}from"./chunk-HMXXHGCW.js";import"./chunk-NFDMGE7Q.js";import{b as V,c as Et,d as Nt,e as kt}from"./chunk-VDZXURWO.js";import{a as x}from"./chunk-UEFEFMYS.js";import"./chunk-YGIPMXAD.js";import"./chunk-PZ34T7DL.js";import"./chunk-5HWP5DW7.js";import{a as T}from"./chunk-3K67FZLU.js";import{e as b}from"./chunk-55TU6MJR.js";function y(){T.throwInstantiationError()}Object.defineProperties(y.prototype,{errorEvent:{get:T.throwInstantiationError},credit:{get:T.throwInstantiationError},tilingScheme:{get:T.throwInstantiationError},hasWaterMask:{get:T.throwInstantiationError},hasVertexNormals:{get:T.throwInstantiationError},availability:{get:T.throwInstantiationError}});var _t=[];y.getRegularGridIndices=function(t,i){if(t*i>=x.FOUR_GIGABYTES)throw new T("The total number of vertices (width * height) must be less than 4,294,967,296.");let n=_t[t];b(n)||(_t[t]=n=[]);let o=n[i];return b(o)||(t*i<x.SIXTY_FOUR_KILOBYTES?o=n[i]=new Uint16Array((t-1)*(i-1)*6):o=n[i]=new Uint32Array((t-1)*(i-1)*6),Yt(t,i,o,0)),o};var Vt=[];y.getRegularGridIndicesAndEdgeIndices=function(t,i){if(t*i>=x.FOUR_GIGABYTES)throw new T("The total number of vertices (width * height) must be less than 4,294,967,296.");let n=Vt[t];b(n)||(Vt[t]=n=[]);let o=n[i];if(!b(o)){let a=y.getRegularGridIndices(t,i),r=Rt(t,i),e=r.westIndicesSouthToNorth,c=r.southIndicesEastToWest,d=r.eastIndicesNorthToSouth,I=r.northIndicesWestToEast;o=n[i]={indices:a,westIndicesSouthToNorth:e,southIndicesEastToWest:c,eastIndicesNorthToSouth:d,northIndicesWestToEast:I}}return o};var Bt=[];y.getRegularGridAndSkirtIndicesAndEdgeIndices=function(t,i){if(t*i>=x.FOUR_GIGABYTES)throw new T("The total number of vertices (width * height) must be less than 4,294,967,296.");let n=Bt[t];b(n)||(Bt[t]=n=[]);let o=n[i];if(!b(o)){let a=t*i,r=(t-1)*(i-1)*6,e=t*2+i*2,c=Math.max(0,e-4)*6,d=a+e,I=r+c,g=Rt(t,i),H=g.westIndicesSouthToNorth,O=g.southIndicesEastToWest,p=g.eastIndicesNorthToSouth,h=g.northIndicesWestToEast,N=rt.createTypedArray(d,I);Yt(t,i,N,0),y.addSkirtIndices(H,O,p,h,a,N,r),o=n[i]={indices:N,westIndicesSouthToNorth:H,southIndicesEastToWest:O,eastIndicesNorthToSouth:p,northIndicesWestToEast:h,indexCountWithoutSkirts:r}}return o};y.addSkirtIndices=function(t,i,n,o,a,r,e){let c=a;e=st(t,c,r,e),c+=t.length,e=st(i,c,r,e),c+=i.length,e=st(n,c,r,e),c+=n.length,st(o,c,r,e)};function Rt(t,i){let n=new Array(i),o=new Array(t),a=new Array(i),r=new Array(t),e;for(e=0;e<t;++e)r[e]=e,o[e]=t*i-1-e;for(e=0;e<i;++e)a[e]=(e+1)*t-1,n[e]=(i-e-1)*t;return{westIndicesSouthToNorth:n,southIndicesEastToWest:o,eastIndicesNorthToSouth:a,northIndicesWestToEast:r}}function Yt(t,i,n,o){let a=0;for(let r=0;r<i-1;++r){for(let e=0;e<t-1;++e){let c=a,d=c+t,I=d+1,g=c+1;n[o++]=c,n[o++]=d,n[o++]=g,n[o++]=g,n[o++]=d,n[o++]=I,++a}++a}}function st(t,i,n,o){let a=t[0],r=t.length;for(let e=1;e<r;++e){let c=t[e];n[o++]=a,n[o++]=c,n[o++]=i,n[o++]=i,n[o++]=c,n[o++]=i+1,a=c,++i}return o}y.heightmapTerrainQuality=.25;y.getEstimatedLevelZeroGeometricErrorForAHeightmap=function(t,i,n){return t.maximumRadius*2*Math.PI*y.heightmapTerrainQuality/(i*n)};y.prototype.requestTileGeometry=T.throwInstantiationError;y.prototype.getLevelMaximumGeometricError=T.throwInstantiationError;y.prototype.getTileDataAvailable=T.throwInstantiationError;y.prototype.loadTileDataAvailability=T.throwInstantiationError;var Ut=y;var pt=32767,nt=new V,ce=new V,ae=new V,l=new Et,Q=new Nt,ct=new Et,q=[],et=[];function zt(t,i){let n=0,o,a,r,e,c=i.length;for(r=i[0],o=1;o<=c;o++)e=i[o%c],t[0]>Math.min(r[0],e[0])&&t[0]<=Math.max(r[0],e[0])&&t[1]<=Math.max(r[1],e[1])&&r[0]!==e[0]&&(a=(t[0]-r[0])*(e[1]-r[1])/(e[0]-r[0])+r[1],(r[1]===e[1]||t[1]<=a)&&n++),r=e;return n%2!==0}function ue(t,i,n,o){let a=(t.x-n.x)*(i.y-n.y)-(t.y-n.y)*(i.x-n.x),r=(t.x-o.x)*(i.y-o.y)-(t.y-o.y)*(i.x-o.x);if(a*r>=0)return!1;let e=(n.x-t.x)*(o.y-t.y)-(n.y-t.y)*(o.x-t.x),c=e+a-r;if(e*c>=0)return!1;let d=e/(r-a),I=d*(i.x-t.x),g=d*(i.y-t.y);return{x:t.x+I,y:t.y+g}}function le(t,i){let n=t.flattenPolygonHeight||[1],o=t.flattenPolygon||[],a=-65565,r=t.quantizedVertices,e=r.length/3,c=t.octEncodedNormals,d=t.westIndices.length+t.eastIndices.length+t.southIndices.length+t.northIndices.length,I=t.includeWebMercatorT,g=t.exaggeration,H=t.exaggerationRelativeHeight,p=g!==1,h=St.clone(t.rectangle),N=h.west,k=h.south,G=h.east,M=h.north;q.length=0,et.length=0;let E=!1,w=[[N,k],[G,k],[G,M],[N,M]];for(let s=0;s<n.length;s++)if(n[s]!==1){E=!1;for(let u=0;u<o[s].length;u++){let S=o[s][u];if(ct.longitude=S[0],ct.latitude=S[1],ct.height=0,St.contains(h,ct)){q.push(n[s]),et.push(o[s]),E=!0;break}}if(!E){for(let u=0;u<w.length;u++)if(zt(w[u],o[s])){q.push(n[s]),et.push(o[s]),E=!0;break}}if(!E)for(let u=0;u<o[s].length-1;u++){for(let S=0;S<w.length-1;S++){let X={x:w[S][0],y:w[S][1]},it={x:w[S+1][0],y:w[S+1][1]},Z={x:o[s][u][0],y:o[s][u][1]},J={x:o[s][u+1][0],y:o[s][u+1][1]};if(ue(X,it,Z,J)){q.push(n[s]),et.push(o[s]),E=!0;break}}if(E)break}}let m=kt.clone(t.ellipsoid),B=t.minimumHeight,F=t.maximumHeight,L=t.relativeToCenter,K=Gt.eastNorthUpToFixedFrame(L,m),_=$.inverseTransformation(K,new $),A,D;I&&(A=tt.geodeticLatitudeToMercatorAngle(k),D=1/(tt.geodeticLatitudeToMercatorAngle(M)-A));let jt=r.subarray(0,e),Dt=r.subarray(e,2*e),qt=r.subarray(e*2,3*e),wt=b(c),f=new Array(e),W=new Array(e),dt=new Array(e),bt=I?new Array(e):[],Mt=p?new Array(e):[],C=ce;C.x=Number.POSITIVE_INFINITY,C.y=Number.POSITIVE_INFINITY,C.z=Number.POSITIVE_INFINITY;let v=ae;v.x=Number.NEGATIVE_INFINITY,v.y=Number.NEGATIVE_INFINITY,v.z=Number.NEGATIVE_INFINITY;let ht=Number.POSITIVE_INFINITY,It=Number.NEGATIVE_INFINITY,ft=Number.POSITIVE_INFINITY,gt=Number.NEGATIVE_INFINITY;for(let s=0;s<e;++s){let u=jt[s],S=Dt[s],X=u/pt,it=S/pt,Z=x.lerp(B,F,qt[s]/pt);l.longitude=x.lerp(N,G,X),l.latitude=x.lerp(k,M,it),l.height=Z;for(let j=0;j<q.length;j++)if(q[j]!==1){let se=[l.longitude,l.latitude];zt(se,et[j])&&(l.height=Z=n[j],a=Math.max(a,n[j]))}ht=Math.min(l.longitude,ht),It=Math.max(l.longitude,It),ft=Math.min(l.latitude,ft),gt=Math.max(l.latitude,gt);let J=m.cartographicToCartesian(l);f[s]=new Nt(X,it),W[s]=Z,dt[s]=J,I&&(bt[s]=(tt.geodeticLatitudeToMercatorAngle(l.latitude)-A)*D),p&&(Mt[s]=m.geodeticSurfaceNormal(J)),$.multiplyByPoint(_,J,nt),V.minimumByComponent(nt,C,C),V.maximumByComponent(nt,v,v)}a!==-65565&&(F=a*1.2);let mt=lt(t.westIndices,function(s,u){return f[s].y-f[u].y}),Tt=lt(t.eastIndices,function(s,u){return f[u].y-f[s].y}),xt=lt(t.southIndices,function(s,u){return f[u].x-f[s].x}),yt=lt(t.northIndices,function(s,u){return f[s].x-f[u].x}),At;B<0&&(At=new Ft(m).computeHorizonCullingPointPossiblyUnderEllipsoid(L,dt,B));let P=B;P=Math.min(P,at(t.westIndices,t.westSkirtHeight,W,f,h,m,_,C,v)),P=Math.min(P,at(t.southIndices,t.southSkirtHeight,W,f,h,m,_,C,v)),P=Math.min(P,at(t.eastIndices,t.eastSkirtHeight,W,f,h,m,_,C,v)),P=Math.min(P,at(t.northIndices,t.northSkirtHeight,W,f,h,m,_,C,v));let Qt=new Ht(C,v,L),R=new Lt(L,Qt,P,F,K,wt,I,p,g,H),Y=R.stride,Kt=e*Y+d*Y,U=new Float32Array(Kt),Wt=0;for(let s=0;s<e;++s){if(wt){let u=s*2;Q.x=c[u],Q.y=c[u+1]}Wt=R.encode(U,Wt,dt[s],f[s],W[s],Q,bt[s],Mt[s])}let Xt=Math.max(0,(d-4)*2),Zt=t.indices.length+Xt*3,ot=rt.createTypedArray(e+d,Zt);ot.set(t.indices,0);let Ct=1e-4,vt=(It-ht)*Ct,Ot=(gt-ft)*Ct,Jt=-vt,$t=0,te=vt,ee=0,ne=0,oe=Ot,ie=0,re=-Ot,z=e*Y;return ut(U,z,mt,R,W,f,c,m,h,t.westSkirtHeight,A,D,Jt,$t),z+=t.westIndices.length*Y,ut(U,z,xt,R,W,f,c,m,h,t.southSkirtHeight,A,D,ie,re),z+=t.southIndices.length*Y,ut(U,z,Tt,R,W,f,c,m,h,t.eastSkirtHeight,A,D,te,ee),z+=t.eastIndices.length*Y,ut(U,z,yt,R,W,f,c,m,h,t.northSkirtHeight,A,D,ne,oe),Ut.addSkirtIndices(mt,xt,Tt,yt,e,ot,t.indices.length),i.push(U.buffer,ot.buffer),{vertices:U.buffer,indices:ot.buffer,westIndicesSouthToNorth:mt,southIndicesEastToWest:xt,eastIndicesNorthToSouth:Tt,northIndicesWestToEast:yt,vertexStride:Y,center:L,minimumHeight:B,maximumHeight:F,occludeePointInScaledSpace:At,encoding:R,indexCountWithoutSkirts:t.indices.length}}function at(t,i,n,o,a,r,e,c,d){let I=Number.POSITIVE_INFINITY,g=a.north,H=a.south,O=a.east,p=a.west;O<p&&(O+=x.TWO_PI);let h=t.length;for(let N=0;N<h;++N){let k=t[N],G=n[k],M=o[k];l.longitude=x.lerp(p,O,M.x),l.latitude=x.lerp(H,g,M.y),l.height=G-i;let E=r.cartographicToCartesian(l,nt);$.multiplyByPoint(e,E,E),V.minimumByComponent(E,c,c),V.maximumByComponent(E,d,d),I=Math.min(I,l.height)}return I}function ut(t,i,n,o,a,r,e,c,d,I,g,H,O,p){let h=b(e),N=d.north,k=d.south,G=d.east,M=d.west;G<M&&(G+=x.TWO_PI);let E=n.length;for(let w=0;w<E;++w){let m=n[w],B=a[m],F=r[m];l.longitude=x.lerp(M,G,F.x)+O,l.latitude=x.lerp(k,N,F.y)+p,l.height=B-I;let L=c.cartographicToCartesian(l,nt);if(h){let A=m*2;Q.x=e[A],Q.y=e[A+1]}let K;o.hasWebMercatorT&&(K=(tt.geodeticLatitudeToMercatorAngle(l.latitude)-g)*H);let _;o.hasGeodeticSurfaceNormals&&(_=c.geodeticSurfaceNormal(L)),i=o.encode(t,i,L,F,l.height,Q,K,_)}}function lt(t,i){let n;return typeof t.slice=="function"&&(n=t.slice(),typeof n.sort!="function"&&(n=void 0)),b(n)||(n=Array.prototype.slice.call(t)),n.sort(i),n}var Ge=Pt(le);export{Ge as default};
|