qa-prevention-gwj-vue/static/map/cesium91/CesiumUnminified/Workers/createVectorTilePolygons.js

2 lines
5.0 KiB
JavaScript

define(["./AttributeCompression-8f752c03","./Cartesian3-e0307675","./Cartesian2-bd414876","./Color-82ef4a75","./defaultValue-81eec7ed","./IndexDatatype-3f3c99e8","./Math-e73894ab","./OrientedBoundingBox-c5d2adb7","./Rectangle-cf3e0e3e","./createTaskProcessorWorker","./ComponentDatatype-aaeec80f","./Check-741c5f3c","./WebGLConstants-508b9636","./Matrix4-4c545f70","./RuntimeError-26acdd3b","./Matrix2-dc0c61cc","./Transforms-5b829630","./when-422ea0ae","./Resource-8ae1a924","./combine-3c023bda","./BoundingSphere-9a3b5656","./GeographicProjection-c931c7fb","./EllipsoidTangentPlane-4d138901","./AxisAlignedBoundingBox-8774439c","./IntersectionTests-80510c7b","./Plane-bc8b6777"],(function(e,t,n,a,r,o,i,s,c,f,d,l,u,h,g,p,b,C,m,y,I,x,w,A,B,E){"use strict";const N=new t.Cartesian3,T=new n.Ellipsoid,k=new c.Rectangle,L={min:void 0,max:void 0,indexBytesPerElement:void 0};function O(e,t,n){const r=t.length,o=2+r*s.OrientedBoundingBox.packedLength+1+function(e){const t=e.length;let n=0;for(let r=0;r<t;++r)n+=a.Color.packedLength+3+e[r].batchIds.length;return n}(n),i=new Float64Array(o);let c=0;i[c++]=e,i[c++]=r;for(let e=0;e<r;++e)s.OrientedBoundingBox.pack(t[e],i,c),c+=s.OrientedBoundingBox.packedLength;const f=n.length;i[c++]=f;for(let e=0;e<f;++e){const t=n[e];a.Color.pack(t.color,i,c),c+=a.Color.packedLength,i[c++]=t.offset,i[c++]=t.count;const r=t.batchIds,o=r.length;i[c++]=o;for(let e=0;e<o;++e)i[c++]=r[e]}return i}const P=new t.Cartesian3,U=new t.Cartesian3,R=new t.Cartesian3,S=new t.Cartesian3,F=new t.Cartesian3,M=new n.Cartographic,D=new c.Rectangle;return f((function(f,d){let l;!function(e){const a=new Float64Array(e);let r=0;L.indexBytesPerElement=a[r++],L.min=a[r++],L.max=a[r++],t.Cartesian3.unpack(a,r,N),r+=t.Cartesian3.packedLength,n.Ellipsoid.unpack(a,r,T),r+=n.Ellipsoid.packedLength,c.Rectangle.unpack(a,r,k)}(f.packedBuffer),l=2===L.indexBytesPerElement?new Uint16Array(f.indices):new Uint32Array(f.indices);const u=new Uint16Array(f.positions),h=new Uint32Array(f.counts),g=new Uint32Array(f.indexCounts),p=new Uint32Array(f.batchIds),b=new Uint32Array(f.batchTableColors),C=new Array(h.length),m=N,y=T;let I=k;const x=L.min,w=L.max;let A,B,E,_=f.minimumHeights,G=f.maximumHeights;r.defined(_)&&r.defined(G)&&(_=new Float32Array(_),G=new Float32Array(G));const V=u.length/2,Y=u.subarray(0,V),v=u.subarray(V,2*V);e.AttributeCompression.zigZagDeltaDecode(Y,v);const H=new Float64Array(3*V);for(A=0;A<V;++A){const e=Y[A],a=v[A],r=i.CesiumMath.lerp(I.west,I.east,e/32767),o=i.CesiumMath.lerp(I.south,I.north,a/32767),s=n.Cartographic.fromRadians(r,o,0,M),c=y.cartographicToCartesian(s,P);t.Cartesian3.pack(c,H,3*A)}const W=h.length,j=new Array(W),z=new Array(W);let Z=0,q=0;for(A=0;A<W;++A)j[A]=Z,z[A]=q,Z+=h[A],q+=g[A];const J=new Float32Array(3*V*2),K=new Uint16Array(2*V),Q=new Uint32Array(z.length),X=new Uint32Array(g.length);let $=[];const ee={};for(A=0;A<W;++A)E=b[A],r.defined(ee[E])?(ee[E].positionLength+=h[A],ee[E].indexLength+=g[A],ee[E].batchIds.push(A)):ee[E]={positionLength:h[A],indexLength:g[A],offset:0,indexOffset:0,batchIds:[A]};let te,ne=0,ae=0;for(E in ee)if(ee.hasOwnProperty(E)){te=ee[E],te.offset=ne,te.indexOffset=ae;const e=2*te.positionLength,t=2*te.indexLength+6*te.positionLength;ne+=e,ae+=t,te.indexLength=t}const re=[];for(E in ee)ee.hasOwnProperty(E)&&(te=ee[E],re.push({color:a.Color.fromRgba(parseInt(E)),offset:te.indexOffset,count:te.indexLength,batchIds:te.batchIds}));for(A=0;A<W;++A){E=b[A],te=ee[E];const e=te.offset;let n=3*e,a=e;const o=j[A],i=h[A],c=p[A];let f=x,d=w;r.defined(_)&&r.defined(G)&&(f=_[A],d=G[A]);let u=Number.POSITIVE_INFINITY,N=Number.NEGATIVE_INFINITY,T=Number.POSITIVE_INFINITY,k=Number.NEGATIVE_INFINITY;for(B=0;B<i;++B){const e=t.Cartesian3.unpack(H,3*o+3*B,P);y.scaleToGeodeticSurface(e,e);const r=y.cartesianToCartographic(e,M),i=r.latitude,s=r.longitude;u=Math.min(i,u),N=Math.max(i,N),T=Math.min(s,T),k=Math.max(s,k);const l=y.geodeticSurfaceNormal(e,U);let h=t.Cartesian3.multiplyByScalar(l,f,R);const g=t.Cartesian3.add(e,h,S);h=t.Cartesian3.multiplyByScalar(l,d,h);const p=t.Cartesian3.add(e,h,F);t.Cartesian3.subtract(p,m,p),t.Cartesian3.subtract(g,m,g),t.Cartesian3.pack(p,J,n),t.Cartesian3.pack(g,J,n+3),K[a]=c,K[a+1]=c,n+=6,a+=2}I=D,I.west=T,I.east=k,I.south=u,I.north=N,C[A]=s.OrientedBoundingBox.fromRectangle(I,x,w,y);let L=te.indexOffset;const O=z[A],V=g[A];for(Q[A]=L,B=0;B<V;B+=3){const t=l[O+B]-o,n=l[O+B+1]-o,a=l[O+B+2]-o;$[L++]=2*t+e,$[L++]=2*n+e,$[L++]=2*a+e,$[L++]=2*a+1+e,$[L++]=2*n+1+e,$[L++]=2*t+1+e}for(B=0;B<i;++B){const t=B,n=(B+1)%i;$[L++]=2*t+1+e,$[L++]=2*n+e,$[L++]=2*t+e,$[L++]=2*t+1+e,$[L++]=2*n+1+e,$[L++]=2*n+e}te.offset+=2*i,te.indexOffset=L,X[A]=L-Q[A]}$=o.IndexDatatype.createTypedArray(J.length/3,$);const oe=re.length;for(let e=0;e<oe;++e){const t=re[e].batchIds;let n=0;const a=t.length;for(let e=0;e<a;++e)n+=X[t[e]];re[e].count=n}const ie=O(2===$.BYTES_PER_ELEMENT?o.IndexDatatype.UNSIGNED_SHORT:o.IndexDatatype.UNSIGNED_INT,C,re);return d.push(J.buffer,$.buffer,Q.buffer,X.buffer,K.buffer,ie.buffer),{positions:J.buffer,indices:$.buffer,indexOffsets:Q.buffer,indexCounts:X.buffer,batchIds:K.buffer,packedBuffer:ie.buffer}}))}));