UNPKG

rlayers

Version:

React Components for OpenLayers

1 lines 1.69 kB
"use strict";(self.webpackChunkrlayers=self.webpackChunkrlayers||[]).push([[1030],{1030(e,t,r){r.d(t,{default:()=>o});var n=r(2132);class o extends n.A{decodeBlock(e){const t=new DataView(e),r=[];for(let n=0;n<e.byteLength;++n){let e=t.getInt8(n);if(e<0){const o=t.getUint8(n+1);e=-e;for(let t=0;t<=e;++t)r.push(o);n+=1}else{for(let o=0;o<=e;++o)r.push(t.getUint8(n+o+1));n+=e+1}}return new Uint8Array(r).buffer}}},2132(e,t,r){function n(e,t){let r=e.length-t,n=0;do{for(let r=t;r>0;r--)e[n+t]+=e[n],n++;r-=t}while(r>0)}function o(e,t,r){let n=0,o=e.length;const l=o/r;for(;o>t;){for(let r=t;r>0;--r)e[n+t]+=e[n],++n;o-=t}const i=e.slice();for(let t=0;t<l;++t)for(let n=0;n<r;++n)e[r*t+n]=i[(r-n-1)*l+t]}r.d(t,{A:()=>l});class l{constructor(e){this.parameters=e}decodeBlock(e){throw new Error("decodeBlock not implemented")}async decode(e){const t=await this.decodeBlock(e),{tileWidth:r,tileHeight:l,predictor:i,bitsPerSample:s,planarConfiguration:a}=this.parameters;return 1!==i?function(e,t,r,l,i,s){if(!t||1===t)return e;for(let e=0;e<i.length;++e){if(i[e]%8!=0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(i[e]!==i[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const a=i[0]/8,c=2===s?1:i.length;for(let s=0;s<l&&!(s*c*r*a>=e.byteLength);++s){let l;if(2===t){switch(i[0]){case 8:l=new Uint8Array(e,s*c*r*a,c*r*a);break;case 16:l=new Uint16Array(e,s*c*r*a,c*r*a/2);break;case 32:l=new Uint32Array(e,s*c*r*a,c*r*a/4);break;default:throw new Error(`Predictor 2 not allowed with ${i[0]} bits per sample.`)}n(l,c)}else 3===t&&(l=new Uint8Array(e,s*c*r*a,c*r*a),o(l,c,a))}return e}(t,i,r,l,s,a):t}}}}]);