@loaders.gl/geotiff 4.4.0-alpha.18 → 4.4.0-alpha.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dist.min.js +1 -1
- package/dist/geotiff-loader.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/loaders.js +1 -1
- package/package.json +3 -3
package/dist/dist.min.js
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
`;function gs(e){if(typeof Object.fromEntries<"u")return Object.fromEntries(e);let t={};for(let[A,i]of e)t[A.toLowerCase()]=i;return t}function wf(e){let t=e.split(`\r
|
|
12
12
|
`).map(A=>{let i=A.split(":").map(n=>n.trim());return i[0]=i[0].toLowerCase(),i});return gs(t)}function ls(e){let[t,...A]=e.split(";").map(n=>n.trim()),i=A.map(n=>n.split("="));return{type:t,params:gs(i)}}function Jt(e){let t,A,i;return e&&([,t,A,i]=e.match(/bytes (\d+)-(\d+)\/(\d+)/),t=parseInt(t,10),A=parseInt(A,10),i=parseInt(i,10)),{start:t,end:A,total:i}}function fs(e,t){let A=null,i=new TextDecoder("ascii"),n=[],r=`--${t}`,g=`${r}--`;for(let a=0;a<10;++a)i.decode(new Uint8Array(e,a,r.length))===r&&(A=a);if(A===null)throw new Error("Could not find initial boundary");for(;A<e.byteLength;){let a=i.decode(new Uint8Array(e,A,Math.min(r.length+1024,e.byteLength-A)));if(a.length===0||a.startsWith(g))break;if(!a.startsWith(r))throw new Error("Part does not start with boundary");let l=a.substr(r.length+2);if(l.length===0)break;let o=l.indexOf(as),s=wf(l.substr(0,o)),{start:I,end:c,total:f}=Jt(s["content-range"]),h=A+r.length+o+as.length,E=parseInt(c,10)+1-parseInt(I,10);n.push({headers:s,data:e.slice(h,h+E),offset:I,length:E,fileSize:f}),A=h+E+4}return n}var De=class{async fetch(t,A=void 0){return Promise.all(t.map(i=>this.fetchSlice(i,A)))}async fetchSlice(t){throw new Error(`fetching of slice ${t} not possible, not implemented`)}get fileSize(){return null}async close(){}};var zA=class extends Map{constructor(t={}){if(super(),!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");if(typeof t.maxAge=="number"&&t.maxAge===0)throw new TypeError("`maxAge` must be a number greater than 0");this.maxSize=t.maxSize,this.maxAge=t.maxAge||Number.POSITIVE_INFINITY,this.onEviction=t.onEviction,this.cache=new Map,this.oldCache=new Map,this._size=0}_emitEvictions(t){if(typeof this.onEviction=="function")for(let[A,i]of t)this.onEviction(A,i.value)}_deleteIfExpired(t,A){return typeof A.expiry=="number"&&A.expiry<=Date.now()?(typeof this.onEviction=="function"&&this.onEviction(t,A.value),this.delete(t)):!1}_getOrDeleteIfExpired(t,A){if(this._deleteIfExpired(t,A)===!1)return A.value}_getItemValue(t,A){return A.expiry?this._getOrDeleteIfExpired(t,A):A.value}_peek(t,A){let i=A.get(t);return this._getItemValue(t,i)}_set(t,A){this.cache.set(t,A),this._size++,this._size>=this.maxSize&&(this._size=0,this._emitEvictions(this.oldCache),this.oldCache=this.cache,this.cache=new Map)}_moveToRecent(t,A){this.oldCache.delete(t),this._set(t,A)}*_entriesAscending(){for(let t of this.oldCache){let[A,i]=t;this.cache.has(A)||this._deleteIfExpired(A,i)===!1&&(yield t)}for(let t of this.cache){let[A,i]=t;this._deleteIfExpired(A,i)===!1&&(yield t)}}get(t){if(this.cache.has(t)){let A=this.cache.get(t);return this._getItemValue(t,A)}if(this.oldCache.has(t)){let A=this.oldCache.get(t);if(this._deleteIfExpired(t,A)===!1)return this._moveToRecent(t,A),A.value}}set(t,A,{maxAge:i=this.maxAge}={}){let n=typeof i=="number"&&i!==Number.POSITIVE_INFINITY?Date.now()+i:void 0;return this.cache.has(t)?this.cache.set(t,{value:A,expiry:n}):this._set(t,{value:A,expiry:n}),this}has(t){return this.cache.has(t)?!this._deleteIfExpired(t,this.cache.get(t)):this.oldCache.has(t)?!this._deleteIfExpired(t,this.oldCache.get(t)):!1}peek(t){if(this.cache.has(t))return this._peek(t,this.cache);if(this.oldCache.has(t))return this._peek(t,this.oldCache)}delete(t){let A=this.cache.delete(t);return A&&this._size--,this.oldCache.delete(t)||A}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}resize(t){if(!(t&&t>0))throw new TypeError("`maxSize` must be a number greater than 0");let A=[...this._entriesAscending()],i=A.length-t;i<0?(this.cache=new Map(A),this.oldCache=new Map,this._size=A.length):(i>0&&this._emitEvictions(A.slice(0,i)),this.oldCache=new Map(A.slice(i)),this.cache=new Map,this._size=0),this.maxSize=t}*keys(){for(let[t]of this)yield t}*values(){for(let[,t]of this)yield t}*[Symbol.iterator](){for(let t of this.cache){let[A,i]=t;this._deleteIfExpired(A,i)===!1&&(yield[A,i.value])}for(let t of this.oldCache){let[A,i]=t;this.cache.has(A)||this._deleteIfExpired(A,i)===!1&&(yield[A,i.value])}}*entriesDescending(){let t=[...this.cache];for(let A=t.length-1;A>=0;--A){let i=t[A],[n,r]=i;this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}t=[...this.oldCache];for(let A=t.length-1;A>=0;--A){let i=t[A],[n,r]=i;this.cache.has(n)||this._deleteIfExpired(n,r)===!1&&(yield[n,r.value])}}*entriesAscending(){for(let[t,A]of this._entriesAscending())yield[t,A.value]}get size(){if(!this._size)return this.oldCache.size;let t=0;for(let A of this.oldCache.keys())this.cache.has(A)||t++;return Math.min(this._size+t,this.maxSize)}entries(){return this.entriesAscending()}forEach(t,A=this){for(let[i,n]of this.entriesAscending())t.call(A,n,i,this)}get[Symbol.toStringTag](){return JSON.stringify([...this.entriesAscending()])}};async function cs(e){return new Promise(t=>setTimeout(t,e))}function Is(e,t){let A=Array.isArray(e)?e:Array.from(e),i=Array.isArray(t)?t:Array.from(t);return A.map((n,r)=>[n,i[r]])}var fe=class extends Error{constructor(t){super(t),Error.captureStackTrace&&Error.captureStackTrace(this,fe),this.name="AbortError"}},$i=class extends Error{constructor(t,A){super(A),this.errors=t,this.message=A,this.name="AggregateError"}},hs=$i;var en=class{constructor(t,A,i=null){this.offset=t,this.length=A,this.data=i}get top(){return this.offset+this.length}},Kt=class{constructor(t,A,i){this.offset=t,this.length=A,this.blockIds=i}},Vt=class extends De{constructor(t,{blockSize:A=65536,cacheSize:i=100}={}){super(),this.source=t,this.blockSize=A,this.blockCache=new zA({maxSize:i,onEviction:(n,r)=>{this.evictedBlocks.set(n,r)}}),this.evictedBlocks=new Map,this.blockRequests=new Map,this.blockIdsToFetch=new Set,this.abortedBlockIds=new Set}get fileSize(){return this.source.fileSize}async fetch(t,A){let i=[],n=[],r=[];this.evictedBlocks.clear();for(let{offset:c,length:f}of t){let h=c+f,{fileSize:E}=this;E!==null&&(h=Math.min(h,E));let u=Math.floor(c/this.blockSize)*this.blockSize;for(let Q=u;Q<h;Q+=this.blockSize){let C=Math.floor(Q/this.blockSize);!this.blockCache.has(C)&&!this.blockRequests.has(C)&&(this.blockIdsToFetch.add(C),n.push(C)),this.blockRequests.has(C)&&i.push(this.blockRequests.get(C)),r.push(C)}}await cs(),this.fetchBlocks(A);let g=[];for(let c of n)this.blockRequests.has(c)&&g.push(this.blockRequests.get(c));await Promise.allSettled(i),await Promise.allSettled(g);let a=[],l=r.filter(c=>this.abortedBlockIds.has(c)||!this.blockCache.has(c));if(l.forEach(c=>this.blockIdsToFetch.add(c)),l.length>0&&A&&!A.aborted){this.fetchBlocks(null);for(let c of l){let f=this.blockRequests.get(c);if(!f)throw new Error(`Block ${c} is not in the block requests`);a.push(f)}await Promise.allSettled(a)}if(A&&A.aborted)throw new fe("Request was aborted");let o=r.map(c=>this.blockCache.get(c)||this.evictedBlocks.get(c)),s=o.filter(c=>!c);if(s.length)throw new hs(s,"Request failed");let I=new Map(Is(r,o));return this.readSliceData(t,I)}fetchBlocks(t){if(this.blockIdsToFetch.size>0){let A=this.groupBlocks(this.blockIdsToFetch),i=this.source.fetch(A,t);for(let n=0;n<A.length;++n){let r=A[n];for(let g of r.blockIds)this.blockRequests.set(g,(async()=>{try{let a=(await i)[n],l=g*this.blockSize,o=l-a.offset,s=Math.min(o+this.blockSize,a.data.byteLength),I=a.data.slice(o,s),c=new en(l,I.byteLength,I,g);this.blockCache.set(g,c),this.abortedBlockIds.delete(g)}catch(a){if(a.name==="AbortError")a.signal=t,this.blockCache.delete(g),this.abortedBlockIds.add(g);else throw a}finally{this.blockRequests.delete(g)}})())}this.blockIdsToFetch.clear()}}groupBlocks(t){let A=Array.from(t).sort((g,a)=>g-a);if(A.length===0)return[];let i=[],n=null,r=[];for(let g of A)n===null||n+1===g?(i.push(g),n=g):(r.push(new Kt(i[0]*this.blockSize,i.length*this.blockSize,i)),i=[g],n=g);return r.push(new Kt(i[0]*this.blockSize,i.length*this.blockSize,i)),r}readSliceData(t,A){return t.map(i=>{let n=i.offset+i.length;this.fileSize!==null&&(n=Math.min(this.fileSize,n));let r=Math.floor(i.offset/this.blockSize),g=Math.floor(n/this.blockSize),a=new ArrayBuffer(i.length),l=new Uint8Array(a);for(let o=r;o<=g;++o){let s=A.get(o),I=s.offset-i.offset,c=s.top-n,f=0,h=0,E;I<0?f=-I:I>0&&(h=I),c<0?E=s.length-f:E=n-s.offset-f;let u=new Uint8Array(s.data,f,E);l.set(u,h)}return a})}};var He=class{get ok(){return this.status>=200&&this.status<=299}get status(){throw new Error("not implemented")}getHeader(t){throw new Error("not implemented")}async getData(){throw new Error("not implemented")}},Je=class{constructor(t){this.url=t}async request({headers:t,signal:A}={}){throw new Error("request is not implemented")}};var An=class extends He{constructor(t){super(),this.response=t}get status(){return this.response.status}getHeader(t){return this.response.headers.get(t)}async getData(){return this.response.arrayBuffer?await this.response.arrayBuffer():(await this.response.buffer()).buffer}},zt=class extends Je{constructor(t,A){super(t),this.credentials=A}async request({headers:t,signal:A}={}){let i=await fetch(this.url,{headers:t,credentials:this.credentials,signal:A});return new An(i)}};var tn=class extends He{constructor(t,A){super(),this.xhr=t,this.data=A}get status(){return this.xhr.status}getHeader(t){return this.xhr.getResponseHeader(t)}async getData(){return this.data}},Pt=class extends Je{constructRequest(t,A){return new Promise((i,n)=>{let r=new XMLHttpRequest;r.open("GET",this.url),r.responseType="arraybuffer";for(let[g,a]of Object.entries(t))r.setRequestHeader(g,a);r.onload=()=>{let g=r.response;i(new tn(r,g))},r.onerror=n,r.onabort=()=>n(new fe("Request aborted")),r.send(),A&&(A.aborted&&r.abort(),A.addEventListener("abort",()=>r.abort()))})}async request({headers:t,signal:A}={}){return await this.constructRequest(t,A)}};var Cs=Ve(us(),1),ds=Ve(Es(),1),Qs=Ve(Bs(),1);var nn=class extends He{constructor(t,A){super(),this.response=t,this.dataPromise=A}get status(){return this.response.statusCode}getHeader(t){return this.response.headers[t]}async getData(){return await this.dataPromise}},Zt=class extends Je{constructor(t){super(t),this.parsedUrl=Qs.default.parse(this.url),this.httpApi=this.parsedUrl.protocol==="http:"?Cs.default:ds.default}constructRequest(t,A){return new Promise((i,n)=>{let r=this.httpApi.get({...this.parsedUrl,headers:t},g=>{let a=new Promise(l=>{let o=[];g.on("data",s=>{o.push(s)}),g.on("end",()=>{let s=Buffer.concat(o).buffer;l(s)}),g.on("error",n)});i(new nn(g,a))});r.on("error",n),A&&(A.aborted&&r.destroy(new fe("Request aborted")),A.addEventListener("abort",()=>r.destroy(new fe("Request aborted"))))})}async request({headers:t,signal:A}={}){return await this.constructRequest(t,A)}};var PA=class extends De{constructor(t,A,i,n){super(),this.client=t,this.headers=A,this.maxRanges=i,this.allowFullFile=n,this._fileSize=null}async fetch(t,A){return this.maxRanges>=t.length?this.fetchSlices(t,A):(this.maxRanges>0&&t.length>1,Promise.all(t.map(i=>this.fetchSlice(i,A))))}async fetchSlices(t,A){let i=await this.client.request({headers:{...this.headers,Range:`bytes=${t.map(({offset:n,length:r})=>`${n}-${n+r}`).join(",")}`},signal:A});if(i.ok)if(i.status===206){let{type:n,params:r}=ls(i.getHeader("content-type"));if(n==="multipart/byteranges"){let I=fs(await i.getData(),r.boundary);return this._fileSize=I[0].fileSize||null,I}let g=await i.getData(),{start:a,end:l,total:o}=Jt(i.getHeader("content-range"));this._fileSize=o||null;let s=[{data:g,offset:a,length:l-a}];if(t.length>1){let I=await Promise.all(t.slice(1).map(c=>this.fetchSlice(c,A)));return s.concat(I)}return s}else{if(!this.allowFullFile)throw new Error("Server responded with full file");let n=await i.getData();return this._fileSize=n.byteLength,[{data:n,offset:0,length:n.byteLength}]}else throw new Error("Error fetching data.")}async fetchSlice(t,A){let{offset:i,length:n}=t,r=await this.client.request({headers:{...this.headers,Range:`bytes=${i}-${i+n}`},signal:A});if(r.ok)if(r.status===206){let g=await r.getData(),{total:a}=Jt(r.getHeader("content-range"));return this._fileSize=a||null,{data:g,offset:i,length:n}}else{if(!this.allowFullFile)throw new Error("Server responded with full file");let g=await r.getData();return this._fileSize=g.byteLength,{data:g,offset:0,length:g.byteLength}}else throw new Error("Error fetching data.")}get fileSize(){return this._fileSize}};function rn(e,{blockSize:t,cacheSize:A}){return t===null?e:new Vt(e,{blockSize:t,cacheSize:A})}function yf(e,{headers:t={},credentials:A,maxRanges:i=0,allowFullFile:n=!1,...r}={}){let g=new zt(e,A),a=new PA(g,t,i,n);return rn(a,r)}function _f(e,{headers:t={},maxRanges:A=0,allowFullFile:i=!1,...n}={}){let r=new Pt(e),g=new PA(r,t,A,i);return rn(g,n)}function mf(e,{headers:t={},maxRanges:A=0,allowFullFile:i=!1,...n}={}){let r=new Zt(e),g=new PA(r,t,A,i);return rn(g,n)}function ps(e,{forceXHR:t=!1,...A}={}){return typeof fetch=="function"&&!t?yf(e,A):typeof XMLHttpRequest<"u"?_f(e,A):mf(e,A)}var on=class extends De{constructor(t){super(),this.arrayBuffer=t}fetchSlice(t,A){if(A&&A.aborted)throw new fe("Request aborted");return this.arrayBuffer.slice(t.offset,t.offset+t.length)}};function ws(e){return new on(e)}var sn=class extends De{constructor(t){super(),this.file=t}async fetchSlice(t,A){return new Promise((i,n)=>{let r=this.file.slice(t.offset,t.offset+t.length),g=new FileReader;g.onload=a=>i(a.target.result),g.onerror=n,g.onabort=n,g.readAsArrayBuffer(r),A&&A.addEventListener("abort",()=>g.abort())})}};function ys(e){return new sn(e)}ct();function an(e){switch(e){case M.BYTE:case M.ASCII:case M.SBYTE:case M.UNDEFINED:return 1;case M.SHORT:case M.SSHORT:return 2;case M.LONG:case M.SLONG:case M.FLOAT:case M.IFD:return 4;case M.RATIONAL:case M.SRATIONAL:case M.DOUBLE:case M.LONG8:case M.SLONG8:case M.IFD8:return 8;default:throw new RangeError(`Invalid field type: ${e}`)}}function xf(e){let t=e.GeoKeyDirectory;if(!t)return null;let A={};for(let i=4;i<=t[3]*4;i+=4){let n=_A[t[i]],r=t[i+1]?oA[t[i+1]]:null,g=t[i+2],a=t[i+3],l=null;if(!r)l=a;else{if(l=e[r],typeof l>"u"||l===null)throw new Error(`Could not get value of geoKey '${n}'.`);typeof l=="string"?l=l.substring(a,a+g-1):l.subarray&&(l=l.subarray(a,a+g),g===1&&(l=l[0]))}A[n]=l}return A}function CA(e,t,A,i){let n=null,r=null,g=an(t);switch(t){case M.BYTE:case M.ASCII:case M.UNDEFINED:n=new Uint8Array(A),r=e.readUint8;break;case M.SBYTE:n=new Int8Array(A),r=e.readInt8;break;case M.SHORT:n=new Uint16Array(A),r=e.readUint16;break;case M.SSHORT:n=new Int16Array(A),r=e.readInt16;break;case M.LONG:case M.IFD:n=new Uint32Array(A),r=e.readUint32;break;case M.SLONG:n=new Int32Array(A),r=e.readInt32;break;case M.LONG8:case M.IFD8:n=new Array(A),r=e.readUint64;break;case M.SLONG8:n=new Array(A),r=e.readInt64;break;case M.RATIONAL:n=new Uint32Array(A*2),r=e.readUint32;break;case M.SRATIONAL:n=new Int32Array(A*2),r=e.readInt32;break;case M.FLOAT:n=new Float32Array(A),r=e.readFloat32;break;case M.DOUBLE:n=new Float64Array(A),r=e.readFloat64;break;default:throw new RangeError(`Invalid field type: ${t}`)}if(t===M.RATIONAL||t===M.SRATIONAL)for(let a=0;a<A;a+=2)n[a]=r.call(e,i+a*g),n[a+1]=r.call(e,i+(a*g+4));else for(let a=0;a<A;++a)n[a]=r.call(e,i+a*g);return t===M.ASCII?new TextDecoder("utf-8").decode(n):n}var gn=class{constructor(t,A,i){this.fileDirectory=t,this.geoKeyDirectory=A,this.nextIFDByteOffset=i}},dA=class extends Error{constructor(t){super(`No image at index ${t}`),this.index=t}},ln=class{async readRasters(t={}){let{window:A,width:i,height:n}=t,{resX:r,resY:g,bbox:a}=t,l=await this.getImage(),o=l,s=await this.getImageCount(),I=l.getBoundingBox();if(A&&a)throw new Error('Both "bbox" and "window" passed.');if(i||n){if(A){let[h,E]=l.getOrigin(),[u,Q]=l.getResolution();a=[h+A[0]*u,E+A[1]*Q,h+A[2]*u,E+A[3]*Q]}let f=a||I;if(i){if(r)throw new Error("Both width and resX passed");r=(f[2]-f[0])/i}if(n){if(g)throw new Error("Both width and resY passed");g=(f[3]-f[1])/n}}if(r||g){let f=[];for(let h=0;h<s;++h){let E=await this.getImage(h),{SubfileType:u,NewSubfileType:Q}=E.fileDirectory;(h===0||u===2||Q&1)&&f.push(E)}f.sort((h,E)=>h.getWidth()-E.getWidth());for(let h=0;h<f.length;++h){let E=f[h],u=(I[2]-I[0])/E.getWidth(),Q=(I[3]-I[1])/E.getHeight();if(o=E,r&&r>u||g&&g>Q)break}}let c=A;if(a){let[f,h]=l.getOrigin(),[E,u]=o.getResolution(l);c=[Math.round((a[0]-f)/E),Math.round((a[1]-h)/u),Math.round((a[2]-f)/E),Math.round((a[3]-h)/u)],c=[Math.min(c[0],c[2]),Math.min(c[1],c[3]),Math.max(c[0],c[2]),Math.max(c[1],c[3])]}return o.readRasters({...t,window:c})}},Ne=class extends ln{constructor(t,A,i,n,r={}){super(),this.source=t,this.littleEndian=A,this.bigTiff=i,this.firstIFDOffset=n,this.cache=r.cache||!1,this.ifdRequests=[],this.ghostValues=null}async getSlice(t,A){let i=this.bigTiff?4048:1024;return new VA((await this.source.fetch([{offset:t,length:typeof A<"u"?A:i}]))[0],t,this.littleEndian,this.bigTiff)}async parseFileDirectoryAt(t){let A=this.bigTiff?20:12,i=this.bigTiff?8:2,n=await this.getSlice(t),r=this.bigTiff?n.readUint64(t):n.readUint16(t),g=r*A+(this.bigTiff?16:6);n.covers(t,g)||(n=await this.getSlice(t,g));let a={},l=t+(this.bigTiff?8:2);for(let I=0;I<r;l+=A,++I){let c=n.readUint16(l),f=n.readUint16(l+2),h=this.bigTiff?n.readUint64(l+4):n.readUint32(l+4),E,u,Q=an(f),C=l+(this.bigTiff?12:8);if(Q*h<=(this.bigTiff?8:4))E=CA(n,f,h,C);else{let p=n.readOffset(C),w=an(f)*h;if(n.covers(p,w))E=CA(n,f,h,p);else{let d=await this.getSlice(p,w);E=CA(d,f,h,p)}}h===1&&nr.indexOf(c)===-1&&!(f===M.RATIONAL||f===M.SRATIONAL)?u=E[0]:u=E,a[oA[c]]=u}let o=xf(a),s=n.readOffset(t+i+A*r);return new gn(a,o,s)}async requestIFD(t){if(this.ifdRequests[t])return this.ifdRequests[t];if(t===0)return this.ifdRequests[t]=this.parseFileDirectoryAt(this.firstIFDOffset),this.ifdRequests[t];if(!this.ifdRequests[t-1])try{this.ifdRequests[t-1]=this.requestIFD(t-1)}catch(A){throw A instanceof dA?new dA(t):A}return this.ifdRequests[t]=(async()=>{let A=await this.ifdRequests[t-1];if(A.nextIFDByteOffset===0)throw new dA(t);return this.parseFileDirectoryAt(A.nextIFDByteOffset)})(),this.ifdRequests[t]}async getImage(t=0){let A=await this.requestIFD(t);return new ss(A.fileDirectory,A.geoKeyDirectory,this.dataView,this.littleEndian,this.cache,this.source)}async getImageCount(){let t=0,A=!0;for(;A;)try{await this.requestIFD(t),++t}catch(i){if(i instanceof dA)A=!1;else throw i}return t}async getGhostValues(){let t=this.bigTiff?16:8;if(this.ghostValues)return this.ghostValues;let A="GDAL_STRUCTURAL_METADATA_SIZE=",i=A.length+100,n=await this.getSlice(t,i);if(A===CA(n,M.ASCII,A.length,t)){let g=CA(n,M.ASCII,i,t).split(`
|
|
13
13
|
`)[0],a=Number(g.split("=")[1].split(" ")[0])+g.length;a>i&&(n=await this.getSlice(t,a));let l=CA(n,M.ASCII,a,t);this.ghostValues={},l.split(`
|
|
14
|
-
`).filter(o=>o.length>0).map(o=>o.split("=")).forEach(([o,s])=>{this.ghostValues[o]=s})}return this.ghostValues}static async fromSource(t,A,i){let n=(await t.fetch([{offset:0,length:1024}],i))[0],r=new KA(n),g=r.getUint16(0,0),a;if(g===18761)a=!0;else if(g===19789)a=!1;else throw new TypeError("Invalid byte order value.");let l=r.getUint16(2,a),o;if(l===42)o=!1;else if(l===43){if(o=!0,r.getUint16(4,a)!==8)throw new Error("Unsupported offset byte-size.")}else throw new TypeError("Invalid magic number.");let s=o?r.getUint64(8,a):r.getUint32(4,a);return new Ne(t,a,o,s,A)}close(){return typeof this.source.close=="function"?this.source.close():!1}};async function _s(e,t={},A){return Ne.fromSource(ps(e,t),A)}async function ms(e,t){return Ne.fromSource(ws(e),t)}async function xs(e,t){return Ne.fromSource(ys(e),t)}var Df="4.4.0-alpha.
|
|
14
|
+
`).filter(o=>o.length>0).map(o=>o.split("=")).forEach(([o,s])=>{this.ghostValues[o]=s})}return this.ghostValues}static async fromSource(t,A,i){let n=(await t.fetch([{offset:0,length:1024}],i))[0],r=new KA(n),g=r.getUint16(0,0),a;if(g===18761)a=!0;else if(g===19789)a=!1;else throw new TypeError("Invalid byte order value.");let l=r.getUint16(2,a),o;if(l===42)o=!1;else if(l===43){if(o=!0,r.getUint16(4,a)!==8)throw new Error("Unsupported offset byte-size.")}else throw new TypeError("Invalid magic number.");let s=o?r.getUint64(8,a):r.getUint32(4,a);return new Ne(t,a,o,s,A)}close(){return typeof this.source.close=="function"?this.source.close():!1}};async function _s(e,t={},A){return Ne.fromSource(ps(e,t),A)}async function ms(e,t){return Ne.fromSource(ws(e),t)}async function xs(e,t){return Ne.fromSource(ys(e),t)}var Df="4.4.0-alpha.19",Ds={dataType:null,batchType:null,id:"geotiff",name:"GeoTIFF",module:"geotiff",version:Df,options:{geotiff:{enableAlpha:!0}},mimeTypes:["image/tiff","image/geotiff"],extensions:["geotiff","tiff","geotif","tif"],parse:bf};async function bf(e,t){let i=await(await ms(e)).getImage(),n=await i.readRGB({enableAlpha:t?.geotiff?.enableAlpha}),r=i.getWidth(),g=i.getHeight(),a=new Uint8ClampedArray(n),l=i.getBoundingBox(),o=i.getGeoKeys(),s;return o?.ProjectedCSTypeGeoKey&&(s=`EPSG:${o.ProjectedCSTypeGeoKey}`),{crs:s,bounds:l,width:r,height:g,data:a,metadata:o}}function fn(e){return Array.isArray(e)?e:[e]}function bs(e){if(!Number.isInteger(e))throw Error("Not an integer.");let t=new ArrayBuffer(4);new DataView(t).setInt32(0,e,!1);let i=new Uint8Array(t);return Array.from(i)}function cn(e){let t=e[e.length-1];return t===3||t===4}function Ss(e){let t=cn(e.shape),[A,i]=e.shape.slice(t?-3:-2);return{height:A,width:i}}var ks="__vivSignalAborted";var QA=class{dtype;tileSize;shape;labels;meta;_indexer;constructor(t,A,i,n,r,g){this._indexer=t,this.dtype=A,this.tileSize=i,this.shape=n,this.labels=r,this.meta=g}async getRaster({selection:t,signal:A}){let i=await this._indexer(t);return this._readRasters(i,{signal:A})}async getTile({x:t,y:A,selection:i,signal:n}){let{height:r,width:g}=this._getTileExtent(t,A),a=t*this.tileSize,l=A*this.tileSize,o=[a,l,a+g,l+r],s=await this._indexer(i);return this._readRasters(s,{window:o,width:g,height:r,signal:n})}async _readRasters(t,A){let i=cn(this.shape),n=await t.readRasters({interleave:i,...A});if(A?.signal?.aborted)throw ks;return{data:i?n:n[0],width:n.width,height:n.height}}_getTileExtent(t,A){let{height:i,width:n}=Ss(this),r=this.tileSize,g=this.tileSize,a=Math.floor(n/this.tileSize),l=Math.floor(i/this.tileSize);return t===a&&(g=n%this.tileSize),A===l&&(r=i%this.tileSize),{height:r,width:g}}onTileError(t){console.error(t)}};function Fs(e,t){let A=t[0],{SizeT:i,SizeC:n,SizeZ:r}=A.Pixels,g=Rs(A);return(a,l)=>{let o=g(a),s=l*r*i*n;return e.getImage(o+s)}}function Ns(e,t){let A=t[0],i=Rs(A),n=new Map;return async(r,g)=>{let a=i(r),l=await e.getImage(a);if(g===0)return l;let{SubIFDs:o}=l.fileDirectory;if(!o)throw Error("Indexing Error: OME-TIFF is missing SubIFDs.");let s=`${r.t}-${r.c}-${r.z}-${g}`;if(!n.has(s)){let c=o[g-1];n.set(s,e.parseFileDirectoryAt(c))}let I=await n.get(s);return new l.constructor(I.fileDirectory,I.geoKeyDirectory,e.dataView,e.littleEndian,e.cache,e.source)}}function Rs(e){let{SizeC:t,SizeZ:A,SizeT:i,DimensionOrder:n}=e.Pixels;switch(n){case"XYZCT":return({t:r,c:g,z:a})=>r*A*t+g*A+a;case"XYZTC":return({t:r,c:g,z:a})=>g*A*i+r*A+a;case"XYCTZ":return({t:r,c:g,z:a})=>a*t*i+r*t+g;case"XYCZT":return({t:r,c:g,z:a})=>r*t*A+a*t+g;case"XYTCZ":return({t:r,c:g,z:a})=>a*i*t+g*i+r;case"XYTZC":return({t:r,c:g,z:a})=>g*i*A+a*i+r;default:throw new Error(`Invalid OME-XML DimensionOrder, got ${n}.`)}}function Ts(e){return e.toLowerCase().split("").reverse()}function vs(e){let t=new Map(e.map((A,i)=>[A,i]));if(t.size!==e.length)throw Error("Labels must be unique, found duplicated label.");return A=>{let i=t.get(A);if(i===void 0)throw Error("Invalid dimension.");return i}}var Us={uint8:"Uint8",uint16:"Uint16",uint32:"Uint32",float:"Float32",double:"Float64",int8:"Int8",int16:"Int16",int32:"Int32"};function Ls({Pixels:e}){let t=Ts(e.DimensionOrder),A=vs(t),i=Array(t.length).fill(0);i[A("t")]=e.SizeT,i[A("c")]=e.SizeC,i[A("z")]=e.SizeZ,e.Interleaved&&(t.push("_c"),i.push(3));let n=g=>{let a=[...i];return a[A("x")]=e.SizeX>>g,a[A("y")]=e.SizeY>>g,a};if(!(e.Type in Us))throw Error(`Pixel type ${e.Type} not supported.`);let r=Us[e.Type];if(e.PhysicalSizeX&&e.PhysicalSizeY){let g={x:{size:e.PhysicalSizeX,unit:e.PhysicalSizeXUnit},y:{size:e.PhysicalSizeY,unit:e.PhysicalSizeYUnit}};return e.PhysicalSizeZ&&(g.z={size:e.PhysicalSizeZ,unit:e.PhysicalSizeZUnit}),{labels:t,getShape:n,physicalSizes:g,dtype:r}}return{labels:t,getShape:n,dtype:r}}var Gs=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",Sf=Gs+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",kf="["+Gs+"]["+Sf+"]*",Ff=new RegExp("^"+kf+"$");function Xt(e,t){let A=[],i=t.exec(e);for(;i;){let n=[];n.startIndex=t.lastIndex-i[0].length;let r=i.length;for(let g=0;g<r;g++)n.push(i[g]);A.push(n),i=t.exec(e)}return A}var pA=function(e){let t=Ff.exec(e);return!(t===null||typeof t>"u")};function Ms(e){return typeof e<"u"}var Nf={allowBooleanAttributes:!1,unpairedTags:[]};function Js(e,t){t=Object.assign({},Nf,t);let A=[],i=!1,n=!1;e[0]==="\uFEFF"&&(e=e.substr(1));for(let r=0;r<e.length;r++)if(e[r]==="<"&&e[r+1]==="?"){if(r+=2,r=qs(e,r),r.err)return r}else if(e[r]==="<"){let g=r;if(r++,e[r]==="!"){r=Ys(e,r);continue}else{let a=!1;e[r]==="/"&&(a=!0,r++);let l="";for(;r<e.length&&e[r]!==">"&&e[r]!==" "&&e[r]!==" "&&e[r]!==`
|
|
15
15
|
`&&e[r]!=="\r";r++)l+=e[r];if(l=l.trim(),l[l.length-1]==="/"&&(l=l.substring(0,l.length-1),r--),!Of(l)){let I;return l.trim().length===0?I="Invalid space after '<'.":I="Tag '"+l+"' is an invalid name.",W("InvalidTag",I,re(e,r))}let o=vf(e,r);if(o===!1)return W("InvalidAttr","Attributes for '"+l+"' have open quote.",re(e,r));let s=o.value;if(r=o.index,s[s.length-1]==="/"){let I=r-s.length;s=s.substring(0,s.length-1);let c=Hs(s,t);if(c===!0)i=!0;else return W(c.err.code,c.err.msg,re(e,I+c.err.line))}else if(a)if(o.tagClosed){if(s.trim().length>0)return W("InvalidTag","Closing tag '"+l+"' can't have attributes or invalid starting.",re(e,g));if(A.length===0)return W("InvalidTag","Closing tag '"+l+"' has not been opened.",re(e,g));{let I=A.pop();if(l!==I.tagName){let c=re(e,I.tagStartPos);return W("InvalidTag","Expected closing tag '"+I.tagName+"' (opened in line "+c.line+", col "+c.col+") instead of closing tag '"+l+"'.",re(e,g))}A.length==0&&(n=!0)}}else return W("InvalidTag","Closing tag '"+l+"' doesn't have proper closing.",re(e,r));else{let I=Hs(s,t);if(I!==!0)return W(I.err.code,I.err.msg,re(e,r-s.length+I.err.line));if(n===!0)return W("InvalidXml","Multiple possible root nodes found.",re(e,r));t.unpairedTags.indexOf(l)!==-1||A.push({tagName:l,tagStartPos:g}),i=!0}for(r++;r<e.length;r++)if(e[r]==="<")if(e[r+1]==="!"){r++,r=Ys(e,r);continue}else if(e[r+1]==="?"){if(r=qs(e,++r),r.err)return r}else break;else if(e[r]==="&"){let I=Gf(e,r);if(I==-1)return W("InvalidChar","char '&' is not expected.",re(e,r));r=I}else if(n===!0&&!Os(e[r]))return W("InvalidXml","Extra text at the end",re(e,r));e[r]==="<"&&r--}}else{if(Os(e[r]))continue;return W("InvalidChar","char '"+e[r]+"' is not expected.",re(e,r))}if(i){if(A.length==1)return W("InvalidTag","Unclosed tag '"+A[0].tagName+"'.",re(e,A[0].tagStartPos));if(A.length>0)return W("InvalidXml","Invalid '"+JSON.stringify(A.map(r=>r.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return W("InvalidXml","Start tag expected.",1);return!0}function Os(e){return e===" "||e===" "||e===`
|
|
16
16
|
`||e==="\r"}function qs(e,t){let A=t;for(;t<e.length;t++)if(e[t]=="?"||e[t]==" "){let i=e.substr(A,t-A);if(t>5&&i==="xml")return W("InvalidXml","XML declaration allowed only at the start of the document.",re(e,t));if(e[t]=="?"&&e[t+1]==">"){t++;break}else continue}return t}function Ys(e,t){if(e.length>t+5&&e[t+1]==="-"&&e[t+2]==="-"){for(t+=3;t<e.length;t++)if(e[t]==="-"&&e[t+1]==="-"&&e[t+2]===">"){t+=2;break}}else if(e.length>t+8&&e[t+1]==="D"&&e[t+2]==="O"&&e[t+3]==="C"&&e[t+4]==="T"&&e[t+5]==="Y"&&e[t+6]==="P"&&e[t+7]==="E"){let A=1;for(t+=8;t<e.length;t++)if(e[t]==="<")A++;else if(e[t]===">"&&(A--,A===0))break}else if(e.length>t+9&&e[t+1]==="["&&e[t+2]==="C"&&e[t+3]==="D"&&e[t+4]==="A"&&e[t+5]==="T"&&e[t+6]==="A"&&e[t+7]==="["){for(t+=8;t<e.length;t++)if(e[t]==="]"&&e[t+1]==="]"&&e[t+2]===">"){t+=2;break}}return t}var Rf='"',Tf="'";function vf(e,t){let A="",i="",n=!1;for(;t<e.length;t++){if(e[t]===Rf||e[t]===Tf)i===""?i=e[t]:i!==e[t]||(i="");else if(e[t]===">"&&i===""){n=!0;break}A+=e[t]}return i!==""?!1:{value:A,index:t,tagClosed:n}}var Uf=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function Hs(e,t){let A=Xt(e,Uf),i={};for(let n=0;n<A.length;n++){if(A[n][1].length===0)return W("InvalidAttr","Attribute '"+A[n][2]+"' has no space in starting.",ZA(A[n]));if(A[n][3]!==void 0&&A[n][4]===void 0)return W("InvalidAttr","Attribute '"+A[n][2]+"' is without value.",ZA(A[n]));if(A[n][3]===void 0&&!t.allowBooleanAttributes)return W("InvalidAttr","boolean attribute '"+A[n][2]+"' is not allowed.",ZA(A[n]));let r=A[n][2];if(!Mf(r))return W("InvalidAttr","Attribute '"+r+"' is an invalid name.",ZA(A[n]));if(!i.hasOwnProperty(r))i[r]=1;else return W("InvalidAttr","Attribute '"+r+"' is repeated.",ZA(A[n]))}return!0}function Lf(e,t){let A=/\d/;for(e[t]==="x"&&(t++,A=/[\da-fA-F]/);t<e.length;t++){if(e[t]===";")return t;if(!e[t].match(A))break}return-1}function Gf(e,t){if(t++,e[t]===";")return-1;if(e[t]==="#")return t++,Lf(e,t);let A=0;for(;t<e.length;t++,A++)if(!(e[t].match(/\w/)&&A<20)){if(e[t]===";")break;return-1}return t}function W(e,t,A){return{err:{code:e,msg:t,line:A.line||A,col:A.col}}}function Mf(e){return pA(e)}function Of(e){return pA(e)}function re(e,t){let A=e.substring(0,t).split(/\r?\n/);return{line:A.length,col:A[A.length-1].length+1}}function ZA(e){return e.startIndex+e[1].length}var qf={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(e,t){return t},attributeValueProcessor:function(e,t){return t},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(e,t,A){return e},captureMetaData:!1};function Ks(e){return typeof e=="boolean"?{enabled:e,maxEntitySize:1e4,maxExpansionDepth:10,maxTotalExpansions:1e3,maxExpandedLength:1e5,allowedTags:null,tagFilter:null}:typeof e=="object"&&e!==null?{enabled:e.enabled!==!1,maxEntitySize:e.maxEntitySize??1e4,maxExpansionDepth:e.maxExpansionDepth??10,maxTotalExpansions:e.maxTotalExpansions??1e3,maxExpandedLength:e.maxExpandedLength??1e5,allowedTags:e.allowedTags??null,tagFilter:e.tagFilter??null}:Ks(!0)}var Vs=function(e){let t=Object.assign({},qf,e);return t.processEntities=Ks(t.processEntities),t};var jt;typeof Symbol!="function"?jt="@@xmlMetadata":jt=Symbol("XML Node Metadata");var ce=class{constructor(t){this.tagname=t,this.child=[],this[":@"]={}}add(t,A){t==="__proto__"&&(t="#__proto__"),this.child.push({[t]:A})}addChild(t,A){t.tagname==="__proto__"&&(t.tagname="#__proto__"),t[":@"]&&Object.keys(t[":@"]).length>0?this.child.push({[t.tagname]:t.child,[":@"]:t[":@"]}):this.child.push({[t.tagname]:t.child}),A!==void 0&&(this.child[this.child.length-1][jt]={startIndex:A})}static getMetaDataSymbol(){return jt}};var jA=class{constructor(t){this.suppressValidationErr=!t,this.options=t}readDocType(t,A){let i={};if(t[A+3]==="O"&&t[A+4]==="C"&&t[A+5]==="T"&&t[A+6]==="Y"&&t[A+7]==="P"&&t[A+8]==="E"){A=A+9;let n=1,r=!1,g=!1,a="";for(;A<t.length;A++)if(t[A]==="<"&&!g){if(r&&eA(t,"!ENTITY",A)){A+=7;let l,o;if([l,o,A]=this.readEntityExp(t,A+1,this.suppressValidationErr),o.indexOf("&")===-1){let s=l.replace(/[.\-+*:]/g,"\\.");i[l]={regx:RegExp(`&${s};`,"g"),val:o}}}else if(r&&eA(t,"!ELEMENT",A)){A+=8;let{index:l}=this.readElementExp(t,A+1);A=l}else if(r&&eA(t,"!ATTLIST",A))A+=8;else if(r&&eA(t,"!NOTATION",A)){A+=9;let{index:l}=this.readNotationExp(t,A+1,this.suppressValidationErr);A=l}else if(eA(t,"!--",A))g=!0;else throw new Error("Invalid DOCTYPE");n++,a=""}else if(t[A]===">"){if(g?t[A-1]==="-"&&t[A-2]==="-"&&(g=!1,n--):n--,n===0)break}else t[A]==="["?r=!0:a+=t[A];if(n!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:i,i:A}}readEntityExp(t,A){A=ae(t,A);let i="";for(;A<t.length&&!/\s/.test(t[A])&&t[A]!=='"'&&t[A]!=="'";)i+=t[A],A++;if(XA(i),A=ae(t,A),!this.suppressValidationErr){if(t.substring(A,A+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(t[A]==="%")throw new Error("Parameter entities are not supported")}let n="";if([A,n]=this.readIdentifierVal(t,A,"entity"),this.options.enabled!==!1&&this.options.maxEntitySize&&n.length>this.options.maxEntitySize)throw new Error(`Entity "${i}" size (${n.length}) exceeds maximum allowed size (${this.options.maxEntitySize})`);return A--,[i,n,A]}readNotationExp(t,A){A=ae(t,A);let i="";for(;A<t.length&&!/\s/.test(t[A]);)i+=t[A],A++;!this.suppressValidationErr&&XA(i),A=ae(t,A);let n=t.substring(A,A+6).toUpperCase();if(!this.suppressValidationErr&&n!=="SYSTEM"&&n!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${n}"`);A+=n.length,A=ae(t,A);let r=null,g=null;if(n==="PUBLIC")[A,r]=this.readIdentifierVal(t,A,"publicIdentifier"),A=ae(t,A),(t[A]==='"'||t[A]==="'")&&([A,g]=this.readIdentifierVal(t,A,"systemIdentifier"));else if(n==="SYSTEM"&&([A,g]=this.readIdentifierVal(t,A,"systemIdentifier"),!this.suppressValidationErr&&!g))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:i,publicIdentifier:r,systemIdentifier:g,index:--A}}readIdentifierVal(t,A,i){let n="",r=t[A];if(r!=='"'&&r!=="'")throw new Error(`Expected quoted string, found "${r}"`);for(A++;A<t.length&&t[A]!==r;)n+=t[A],A++;if(t[A]!==r)throw new Error(`Unterminated ${i} value`);return A++,[A,n]}readElementExp(t,A){A=ae(t,A);let i="";for(;A<t.length&&!/\s/.test(t[A]);)i+=t[A],A++;if(!this.suppressValidationErr&&!pA(i))throw new Error(`Invalid element name: "${i}"`);A=ae(t,A);let n="";if(t[A]==="E"&&eA(t,"MPTY",A))A+=4;else if(t[A]==="A"&&eA(t,"NY",A))A+=2;else if(t[A]==="("){for(A++;A<t.length&&t[A]!==")";)n+=t[A],A++;if(t[A]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${t[A]}"`);return{elementName:i,contentModel:n.trim(),index:A}}readAttlistExp(t,A){A=ae(t,A);let i="";for(;A<t.length&&!/\s/.test(t[A]);)i+=t[A],A++;XA(i),A=ae(t,A);let n="";for(;A<t.length&&!/\s/.test(t[A]);)n+=t[A],A++;if(!XA(n))throw new Error(`Invalid attribute name: "${n}"`);A=ae(t,A);let r="";if(t.substring(A,A+8).toUpperCase()==="NOTATION"){if(r="NOTATION",A+=8,A=ae(t,A),t[A]!=="(")throw new Error(`Expected '(', found "${t[A]}"`);A++;let a=[];for(;A<t.length&&t[A]!==")";){let l="";for(;A<t.length&&t[A]!=="|"&&t[A]!==")";)l+=t[A],A++;if(l=l.trim(),!XA(l))throw new Error(`Invalid notation name: "${l}"`);a.push(l),t[A]==="|"&&(A++,A=ae(t,A))}if(t[A]!==")")throw new Error("Unterminated list of notations");A++,r+=" ("+a.join("|")+")"}else{for(;A<t.length&&!/\s/.test(t[A]);)r+=t[A],A++;let a=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!a.includes(r.toUpperCase()))throw new Error(`Invalid attribute type: "${r}"`)}A=ae(t,A);let g="";return t.substring(A,A+8).toUpperCase()==="#REQUIRED"?(g="#REQUIRED",A+=8):t.substring(A,A+7).toUpperCase()==="#IMPLIED"?(g="#IMPLIED",A+=7):[A,g]=this.readIdentifierVal(t,A,"ATTLIST"),{elementName:i,attributeName:n,attributeType:r,defaultValue:g,index:A}}},ae=(e,t)=>{for(;t<e.length&&/\s/.test(e[t]);)t++;return t};function eA(e,t,A){for(let i=0;i<t.length;i++)if(t[i]!==e[A+i+1])return!1;return!0}function XA(e){if(pA(e))return e;throw new Error(`Invalid entity name ${e}`)}var Yf=/^[-+]?0x[a-fA-F0-9]+$/,Hf=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Jf={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function In(e,t={}){if(t=Object.assign({},Jf,t),!e||typeof e!="string")return e;let A=e.trim();if(t.skipLike!==void 0&&t.skipLike.test(A))return e;if(e==="0")return 0;if(t.hex&&Yf.test(A))return Pf(A,16);if(A.includes("e")||A.includes("E"))return Vf(e,A,t);{let i=Hf.exec(A);if(i){let n=i[1]||"",r=i[2],g=zf(i[3]),a=n?e[r.length+1]===".":e[r.length]===".";if(!t.leadingZeros&&(r.length>1||r.length===1&&!a))return e;{let l=Number(A),o=String(l);if(l===0)return l;if(o.search(/[eE]/)!==-1)return t.eNotation?l:e;if(A.indexOf(".")!==-1)return o==="0"||o===g||o===`${n}${g}`?l:e;let s=r?g:A;return r?s===o||n+s===o?l:e:s===o||s===n+o?l:e}}else return e}}var Kf=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function Vf(e,t,A){if(!A.eNotation)return e;let i=t.match(Kf);if(i){let n=i[1]||"",r=i[3].indexOf("e")===-1?"E":"e",g=i[2],a=n?e[g.length+1]===r:e[g.length]===r;return g.length>1&&a?e:g.length===1&&(i[3].startsWith(`.${r}`)||i[3][0]===r)?Number(t):A.leadingZeros&&!a?(t=(i[1]||"")+i[3],Number(t)):e}else return e}function zf(e){return e&&e.indexOf(".")!==-1&&(e=e.replace(/0+$/,""),e==="."?e="0":e[0]==="."?e="0"+e:e[e.length-1]==="."&&(e=e.substring(0,e.length-1))),e}function Pf(e,t){if(parseInt)return parseInt(e,t);if(Number.parseInt)return Number.parseInt(e,t);if(window&&window.parseInt)return window.parseInt(e,t);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function hn(e){return typeof e=="function"?e:Array.isArray(e)?t=>{for(let A of e)if(typeof A=="string"&&t===A||A instanceof RegExp&&A.test(t))return!0}:()=>!1}var WA=class{constructor(t){if(this.options=t,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"\xA2"},pound:{regex:/&(pound|#163);/g,val:"\xA3"},yen:{regex:/&(yen|#165);/g,val:"\xA5"},euro:{regex:/&(euro|#8364);/g,val:"\u20AC"},copyright:{regex:/&(copy|#169);/g,val:"\xA9"},reg:{regex:/&(reg|#174);/g,val:"\xAE"},inr:{regex:/&(inr|#8377);/g,val:"\u20B9"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(A,i)=>zs(i,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(A,i)=>zs(i,16,"&#x")}},this.addExternalEntities=Zf,this.parseXml=ec,this.parseTextData=Xf,this.resolveNameSpace=jf,this.buildAttributesMap=$f,this.isItStopNode=nc,this.replaceEntitiesValue=tc,this.readStopNodeData=oc,this.saveTextToParentTag=ic,this.addChild=Ac,this.ignoreAttributesFn=hn(this.options.ignoreAttributes),this.entityExpansionCount=0,this.currentExpandedLength=0,this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let A=0;A<this.options.stopNodes.length;A++){let i=this.options.stopNodes[A];typeof i=="string"&&(i.startsWith("*.")?this.stopNodesWildcard.add(i.substring(2)):this.stopNodesExact.add(i))}}}};function Zf(e){let t=Object.keys(e);for(let A=0;A<t.length;A++){let i=t[A],n=i.replace(/[.\-+*:]/g,"\\.");this.lastEntities[i]={regex:new RegExp("&"+n+";","g"),val:e[i]}}}function Xf(e,t,A,i,n,r,g){if(e!==void 0&&(this.options.trimValues&&!i&&(e=e.trim()),e.length>0)){g||(e=this.replaceEntitiesValue(e,t,A));let a=this.options.tagValueProcessor(t,e,A,n,r);return a==null?e:typeof a!=typeof e||a!==e?a:this.options.trimValues?En(e,this.options.parseTagValue,this.options.numberParseOptions):e.trim()===e?En(e,this.options.parseTagValue,this.options.numberParseOptions):e}}function jf(e){if(this.options.removeNSPrefix){let t=e.split(":"),A=e.charAt(0)==="/"?"/":"";if(t[0]==="xmlns")return"";t.length===2&&(e=A+t[1])}return e}var Wf=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function $f(e,t,A){if(this.options.ignoreAttributes!==!0&&typeof e=="string"){let i=Xt(e,Wf),n=i.length,r={};for(let g=0;g<n;g++){let a=this.resolveNameSpace(i[g][1]);if(this.ignoreAttributesFn(a,t))continue;let l=i[g][4],o=this.options.attributeNamePrefix+a;if(a.length)if(this.options.transformAttributeName&&(o=this.options.transformAttributeName(o)),o==="__proto__"&&(o="#__proto__"),l!==void 0){this.options.trimValues&&(l=l.trim()),l=this.replaceEntitiesValue(l,A,t);let s=this.options.attributeValueProcessor(a,l,t);s==null?r[o]=l:typeof s!=typeof l||s!==l?r[o]=s:r[o]=En(l,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(r[o]=!0)}if(!Object.keys(r).length)return;if(this.options.attributesGroupName){let g={};return g[this.options.attributesGroupName]=r,g}return r}}var ec=function(e){e=e.replace(/\r\n?/g,`
|
|
17
17
|
`);let t=new ce("!xml"),A=t,i="",n="";this.entityExpansionCount=0,this.currentExpandedLength=0;let r=new jA(this.options.processEntities);for(let g=0;g<e.length;g++)if(e[g]==="<")if(e[g+1]==="/"){let l=AA(e,">",g,"Closing Tag is not closed."),o=e.substring(g+2,l).trim();if(this.options.removeNSPrefix){let c=o.indexOf(":");c!==-1&&(o=o.substr(c+1))}this.options.transformTagName&&(o=this.options.transformTagName(o)),A&&(i=this.saveTextToParentTag(i,A,n));let s=n.substring(n.lastIndexOf(".")+1);if(o&&this.options.unpairedTags.indexOf(o)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${o}>`);let I=0;s&&this.options.unpairedTags.indexOf(s)!==-1?(I=n.lastIndexOf(".",n.lastIndexOf(".")-1),this.tagsNodeStack.pop()):I=n.lastIndexOf("."),n=n.substring(0,I),A=this.tagsNodeStack.pop(),i="",g=l}else if(e[g+1]==="?"){let l=un(e,g,!1,"?>");if(!l)throw new Error("Pi Tag is not closed.");if(i=this.saveTextToParentTag(i,A,n),!(this.options.ignoreDeclaration&&l.tagName==="?xml"||this.options.ignorePiTags)){let o=new ce(l.tagName);o.add(this.options.textNodeName,""),l.tagName!==l.tagExp&&l.attrExpPresent&&(o[":@"]=this.buildAttributesMap(l.tagExp,n,l.tagName)),this.addChild(A,o,n,g)}g=l.closeIndex+1}else if(e.substr(g+1,3)==="!--"){let l=AA(e,"-->",g+4,"Comment is not closed.");if(this.options.commentPropName){let o=e.substring(g+4,l-2);i=this.saveTextToParentTag(i,A,n),A.add(this.options.commentPropName,[{[this.options.textNodeName]:o}])}g=l}else if(e.substr(g+1,2)==="!D"){let l=r.readDocType(e,g);this.docTypeEntities=l.entities,g=l.i}else if(e.substr(g+1,2)==="!["){let l=AA(e,"]]>",g,"CDATA is not closed.")-2,o=e.substring(g+9,l);i=this.saveTextToParentTag(i,A,n);let s=this.parseTextData(o,A.tagname,n,!0,!1,!0,!0);s==null&&(s=""),this.options.cdataPropName?A.add(this.options.cdataPropName,[{[this.options.textNodeName]:o}]):A.add(this.options.textNodeName,s),g=l+2}else{let l=un(e,g,this.options.removeNSPrefix),o=l.tagName,s=l.rawTagName,I=l.tagExp,c=l.attrExpPresent,f=l.closeIndex;if(this.options.transformTagName){let u=this.options.transformTagName(o);I===o&&(I=u),o=u}A&&i&&A.tagname!=="!xml"&&(i=this.saveTextToParentTag(i,A,n,!1));let h=A;h&&this.options.unpairedTags.indexOf(h.tagname)!==-1&&(A=this.tagsNodeStack.pop(),n=n.substring(0,n.lastIndexOf("."))),o!==t.tagname&&(n+=n?"."+o:o);let E=g;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,n,o)){let u="";if(I.length>0&&I.lastIndexOf("/")===I.length-1)o[o.length-1]==="/"?(o=o.substr(0,o.length-1),n=n.substr(0,n.length-1),I=o):I=I.substr(0,I.length-1),g=l.closeIndex;else if(this.options.unpairedTags.indexOf(o)!==-1)g=l.closeIndex;else{let C=this.readStopNodeData(e,s,f+1);if(!C)throw new Error(`Unexpected end of ${s}`);g=C.i,u=C.tagContent}let Q=new ce(o);o!==I&&c&&(Q[":@"]=this.buildAttributesMap(I,n,o)),u&&(u=this.parseTextData(u,o,n,!0,c,!0,!0)),n=n.substr(0,n.lastIndexOf(".")),Q.add(this.options.textNodeName,u),this.addChild(A,Q,n,E)}else{if(I.length>0&&I.lastIndexOf("/")===I.length-1){if(o[o.length-1]==="/"?(o=o.substr(0,o.length-1),n=n.substr(0,n.length-1),I=o):I=I.substr(0,I.length-1),this.options.transformTagName){let Q=this.options.transformTagName(o);I===o&&(I=Q),o=Q}let u=new ce(o);o!==I&&c&&(u[":@"]=this.buildAttributesMap(I,n,o)),this.addChild(A,u,n,E),n=n.substr(0,n.lastIndexOf("."))}else{let u=new ce(o);this.tagsNodeStack.push(A),o!==I&&c&&(u[":@"]=this.buildAttributesMap(I,n,o)),this.addChild(A,u,n,E),A=u}i="",g=f}}else i+=e[g];return t.child};function Ac(e,t,A,i){this.options.captureMetaData||(i=void 0);let n=this.options.updateTag(t.tagname,A,t[":@"]);n===!1||(typeof n=="string"&&(t.tagname=n),e.addChild(t,i))}var tc=function(e,t,A){if(e.indexOf("&")===-1)return e;let i=this.options.processEntities;if(!i.enabled||i.allowedTags&&!i.allowedTags.includes(t)||i.tagFilter&&!i.tagFilter(t,A))return e;for(let n in this.docTypeEntities){let r=this.docTypeEntities[n],g=e.match(r.regx);if(g){if(this.entityExpansionCount+=g.length,i.maxTotalExpansions&&this.entityExpansionCount>i.maxTotalExpansions)throw new Error(`Entity expansion limit exceeded: ${this.entityExpansionCount} > ${i.maxTotalExpansions}`);let a=e.length;if(e=e.replace(r.regx,r.val),i.maxExpandedLength&&(this.currentExpandedLength+=e.length-a,this.currentExpandedLength>i.maxExpandedLength))throw new Error(`Total expanded content size exceeded: ${this.currentExpandedLength} > ${i.maxExpandedLength}`)}}if(e.indexOf("&")===-1)return e;for(let n in this.lastEntities){let r=this.lastEntities[n];e=e.replace(r.regex,r.val)}if(e.indexOf("&")===-1)return e;if(this.options.htmlEntities)for(let n in this.htmlEntities){let r=this.htmlEntities[n];e=e.replace(r.regex,r.val)}return e=e.replace(this.ampEntity.regex,this.ampEntity.val),e};function ic(e,t,A,i){return e&&(i===void 0&&(i=t.child.length===0),e=this.parseTextData(e,t.tagname,A,!1,t[":@"]?Object.keys(t[":@"]).length!==0:!1,i),e!==void 0&&e!==""&&t.add(this.options.textNodeName,e),e=""),e}function nc(e,t,A,i){return!!(t&&t.has(i)||e&&e.has(A))}function rc(e,t,A=">"){let i,n="";for(let r=t;r<e.length;r++){let g=e[r];if(i)g===i&&(i="");else if(g==='"'||g==="'")i=g;else if(g===A[0])if(A[1]){if(e[r+1]===A[1])return{data:n,index:r}}else return{data:n,index:r};else g===" "&&(g=" ");n+=g}}function AA(e,t,A,i){let n=e.indexOf(t,A);if(n===-1)throw new Error(i);return n+t.length-1}function un(e,t,A,i=">"){let n=rc(e,t+1,i);if(!n)return;let r=n.data,g=n.index,a=r.search(/\s/),l=r,o=!0;a!==-1&&(l=r.substring(0,a),r=r.substring(a+1).trimStart());let s=l;if(A){let I=l.indexOf(":");I!==-1&&(l=l.substr(I+1),o=l!==n.data.substr(I+1))}return{tagName:l,tagExp:r,closeIndex:g,attrExpPresent:o,rawTagName:s}}function oc(e,t,A){let i=A,n=1;for(;A<e.length;A++)if(e[A]==="<")if(e[A+1]==="/"){let r=AA(e,">",A,`${t} is not closed`);if(e.substring(A+2,r).trim()===t&&(n--,n===0))return{tagContent:e.substring(i,A),i:r};A=r}else if(e[A+1]==="?")A=AA(e,"?>",A+1,"StopNode is not closed.");else if(e.substr(A+1,3)==="!--")A=AA(e,"-->",A+3,"StopNode is not closed.");else if(e.substr(A+1,2)==="![")A=AA(e,"]]>",A,"StopNode is not closed.")-2;else{let r=un(e,A,">");r&&((r&&r.tagName)===t&&r.tagExp[r.tagExp.length-1]!=="/"&&n++,A=r.closeIndex)}}function En(e,t,A){if(t&&typeof e=="string"){let i=e.trim();return i==="true"?!0:i==="false"?!1:In(e,A)}else return Ms(e)?e:""}function zs(e,t,A){let i=Number.parseInt(e,t);return i>=0&&i<=1114111?String.fromCodePoint(i):A+e+";"}var Bn=ce.getMetaDataSymbol();function Cn(e,t){return Ps(e,t)}function Ps(e,t,A){let i,n={};for(let r=0;r<e.length;r++){let g=e[r],a=sc(g),l="";if(A===void 0?l=a:l=A+"."+a,a===t.textNodeName)i===void 0?i=g[a]:i+=""+g[a];else{if(a===void 0)continue;if(g[a]){let o=Ps(g[a],t,l),s=gc(o,t);g[Bn]!==void 0&&(o[Bn]=g[Bn]),g[":@"]?ac(o,g[":@"],l,t):Object.keys(o).length===1&&o[t.textNodeName]!==void 0&&!t.alwaysCreateTextNode?o=o[t.textNodeName]:Object.keys(o).length===0&&(t.alwaysCreateTextNode?o[t.textNodeName]="":o=""),n[a]!==void 0&&n.hasOwnProperty(a)?(Array.isArray(n[a])||(n[a]=[n[a]]),n[a].push(o)):t.isArray(a,l,s)?n[a]=[o]:n[a]=o}}}return typeof i=="string"?i.length>0&&(n[t.textNodeName]=i):i!==void 0&&(n[t.textNodeName]=i),n}function sc(e){let t=Object.keys(e);for(let A=0;A<t.length;A++){let i=t[A];if(i!==":@")return i}}function ac(e,t,A,i){if(t){let n=Object.keys(t),r=n.length;for(let g=0;g<r;g++){let a=n[g];i.isArray(a,A+"."+a,!0,!0)?e[a]=[t[a]]:e[a]=t[a]}}}function gc(e,t){let{textNodeName:A}=t,i=Object.keys(e).length;return!!(i===0||i===1&&(e[A]||typeof e[A]=="boolean"||e[A]===0))}var wA=class{constructor(t){this.externalEntities={},this.options=Vs(t)}parse(t,A){if(typeof t!="string"&&t.toString)t=t.toString();else if(typeof t!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(A){A===!0&&(A={});let r=Js(t,A);if(r!==!0)throw Error(`${r.err.msg}:${r.err.line}:${r.err.col}`)}let i=new WA(this.options);i.addExternalEntities(this.externalEntities);let n=i.parseXml(t);return this.options.preserveOrder||n===void 0?n:Cn(n,this.options)}addEntity(t,A){if(A.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(t.indexOf("&")!==-1||t.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '
'");if(A==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[t]=A}static getMetaDataSymbol(){return ce.getMetaDataSymbol()}};var lc=new wA({attributeNamePrefix:"",attributesGroupName:"attr",parseTagValue:!0,parseAttributeValue:!0,ignoreAttributes:!1}),fc=e=>lc.parse(e);function Zs(e){let t=fc(e);if(!t.OME)throw Error("Failed to parse OME-XML metadata.");return fn(t.OME.Image).map(A=>{let i=fn(A.Pixels.Channel).map(a=>"Color"in a.attr?{...a.attr,Color:bs(a.attr.Color)}:{...a.attr}),{AquisitionDate:n="",Description:r=""}=A,g={...A.attr,AquisitionDate:n,Description:r,Pixels:{...A.Pixels.attr,Channels:i}};return{...g,format(){let{Pixels:a}=g,l=["X","Y","Z"].map(o=>{let s=a[`PhysicalSize${o}`],I=a[`PhysicalSize${o}Unit`];return s&&I?`${s} ${I}`:"-"}).join(" x ");return{"Acquisition Date":g.AquisitionDate,"Dimensions (XY)":`${a.SizeX} x ${a.SizeY}`,"Pixels Type":a.Type,"Pixels Size (XYZ)":l,"Z-sections/Timepoints":`${a.SizeZ} x ${a.SizeT}`,Channels:a.SizeC}}}})}var Xs=e=>e.fileDirectory.ImageDescription.includes("<OME");async function js(e,t){let{ImageDescription:A,SubIFDs:i,PhotometricInterpretation:n}=t.fileDirectory,r=Zs(A),g,a;i?(g=i.length+1,a=Ns(e,r)):(g=r.length,a=Fs(e,r));let l=r[0],{labels:o,getShape:s,physicalSizes:I,dtype:c}=Ls(l),f=t.getTileWidth(),h={photometricInterpretation:n,physicalSizes:I};return{data:Array.from({length:g}).map((u,Q)=>{let C=s(Q),p=d=>a(d,Q);return new QA(p,c,f,C,o,h)}),metadata:l}}async function Ws(e,t={}){let{headers:A,offsets:i}=t,n;e instanceof Ne?n=e:typeof e=="string"?n=await _s(e,A):n=await xs(e);let r=await n.getImage(0);if(Xs(r))return js(n,r);throw new Error("GeoTIFF not recognized.")}return ra($A);})();
|
package/dist/geotiff-loader.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { fromArrayBuffer } from 'geotiff';
|
|
5
5
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
6
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
-
const VERSION = typeof "4.4.0-alpha.
|
|
7
|
+
const VERSION = typeof "4.4.0-alpha.19" !== 'undefined' ? "4.4.0-alpha.19" : 'latest';
|
|
8
8
|
/** GeoTIFF loader */
|
|
9
9
|
export const GeoTIFFLoader = {
|
|
10
10
|
dataType: null,
|
package/dist/index.cjs
CHANGED
|
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(dist_exports);
|
|
|
28
28
|
|
|
29
29
|
// dist/geotiff-loader.js
|
|
30
30
|
var import_geotiff = require("geotiff");
|
|
31
|
-
var VERSION = true ? "4.4.0-alpha.
|
|
31
|
+
var VERSION = true ? "4.4.0-alpha.19" : "latest";
|
|
32
32
|
var GeoTIFFLoader = {
|
|
33
33
|
dataType: null,
|
|
34
34
|
batchType: null,
|
package/dist/loaders.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { fromArrayBuffer } from 'geotiff';
|
|
5
5
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
6
6
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
7
|
-
const VERSION = typeof "4.4.0-alpha.
|
|
7
|
+
const VERSION = typeof "4.4.0-alpha.19" !== 'undefined' ? "4.4.0-alpha.19" : 'latest';
|
|
8
8
|
/**
|
|
9
9
|
* Loads a GeoTIFF file containing a RGB image.
|
|
10
10
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/geotiff",
|
|
3
|
-
"version": "4.4.0-alpha.
|
|
3
|
+
"version": "4.4.0-alpha.19",
|
|
4
4
|
"description": "Framework-independent loaders for tiff and geotiff",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"geotiff": "ilan-gold/geotiff.js#ilan-gold/viv_094"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@loaders.gl/loader-utils": "4.4.0-alpha.
|
|
49
|
+
"@loaders.gl/loader-utils": "4.4.0-alpha.19",
|
|
50
50
|
"fast-xml-parser": "^5.3.6",
|
|
51
51
|
"geotiff": "^2.1.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@loaders.gl/core": "4.4.0-alpha.1"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "e29d8964be2d7304d212560b44e6669ce01e9b8a"
|
|
57
57
|
}
|