/** * @license * Cesium - https://github.com/CesiumGS/cesium * Version 1.120.1 * * Copyright 2011-2022 Cesium Contributors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Columbus View (Pat. Pend.) * * Portions licensed separately. * See https://github.com/CesiumGS/cesium/blob/main/LICENSE.md for full licensing details. */ import{a as Gt,b as Xt}from"./chunk-KTYEIHPA.js";import{a as kt}from"./chunk-7CHYY4MB.js";import{a as lt}from"./chunk-Q3OGYXB5.js";import{a as Dt}from"./chunk-JA4HQIWI.js";import"./chunk-AWTNTFWT.js";import"./chunk-HVRCTCKZ.js";import{a as qt}from"./chunk-PCAQWIAU.js";import"./chunk-ZZPAAKFL.js";import"./chunk-A2J5OJ74.js";import{d as Lt}from"./chunk-JYT7LKWQ.js";import{b as $,g as Ot,h as zt}from"./chunk-DPXXHKCX.js";import"./chunk-UTQP35IH.js";import{a as P,b as N,c as wt,d as Ht}from"./chunk-S74IVKSO.js";import{a as r}from"./chunk-XQPFZTAL.js";import"./chunk-CYX2VK56.js";import{a as Vt}from"./chunk-A5LGJSYE.js";import{a as Ut}from"./chunk-CDFKIAC5.js";import"./chunk-DRUYFASX.js";import{e as ht}from"./chunk-A4U73JJE.js";var te=Uint16Array.BYTES_PER_ELEMENT,mt=Int32Array.BYTES_PER_ELEMENT,Pt=Uint32Array.BYTES_PER_ELEMENT,ee=Float32Array.BYTES_PER_ELEMENT,H=Float64Array.BYTES_PER_ELEMENT;function tt(t,e,n){n=Ut(n,r);let i=t.length;for(let o=0;o<i;++o)if(n.equalsEpsilon(t[o],e,r.EPSILON12))return o;return-1}function oe(t,e){t.ellipsoid=Ht.clone(t.ellipsoid),t.rectangle=zt.clone(t.rectangle);let n=se(t.buffer,t.relativeToCenter,t.ellipsoid,t.rectangle,t.nativeRectangle,t.exaggeration,t.exaggerationRelativeHeight,t.skirtHeight,t.includeWebMercatorT,t.negativeAltitudeExponentBias,t.negativeElevationThreshold),i=n.vertices;e.push(i.buffer);let r=n.indices;return e.push(r.buffer),{vertices:i.buffer,indices:r.buffer,numberOfAttributes:n.encoding.stride,minimumHeight:n.minimumHeight,maximumHeight:n.maximumHeight,boundingSphere3D:n.boundingSphere3D,orientedBoundingBox:n.orientedBoundingBox,occludeePointInScaledSpace:n.occludeePointInScaledSpace,encoding:n.encoding,vertexCountWithoutSkirts:n.vertexCountWithoutSkirts,indexCountWithoutSkirts:n.indexCountWithoutSkirts,westIndicesSouthToNorth:n.westIndicesSouthToNorth,southIndicesEastToWest:n.southIndicesEastToWest,eastIndicesNorthToSouth:n.eastIndicesNorthToSouth,northIndicesWestToEast:n.northIndicesWestToEast}}var u=new N,G=new P,ne=new P,ie=new P,re=new $;function se(t,e,n,i,o,a,s,l,h,c,d){let m,g,p,I,T,f;ht(i)?(m=i.west,g=i.south,p=i.east,I=i.north,T=i.width,f=i.height):(m=r.toRadians(o.west),g=r.toRadians(o.south),p=r.toRadians(o.east),I=r.toRadians(o.north),T=r.toRadians(i.width),f=r.toRadians(i.height));let E,A,x=[g,I],S=[m,p],w=Ot.eastNorthUpToFixedFrame(e,n),k=$.inverseTransformation(w,re);h&&(E=lt.geodeticLatitudeToMercatorAngle(g),A=1/(lt.geodeticLatitudeToMercatorAngle(I)-E));let b=1!==a,y=new DataView(t),F=Number.POSITIVE_INFINITY,R=Number.NEGATIVE_INFINITY,v=ne;v.x=Number.POSITIVE_INFINITY,v.y=Number.POSITIVE_INFINITY,v.z=Number.POSITIVE_INFINITY;let B=ie;B.x=Number.NEGATIVE_INFINITY,B.y=Number.NEGATIVE_INFINITY,B.z=Number.NEGATIVE_INFINITY;let C,M,_=0,Y=0,W=0;for(M=0;M<4;++M){let t=_;C=y.getUint32(t,!0),t+=Pt;let e=r.toRadians(180*y.getFloat64(t,!0));t+=H,-1===tt(S,e)&&S.push(e);let n=r.toRadians(180*y.getFloat64(t,!0));t+=H,-1===tt(x,n)&&x.push(n),t+=2*H;let i=y.getInt32(t,!0);t+=mt,Y+=i,i=y.getInt32(t,!0),W+=3*i,_+=C+Pt}let j=[],U=[],V=new Array(Y),L=new Array(Y),O=new Array(Y),D=h?new Array(Y):[],X=b?new Array(Y):[],K=new Array(W),J=[],Q=[],z=[],Z=[],q=0,et=0;for(_=0,M=0;M<4;++M){C=y.getUint32(_,!0),_+=Pt;let t=_,e=r.toRadians(180*y.getFloat64(_,!0));_+=H;let i=r.toRadians(180*y.getFloat64(_,!0));_+=H;let o=r.toRadians(180*y.getFloat64(_,!0)),a=.5*o;_+=H;let s=r.toRadians(180*y.getFloat64(_,!0)),l=.5*s;_+=H;let T=y.getInt32(_,!0);_+=mt;let f=y.getInt32(_,!0);_+=mt,_+=mt;let w=new Array(T);for(let H=0;H<T;++H){let t=e+y.getUint8(_++)*o;u.longitude=t;let T=i+y.getUint8(_++)*s;u.latitude=T;let f=y.getFloat32(_,!0);if(_+=ee,0!==f&&f<d&&(f*=-Math.pow(2,c)),f*=6371010,u.height=f,-1!==tt(S,t)||-1!==tt(x,T)){let t=tt(j,u,N);if(-1!==t){w[H]=U[t];continue}j.push(N.clone(u)),U.push(q)}w[H]=q,Math.abs(t-m)<a?J.push({index:q,cartographic:N.clone(u)}):Math.abs(t-p)<a?z.push({index:q,cartographic:N.clone(u)}):Math.abs(T-g)<l?Q.push({index:q,cartographic:N.clone(u)}):Math.abs(T-I)<l&&Z.push({index:q,cartographic:N.clone(u)}),F=Math.min(f,F),R=Math.max(f,R),O[q]=f;let C=n.cartographicToCartesian(u);if(V[q]=C,h&&(D[q]=(lt.geodeticLatitudeToMercatorAngle(T)-E)*A),b){let t=n.geodeticSurfaceNormal(C);X[q]=t}$.multiplyByPoint(k,C,G),P.minimumByComponent(G,v,v),P.maximumByComponent(G,B,B);let M=(t-m)/(p-m);M=r.clamp(M,0,1);let Y=(T-g)/(I-g);Y=r.clamp(Y,0,1),L[q]=new wt(M,Y),++q}let M=3*f;for(let n=0;n<M;++n,++et)K[et]=w[y.getUint16(_,!0)],_+=te;if(C!==_-t)throw new Vt("Invalid terrain tile.")}V.length=q,L.length=q,O.length=q,h&&(D.length=q),b&&(X.length=q);let nt=q,it=et,rt={hMin:F,lastBorderPoint:void 0,skirtHeight:l,toENU:k,ellipsoid:n,minimum:v,maximum:B};J.sort((function(t,e){return e.cartographic.latitude-t.cartographic.latitude})),Q.sort((function(t,e){return t.cartographic.longitude-e.cartographic.longitude})),z.sort((function(t,e){return t.cartographic.latitude-e.cartographic.latitude})),Z.sort((function(t,e){return e.cartographic.longitude-t.cartographic.longitude}));let ot=1e-5;if(gt(V,O,L,D,X,K,rt,J,-ot*T,!0,-ot*f),gt(V,O,L,D,X,K,rt,Q,-ot*f,!1),gt(V,O,L,D,X,K,rt,z,ot*T,!0,ot*f),gt(V,O,L,D,X,K,rt,Z,ot*f,!1),J.length>0&&Z.length>0){let t=J[0].index,e=nt,n=Z[Z.length-1].index,i=V.length-1;K.push(n,i,e,e,t,n)}Y=V.length;let at,ut=Lt.fromPoints(V);ht(i)&&(at=Dt.fromRectangle(i,F,R,n));let st=new Gt(n).computeHorizonCullingPointPossiblyUnderEllipsoid(e,V,F),ct=new qt(v,B,e),dt=new Xt(e,ct,rt.hMin,R,w,!1,h,b,a,s),pt=new Float32Array(Y*dt.stride),It=0;for(let r=0;r<Y;++r)It=dt.encode(pt,It,V[r],L[r],O[r],void 0,D[r],X[r]);let Tt=J.map((function(t){return t.index})).reverse(),ft=Q.map((function(t){return t.index})).reverse(),Et=z.map((function(t){return t.index})).reverse(),Nt=Z.map((function(t){return t.index})).reverse();return ft.unshift(Et[Et.length-1]),ft.push(Tt[0]),Nt.unshift(Tt[Tt.length-1]),Nt.push(Et[0]),{vertices:pt,indices:new Uint16Array(K),maximumHeight:R,minimumHeight:F,encoding:dt,boundingSphere3D:ut,orientedBoundingBox:at,occludeePointInScaledSpace:st,vertexCountWithoutSkirts:nt,indexCountWithoutSkirts:it,westIndicesSouthToNorth:Tt,southIndicesEastToWest:ft,eastIndicesNorthToSouth:Et,northIndicesWestToEast:Nt}}function gt(t,e,n,i,o,a,s,l,h,c,d){let m=l.length;for(let g=0;g<m;++g){let p=l[g],I=p.cartographic,T=p.index,f=t.length,E=I.longitude,A=I.latitude;A=r.clamp(A,-r.PI_OVER_TWO,r.PI_OVER_TWO);let x=I.height-s.skirtHeight;s.hMin=Math.min(s.hMin,x),N.fromRadians(E,A,x,u),c&&(u.longitude+=h),c?g===m-1?u.latitude+=d:0===g&&(u.latitude-=d):u.latitude+=h;let S=s.ellipsoid.cartographicToCartesian(u);t.push(S),e.push(x),n.push(wt.clone(n[T])),i.length>0&&i.push(i[T]),o.length>0&&o.push(o[T]),$.multiplyByPoint(s.toENU,S,G);let w=s.minimum,k=s.maximum;P.minimumByComponent(G,w,w),P.maximumByComponent(G,k,k);let b=s.lastBorderPoint;if(ht(b)){let t=b.index;a.push(t,f-1,f,f,T,t)}s.lastBorderPoint=p}}var Ae=kt(oe);export{Ae as default};