/* 2020-9-22 15:23:25 | 版权所有 军懋国兴 */ define(["./when-cbf8cd21","./Check-35e1a91d","./Math-69007a69","./Cartesian2-43e3a3be","./Transforms-2d1ac5ec","./RuntimeError-f4c64df1","./WebGLConstants-95ceb4e9","./ComponentDatatype-607c9a0c","./AttributeCompression-ea810287","./IntersectionTests-459f6f08","./Plane-46b5436f","./WebMercatorProjection-3da37aae","./createTaskProcessorWorker","./EllipsoidTangentPlane-b5927ee3","./OrientedBoundingBox-5e0b7a7c","./TerrainEncoding-848fa40b"],function(Ye,We,Xe,Ze,je,n,e,t,i,a,r,qe,s,Ge,Qe,Je){"use strict";var l=Object.freeze({NONE:0,LERC:1}),Ke={};Ke.DEFAULT_STRUCTURE=Object.freeze({heightScale:1,heightOffset:0,elementsPerHeight:1,stride:1,elementMultiplier:256,isBigEndian:!1});var $e=new Ze.Cartesian3,et=new je.Matrix4,tt=new Ze.Cartesian3,it=new Ze.Cartesian3;Ke.computeVertices=function(e){if(!Ye.defined(e)||!Ye.defined(e.heightmap))throw new We.DeveloperError("options.heightmap is required.");if(!Ye.defined(e.width)||!Ye.defined(e.height))throw new We.DeveloperError("options.width and options.height are required.");if(!Ye.defined(e.nativeRectangle))throw new We.DeveloperError("options.nativeRectangle is required.");if(!Ye.defined(e.skirtHeight))throw new We.DeveloperError("options.skirtHeight is required.");var t,i,a,r=Math.cos,n=Math.sin,s=Math.sqrt,l=Math.atan,o=Math.exp,f=Xe.CesiumMath.PI_OVER_TWO,u=Xe.CesiumMath.toRadians,d=e.heightmap,c=e.width,h=e.height,m=e.skirtHeight,g=Ye.defaultValue(e.isGeographic,!0),p=Ye.defaultValue(e.ellipsoid,Ze.Ellipsoid.WGS84),w=1/p.maximumRadius,x=e.nativeRectangle,k=e.rectangle,y=Ye.defined(k)?(t=k.west,i=k.south,a=k.east,k.north):g?(t=u(x.west),i=u(x.south),a=u(x.east),u(x.north)):(t=x.west*w,i=f-2*l(o(-x.south*w)),a=x.east*w,f-2*l(o(-x.north*w))),I=e.relativeToCenter,b=Ye.defined(I),I=b?I:Ze.Cartesian3.ZERO,v=Ye.defaultValue(e.exaggeration,1),U=Ye.defaultValue(e.includeWebMercatorT,!1),T=Ye.defaultValue(e.structure,Ke.DEFAULT_STRUCTURE),M=Ye.defaultValue(T.heightScale,Ke.DEFAULT_STRUCTURE.heightScale),V=Ye.defaultValue(T.heightOffset,Ke.DEFAULT_STRUCTURE.heightOffset),A=Ye.defaultValue(T.elementsPerHeight,Ke.DEFAULT_STRUCTURE.elementsPerHeight),D=Ye.defaultValue(T.stride,Ke.DEFAULT_STRUCTURE.stride),B=Ye.defaultValue(T.elementMultiplier,Ke.DEFAULT_STRUCTURE.elementMultiplier),S=Ye.defaultValue(T.isBigEndian,Ke.DEFAULT_STRUCTURE.isBigEndian),P=Ze.Rectangle.computeWidth(x),E=Ze.Rectangle.computeHeight(x),C=P/(c-1),F=E/(h-1);g||(P*=w,E*=w);var L,O,N=p.radiiSquared,R=N.x,z=N.y,H=N.z,_=65536,Y=-65536,W=je.Transforms.eastNorthUpToFixedFrame(I,p),X=je.Matrix4.inverseTransformation(W,et);U&&(L=qe.WebMercatorProjection.geodeticLatitudeToMercatorAngle(i),O=1/(qe.WebMercatorProjection.geodeticLatitudeToMercatorAngle(y)-L));var Z=tt;Z.x=Number.POSITIVE_INFINITY,Z.y=Number.POSITIVE_INFINITY,Z.z=Number.POSITIVE_INFINITY;var j=it;j.x=Number.NEGATIVE_INFINITY,j.y=Number.NEGATIVE_INFINITY,j.z=Number.NEGATIVE_INFINITY;var q=Number.POSITIVE_INFINITY,G=c*h,Q=G+(0>3],T<<=7&M),g=0;g>3]),128&T?(l&&(l[M]=1),m=(n=A.encoding<2?b[v++]:U)>=6,2===(y.offsetType=U))y.offset=n.getInt8(1),x++;else if(1===U)y.offset=n.getInt16(1,!0),x+=2;else{if(0!==U)throw"Invalid block offset type";y.offset=n.getFloat32(1,!0),x+=4}if(1===y.encoding)if(U=n.getUint8(x),x++,y.bitsPerPixel=63&U,U>>=6,2===(y.numValidPixelsType=U))y.numValidPixels=n.getUint8(x),x++;else if(1===U)y.numValidPixels=n.getUint16(x,!0),x+=2;else{if(0!==U)throw"Invalid valid pixel count type";y.numValidPixels=n.getUint32(x,!0),x+=4}}if(t+=x,3!==y.encoding)if(0===y.encoding){var T=(a.pixels.numBytes-1)/4;if(T!==Math.floor(T))throw"uncompressed block has invalid length";v=new ArrayBuffer(4*T),new Uint8Array(v).set(new Uint8Array(e,t,4*T));var M=new Float32Array(v);y.rawData=M,t+=4*T}else{1===y.encoding&&(I=Math.ceil(y.numValidPixels*y.bitsPerPixel/8),b=Math.ceil(I/4),v=new ArrayBuffer(4*b),new Uint8Array(v).set(new Uint8Array(e,t,I)),y.stuffedData=new Uint32Array(v),t+=I)}}else t++}return a.eofOffset=t,a},D=function(e,t,i,a,r,n,s){var l,o,f,u,d=(1<>>h-t&d,h-=t):(f=(u&d)<<(o=t-h)&d,f+=(u=e[c++])>>>(h=32-o)),n[l]=f>>g-i&h,g-=i):(f=(u&h)<<(d=i-g)&h,f+=(u=e[m++])>>>(g=32-d)),t[o]=r[f];else for(c=Math.ceil((l-n)/s),o=0;o>>g-i&h,g-=i):(f=(u&h)<<(d=i-g)&h,f+=(u=e[m++])>>>(g=32-d)),t[o]=f>>d-t&o,d-=t):(c=(l&o)<<(s=t-d)&o,c+=(l=e[f++])>>>(d=32-s)),h[u]=c>>m&d,h-=i,m+=i):(o=f>>>m&d,h=32-(u=i-h),o|=((f=e[c++])&(1<>>m&d,h-=i,m+=i):(o=f>>>m&d,h=32-(u=i-h),o|=((f=e[c++])&(1<>>h&o,d-=t,h+=t):(c=l>>>h&o,d=32-(s=t-d),c|=((l=e[f++])&(1<>>u-i&o,u-=i):(n=(s&o)<<(l=i-u)&o,n+=(s=e[f++])>>>(u=32-l)),t[r]=n;return t},E=function(e,t,i,a){for(var r,n,s,l=(1<>>u&l,f-=i,u+=i):(r=n>>>u&l,f=32-(s=i-f),r|=((n=e[o++])&(1<>>16),i=(65535&i)+(i>>>16)}return 1&a&&(i+=t+=e[n]<<8),((i=(65535&i)+(i>>>16))<<16|(t=(65535&t)+(t>>>16)))>>>0},readHeaderInfo:function(e,t){var i=t.ptr,a=new Uint8Array(e,i,6),r={};if(r.fileIdentifierString=String.fromCharCode.apply(null,a),0!==r.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+r.fileIdentifierString;i+=6;var n,s=new DataView(e,i,8),l=s.getInt32(0,!0);if(i+=4,3<=(r.fileVersion=l)&&(r.checksum=s.getUint32(4,!0),i+=4),s=new DataView(e,i,12),r.height=s.getUint32(0,!0),r.width=s.getUint32(4,!0),i+=8,4<=l?(r.numDims=s.getUint32(8,!0),i+=4):r.numDims=1,s=new DataView(e,i,40),r.numValidPixel=s.getUint32(0,!0),r.microBlockSize=s.getInt32(4,!0),r.blobSize=s.getInt32(8,!0),r.imageType=s.getInt32(12,!0),r.maxZError=s.getFloat64(16,!0),r.zMin=s.getFloat64(24,!0),r.zMax=s.getFloat64(32,!0),i+=40,t.headerInfo=r,t.ptr=i,3<=l&&(n=4<=l?52:48,this.computeChecksumFletcher32(new Uint8Array(e,i-n,r.blobSize-14))!==r.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(e,t){var i=t.headerInfo,a=this.getDataTypeArray(i.imageType),r=i.numDims*this.getDataTypeSize(i.imageType),n=this.readSubArray(e,t.ptr,a,r),s=this.readSubArray(e,t.ptr+r,a,r);t.ptr+=2*r;for(var l=!0,o=0;o>3],m<<=7&g):m=i[g>>3],128&m&&(a[g]=1);t.pixels.resultMask=a,f.bitset=i,r+=f.numBytes}return t.ptr=r,t.mask=f,!0},readDataOneSweep:function(e,t,i){var a,r=t.ptr,n=t.headerInfo,s=n.numDims,l=n.width*n.height,o=n.imageType,f=n.numValidPixel*z.getDataTypeSize(o)*s,u=t.pixels.resultMask,d=i===Uint8Array?new Uint8Array(e,r,f):(a=new ArrayBuffer(f),new Uint8Array(a).set(new Uint8Array(e,r,f)),new i(a));if(d.length===l*s)t.pixels.resultPixels=d;else{t.pixels.resultPixels=new i(l*s);var c,h=0,m=0,g=0;if(1>>32-u,u<=32-w?32===(w+=u)&&(w=0,k=p[++x]):(w+=u-32,k=p[++x],d[o].second|=k>>>32-w));var y=0,I=0,b=new C;for(c=0;c>>M&1?(V.right||(V.right=new C),V.right):(V.left||(V.left=new C),V.left),0!==M||V.val||(V.val=v[1]);return{decodeLut:A,numBitsLUTQick:I,numBitsLUT:y,tree:b,stuffedData:p,srcPtr:x,bitPos:w}},readHuffman:function(e,t,i){var a,r,n,s,l,o,f,u,d,c=t.headerInfo,h=c.numDims,m=t.headerInfo.height,g=t.headerInfo.width,p=g*m,w=this.readHuffmanTree(e,t),x=w.decodeLut,k=w.tree,y=w.stuffedData,I=w.srcPtr,b=w.bitPos,v=w.numBitsLUTQick,U=w.numBitsLUT,T=0===t.headerInfo.imageType?128:0,M=t.pixels.resultMask,V=0;0>>32-v,32-b>>64-b-v),x[l])r=x[l][1],b+=x[l][0];else for(l=s=A<>>32-U,32-b>>64-b-U),a=k,d=0;d>>U-d-1&1?a.right:a.left).left&&!a.right){r=a.val,b=b+d+1;break}32<=b&&(b-=32,A=y[++I]),n=r-T,D?(n+=!(0>>32-v,32-b>>64-b-v),x[l])r=x[l][1],b+=x[l][0];else for(l=s=A<>>32-U,32-b>>64-b-U),a=k,d=0;d>>U-d-1&1?a.right:a.left).left&&!a.right){r=a.val,b=b+d+1;break}32<=b&&(b-=32,A=y[++I]),n=r-T,D?(!(0>6,c=0==d?4:3-d,h=0<(32&u),m=31&u,g=0;if(1==c)g=f.getUint8(l),l++;else if(2==c)g=f.getUint16(l,!0),l+=2;else{if(4!=c)throw"Invalid valid pixel count type";g=f.getUint32(l,!0),l+=4}var p,w,x,k,y,I,b,v,U,T=2*n.maxZError,M=1>>U;)U++;k=Math.ceil(g*U/8),y=Math.ceil(k/4),w=new ArrayBuffer(4*y),(x=new Uint8Array(w)).set(new Uint8Array(e,t.ptr,k)),p=new Uint32Array(w),t.ptr+=k,I=(3<=s?S:A)(b,m,v-1,a,T,M),(3<=s?B:V)(p,i,U,g,I)}else t.counter.bitstuffer++,U=m,t.ptr+=l,0>6&255,(m>>2&15)!=(D*s>>3&15))throw"integrity issue";if(3<(b=3&m))throw t.ptr+=E,"Invalid block encoding ("+b+")";if(2!=b)if(0==b){if(t.counter.uncompressed++,t.ptr+=E,S=(S=d*c*o)<(w=e.byteLength-t.ptr)?S:w,y=new ArrayBuffer(S%o==0?S:S+o-S%o),new Uint8Array(y).set(new Uint8Array(e,t.ptr,S)),I=new i(y),P=0,N)for(M=0;M