基于北京SDK的方案预演功能
surprise
2024-04-24 2891e19c690853fa6542502bcd230b6130e95810
1
2
3
define(["./Matrix3-f420af38","./AxisAlignedBoundingBox-817cca2a","./Transforms-ef48b970","./Matrix2-69530458","./defaultValue-f6d5e6da","./TerrainEncoding-4be601fb","./Math-355606c6","./OrientedBoundingBox-e0bc9e6f","./WebMercatorProjection-32cda14d","./AttributeCompression-913aafb2","./RuntimeError-9b4ce3fb","./createTaskProcessorWorker","./combine-0c102d93","./ComponentDatatype-ab629b88","./WebGLConstants-7f557f93","./EllipsoidTangentPlane-312cf901","./IntersectionTests-36dc9259","./Plane-a470374c"],(function(e,t,i,a,n,r,s,l,o,f,u,c,d,h,m,g,p,x){"use strict";var w=Object.freeze({NONE:0,LERC:1});const y={};function k(e,t){let i,a,n,r,s=0;const l=t.length;for(n=t[0],i=1;i<=l;i++)r=t[i%l],e[0]>Math.min(n[0],r[0])&&e[0]<=Math.max(n[0],r[0])&&e[1]<=Math.max(n[1],r[1])&&n[0]!==r[0]&&(a=(e[0]-n[0])*(r[1]-n[1])/(r[0]-n[0])+n[1],(n[1]===r[1]||e[1]<=a)&&s++),n=r;return s%2!=0}y.DEFAULT_STRUCTURE=Object.freeze({heightScale:1,heightOffset:0,elementsPerHeight:1,stride:1,elementMultiplier:256,isBigEndian:!1});const I=new e.Cartesian3,b=new a.Matrix4,U=new e.Cartesian3,M=new e.Cartesian3;y.computeVertices=function(u){const c=u.flattenPolygonHeight||[1],d=u.flattenPolygon||[],h=u.VTN,m=Math.cos,g=Math.sin,p=Math.sqrt,x=Math.atan,w=Math.exp,T=s.CesiumMath.PI_OVER_TWO,v=s.CesiumMath.toRadians,V=u.heightmap,A=u.width,B=u.height,D=u.skirtHeight,S=D>0,P=n.defaultValue(u.isGeographic,!0),E=n.defaultValue(u.ellipsoid,e.Ellipsoid.WGS84),C=1/E.maximumRadius,F=a.Rectangle.clone(u.nativeRectangle),N=a.Rectangle.clone(u.rectangle);let O,R,L,z;n.defined(N)?(O=N.west,R=N.south,L=N.east,z=N.north):P?(O=v(F.west),R=v(F.south),L=v(F.east),z=v(F.north)):(O=F.west*C,R=T-2*x(w(-F.south*C)),L=F.east*C,z=T-2*x(w(-F.north*C)));let H=u.relativeToCenter;const _=n.defined(H);H=_?H:e.Cartesian3.ZERO;const Y=n.defaultValue(u.includeWebMercatorT,!1),W=n.defaultValue(u.exaggeration,1),X=n.defaultValue(u.exaggerationRelativeHeight,0),Z=1!==W,j=n.defaultValue(u.structure,y.DEFAULT_STRUCTURE),G=n.defaultValue(j.heightScale,y.DEFAULT_STRUCTURE.heightScale),q=n.defaultValue(j.heightOffset,y.DEFAULT_STRUCTURE.heightOffset),Q=n.defaultValue(j.elementsPerHeight,y.DEFAULT_STRUCTURE.elementsPerHeight),J=n.defaultValue(j.stride,y.DEFAULT_STRUCTURE.stride),K=n.defaultValue(j.elementMultiplier,y.DEFAULT_STRUCTURE.elementMultiplier),$=n.defaultValue(j.isBigEndian,y.DEFAULT_STRUCTURE.isBigEndian);let ee=a.Rectangle.computeWidth(F),te=a.Rectangle.computeHeight(F);const ie=ee/(A-1),ae=te/(B-1);P||(ee*=C,te*=C);const ne=E.radiiSquared,re=ne.x,se=ne.y,le=ne.z;let oe=65536,fe=-65536;const ue=i.Transforms.eastNorthUpToFixedFrame(H,E),ce=a.Matrix4.inverseTransformation(ue,b);let de,he;Y&&(de=o.WebMercatorProjection.geodeticLatitudeToMercatorAngle(R),he=1/(o.WebMercatorProjection.geodeticLatitudeToMercatorAngle(z)-de));const me=U;me.x=Number.POSITIVE_INFINITY,me.y=Number.POSITIVE_INFINITY,me.z=Number.POSITIVE_INFINITY;const ge=M;ge.x=Number.NEGATIVE_INFINITY,ge.y=Number.NEGATIVE_INFINITY,ge.z=Number.NEGATIVE_INFINITY;let pe=Number.POSITIVE_INFINITY;const xe=A*B,we=xe+(D>0?2*A+2*B:0),ye=new Array(we),ke=new Array(we),Ie=new Array(we),be=Y?new Array(we):[],Ue=Z?new Array(we):[],Me=new Array(we);let Te=0,ve=B,Ve=0,Ae=A;S&&(--Te,++ve,--Ve,++Ae);const Be=1e-5;for(let t=Te;t<ve;++t){let i=t;i<0&&(i=0),i>=B&&(i=B-1);let n=F.north-ae*i;n=P?v(n):T-2*x(w(-n*C));let r=(n-R)/(z-R);r=s.CesiumMath.clamp(r,0,1);const l=t===Te,f=t===ve-1;D>0&&(l?n+=Be*te:f&&(n-=Be*te));const u=m(n),h=g(n),y=le*h;let b;Y&&(b=(o.WebMercatorProjection.geodeticLatitudeToMercatorAngle(n)-de)*he);for(let t=Ve;t<Ae;++t){let o=t;o<0&&(o=0),o>=A&&(o=A-1);const x=i*(A*J)+o*J;let w;if(1===Q)w=V[x];else{let e;if(w=0,$)for(e=0;e<Q;++e)w=w*K+V[x+e];else for(e=Q-1;e>=0;--e)w=w*K+V[x+e]}w=w*G+q,fe=Math.max(fe,w),oe=Math.min(oe,w);let U=F.west+ie*o;P?U=v(U):U*=C;let M=(U-O)/(L-O);M=s.CesiumMath.clamp(M,0,1);let T=i*A+o;if(Me[T]=0,D>0){const e=t===Ve,a=t===Ae-1,n=l||f||e||a;if((l||f)&&(e||a))continue;n&&(w-=D,e?(T=xe+(B-i-1),U-=Be*ee):f?T=xe+B+(A-o-1):a?(T=xe+B+A+i,U+=Be*ee):l&&(T=xe+B+A+B+o),Me[T]=1)}const S=u*m(U),N=u*g(U),R=re*S,z=se*N,H=1/p(R*S+z*N+y*h),_=R*H,W=z*H,X=y*H;for(let e=0;e<c.length;e++)if(1!==c[e]){k([U,n],d[e])&&(w=c[e])}const j=new e.Cartesian3;j.x=_+S*w,j.y=W+N*w,j.z=X+h*w,a.Matrix4.multiplyByPoint(ce,j,I),e.Cartesian3.minimumByComponent(I,me,me),e.Cartesian3.maximumByComponent(I,ge,ge),pe=Math.min(pe,w),ye[T]=j,Ie[T]=new a.Cartesian2(M,r),ke[T]=w,Y&&(be[T]=b),Z&&(Ue[T]=E.geodeticSurfaceNormal(j))}}const De=new Array(we);if(D>0){let t=0;for(let i=0;i<B;++i){let a=-1,n=1;i<2&&(a=0),i>=B-1&&(n=0);for(let r=0;r<A;++r){let s=-1,l=1;r<2&&(s=0),r>=A-1&&(l=0),t=i*A+r;try{const o=ye[(i+a)*A+r],u=ye[(i+n)*A+r],c=ye[i*A+(r+s)],d=ye[i*A+(r+l)],h=e.Cartesian3.subtract(c,d,new e.Cartesian3),m=e.Cartesian3.subtract(o,u,new e.Cartesian3),g=e.Cartesian3.cross(h,m,new e.Cartesian3),p=e.Cartesian3.normalize(g,new e.Cartesian3);De[t]=f.AttributeCompression.octEncodeFloat(p)}catch(e){De[t]=0}}}}const Se=i.BoundingSphere.fromPoints(ye);let Pe,Ee;if(n.defined(N)&&(Pe=l.OrientedBoundingBox.fromRectangle(N,oe,fe,E)),_){Ee=new r.EllipsoidalOccluder(E).computeHorizonCullingPointPossiblyUnderEllipsoid(H,ye,oe)}const Ce=new t.AxisAlignedBoundingBox(me,ge,H),Fe=new r.TerrainEncoding(H,Ce,pe,fe,ue,!!h&&D>0,Y,Z,W,X),Ne=new Float32Array(we*Fe.stride);let Oe=0;for(let e=0;e<we;++e)Oe=Fe.encode(Ne,Oe,ye[e],Ie[e],ke[e],D>0?De[e]:void 0,be[e],Ue[e],D>0||void 0,void 0,Me[e]);return{vertices:Ne,maximumHeight:fe,minimumHeight:oe,encoding:Fe,boundingSphere3D:Se,orientedBoundingBox:Pe,occludeePointInScaledSpace:Ee}};var T,v=y,V={exports:{}};T=V,
/* Copyright 2015-2018 Esri. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 @preserve */
function(){var e,t,i,a,n,r,s,l,o,f,u,c,d,h,m,g,p=(e={defaultNoDataValue:-34027999387901484e22,decode:function(r,s){var l=(s=s||{}).encodedMaskData||null===s.encodedMaskData,o=n(r,s.inputOffset||0,l),f=null!==s.noDataValue?s.noDataValue:e.defaultNoDataValue,u=t(o,s.pixelType||Float32Array,s.encodedMaskData,f,s.returnMask),c={width:o.width,height:o.height,pixelData:u.resultPixels,minValue:u.minValue,maxValue:o.pixels.maxValue,noDataValue:f};return u.resultMask&&(c.maskData=u.resultMask),s.returnEncodedMask&&o.mask&&(c.encodedMaskData=o.mask.bitset?o.mask.bitset:null),s.returnFileInfo&&(c.fileInfo=i(o),s.computeUsedBitDepths&&(c.fileInfo.bitDepths=a(o))),c}},t=function(e,t,i,a,n){var s,l,o,f=0,u=e.pixels.numBlocksX,c=e.pixels.numBlocksY,d=Math.floor(e.width/u),h=Math.floor(e.height/c),m=2*e.maxZError,g=Number.MAX_VALUE;i=i||(e.mask?e.mask.bitset:null),l=new t(e.width*e.height),n&&i&&(o=new Uint8Array(e.width*e.height));for(var p,x,w=new Float32Array(d*h),y=0;y<=c;y++){var k=y!==c?h:e.height%c;if(0!==k)for(var I=0;I<=u;I++){var b=I!==u?d:e.width%u;if(0!==b){var U,M,T,v,V=y*e.width*h+I*d,A=e.width-b,B=e.pixels.blocks[f];if(B.encoding<2?(0===B.encoding?U=B.rawData:(r(B.stuffedData,B.bitsPerPixel,B.numValidPixels,B.offset,m,w,e.pixels.maxValue),U=w),M=0):T=2===B.encoding?0:B.offset,i)for(x=0;x<k;x++){for(7&V&&(v=i[V>>3],v<<=7&V),p=0;p<b;p++)7&V||(v=i[V>>3]),128&v?(o&&(o[V]=1),g=g>(s=B.encoding<2?U[M++]:T)?s:g,l[V++]=s):(o&&(o[V]=0),l[V++]=a),v<<=1;V+=A}else if(B.encoding<2)for(x=0;x<k;x++){for(p=0;p<b;p++)g=g>(s=U[M++])?s:g,l[V++]=s;V+=A}else for(g=g>T?T:g,x=0;x<k;x++){for(p=0;p<b;p++)l[V++]=T;V+=A}if(1===B.encoding&&M!==B.numValidPixels)throw"Block and Mask do not match";f++}}}return{resultPixels:l,resultMask:o,minValue:g}},i=function(e){return{fileIdentifierString:e.fileIdentifierString,fileVersion:e.fileVersion,imageType:e.imageType,height:e.height,width:e.width,maxZError:e.maxZError,eofOffset:e.eofOffset,mask:e.mask?{numBlocksX:e.mask.numBlocksX,numBlocksY:e.mask.numBlocksY,numBytes:e.mask.numBytes,maxValue:e.mask.maxValue}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,numBytes:e.pixels.numBytes,maxValue:e.pixels.maxValue,noDataValue:e.noDataValue}}},a=function(e){for(var t=e.pixels.numBlocksX*e.pixels.numBlocksY,i={},a=0;a<t;a++){var n=e.pixels.blocks[a];0===n.encoding?i.float32=!0:1===n.encoding?i[n.bitsPerPixel]=!0:i[0]=!0}return Object.keys(i)},n=function(e,t,i){var a={},n=new Uint8Array(e,t,10);if(a.fileIdentifierString=String.fromCharCode.apply(null,n),"CntZImage"!==a.fileIdentifierString.trim())throw"Unexpected file identifier string: "+a.fileIdentifierString;t+=10;var r=new DataView(e,t,24);if(a.fileVersion=r.getInt32(0,!0),a.imageType=r.getInt32(4,!0),a.height=r.getUint32(8,!0),a.width=r.getUint32(12,!0),a.maxZError=r.getFloat64(16,!0),t+=24,!i)if(r=new DataView(e,t,16),a.mask={},a.mask.numBlocksY=r.getUint32(0,!0),a.mask.numBlocksX=r.getUint32(4,!0),a.mask.numBytes=r.getUint32(8,!0),a.mask.maxValue=r.getFloat32(12,!0),t+=16,a.mask.numBytes>0){var s=new Uint8Array(Math.ceil(a.width*a.height/8)),l=(r=new DataView(e,t,a.mask.numBytes)).getInt16(0,!0),o=2,f=0;do{if(l>0)for(;l--;)s[f++]=r.getUint8(o++);else{var u=r.getUint8(o++);for(l=-l;l--;)s[f++]=u}l=r.getInt16(o,!0),o+=2}while(o<a.mask.numBytes);if(-32768!==l||f<s.length)throw"Unexpected end of mask RLE encoding";a.mask.bitset=s,t+=a.mask.numBytes}else 0==(a.mask.numBytes|a.mask.numBlocksY|a.mask.maxValue)&&(a.mask.bitset=new Uint8Array(Math.ceil(a.width*a.height/8)));r=new DataView(e,t,16),a.pixels={},a.pixels.numBlocksY=r.getUint32(0,!0),a.pixels.numBlocksX=r.getUint32(4,!0),a.pixels.numBytes=r.getUint32(8,!0),a.pixels.maxValue=r.getFloat32(12,!0),t+=16;var c=a.pixels.numBlocksX,d=a.pixels.numBlocksY,h=c+(a.width%c>0?1:0),m=d+(a.height%d>0?1:0);a.pixels.blocks=new Array(h*m);for(var g=0,p=0;p<m;p++)for(var x=0;x<h;x++){var w=0,y=e.byteLength-t;r=new DataView(e,t,Math.min(10,y));var k={};a.pixels.blocks[g++]=k;var I=r.getUint8(0);if(w++,k.encoding=63&I,k.encoding>3)throw"Invalid block encoding ("+k.encoding+")";if(2!==k.encoding){if(0!==I&&2!==I){if(I>>=6,k.offsetType=I,2===I)k.offset=r.getInt8(1),w++;else if(1===I)k.offset=r.getInt16(1,!0),w+=2;else{if(0!==I)throw"Invalid block offset type";k.offset=r.getFloat32(1,!0),w+=4}if(1===k.encoding)if(I=r.getUint8(w),w++,k.bitsPerPixel=63&I,I>>=6,k.numValidPixelsType=I,2===I)k.numValidPixels=r.getUint8(w),w++;else if(1===I)k.numValidPixels=r.getUint16(w,!0),w+=2;else{if(0!==I)throw"Invalid valid pixel count type";k.numValidPixels=r.getUint32(w,!0),w+=4}}var b;if(t+=w,3!==k.encoding)if(0===k.encoding){var U=(a.pixels.numBytes-1)/4;if(U!==Math.floor(U))throw"uncompressed block has invalid length";b=new ArrayBuffer(4*U),new Uint8Array(b).set(new Uint8Array(e,t,4*U));var M=new Float32Array(b);k.rawData=M,t+=4*U}else if(1===k.encoding){var T=Math.ceil(k.numValidPixels*k.bitsPerPixel/8),v=Math.ceil(T/4);b=new ArrayBuffer(4*v),new Uint8Array(b).set(new Uint8Array(e,t,T)),k.stuffedData=new Uint32Array(b),t+=T}}else t++}return a.eofOffset=t,a},r=function(e,t,i,a,n,r,s){var l,o,f,u=(1<<t)-1,c=0,d=0,h=Math.ceil((s-a)/n),m=4*e.length-Math.ceil(t*i/8);for(e[e.length-1]<<=8*m,l=0;l<i;l++){if(0===d&&(f=e[c++],d=32),d>=t)o=f>>>d-t&u,d-=t;else{var g=t-d;o=(f&u)<<g&u,o+=(f=e[c++])>>>(d=32-g)}r[l]=o<h?a+o*n:s}return r},e),x=(s=function(e,t,i,a,n,r,s,l){var o,f,u,c,d,h=(1<<i)-1,m=0,g=0,p=4*e.length-Math.ceil(i*a/8);if(e[e.length-1]<<=8*p,n)for(o=0;o<a;o++)0===g&&(u=e[m++],g=32),g>=i?(f=u>>>g-i&h,g-=i):(f=(u&h)<<(c=i-g)&h,f+=(u=e[m++])>>>(g=32-c)),t[o]=n[f];else for(d=Math.ceil((l-r)/s),o=0;o<a;o++)0===g&&(u=e[m++],g=32),g>=i?(f=u>>>g-i&h,g-=i):(f=(u&h)<<(c=i-g)&h,f+=(u=e[m++])>>>(g=32-c)),t[o]=f<d?r+f*s:l},l=function(e,t,i,a,n,r){var s,l=(1<<t)-1,o=0,f=0,u=0,c=0,d=0,h=[],m=4*e.length-Math.ceil(t*i/8);e[e.length-1]<<=8*m;var g=Math.ceil((r-a)/n);for(f=0;f<i;f++)0===c&&(s=e[o++],c=32),c>=t?(d=s>>>c-t&l,c-=t):(d=(s&l)<<(u=t-c)&l,d+=(s=e[o++])>>>(c=32-u)),h[f]=d<g?a+d*n:r;return h.unshift(a),h},o=function(e,t,i,a,n,r,s,l){var o,f,u,c,d=(1<<i)-1,h=0,m=0,g=0;if(n)for(o=0;o<a;o++)0===m&&(u=e[h++],m=32,g=0),m>=i?(f=u>>>g&d,m-=i,g+=i):(f=u>>>g&d,m=32-(c=i-m),f|=((u=e[h++])&(1<<c)-1)<<i-c,g=c),t[o]=n[f];else{var p=Math.ceil((l-r)/s);for(o=0;o<a;o++)0===m&&(u=e[h++],m=32,g=0),m>=i?(f=u>>>g&d,m-=i,g+=i):(f=u>>>g&d,m=32-(c=i-m),f|=((u=e[h++])&(1<<c)-1)<<i-c,g=c),t[o]=f<p?r+f*s:l}return t},f=function(e,t,i,a,n,r){var s,l=(1<<t)-1,o=0,f=0,u=0,c=0,d=0,h=0,m=[],g=Math.ceil((r-a)/n);for(f=0;f<i;f++)0===c&&(s=e[o++],c=32,h=0),c>=t?(d=s>>>h&l,c-=t,h+=t):(d=s>>>h&l,c=32-(u=t-c),d|=((s=e[o++])&(1<<u)-1)<<t-u,h=u),m[f]=d<g?a+d*n:r;return m.unshift(a),m},u=function(e,t,i,a){var n,r,s,l,o=(1<<i)-1,f=0,u=0,c=4*e.length-Math.ceil(i*a/8);for(e[e.length-1]<<=8*c,n=0;n<a;n++)0===u&&(s=e[f++],u=32),u>=i?(r=s>>>u-i&o,u-=i):(r=(s&o)<<(l=i-u)&o,r+=(s=e[f++])>>>(u=32-l)),t[n]=r;return t},c=function(e,t,i,a){var n,r,s,l,o=(1<<i)-1,f=0,u=0,c=0;for(n=0;n<a;n++)0===u&&(s=e[f++],u=32,c=0),u>=i?(r=s>>>c&o,u-=i,c+=i):(r=s>>>c&o,u=32-(l=i-u),r|=((s=e[f++])&(1<<l)-1)<<i-l,c=l),t[n]=r;return t},d={HUFFMAN_LUT_BITS_MAX:12,computeChecksumFletcher32:function(e){for(var t=65535,i=65535,a=e.length,n=Math.floor(a/2),r=0;n;){var s=n>=359?359:n;n-=s;do{t+=e[r++]<<8,i+=t+=e[r++]}while(--s);t=(65535&t)+(t>>>16),i=(65535&i)+(i>>>16)}return 1&a&&(i+=t+=e[r]<<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),n={};if(n.fileIdentifierString=String.fromCharCode.apply(null,a),0!==n.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+n.fileIdentifierString;i+=6;var r,s=new DataView(e,i,8),l=s.getInt32(0,!0);if(n.fileVersion=l,i+=4,l>=3&&(n.checksum=s.getUint32(4,!0),i+=4),s=new DataView(e,i,12),n.height=s.getUint32(0,!0),n.width=s.getUint32(4,!0),i+=8,l>=4?(n.numDims=s.getUint32(8,!0),i+=4):n.numDims=1,s=new DataView(e,i,40),n.numValidPixel=s.getUint32(0,!0),n.microBlockSize=s.getInt32(4,!0),n.blobSize=s.getInt32(8,!0),n.imageType=s.getInt32(12,!0),n.maxZError=s.getFloat64(16,!0),n.zMin=s.getFloat64(24,!0),n.zMax=s.getFloat64(32,!0),i+=40,t.headerInfo=n,t.ptr=i,l>=3&&(r=l>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(e,i-r,n.blobSize-14))!==n.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(e,t){var i=t.headerInfo,a=this.getDataTypeArray(i.imageType),n=i.numDims*this.getDataTypeSize(i.imageType),r=this.readSubArray(e,t.ptr,a,n),s=this.readSubArray(e,t.ptr+n,a,n);t.ptr+=2*n;var l,o=!0;for(l=0;l<i.numDims;l++)if(r[l]!==s[l]){o=!1;break}return i.minValues=r,i.maxValues=s,o},readSubArray:function(e,t,i,a){var n;if(i===Uint8Array)n=new Uint8Array(e,t,a);else{var r=new ArrayBuffer(a);new Uint8Array(r).set(new Uint8Array(e,t,a)),n=new i(r)}return n},readMask:function(e,t){var i,a,n=t.ptr,r=t.headerInfo,s=r.width*r.height,l=r.numValidPixel,o=new DataView(e,n,4),f={};if(f.numBytes=o.getUint32(0,!0),n+=4,(0===l||s===l)&&0!==f.numBytes)throw"invalid mask";if(0===l)i=new Uint8Array(Math.ceil(s/8)),f.bitset=i,a=new Uint8Array(s),t.pixels.resultMask=a,n+=f.numBytes;else if(f.numBytes>0){i=new Uint8Array(Math.ceil(s/8));var u=(o=new DataView(e,n,f.numBytes)).getInt16(0,!0),c=2,d=0,h=0;do{if(u>0)for(;u--;)i[d++]=o.getUint8(c++);else for(h=o.getUint8(c++),u=-u;u--;)i[d++]=h;u=o.getInt16(c,!0),c+=2}while(c<f.numBytes);if(-32768!==u||d<i.length)throw"Unexpected end of mask RLE encoding";a=new Uint8Array(s);var m=0,g=0;for(g=0;g<s;g++)7&g?(m=i[g>>3],m<<=7&g):m=i[g>>3],128&m&&(a[g]=1);t.pixels.resultMask=a,f.bitset=i,n+=f.numBytes}return t.ptr=n,t.mask=f,!0},readDataOneSweep:function(e,t,i){var a,n=t.ptr,r=t.headerInfo,s=r.numDims,l=r.width*r.height,o=r.imageType,f=r.numValidPixel*d.getDataTypeSize(o)*s,u=t.pixels.resultMask;if(i===Uint8Array)a=new Uint8Array(e,n,f);else{var c=new ArrayBuffer(f);new Uint8Array(c).set(new Uint8Array(e,n,f)),a=new i(c)}if(a.length===l*s)t.pixels.resultPixels=a;else{t.pixels.resultPixels=new i(l*s);var h=0,m=0,g=0,p=0;if(s>1)for(g=0;g<s;g++)for(p=g*l,m=0;m<l;m++)u[m]&&(t.pixels.resultPixels[p+m]=a[h++]);else for(m=0;m<l;m++)u[m]&&(t.pixels.resultPixels[m]=a[h++])}return n+=f,t.ptr=n,!0},readHuffmanTree:function(e,t){var i=this.HUFFMAN_LUT_BITS_MAX,a=new DataView(e,t.ptr,16);if(t.ptr+=16,a.getInt32(0,!0)<2)throw"unsupported Huffman version";var n=a.getInt32(4,!0),r=a.getInt32(8,!0),s=a.getInt32(12,!0);if(r>=s)return!1;var l=new Uint32Array(s-r);d.decodeBits(e,t,l);var o,f,u,c,m=[];for(o=r;o<s;o++)m[f=o-(o<n?0:n)]={first:l[o-r],second:null};var g=e.byteLength-t.ptr,p=Math.ceil(g/4),x=new ArrayBuffer(4*p);new Uint8Array(x).set(new Uint8Array(e,t.ptr,g));var w,y=new Uint32Array(x),k=0,I=0;for(w=y[0],o=r;o<s;o++)(c=m[f=o-(o<n?0:n)].first)>0&&(m[f].second=w<<k>>>32-c,32-k>=c?32===(k+=c)&&(k=0,w=y[++I]):(k+=c-32,w=y[++I],m[f].second|=w>>>32-k));var b=0,U=0,M=new h;for(o=0;o<m.length;o++)void 0!==m[o]&&(b=Math.max(b,m[o].first));U=b>=i?i:b,b>=30&&console.log("WARning, large NUM LUT BITS IS "+b);var T,v,V,A,B,D=[];for(o=r;o<s;o++)if((c=m[f=o-(o<n?0:n)].first)>0)if(T=[c,f],c<=U)for(v=m[f].second<<U-c,V=1<<U-c,u=0;u<V;u++)D[v|u]=T;else for(v=m[f].second,B=M,A=c-1;A>=0;A--)v>>>A&1?(B.right||(B.right=new h),B=B.right):(B.left||(B.left=new h),B=B.left),0!==A||B.val||(B.val=T[1]);return{decodeLut:D,numBitsLUTQick:U,numBitsLUT:b,tree:M,stuffedData:y,srcPtr:I,bitPos:k}},readHuffman:function(e,t,i){var a,n,r,s,l,o,f,u,c,d=t.headerInfo,h=d.numDims,m=t.headerInfo.height,g=t.headerInfo.width,p=g*m,x=this.readHuffmanTree(e,t),w=x.decodeLut,y=x.tree,k=x.stuffedData,I=x.srcPtr,b=x.bitPos,U=x.numBitsLUTQick,M=x.numBitsLUT,T=0===t.headerInfo.imageType?128:0,v=t.pixels.resultMask,V=0;b>0&&(I++,b=0);var A,B=k[I],D=1===t.encodeMode,S=new i(p*h),P=S;for(A=0;A<d.numDims;A++){if(h>1&&(P=new i(S.buffer,p*A,p),V=0),t.headerInfo.numValidPixel===g*m)for(u=0,o=0;o<m;o++)for(f=0;f<g;f++,u++){if(n=0,l=s=B<<b>>>32-U,32-b<U&&(l=s|=k[I+1]>>>64-b-U),w[l])n=w[l][1],b+=w[l][0];else for(l=s=B<<b>>>32-M,32-b<M&&(l=s|=k[I+1]>>>64-b-M),a=y,c=0;c<M;c++)if(!(a=s>>>M-c-1&1?a.right:a.left).left&&!a.right){n=a.val,b=b+c+1;break}b>=32&&(b-=32,B=k[++I]),r=n-T,D?(r+=f>0?V:o>0?P[u-g]:V,r&=255,P[u]=r,V=r):P[u]=r}else for(u=0,o=0;o<m;o++)for(f=0;f<g;f++,u++)if(v[u]){if(n=0,l=s=B<<b>>>32-U,32-b<U&&(l=s|=k[I+1]>>>64-b-U),w[l])n=w[l][1],b+=w[l][0];else for(l=s=B<<b>>>32-M,32-b<M&&(l=s|=k[I+1]>>>64-b-M),a=y,c=0;c<M;c++)if(!(a=s>>>M-c-1&1?a.right:a.left).left&&!a.right){n=a.val,b=b+c+1;break}b>=32&&(b-=32,B=k[++I]),r=n-T,D?(f>0&&v[u-1]?r+=V:o>0&&v[u-g]?r+=P[u-g]:r+=V,r&=255,P[u]=r,V=r):P[u]=r}t.ptr=t.ptr+4*(I+1)+(b>0?4:0)}t.pixels.resultPixels=S},decodeBits:function(e,t,i,a,n){var r=t.headerInfo,d=r.fileVersion,h=0,m=new DataView(e,t.ptr,5),g=m.getUint8(0);h++;var p=g>>6,x=0===p?4:3-p,w=(32&g)>0,y=31&g,k=0;if(1===x)k=m.getUint8(h),h++;else if(2===x)k=m.getUint16(h,!0),h+=2;else{if(4!==x)throw"Invalid valid pixel count type";k=m.getUint32(h,!0),h+=4}var I,b,U,M,T,v,V,A,B,D=2*r.maxZError,S=r.numDims>1?r.maxValues[n]:r.zMax;if(w){for(t.counter.lut++,A=m.getUint8(h),h++,M=Math.ceil((A-1)*y/8),T=Math.ceil(M/4),b=new ArrayBuffer(4*T),U=new Uint8Array(b),t.ptr+=h,U.set(new Uint8Array(e,t.ptr,M)),V=new Uint32Array(b),t.ptr+=M,B=0;A-1>>>B;)B++;M=Math.ceil(k*B/8),T=Math.ceil(M/4),b=new ArrayBuffer(4*T),(U=new Uint8Array(b)).set(new Uint8Array(e,t.ptr,M)),I=new Uint32Array(b),t.ptr+=M,v=d>=3?f(V,y,A-1,a,D,S):l(V,y,A-1,a,D,S),d>=3?o(I,i,B,k,v):s(I,i,B,k,v)}else t.counter.bitstuffer++,B=y,t.ptr+=h,B>0&&(M=Math.ceil(k*B/8),T=Math.ceil(M/4),b=new ArrayBuffer(4*T),(U=new Uint8Array(b)).set(new Uint8Array(e,t.ptr,M)),I=new Uint32Array(b),t.ptr+=M,d>=3?null==a?c(I,i,B,k):o(I,i,B,k,!1,a,D,S):null==a?u(I,i,B,k):s(I,i,B,k,!1,a,D,S))},readTiles:function(e,t,i){var a=t.headerInfo,n=a.width,r=a.height,s=a.microBlockSize,l=a.imageType,o=d.getDataTypeSize(l),f=Math.ceil(n/s),u=Math.ceil(r/s);t.pixels.numBlocksY=u,t.pixels.numBlocksX=f,t.pixels.ptr=0;var c,h,m,g,p,x,w,y,k=0,I=0,b=0,U=0,M=0,T=0,v=0,V=0,A=0,B=0,D=0,S=0,P=0,E=0,C=0,F=new i(s*s),N=r%s||s,O=n%s||s,R=a.numDims,L=t.pixels.resultMask,z=t.pixels.resultPixels;for(b=0;b<u;b++)for(M=b!==u-1?s:N,U=0;U<f;U++)for(B=b*n*s+U*s,D=n-(T=U!==f-1?s:O),y=0;y<R;y++){if(R>1&&(z=new i(t.pixels.resultPixels.buffer,n*r*y*o,n*r)),v=e.byteLength-t.ptr,h={},C=0,C++,A=(V=(c=new DataView(e,t.ptr,Math.min(10,v))).getUint8(0))>>6&255,(V>>2&15)!=(U*s>>3&15))throw"integrity issue";if((p=3&V)>3)throw t.ptr+=C,"Invalid block encoding ("+p+")";if(2!==p)if(0===p){if(t.counter.uncompressed++,t.ptr+=C,S=(S=M*T*o)<(P=e.byteLength-t.ptr)?S:P,m=new ArrayBuffer(S%o==0?S:S+o-S%o),new Uint8Array(m).set(new Uint8Array(e,t.ptr,S)),g=new i(m),E=0,L)for(k=0;k<M;k++){for(I=0;I<T;I++)L[B]&&(z[B]=g[E++]),B++;B+=D}else for(k=0;k<M;k++){for(I=0;I<T;I++)z[B++]=g[E++];B+=D}t.ptr+=E*o}else if(x=d.getDataTypeUsed(l,A),w=d.getOnePixel(h,C,x,c),C+=d.getDataTypeSize(x),3===p)if(t.ptr+=C,t.counter.constantoffset++,L)for(k=0;k<M;k++){for(I=0;I<T;I++)L[B]&&(z[B]=w),B++;B+=D}else for(k=0;k<M;k++){for(I=0;I<T;I++)z[B++]=w;B+=D}else if(t.ptr+=C,d.decodeBits(e,t,F,w,y),C=0,L)for(k=0;k<M;k++){for(I=0;I<T;I++)L[B]&&(z[B]=F[C++]),B++;B+=D}else for(k=0;k<M;k++){for(I=0;I<T;I++)z[B++]=F[C++];B+=D}else t.counter.constant++,t.ptr+=C}},formatFileInfo:function(e){return{fileIdentifierString:e.headerInfo.fileIdentifierString,fileVersion:e.headerInfo.fileVersion,imageType:e.headerInfo.imageType,height:e.headerInfo.height,width:e.headerInfo.width,numValidPixel:e.headerInfo.numValidPixel,microBlockSize:e.headerInfo.microBlockSize,blobSize:e.headerInfo.blobSize,maxZError:e.headerInfo.maxZError,pixelType:d.getPixelType(e.headerInfo.imageType),eofOffset:e.eofOffset,mask:e.mask?{numBytes:e.mask.numBytes}:null,pixels:{numBlocksX:e.pixels.numBlocksX,numBlocksY:e.pixels.numBlocksY,maxValue:e.headerInfo.zMax,minValue:e.headerInfo.zMin,noDataValue:e.noDataValue}}},constructConstantSurface:function(e){var t=e.headerInfo.zMax,i=e.headerInfo.numDims,a=e.headerInfo.height*e.headerInfo.width,n=a*i,r=0,s=0,l=0,o=e.pixels.resultMask;if(o)if(i>1)for(r=0;r<i;r++)for(l=r*a,s=0;s<a;s++)o[s]&&(e.pixels.resultPixels[l+s]=t);else for(s=0;s<a;s++)o[s]&&(e.pixels.resultPixels[s]=t);else if(e.pixels.resultPixels.fill)e.pixels.resultPixels.fill(t);else for(s=0;s<n;s++)e.pixels.resultPixels[s]=t},getDataTypeArray:function(e){var t;switch(e){case 0:t=Int8Array;break;case 1:t=Uint8Array;break;case 2:t=Int16Array;break;case 3:t=Uint16Array;break;case 4:t=Int32Array;break;case 5:t=Uint32Array;break;case 6:default:t=Float32Array;break;case 7:t=Float64Array}return t},getPixelType:function(e){var t;switch(e){case 0:t="S8";break;case 1:t="U8";break;case 2:t="S16";break;case 3:t="U16";break;case 4:t="S32";break;case 5:t="U32";break;case 6:default:t="F32";break;case 7:t="F64"}return t},isValidPixelValue:function(e,t){if(null==t)return!1;var i;switch(e){case 0:i=t>=-128&&t<=127;break;case 1:i=t>=0&&t<=255;break;case 2:i=t>=-32768&&t<=32767;break;case 3:i=t>=0&&t<=65536;break;case 4:i=t>=-2147483648&&t<=2147483647;break;case 5:i=t>=0&&t<=4294967296;break;case 6:i=t>=-34027999387901484e22&&t<=34027999387901484e22;break;case 7:i=t>=5e-324&&t<=17976931348623157e292;break;default:i=!1}return i},getDataTypeSize:function(e){var t=0;switch(e){case 0:case 1:t=1;break;case 2:case 3:t=2;break;case 4:case 5:case 6:t=4;break;case 7:t=8;break;default:t=e}return t},getDataTypeUsed:function(e,t){var i=e;switch(e){case 2:case 4:i=e-t;break;case 3:case 5:i=e-2*t;break;case 6:i=0===t?e:1===t?2:1;break;case 7:i=0===t?e:e-2*t+1;break;default:i=e}return i},getOnePixel:function(e,t,i,a){var n=0;switch(i){case 0:n=a.getInt8(t);break;case 1:n=a.getUint8(t);break;case 2:n=a.getInt16(t,!0);break;case 3:n=a.getUint16(t,!0);break;case 4:n=a.getInt32(t,!0);break;case 5:n=a.getUInt32(t,!0);break;case 6:n=a.getFloat32(t,!0);break;case 7:n=a.getFloat64(t,!0);break;default:throw"the decoder does not understand this pixel type"}return n}},h=function(e,t,i){this.val=e,this.left=t,this.right=i},{decode:function(e,t){var i=(t=t||{}).noDataValue,a=0,n={};if(n.ptr=t.inputOffset||0,n.pixels={},d.readHeaderInfo(e,n)){var r=n.headerInfo,s=r.fileVersion,l=d.getDataTypeArray(r.imageType);d.readMask(e,n),r.numValidPixel===r.width*r.height||n.pixels.resultMask||(n.pixels.resultMask=t.maskData);var o,f=r.width*r.height;if(n.pixels.resultPixels=new l(f*r.numDims),n.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0},0!==r.numValidPixel)if(r.zMax===r.zMin)d.constructConstantSurface(n);else if(s>=4&&d.checkMinMaxRanges(e,n))d.constructConstantSurface(n);else{var u=new DataView(e,n.ptr,2),c=u.getUint8(0);if(n.ptr++,c)d.readDataOneSweep(e,n,l);else if(s>1&&r.imageType<=1&&Math.abs(r.maxZError-.5)<1e-5){var h=u.getUint8(1);if(n.ptr++,n.encodeMode=h,h>2||s<4&&h>1)throw"Invalid Huffman flag "+h;h?d.readHuffman(e,n,l):d.readTiles(e,n,l)}else d.readTiles(e,n,l)}n.eofOffset=n.ptr,t.inputOffset?(o=n.headerInfo.blobSize+t.inputOffset-n.ptr,Math.abs(o)>=1&&(n.eofOffset=t.inputOffset+n.headerInfo.blobSize)):(o=n.headerInfo.blobSize-n.ptr,Math.abs(o)>=1&&(n.eofOffset=n.headerInfo.blobSize));var m={width:r.width,height:r.height,pixelData:n.pixels.resultPixels,minValue:r.zMin,maxValue:r.zMax,validPixelCount:r.numValidPixel,dimCount:r.numDims,dimStats:{minValues:r.minValues,maxValues:r.maxValues},maskData:n.pixels.resultMask};if(n.pixels.resultMask&&d.isValidPixelValue(r.imageType,i)){var g=n.pixels.resultMask;for(a=0;a<f;a++)g[a]||(m.pixelData[a]=i);m.noDataValue=i}return n.noDataValue=i,t.returnFileInfo&&(m.fileInfo=d.formatFileInfo(n)),m}},getBandCount:function(e){for(var t=0,i=0,a={ptr:0,pixels:{}};i<e.byteLength-58;)d.readHeaderInfo(e,a),i+=a.headerInfo.blobSize,t++,a.ptr=i;return t}}),w=(m=new ArrayBuffer(4),g=new Uint8Array(m),new Uint32Array(m)[0]=1,1===g[0]),y={decode:function(e,t){if(!w)throw"Big endian system is not supported.";var i,a,n=(t=t||{}).inputOffset||0,r=new Uint8Array(e,n,10),s=String.fromCharCode.apply(null,r);if("CntZImage"===s.trim())i=p,a=1;else{if("Lerc2"!==s.substring(0,5))throw"Unexpected file identifier string: "+s;i=x,a=2}for(var l,o,f,u,c,d,h=0,m=e.byteLength-10,g=[],y={width:0,height:0,pixels:[],pixelType:t.pixelType,mask:null,statistics:[]};n<m;){var k=i.decode(e,{inputOffset:n,encodedMaskData:l,maskData:f,returnMask:0===h,returnEncodedMask:0===h,returnFileInfo:!0,pixelType:t.pixelType||null,noDataValue:t.noDataValue||null});n=k.fileInfo.eofOffset,0===h&&(l=k.encodedMaskData,f=k.maskData,y.width=k.width,y.height=k.height,y.dimCount=k.dimCount||1,y.pixelType=k.pixelType||k.fileInfo.pixelType,y.mask=k.maskData),a>1&&k.fileInfo.mask&&k.fileInfo.mask.numBytes>0&&g.push(k.maskData),h++,y.pixels.push(k.pixelData),y.statistics.push({minValue:k.minValue,maxValue:k.maxValue,noDataValue:k.noDataValue,dimStats:k.dimStats})}if(a>1&&g.length>1){for(d=y.width*y.height,y.bandMasks=g,(f=new Uint8Array(d)).set(g[0]),u=1;u<g.length;u++)for(o=g[u],c=0;c<d;c++)f[c]=f[c]&o[c];y.maskData=f}return y}};T.exports?T.exports=y:this.Lerc=y}();var A=V.exports,B=s.getDefaultExportFromCjs(A);return c((function(t,i){if(t.encoding===w.LERC){let e;try{e=B.decode(t.heightmap)}catch(e){throw new u.RuntimeError(e)}if(e.statistics[0].minValue===Number.MAX_VALUE)throw new u.RuntimeError("Invalid tile data");t.heightmap=e.pixels[0],t.width=e.width,t.height=e.height}t.ellipsoid=e.Ellipsoid.clone(t.ellipsoid),t.rectangle=a.Rectangle.clone(t.rectangle);const n=v.computeVertices(t),r=n.vertices;return i.push(r.buffer),{vertices:r.buffer,numberOfAttributes:n.encoding.stride,minimumHeight:n.minimumHeight,maximumHeight:n.maximumHeight,gridWidth:t.width,gridHeight:t.height,boundingSphere3D:n.boundingSphere3D,orientedBoundingBox:n.orientedBoundingBox,occludeePointInScaledSpace:n.occludeePointInScaledSpace,encoding:n.encoding,westIndicesSouthToNorth:n.westIndicesSouthToNorth,southIndicesEastToWest:n.southIndicesEastToWest,eastIndicesNorthToSouth:n.eastIndicesNorthToSouth,northIndicesWestToEast:n.northIndicesWestToEast}}))}));