/*! For license information please see 54.ol.js.LICENSE.txt */ (self.webpackChunkol=self.webpackChunkol||[]).push([[54],{943:function(e,r){var n,a,t,i,f,o,u,s,l,c,w,h,v;a={defaultNoDataValue:-34027999387901484e22,decode:function(e,r){var n=(r=r||{}).encodedMaskData||null===r.encodedMaskData,u=o(e,r.inputOffset||0,n),s=null!==r.noDataValue?r.noDataValue:a.defaultNoDataValue,l=t(u,r.pixelType||Float32Array,r.encodedMaskData,s,r.returnMask),c={width:u.width,height:u.height,pixelData:l.resultPixels,minValue:l.minValue,maxValue:u.pixels.maxValue,noDataValue:s};return l.resultMask&&(c.maskData=l.resultMask),r.returnEncodedMask&&u.mask&&(c.encodedMaskData=u.mask.bitset?u.mask.bitset:null),r.returnFileInfo&&(c.fileInfo=i(u),r.computeUsedBitDepths&&(c.fileInfo.bitDepths=f(u))),c}},t=function(e,r,n,a,t){var i,f,o,s=0,l=e.pixels.numBlocksX,c=e.pixels.numBlocksY,w=Math.floor(e.width/l),h=Math.floor(e.height/c),v=2*e.maxZError,y=Number.MAX_VALUE;n=n||(e.mask?e.mask.bitset:null),f=new r(e.width*e.height),t&&n&&(o=new Uint8Array(e.width*e.height));for(var d,b,k=new Float32Array(w*h),m=0;m<=c;m++){var A=m!==c?h:e.height%c;if(0!==A)for(var p=0;p<=l;p++){var U=p!==l?w:e.width%l;if(0!==U){var M,x,V,g,D=m*e.width*h+p*w,B=e.width-U,S=e.pixels.blocks[s];if(S.encoding<2?(0===S.encoding?M=S.rawData:(u(S.stuffedData,S.bitsPerPixel,S.numValidPixels,S.offset,v,k,e.pixels.maxValue),M=k),x=0):V=2===S.encoding?0:S.offset,n)for(b=0;b>3],g<<=7&D),d=0;d>3]),128&g?(o&&(o[D]=1),y=y>(i=S.encoding<2?M[x++]:V)?i:y,f[D++]=i):(o&&(o[D]=0),f[D++]=a),g<<=1;D+=B}else if(S.encoding<2)for(b=0;b(i=M[x++])?i:y,f[D++]=i;D+=B}else for(y=y>V?V:y,b=0;b0){var f=new Uint8Array(Math.ceil(a.width*a.height/8)),o=(i=new DataView(e,r,a.mask.numBytes)).getInt16(0,!0),u=2,s=0;do{if(o>0)for(;o--;)f[s++]=i.getUint8(u++);else{var l=i.getUint8(u++);for(o=-o;o--;)f[s++]=l}o=i.getInt16(u,!0),u+=2}while(u0?1:0),v=w+(a.height%w>0?1:0);a.pixels.blocks=new Array(h*v);for(var y=0,d=0;d3)throw"Invalid block encoding ("+A.encoding+")";if(2!==A.encoding){if(0!==p&&2!==p){if(p>>=6,A.offsetType=p,2===p)A.offset=i.getInt8(1),k++;else if(1===p)A.offset=i.getInt16(1,!0),k+=2;else{if(0!==p)throw"Invalid block offset type";A.offset=i.getFloat32(1,!0),k+=4}if(1===A.encoding)if(p=i.getUint8(k),k++,A.bitsPerPixel=63&p,p>>=6,A.numValidPixelsType=p,2===p)A.numValidPixels=i.getUint8(k),k++;else if(1===p)A.numValidPixels=i.getUint16(k,!0),k+=2;else{if(0!==p)throw"Invalid valid pixel count type";A.numValidPixels=i.getUint32(k,!0),k+=4}}var U;if(r+=k,3!==A.encoding)if(0===A.encoding){var M=(a.pixels.numBytes-1)/4;if(M!==Math.floor(M))throw"uncompressed block has invalid length";U=new ArrayBuffer(4*M),new Uint8Array(U).set(new Uint8Array(e,r,4*M));var x=new Float32Array(U);A.rawData=x,r+=4*M}else if(1===A.encoding){var V=Math.ceil(A.numValidPixels*A.bitsPerPixel/8),g=Math.ceil(V/4);U=new ArrayBuffer(4*g),new Uint8Array(U).set(new Uint8Array(e,r,V)),A.stuffedData=new Uint32Array(U),r+=V}}else r++}return a.eofOffset=r,a},u=function(e,r,n,a,t,i,f){var o,u,s,l=(1<=r)u=s>>>w-r&l,w-=r;else{var y=r-w;u=(s&l)<>>(w=32-y)}i[o]=u=n?(s=l>>>y-n&h,y-=n):(s=(l&h)<<(c=n-y)&h,s+=(l=e[v++])>>>(y=32-c)),r[u]=t[s];else for(w=Math.ceil((o-i)/f),u=0;u=n?(s=l>>>y-n&h,y-=n):(s=(l&h)<<(c=n-y)&h,s+=(l=e[v++])>>>(y=32-c)),r[u]=s=r?(w=f>>>c-r&o,c-=r):(w=(f&o)<<(l=r-c)&o,w+=(f=e[u++])>>>(c=32-l)),h[s]=w=n?(s=l>>>y&w,v-=n,y+=n):(s=l>>>y&w,v=32-(c=n-v),s|=((l=e[h++])&(1<=n?(s=l>>>y&w,v-=n,y+=n):(s=l>>>y&w,v=32-(c=n-v),s|=((l=e[h++])&(1<=r?(w=f>>>h&o,c-=r,h+=r):(w=f>>>h&o,c=32-(l=r-c),w|=((f=e[u++])&(1<=n?(i=f>>>l-n&u,l-=n):(i=(f&u)<<(o=n-l)&u,i+=(f=e[s++])>>>(l=32-o)),r[t]=i;return r},i=function(e,r,n,a){var t,i,f,o,u=(1<=n?(i=f>>>c&u,l-=n,c+=n):(i=f>>>c&u,l=32-(o=n-l),i|=((f=e[s++])&(1<=359?359:t;t-=f;do{r+=e[i++]<<8,n+=r+=e[i++]}while(--f);r=(65535&r)+(r>>>16),n=(65535&n)+(n>>>16)}return 1&a&&(n+=r+=e[i]<<8),((n=(65535&n)+(n>>>16))<<16|(r=(65535&r)+(r>>>16)))>>>0},readHeaderInfo:function(e,r){var n=r.ptr,a=new Uint8Array(e,n,6),t={};if(t.fileIdentifierString=String.fromCharCode.apply(null,a),0!==t.fileIdentifierString.lastIndexOf("Lerc2",0))throw"Unexpected file identifier string (expect Lerc2 ): "+t.fileIdentifierString;n+=6;var i,f=new DataView(e,n,8),o=f.getInt32(0,!0);if(t.fileVersion=o,n+=4,o>=3&&(t.checksum=f.getUint32(4,!0),n+=4),f=new DataView(e,n,12),t.height=f.getUint32(0,!0),t.width=f.getUint32(4,!0),n+=8,o>=4?(t.numDims=f.getUint32(8,!0),n+=4):t.numDims=1,f=new DataView(e,n,40),t.numValidPixel=f.getUint32(0,!0),t.microBlockSize=f.getInt32(4,!0),t.blobSize=f.getInt32(8,!0),t.imageType=f.getInt32(12,!0),t.maxZError=f.getFloat64(16,!0),t.zMin=f.getFloat64(24,!0),t.zMax=f.getFloat64(32,!0),n+=40,r.headerInfo=t,r.ptr=n,o>=3&&(i=o>=4?52:48,this.computeChecksumFletcher32(new Uint8Array(e,n-i,t.blobSize-14))!==t.checksum))throw"Checksum failed.";return!0},checkMinMaxRanges:function(e,r){var n=r.headerInfo,a=this.getDataTypeArray(n.imageType),t=n.numDims*this.getDataTypeSize(n.imageType),i=this.readSubArray(e,r.ptr,a,t),f=this.readSubArray(e,r.ptr+t,a,t);r.ptr+=2*t;var o,u=!0;for(o=0;o0){n=new Uint8Array(Math.ceil(f/8));var l=(u=new DataView(e,t,s.numBytes)).getInt16(0,!0),c=2,w=0,h=0;do{if(l>0)for(;l--;)n[w++]=u.getUint8(c++);else for(h=u.getUint8(c++),l=-l;l--;)n[w++]=h;l=u.getInt16(c,!0),c+=2}while(c>3],v<<=7&y):v=n[y>>3],128&v&&(a[y]=1);r.pixels.resultMask=a,s.bitset=n,t+=s.numBytes}return r.ptr=t,r.mask=s,!0},readDataOneSweep:function(e,r,n,a){var t,i=r.ptr,o=r.headerInfo,u=o.numDims,s=o.width*o.height,l=o.imageType,c=o.numValidPixel*f.getDataTypeSize(l)*u,w=r.pixels.resultMask;if(n===Uint8Array)t=new Uint8Array(e,i,c);else{var h=new ArrayBuffer(c);new Uint8Array(h).set(new Uint8Array(e,i,c)),t=new n(h)}if(t.length===s*u)r.pixels.resultPixels=a?f.swapDimensionOrder(t,s,u,n,!0):t;else{r.pixels.resultPixels=new n(s*u);var v=0,y=0,d=0,b=0;if(u>1){if(a){for(y=0;y=u)return!1;var s=new Uint32Array(u-i);f.decodeBits(e,r,s);var l,c,w,h,v=[];for(l=i;l0&&(v[c].second=k<>>32-h,32-A>=h?32===(A+=h)&&(A=0,k=m[++p]):(A+=h-32,k=m[++p],v[c].second|=k>>>32-A));var U=0,M=0,x=new o;for(l=0;l=n?n:U;var V,g,D,B,S,I=[];for(l=i;l0)if(V=[h,c],h<=M)for(g=v[c].second<=0;B--)g>>>B&1?(S.right||(S.right=new o),S=S.right):(S.left||(S.left=new o),S=S.left),0!==B||S.val||(S.val=V[1]);return{decodeLut:I,numBitsLUTQick:M,numBitsLUT:U,tree:x,stuffedData:m,srcPtr:p,bitPos:A}},readHuffman:function(e,r,n,a){var t,i,o,u,s,l,c,w,h,v=r.headerInfo.numDims,y=r.headerInfo.height,d=r.headerInfo.width,b=d*y,k=this.readHuffmanTree(e,r),m=k.decodeLut,A=k.tree,p=k.stuffedData,U=k.srcPtr,M=k.bitPos,x=k.numBitsLUTQick,V=k.numBitsLUT,g=0===r.headerInfo.imageType?128:0,D=r.pixels.resultMask,B=0;M>0&&(U++,M=0);var S,I=p[U],T=1===r.encodeMode,O=new n(b*v),F=O;if(v<2||T){for(S=0;S1&&(F=new n(O.buffer,b*S,b),B=0),r.headerInfo.numValidPixel===d*y)for(w=0,l=0;l>>32-x,32-M>>64-M-x),m[s])i=m[s][1],M+=m[s][0];else for(s=u=I<>>32-V,32-M>>64-M-V),t=A,h=0;h>>V-h-1&1?t.right:t.left).left&&!t.right){i=t.val,M=M+h+1;break}M>=32&&(M-=32,I=p[++U]),o=i-g,T?(o+=c>0?B:l>0?F[w-d]:B,o&=255,F[w]=o,B=o):F[w]=o}else for(w=0,l=0;l>>32-x,32-M>>64-M-x),m[s])i=m[s][1],M+=m[s][0];else for(s=u=I<>>32-V,32-M>>64-M-V),t=A,h=0;h>>V-h-1&1?t.right:t.left).left&&!t.right){i=t.val,M=M+h+1;break}M>=32&&(M-=32,I=p[++U]),o=i-g,T?(c>0&&D[w-1]?o+=B:l>0&&D[w-d]?o+=F[w-d]:o+=B,o&=255,F[w]=o,B=o):F[w]=o}}else for(w=0,l=0;l>>32-x,32-M>>64-M-x),m[s])i=m[s][1],M+=m[s][0];else for(s=u=I<>>32-V,32-M>>64-M-V),t=A,h=0;h>>V-h-1&1?t.right:t.left).left&&!t.right){i=t.val,M=M+h+1;break}M>=32&&(M-=32,I=p[++U]),o=i-g,F[w]=o}r.ptr=r.ptr+4*(U+1)+(M>0?4:0),r.pixels.resultPixels=O,v>1&&!a&&(r.pixels.resultPixels=f.swapDimensionOrder(O,b,v,n))},decodeBits:function(f,o,u,s,l){var c=o.headerInfo,w=c.fileVersion,h=0,v=f.byteLength-o.ptr>=5?5:f.byteLength-o.ptr,y=new DataView(f,o.ptr,v),d=y.getUint8(0);h++;var b=d>>6,k=0===b?4:3-b,m=(32&d)>0,A=31&d,p=0;if(1===k)p=y.getUint8(h),h++;else if(2===k)p=y.getUint16(h,!0),h+=2;else{if(4!==k)throw"Invalid valid pixel count type";p=y.getUint32(h,!0),h+=4}var U,M,x,V,g,D,B,S,I,T=2*c.maxZError,O=c.numDims>1?c.maxValues[l]:c.zMax;if(m){for(o.counter.lut++,S=y.getUint8(h),h++,V=Math.ceil((S-1)*A/8),g=Math.ceil(V/4),M=new ArrayBuffer(4*g),x=new Uint8Array(M),o.ptr+=h,x.set(new Uint8Array(f,o.ptr,V)),B=new Uint32Array(M),o.ptr+=V,I=0;S-1>>>I;)I++;V=Math.ceil(p*I/8),g=Math.ceil(V/4),M=new ArrayBuffer(4*g),(x=new Uint8Array(M)).set(new Uint8Array(f,o.ptr,V)),U=new Uint32Array(M),o.ptr+=V,D=w>=3?a(B,A,S-1,s,T,O):r(B,A,S-1,s,T,O),w>=3?n(U,u,I,p,D):e(U,u,I,p,D)}else o.counter.bitstuffer++,I=A,o.ptr+=h,I>0&&(V=Math.ceil(p*I/8),g=Math.ceil(V/4),M=new ArrayBuffer(4*g),(x=new Uint8Array(M)).set(new Uint8Array(f,o.ptr,V)),U=new Uint32Array(M),o.ptr+=V,w>=3?null==s?i(U,u,I,p):n(U,u,I,p,!1,s,T,O):null==s?t(U,u,I,p):e(U,u,I,p,!1,s,T,O))},readTiles:function(e,r,n,a){var t=r.headerInfo,i=t.width,o=t.height,u=i*o,s=t.microBlockSize,l=t.imageType,c=f.getDataTypeSize(l),w=Math.ceil(i/s),h=Math.ceil(o/s);r.pixels.numBlocksY=h,r.pixels.numBlocksX=w,r.pixels.ptr=0;var v,y,d,b,k,m,A,p,U,M,x=0,V=0,g=0,D=0,B=0,S=0,I=0,T=0,O=0,F=0,j=0,E=0,P=0,C=0,L=0,R=new n(s*s),H=o%s||s,X=i%s||s,Z=t.numDims,z=r.pixels.resultMask,N=r.pixels.resultPixels,Y=t.fileVersion>=5?14:15,_=t.zMax;for(g=0;g1?(M=N,F=g*i*s+D*s,N=new n(r.pixels.resultPixels.buffer,u*p*c,u),_=t.maxValues[p]):M=null,I=e.byteLength-r.ptr,y={},L=0,T=(v=new DataView(e,r.ptr,Math.min(10,I))).getUint8(0),L++,U=t.fileVersion>=5?4&T:0,O=T>>6&255,(T>>2&Y)!=(D*s>>3&Y))throw"integrity issue";if(U&&0===p)throw"integrity issue";if((k=3&T)>3)throw r.ptr+=L,"Invalid block encoding ("+k+")";if(2!==k)if(0===k){if(U)throw"integrity issue";if(r.counter.uncompressed++,r.ptr+=L,E=(E=B*S*c)<(P=e.byteLength-r.ptr)?E:P,d=new ArrayBuffer(E%c==0?E:E+c-E%c),new Uint8Array(d).set(new Uint8Array(e,r.ptr,E)),b=new n(d),C=0,z)for(x=0;x1&&!a&&(r.pixels.resultPixels=f.swapDimensionOrder(r.pixels.resultPixels,u,Z,n))},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:f.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,r){var n=e.headerInfo.zMax,a=e.headerInfo.zMin,t=e.headerInfo.maxValues,i=e.headerInfo.numDims,f=e.headerInfo.height*e.headerInfo.width,o=0,u=0,s=0,l=e.pixels.resultMask,c=e.pixels.resultPixels;if(l)if(i>1){if(r)for(o=0;o1&&a!==n)if(r)for(o=0;o=-128&&r<=127;break;case 1:n=r>=0&&r<=255;break;case 2:n=r>=-32768&&r<=32767;break;case 3:n=r>=0&&r<=65536;break;case 4:n=r>=-2147483648&&r<=2147483647;break;case 5:n=r>=0&&r<=4294967296;break;case 6:n=r>=-34027999387901484e22&&r<=34027999387901484e22;break;case 7:n=r>=-17976931348623157e292&&r<=17976931348623157e292;break;default:n=!1}return n},getDataTypeSize:function(e){var r=0;switch(e){case 0:case 1:r=1;break;case 2:case 3:r=2;break;case 4:case 5:case 6:r=4;break;case 7:r=8;break;default:r=e}return r},getDataTypeUsed:function(e,r){var n=e;switch(e){case 2:case 4:n=e-r;break;case 3:case 5:n=e-2*r;break;case 6:n=0===r?e:1===r?2:1;break;case 7:n=0===r?e:e-2*r+1;break;default:n=e}return n},getOnePixel:function(e,r,n,a){var t=0;switch(n){case 0:t=a.getInt8(r);break;case 1:t=a.getUint8(r);break;case 2:t=a.getInt16(r,!0);break;case 3:t=a.getUint16(r,!0);break;case 4:t=a.getInt32(r,!0);break;case 5:t=a.getUInt32(r,!0);break;case 6:t=a.getFloat32(r,!0);break;case 7:t=a.getFloat64(r,!0);break;default:throw"the decoder does not understand this pixel type"}return t},swapDimensionOrder:function(e,r,n,a,t){var i=0,f=0,o=0,u=0,s=e;if(n>1)if(s=new a(r*n),t)for(i=0;i5)throw"unsupported lerc version 2."+o;f.readMask(e,t),i.numValidPixel===i.width*i.height||t.pixels.resultMask||(t.pixels.resultMask=r.maskData);var s=i.width*i.height;t.pixels.resultPixels=new u(s*i.numDims),t.counter={onesweep:0,uncompressed:0,lut:0,bitstuffer:0,constant:0,constantoffset:0};var l,c=!r.returnPixelInterleavedDims;if(0!==i.numValidPixel)if(i.zMax===i.zMin)f.constructConstantSurface(t,c);else if(o>=4&&f.checkMinMaxRanges(e,t))f.constructConstantSurface(t,c);else{var w=new DataView(e,t.ptr,2),h=w.getUint8(0);if(t.ptr++,h)f.readDataOneSweep(e,t,u,c);else if(o>1&&i.imageType<=1&&Math.abs(i.maxZError-.5)<1e-5){var v=w.getUint8(1);if(t.ptr++,t.encodeMode=v,v>2||o<4&&v>1)throw"Invalid Huffman flag "+v;v?f.readHuffman(e,t,u,c):f.readTiles(e,t,u,c)}else f.readTiles(e,t,u,c)}t.eofOffset=t.ptr,r.inputOffset?(l=t.headerInfo.blobSize+r.inputOffset-t.ptr,Math.abs(l)>=1&&(t.eofOffset=r.inputOffset+t.headerInfo.blobSize)):(l=t.headerInfo.blobSize-t.ptr,Math.abs(l)>=1&&(t.eofOffset=t.headerInfo.blobSize));var y={width:i.width,height:i.height,pixelData:t.pixels.resultPixels,minValue:i.zMin,maxValue:i.zMax,validPixelCount:i.numValidPixel,dimCount:i.numDims,dimStats:{minValues:i.minValues,maxValues:i.maxValues},maskData:t.pixels.resultMask};if(t.pixels.resultMask&&f.isValidPixelValue(i.imageType,n)){var d=t.pixels.resultMask;for(a=0;a1&&(s&&k.push(s),p.fileInfo.mask&&p.fileInfo.mask.numBytes>0&&A++),d++,m.pixels.push(p.pixelData),m.statistics.push({minValue:p.minValue,maxValue:p.maxValue,noDataValue:p.noDataValue,dimStats:p.dimStats})}if(a>1&&A>1){for(y=m.width*m.height,m.bandMasks=k,(s=new Uint8Array(y)).set(k[0]),l=1;l