@dp_unity/dpu-gis-viewer
Version:
DPU GIS Viewer version Beta
2 lines • 4.53 kB
JavaScript
/*! For license information please see createVectorTilePolygons.js.LICENSE.txt */
import{a as R}from"./chunk-JXLT7VPX.js";import{a as It}from"./chunk-4BYMTYMT.js";import{a as M}from"./chunk-SOCYD7RP.js";import{a as bt}from"./chunk-Q5MYX5A2.js";import"./chunk-CTRWX4F5.js";import"./chunk-Z7BLUZ7R.js";import"./chunk-PY4CW263.js";import"./chunk-RRZIPF5C.js";import{a as W}from"./chunk-34ULWVZF.js";import"./chunk-K2M3OJ7Z.js";import{h as z}from"./chunk-M3A6SPGI.js";import"./chunk-D5HNP2LB.js";import{a as o,b as nt,d as j}from"./chunk-S4VBGY2U.js";import{a as et}from"./chunk-UCTPWOTZ.js";import"./chunk-54PMPXZ4.js";import"./chunk-R62IKKEC.js";import"./chunk-N3A5CZ2S.js";import"./chunk-G75U3WZT.js";import{e as A}from"./chunk-3THTQ4QB.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),h=kt,l=Bt,u=Nt,m=E.min,p=E.max,d=t.minimumHeights,k=t.maximumHeights;A(d)&&A(k)&&(d=new Float32Array(d),k=new Float32Array(k));let g,w,I,b=r.length/2,y=r.subarray(0,b),T=r.subarray(b,2*b);bt.zigZagDeltaDecode(y,T);let N=new Float64Array(3*b);for(g=0;g<b;++g){let t=y[g],e=T[g],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=l.cartographicToCartesian(a,wt);o.pack(i,N,3*g)}let j=a.length,x=new Array(j),L=new Array(j),P=0,U=0;for(g=0;g<j;++g)x[g]=P,L[g]=U,P+=a[g],U+=i[g];let B=new Float32Array(3*b*2),S=new Uint16Array(2*b),F=new Uint32Array(L.length),C=new Uint32Array(i.length),O=[],Y={};for(g=0;g<j;++g)I=f[g],A(Y[I])?(Y[I].positionLength+=a[g],Y[I].indexLength+=i[g],Y[I].batchIds.push(g)):Y[I]={positionLength:a[g],indexLength:i[g],offset:0,indexOffset:0,batchIds:[g]};let Z,G=0,_=0;for(I in Y)if(Y.hasOwnProperty(I)){Z=Y[I],Z.offset=G,Z.indexOffset=_;let t=2*Z.positionLength,e=2*Z.indexLength+6*Z.positionLength;G+=t,_+=e,Z.indexLength=e}let H=[];for(I in Y)Y.hasOwnProperty(I)&&(Z=Y[I],H.push({color:R.fromRgba(parseInt(I)),offset:Z.indexOffset,count:Z.indexLength,batchIds:Z.batchIds}));for(g=0;g<j;++g){I=f[g],Z=Y[I];let t=Z.offset,e=3*t,r=t,b=x[g],y=a[g],T=s[g],E=m,j=p;A(d)&&A(k)&&(E=d[g],j=k[g]);let P=Number.POSITIVE_INFINITY,U=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY,W=Number.NEGATIVE_INFINITY;for(w=0;w<y;++w){let t=o.unpack(N,3*b+3*w,wt);l.scaleToGeodeticSurface(t,t);let n=l.cartesianToCartographic(t,Lt),a=n.latitude,i=n.longitude;P=Math.min(a,P),U=Math.max(a,U),R=Math.min(i,R),W=Math.max(i,W);let s=l.geodeticSurfaceNormal(t,Ht),f=o.multiplyByScalar(s,E,St),c=o.add(t,f,Ut);f=o.multiplyByScalar(s,j,f);let u=o.add(t,f,Ft);o.subtract(u,h,u),o.subtract(c,h,c),o.pack(u,B,e),o.pack(c,B,e+3),S[r]=T,S[r+1]=T,e+=6,r+=2}u=Mt,u.west=R,u.east=W,u.south=P,u.north=U,c[g]=M.fromRectangle(u,m,p,l);let G=Z.indexOffset,_=L[g],H=i[g];for(F[g]=G,w=0;w<H;w+=3){let e=n[_+w]-b,r=n[_+w+1]-b,o=n[_+w+2]-b;O[G++]=2*e+t,O[G++]=2*r+t,O[G++]=2*o+t,O[G++]=2*o+1+t,O[G++]=2*r+1+t,O[G++]=2*e+1+t}for(w=0;w<y;++w){let e=w,n=(w+1)%y;O[G++]=2*e+1+t,O[G++]=2*n+t,O[G++]=2*e+t,O[G++]=2*e+1+t,O[G++]=2*n+1+t,O[G++]=2*n+t}Z.offset+=2*y,Z.indexOffset=G,C[g]=G-F[g]}O=W.createTypedArray(B.length/3,O);let V=H.length;for(let t=0;t<V;++t){let e=H[t].batchIds,n=0,r=e.length;for(let t=0;t<r;++t)n+=C[e[t]];H[t].count=n}let v=Ct(2===O.BYTES_PER_ELEMENT?W.UNSIGNED_SHORT:W.UNSIGNED_INT,c,H);return e.push(B.buffer,O.buffer,F.buffer,C.buffer,S.buffer,v.buffer),{positions:B.buffer,indices:O.buffer,indexOffsets:F.buffer,indexCounts:C.buffer,batchIds:S.buffer,packedBuffer:v.buffer}}var Jt=It(Rt);export{Jt as default};