UNPKG

@dp_unity/dpu-gis-viewer

Version:

DPU GIS Viewer version Beta

2 lines 7.01 kB
/*! For license information please see createVerticesFromGoogleEarthEnterpriseBuffer.js.LICENSE.txt */ import{a as Gt,b as Xt}from"./chunk-PJQ53UQY.js";import{a as kt}from"./chunk-4BYMTYMT.js";import{a as lt}from"./chunk-UJMUN4NO.js";import{a as Dt}from"./chunk-SOCYD7RP.js";import"./chunk-Q5MYX5A2.js";import"./chunk-CTRWX4F5.js";import{a as qt}from"./chunk-Z7BLUZ7R.js";import"./chunk-PY4CW263.js";import"./chunk-RRZIPF5C.js";import{d as Lt}from"./chunk-K2M3OJ7Z.js";import{b as $,g as Ot,h as zt}from"./chunk-M3A6SPGI.js";import"./chunk-D5HNP2LB.js";import{a as P,b as N,c as wt,d as Ht}from"./chunk-S4VBGY2U.js";import{a as r}from"./chunk-UCTPWOTZ.js";import"./chunk-54PMPXZ4.js";import{a as Vt}from"./chunk-R62IKKEC.js";import{a as Ut}from"./chunk-N3A5CZ2S.js";import"./chunk-G75U3WZT.js";import{e as ht}from"./chunk-3THTQ4QB.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,x,S=[g,I],w=[m,p],k=Ot.eastNorthUpToFixedFrame(e,n),R=$.inverseTransformation(k,re);h&&(E=lt.geodeticLatitudeToMercatorAngle(g),x=1/(lt.geodeticLatitudeToMercatorAngle(I)-E));let A=1!==a,M=new DataView(t),b=Number.POSITIVE_INFINITY,B=Number.NEGATIVE_INFINITY,y=ne;y.x=Number.POSITIVE_INFINITY,y.y=Number.POSITIVE_INFINITY,y.z=Number.POSITIVE_INFINITY;let v=ie;v.x=Number.NEGATIVE_INFINITY,v.y=Number.NEGATIVE_INFINITY,v.z=Number.NEGATIVE_INFINITY;let F,_,C=0,U=0,Y=0;for(_=0;_<4;++_){let t=C;F=M.getUint32(t,!0),t+=Pt;let e=r.toRadians(180*M.getFloat64(t,!0));t+=H,-1===tt(w,e)&&w.push(e);let n=r.toRadians(180*M.getFloat64(t,!0));t+=H,-1===tt(S,n)&&S.push(n),t+=2*H;let i=M.getInt32(t,!0);t+=mt,U+=i,i=M.getInt32(t,!0),Y+=3*i,C+=F+Pt}let j=[],W=[],O=new Array(U),V=new Array(U),L=new Array(U),D=h?new Array(U):[],Z=A?new Array(U):[],z=new Array(Y),Q=[],X=[],q=[],J=[],K=0,et=0;for(C=0,_=0;_<4;++_){F=M.getUint32(C,!0),C+=Pt;let t=C,e=r.toRadians(180*M.getFloat64(C,!0));C+=H;let i=r.toRadians(180*M.getFloat64(C,!0));C+=H;let o=r.toRadians(180*M.getFloat64(C,!0)),a=.5*o;C+=H;let s=r.toRadians(180*M.getFloat64(C,!0)),l=.5*s;C+=H;let T=M.getInt32(C,!0);C+=mt;let f=M.getInt32(C,!0);C+=mt,C+=mt;let k=new Array(T);for(let t=0;t<T;++t){let T=e+M.getUint8(C++)*o;u.longitude=T;let f=i+M.getUint8(C++)*s;u.latitude=f;let H=M.getFloat32(C,!0);if(C+=ee,0!==H&&H<d&&(H*=-Math.pow(2,c)),H*=6371010,u.height=H,-1!==tt(w,T)||-1!==tt(S,f)){let e=tt(j,u,N);if(-1!==e){k[t]=W[e];continue}j.push(N.clone(u)),W.push(K)}k[t]=K,Math.abs(T-m)<a?Q.push({index:K,cartographic:N.clone(u)}):Math.abs(T-p)<a?q.push({index:K,cartographic:N.clone(u)}):Math.abs(f-g)<l?X.push({index:K,cartographic:N.clone(u)}):Math.abs(f-I)<l&&J.push({index:K,cartographic:N.clone(u)}),b=Math.min(H,b),B=Math.max(H,B),L[K]=H;let F=n.cartographicToCartesian(u);if(O[K]=F,h&&(D[K]=(lt.geodeticLatitudeToMercatorAngle(f)-E)*x),A){let t=n.geodeticSurfaceNormal(F);Z[K]=t}$.multiplyByPoint(R,F,G),P.minimumByComponent(G,y,y),P.maximumByComponent(G,v,v);let _=(T-m)/(p-m);_=r.clamp(_,0,1);let U=(f-g)/(I-g);U=r.clamp(U,0,1),V[K]=new wt(_,U),++K}let _=3*f;for(let t=0;t<_;++t,++et)z[et]=k[M.getUint16(C,!0)],C+=te;if(F!==C-t)throw new Vt("Invalid terrain tile.")}O.length=K,V.length=K,L.length=K,h&&(D.length=K),A&&(Z.length=K);let nt=K,it=et,rt={hMin:b,lastBorderPoint:void 0,skirtHeight:l,toENU:R,ellipsoid:n,minimum:y,maximum:v};Q.sort((function(t,e){return e.cartographic.latitude-t.cartographic.latitude})),X.sort((function(t,e){return t.cartographic.longitude-e.cartographic.longitude})),q.sort((function(t,e){return t.cartographic.latitude-e.cartographic.latitude})),J.sort((function(t,e){return e.cartographic.longitude-t.cartographic.longitude}));let ot=1e-5;if(gt(O,L,V,D,Z,z,rt,Q,-ot*T,!0,-ot*f),gt(O,L,V,D,Z,z,rt,X,-ot*f,!1),gt(O,L,V,D,Z,z,rt,q,ot*T,!0,ot*f),gt(O,L,V,D,Z,z,rt,J,ot*f,!1),Q.length>0&&J.length>0){let t=Q[0].index,e=nt,n=J[J.length-1].index,i=O.length-1;z.push(n,i,e,e,t,n)}U=O.length;let at,ut=Lt.fromPoints(O);ht(i)&&(at=Dt.fromRectangle(i,b,B,n));let st=new Gt(n).computeHorizonCullingPointPossiblyUnderEllipsoid(e,O,b),ct=new qt(y,v,e),dt=new Xt(e,ct,rt.hMin,B,k,!1,h,A,a,s),pt=new Float32Array(U*dt.stride),It=0;for(let t=0;t<U;++t)It=dt.encode(pt,It,O[t],V[t],L[t],void 0,D[t],Z[t]);let Tt=Q.map((function(t){return t.index})).reverse(),ft=X.map((function(t){return t.index})).reverse(),Nt=q.map((function(t){return t.index})).reverse(),Et=J.map((function(t){return t.index})).reverse();return ft.unshift(Nt[Nt.length-1]),ft.push(Tt[0]),Et.unshift(Tt[Tt.length-1]),Et.push(Nt[0]),{vertices:pt,indices:new Uint16Array(z),maximumHeight:B,minimumHeight:b,encoding:dt,boundingSphere3D:ut,orientedBoundingBox:at,occludeePointInScaledSpace:st,vertexCountWithoutSkirts:nt,indexCountWithoutSkirts:it,westIndicesSouthToNorth:Tt,southIndicesEastToWest:ft,eastIndicesNorthToSouth:Nt,northIndicesWestToEast:Et}}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,x=I.latitude;x=r.clamp(x,-r.PI_OVER_TWO,r.PI_OVER_TWO);let S=I.height-s.skirtHeight;s.hMin=Math.min(s.hMin,S),N.fromRadians(E,x,S,u),c&&(u.longitude+=h),c?g===m-1?u.latitude+=d:0===g&&(u.latitude-=d):u.latitude+=h;let w=s.ellipsoid.cartographicToCartesian(u);t.push(w),e.push(S),n.push(wt.clone(n[T])),i.length>0&&i.push(i[T]),o.length>0&&o.push(o[T]),$.multiplyByPoint(s.toENU,w,G);let k=s.minimum,R=s.maximum;P.minimumByComponent(G,k,k),P.maximumByComponent(G,R,R);let A=s.lastBorderPoint;if(ht(A)){let t=A.index;a.push(t,f-1,f,f,T,t)}s.lastBorderPoint=p}}var Ae=kt(oe);export{Ae as default};