UNPKG

cong-gis-viewer

Version:

The minimal recommended setup for an app using Cesium with Webpack 5

2 lines 4.53 kB
/*! For license information please see createVectorTilePolygons.js.LICENSE.txt */ import{a as R}from"./chunk-45XN4A3L.js";import{a as It}from"./chunk-RKXUFMEE.js";import{a as M}from"./chunk-NSYXLK76.js";import{a as bt}from"./chunk-EU6MOGEX.js";import"./chunk-ZS2W345Z.js";import"./chunk-XS3SI335.js";import"./chunk-MQA5R2TD.js";import"./chunk-BNIMZJFI.js";import{a as W}from"./chunk-UENNBKKY.js";import"./chunk-MEAQKBL7.js";import{i as z}from"./chunk-RKBLQ2M4.js";import"./chunk-K3VQHMI6.js";import{a as o,b as nt,d as j}from"./chunk-UTRPTI5S.js";import{a as et}from"./chunk-TFNGIACM.js";import"./chunk-ISVCOS3X.js";import"./chunk-XUAQFAMT.js";import"./chunk-OW23VKVW.js";import"./chunk-LKAZ42NI.js";import{e as A}from"./chunk-MYHWD27O.js";var kt=new o,Bt=new j,Nt=new z,E={min:void 0,max:void 0,indexBytesPerElement:void 0};function Pt(t){let e=new Float64Array(t),n=0;E.indexBytesPerElement=e[n++],E.min=e[n++],E.max=e[n++],o.unpack(e,n,kt),n+=o.packedLength,j.unpack(e,n,Bt),n+=j.packedLength,z.unpack(e,n,Nt)}function Tt(t){let e=t.length,n=0;for(let r=0;r<e;++r)n+=R.packedLength+3+t[r].batchIds.length;return n}function Ct(t,e,n){let r=e.length,o=2+r*M.packedLength+1+Tt(n),a=new Float64Array(o),i=0;a[i++]=t,a[i++]=r;for(let t=0;t<r;++t)M.pack(e[t],a,i),i+=M.packedLength;let s=n.length;a[i++]=s;for(let t=0;t<s;++t){let e=n[t];R.pack(e.color,a,i),i+=R.packedLength,a[i++]=e.offset,a[i++]=e.count;let r=e.batchIds,o=r.length;a[i++]=o;for(let t=0;t<o;++t)a[i++]=r[t]}return a}var yt=32767,wt=new o,Ht=new o,St=new o,Ut=new o,Ft=new o,Lt=new nt,Mt=new z;function Rt(t,e){let n;Pt(t.packedBuffer),n=2===E.indexBytesPerElement?new Uint16Array(t.indices):new Uint32Array(t.indices);let r=new Uint16Array(t.positions),a=new Uint32Array(t.counts),i=new Uint32Array(t.indexCounts),s=new Uint32Array(t.batchIds),f=new Uint32Array(t.batchTableColors),c=new Array(a.length),l=kt,h=Bt,u=Nt,m=E.min,p=E.max,d=t.minimumHeights,I=t.maximumHeights;A(d)&&A(I)&&(d=new Float32Array(d),I=new Float32Array(I));let k,g,w,b=r.length/2,y=r.subarray(0,b),N=r.subarray(b,2*b);bt.zigZagDeltaDecode(y,N);let L=new Float64Array(3*b);for(k=0;k<b;++k){let t=y[k],e=N[k],n=et.lerp(u.west,u.east,t/yt),r=et.lerp(u.south,u.north,e/yt),a=nt.fromRadians(n,r,0,Lt),i=h.cartographicToCartesian(a,wt);o.pack(i,L,3*k)}let T=a.length,j=new Array(T),x=new Array(T),S=0,U=0;for(k=0;k<T;++k)j[k]=S,x[k]=U,S+=a[k],U+=i[k];let F=new Float32Array(3*b*2),B=new Uint16Array(2*b),O=new Uint32Array(x.length),P=new Uint32Array(i.length),C=[],K={};for(k=0;k<T;++k)w=f[k],A(K[w])?(K[w].positionLength+=a[k],K[w].indexLength+=i[k],K[w].batchIds.push(k)):K[w]={positionLength:a[k],indexLength:i[k],offset:0,indexOffset:0,batchIds:[k]};let V,Y=0,_=0;for(w in K)if(K.hasOwnProperty(w)){V=K[w],V.offset=Y,V.indexOffset=_;let t=2*V.positionLength,e=2*V.indexLength+6*V.positionLength;Y+=t,_+=e,V.indexLength=e}let G=[];for(w in K)K.hasOwnProperty(w)&&(V=K[w],G.push({color:R.fromRgba(parseInt(w)),offset:V.indexOffset,count:V.indexLength,batchIds:V.batchIds}));for(k=0;k<T;++k){w=f[k],V=K[w];let t=V.offset,e=3*t,r=t,b=j[k],y=a[k],N=s[k],E=m,T=p;A(d)&&A(I)&&(E=d[k],T=I[k]);let S=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY,W=Number.NEGATIVE_INFINITY;for(g=0;g<y;++g){let t=o.unpack(L,3*b+3*g,wt);h.scaleToGeodeticSurface(t,t);let n=h.cartesianToCartographic(t,Lt),a=n.latitude,i=n.longitude;S=Math.min(a,S),U=Math.max(a,U),R=Math.min(i,R),W=Math.max(i,W);let s=h.geodeticSurfaceNormal(t,Ht),f=o.multiplyByScalar(s,E,St),c=o.add(t,f,Ut);f=o.multiplyByScalar(s,T,f);let u=o.add(t,f,Ft);o.subtract(u,l,u),o.subtract(c,l,c),o.pack(u,F,e),o.pack(c,F,e+3),B[r]=N,B[r+1]=N,e+=6,r+=2}u=Mt,u.west=R,u.east=W,u.south=S,u.north=U,c[k]=M.fromRectangle(u,m,p,h);let Y=V.indexOffset,_=x[k],G=i[k];for(O[k]=Y,g=0;g<G;g+=3){let e=n[_+g]-b,r=n[_+g+1]-b,o=n[_+g+2]-b;C[Y++]=2*e+t,C[Y++]=2*r+t,C[Y++]=2*o+t,C[Y++]=2*o+1+t,C[Y++]=2*r+1+t,C[Y++]=2*e+1+t}for(g=0;g<y;++g){let e=g,n=(g+1)%y;C[Y++]=2*e+1+t,C[Y++]=2*n+t,C[Y++]=2*e+t,C[Y++]=2*e+1+t,C[Y++]=2*n+1+t,C[Y++]=2*n+t}V.offset+=2*y,V.indexOffset=Y,P[k]=Y-O[k]}C=W.createTypedArray(F.length/3,C);let H=G.length;for(let t=0;t<H;++t){let e=G[t].batchIds,n=0,r=e.length;for(let t=0;t<r;++t)n+=P[e[t]];G[t].count=n}let X=Ct(2===C.BYTES_PER_ELEMENT?W.UNSIGNED_SHORT:W.UNSIGNED_INT,c,G);return e.push(F.buffer,C.buffer,O.buffer,P.buffer,B.buffer,X.buffer),{positions:F.buffer,indices:C.buffer,indexOffsets:O.buffer,indexCounts:P.buffer,batchIds:B.buffer,packedBuffer:X.buffer}}var Jt=It(Rt);export{Jt as default};