rlayers
Version:
React Components for OpenLayers
1 lines • 2.72 kB
JavaScript
;(self.webpackChunkrlayers=self.webpackChunkrlayers||[]).push([[2764],{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 i=o/r;for(;o>t;){for(let r=t;r>0;--r)e[n+t]+=e[n],++n;o-=t}const l=e.slice();for(let t=0;t<i;++t)for(let n=0;n<r;++n)e[r*t+n]=l[(r-n-1)*i+t]}r.d(t,{A:()=>i});class i{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:i,predictor:l,bitsPerSample:c,planarConfiguration:s}=this.parameters;return 1!==l?function(e,t,r,i,l,c){if(!t||1===t)return e;for(let e=0;e<l.length;++e){if(l[e]%8!=0)throw new Error("When decoding with predictor, only multiple of 8 bits are supported.");if(l[e]!==l[0])throw new Error("When decoding with predictor, all samples must have the same size.")}const s=l[0]/8,a=2===c?1:l.length;for(let c=0;c<i&&!(c*a*r*s>=e.byteLength);++c){let i;if(2===t){switch(l[0]){case 8:i=new Uint8Array(e,c*a*r*s,a*r*s);break;case 16:i=new Uint16Array(e,c*a*r*s,a*r*s/2);break;case 32:i=new Uint32Array(e,c*a*r*s,a*r*s/4);break;default:throw new Error(`Predictor 2 not allowed with ${l[0]} bits per sample.`)}n(i,a)}else 3===t&&(i=new Uint8Array(e,c*a*r*s,a*r*s),o(i,a,s))}return e}(t,l,r,i,c,s):t}}},2764(e,t,r){r.d(t,{default:()=>i});var n=r(2132);function o(e,t){for(let r=t.length-1;r>=0;r--)e.push(t[r]);return e}class i extends n.A{decodeBlock(e){return function(e){const t=new Uint16Array(4093),r=new Uint8Array(4093);for(let e=0;e<=257;e++)t[e]=4096,r[e]=e;let n=258,i=9,l=0;function c(){n=258,i=9}function s(e){const t=function(e,t,r){const n=t%8,o=Math.floor(t/8),i=8-n,l=t+r-8*(o+1);let c=8*(o+2)-(t+r);const s=8*(o+2)-t;if(c=Math.max(0,c),o>=e.length)return console.warn("ran off the end of the buffer before finding EOI_CODE (end on input code)"),257;let a=e[o]&2**(8-n)-1;a<<=r-i;let f=a;if(o+1<e.length){let t=e[o+1]>>>c;t<<=Math.max(0,r-s),f+=t}if(l>8&&o+2<e.length){const n=8*(o+3)-(t+r);f+=e[o+2]>>>n}return f}(e,l,i);return l+=i,t}function a(e,o){return r[n]=o,t[n]=e,n++,n-1}function f(e){const n=[];for(let o=e;4096!==o;o=t[o])n.push(r[o]);return n}const h=[];c();const u=new Uint8Array(e);let d,w=s(u);for(;257!==w;){if(256===w){for(c(),w=s(u);256===w;)w=s(u);if(257===w)break;if(w>256)throw new Error(`corrupted code at scanline ${w}`);o(h,f(w)),d=w}else if(w<n){const e=f(w);o(h,e),a(d,e[e.length-1]),d=w}else{const e=f(d);if(!e)throw new Error(`Bogus entry. Not in dictionary, ${d} / ${n}, position: ${l}`);o(h,e),h.push(e[e.length-1]),a(d,e[e.length-1]),d=w}n+1>=2**i&&(12===i?d=void 0:i++),w=s(u)}return new Uint8Array(h)}(e).buffer}}}}]);