@loaders.gl/netcdf 4.4.0-alpha.13 → 4.4.0-alpha.14
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/index.cjs +1 -1
- package/dist/netcdf-loader.js +1 -1
- package/package.json +3 -3
package/dist/dist.min.js
CHANGED
|
@@ -5,6 +5,6 @@
|
|
|
5
5
|
else if (typeof exports === 'object') exports['loaders'] = factory();
|
|
6
6
|
else root['loaders'] = factory();})(globalThis, function () {
|
|
7
7
|
"use strict";var __exports__=(()=>{var H=Object.create;var g=Object.defineProperty;var V=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var Y=Object.getPrototypeOf,z=Object.prototype.hasOwnProperty;var M=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),G=(e,t)=>{for(var r in t)g(e,r,{get:t[r],enumerable:!0})},w=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of $(t))!z.call(e,n)&&n!==r&&g(e,n,{get:()=>t[n],enumerable:!(i=V(t,n))||i.enumerable});return e},E=(e,t,r)=>(w(e,t,"default"),r&&w(r,t,"default")),J=(e,t,r)=>(r=e!=null?H(Y(e)):{},w(t||!e||!e.__esModule?g(r,"default",{value:e,enumerable:!0}):r,e)),j=e=>w(g({},"__esModule",{value:!0}),e);var F=M((st,T)=>{T.exports=globalThis.loaders});var p={};G(p,{NetCDFLoader:()=>R,NetCDFReader:()=>u});E(p,J(F(),1));var f=class{buffer;byteLength;byteOffset;length;offset;lastWrittenByte;littleEndian;_data;_mark;_marks;textDecoder=new TextDecoder;textEncoder=new TextEncoder;constructor(t=8192,r={}){let i=!1;typeof t=="number"?t=new ArrayBuffer(t):(i=!0,this.lastWrittenByte=t.byteLength);let n=r.offset?r.offset>>>0:0,a=t.byteLength-n,o=n;(ArrayBuffer.isView(t)||t instanceof f)&&(t.byteLength!==t.buffer.byteLength&&(o=t.byteOffset+n),t=t.buffer),i?this.lastWrittenByte=a:this.lastWrittenByte=0,this.buffer=t,this.length=a,this.byteLength=a,this.byteOffset=o,this.offset=0,this.littleEndian=!0,this._data=new DataView(this.buffer,o,a),this._mark=0,this._marks=[]}available(t=1){return this.offset+t<=this.length}isLittleEndian(){return this.littleEndian}setLittleEndian(){return this.littleEndian=!0,this}isBigEndian(){return!this.littleEndian}setBigEndian(){return this.littleEndian=!1,this}skip(t=1){return this.offset+=t,this}seek(t){return this.offset=t,this}mark(){return this._mark=this.offset,this}reset(){return this.offset=this._mark,this}pushMark(){return this._marks.push(this.offset),this}popMark(){let t=this._marks.pop();if(t===void 0)throw new Error("Mark stack empty");return this.seek(t),this}rewind(){return this.offset=0,this}ensureAvailable(t=1){if(!this.available(t)){let i=(this.offset+t)*2,n=new Uint8Array(i);n.set(new Uint8Array(this.buffer)),this.buffer=n.buffer,this.length=this.byteLength=i,this._data=new DataView(this.buffer)}return this}readBoolean(){return this.readUint8()!==0}readInt8(){return this._data.getInt8(this.offset++)}readUint8(){return this._data.getUint8(this.offset++)}readByte(){return this.readUint8()}readBytes(t=1){let r=new Uint8Array(t);for(let i=0;i<t;i++)r[i]=this.readByte();return r}readInt16(){let t=this._data.getInt16(this.offset,this.littleEndian);return this.offset+=2,t}readUint16(){let t=this._data.getUint16(this.offset,this.littleEndian);return this.offset+=2,t}readInt32(){let t=this._data.getInt32(this.offset,this.littleEndian);return this.offset+=4,t}readUint32(){let t=this._data.getUint32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat32(){let t=this._data.getFloat32(this.offset,this.littleEndian);return this.offset+=4,t}readFloat64(){let t=this._data.getFloat64(this.offset,this.littleEndian);return this.offset+=8,t}readChar(){return String.fromCharCode(this.readInt8())}readChars(t=1){let r="";for(let i=0;i<t;i++)r+=this.readChar();return r}readUtf8(t=1){return this.textDecoder.decode(this.readBytes(t))}writeBoolean(t){return this.writeUint8(t?255:0),this}writeInt8(t){return this.ensureAvailable(1),this._data.setInt8(this.offset++,t),this._updateLastWrittenByte(),this}writeUint8(t){return this.ensureAvailable(1),this._data.setUint8(this.offset++,t),this._updateLastWrittenByte(),this}writeByte(t){return this.writeUint8(t)}writeBytes(t){this.ensureAvailable(t.length);for(let r=0;r<t.length;r++)this._data.setUint8(this.offset++,t[r]);return this._updateLastWrittenByte(),this}writeInt16(t){return this.ensureAvailable(2),this._data.setInt16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeUint16(t){return this.ensureAvailable(2),this._data.setUint16(this.offset,t,this.littleEndian),this.offset+=2,this._updateLastWrittenByte(),this}writeInt32(t){return this.ensureAvailable(4),this._data.setInt32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeUint32(t){return this.ensureAvailable(4),this._data.setUint32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat32(t){return this.ensureAvailable(4),this._data.setFloat32(this.offset,t,this.littleEndian),this.offset+=4,this._updateLastWrittenByte(),this}writeFloat64(t){return this.ensureAvailable(8),this._data.setFloat64(this.offset,t,this.littleEndian),this.offset+=8,this._updateLastWrittenByte(),this}writeChar(t){return this.writeUint8(t.charCodeAt(0))}writeChars(t){for(let r=0;r<t.length;r++)this.writeUint8(t.charCodeAt(r));return this}writeUtf8(t){let r=this.textEncoder.encode(t);return this.writeBytes(r)}toArray(){return new Uint8Array(this.buffer,this.byteOffset,this.lastWrittenByte)}_updateLastWrittenByte(){this.offset>this.lastWrittenByte&&(this.lastWrittenByte=this.offset)}};var s={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function c(e,t,r){switch(t){case s.BYTE:return e.readBytes(r);case s.CHAR:return P(e.readChars(r));case s.SHORT:return b(r,e.readInt16.bind(e));case s.INT:return b(r,e.readInt32.bind(e));case s.FLOAT:return b(r,e.readFloat32.bind(e));case s.DOUBLE:return b(r,e.readFloat64.bind(e));default:throw new Error(`NetCDF: non valid type ${t}`)}}function B(e){switch(Number(e)){case s.BYTE:return"byte";case s.CHAR:return"char";case s.SHORT:return"short";case s.INT:return"int";case s.FLOAT:return"float";case s.DOUBLE:return"double";default:return"undefined"}}function D(e){switch(Number(e)){case s.BYTE:return 1;case s.CHAR:return 1;case s.SHORT:return 2;case s.INT:return 4;case s.FLOAT:return 4;case s.DOUBLE:return 8;default:return-1}}function N(e){switch(String(e)){case"byte":return s.BYTE;case"char":return s.CHAR;case"short":return s.SHORT;case"int":return s.INT;case"float":return s.FLOAT;case"double":return s.DOUBLE;default:return-1}}function b(e,t){if(e!==1){let r=new Array(e);for(let i=0;i<e;i++)r[i]=t();return r}return t()}function P(e){return e.charCodeAt(e.length-1)===0?e.substring(0,e.length-1):e}var l=0,Z=10,q=11,K=12,Q=0;function I(e,t){let r=e.readUint32(),i=X(e),n=x(e),a=tt(e,i.recordId,t);return{version:t,recordDimension:{length:r,id:i.recordId,name:i.recordName,recordStep:a.recordStep},dimensions:i.dimensions,variables:a.variables,attributes:n}}function X(e){let t=e.readUint32();if(t===l){if(e.readUint32()!==l)throw new Error("NetCDF: wrong empty tag for list of dimensions");return{recordId:0,recordName:"",dimensions:[]}}if(t!==Z)throw new Error("NetCDF: wrong tag for list of dimensions");let r=e.readUint32(),i=new Array(r),n,a;for(let o=0;o<r;o++){let h=v(e),d=e.readUint32();d===Q&&(n=o,a=h),i[o]={name:h,size:d}}return{dimensions:i,recordId:n,recordName:a}}function x(e){let t=e.readUint32();if(t===l){if(e.readUint32()!==l)throw new Error("NetCDF: wrong empty tag for list of attributes");return[]}if(t!==K)throw new Error("NetCDF: wrong tag for list of attributes");let r=e.readUint32(),i=new Array(r);for(let n=0;n<r;n++){let a=v(e),o=e.readUint32();if(o<1||o>6)throw new Error(`NetCDF: non valid type ${o}`);let h=e.readUint32(),d=c(e,o,h);O(e),i[n]={name:a,type:B(o),value:d}}return i}function tt(e,t,r){let i=e.readUint32(),n=0;if(i===l){if(e.readUint32()!==l)throw new Error("NetCDF: wrong empty tag for list of variables");return{recordStep:n,variables:[]}}if(i!==q)throw new Error("NetCDF: wrong tag for list of variables");let a=e.readUint32(),o=new Array(a);for(let h=0;h<a;h++){let d=v(e),y=e.readUint32(),U=new Array(y);for(let L=0;L<y;L++)U[L]=e.readUint32();let W=x(e),m=e.readUint32();if(m<1&&m>6)throw new Error(`NetCDF: non valid type ${m}`);let C=e.readUint32(),A=e.readUint32();if(r===2){if(A>0)throw new Error("NetCDF: offsets larger than 4GB not supported");A=e.readUint32()}let _=!1;typeof t<"u"&&U[0]===t&&(n+=C,_=!0),o[h]={name:d,dimensions:U,attributes:W,type:B(m),size:C,offset:A,record:_}}return{variables:o,recordStep:n}}function v(e){let t=e.readUint32(),r=e.readChars(t);return O(e),r}function O(e){e.offset%4!==0&&e.skip(4-e.offset%4)}function S(e,t){let r=N(t.type),i=t.size/D(r),n=new Array(i);for(let a=0;a<i;a++)n[a]=c(e,r,1);return n}function k(e,t,r){let i=N(t.type),n=t.size?t.size/D(i):1,a=r.length,o=new Array(a),h=r.recordStep;for(let d=0;d<a;d++){let y=e.offset;o[d]=c(e,i,n),e.seek(y+h)}return o}var u=class{header;buffer;constructor(t){let r=new f(t);r.setBigEndian();let i=r.readChars(3);if(i!=="CDF")throw new Error(`NetCDF: file should start with 'CDF', found ${i}`);let n=r.readByte();if(n>2)throw new Error(`NetCDF: unsupported version ${n}`);this.header=I(r,n),this.buffer=r}get version(){return this.header.version===1?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get attributes(){return this.header.attributes}get variables(){return this.header.variables}attributeExists(t){return this.attributes.find(i=>i.name===t)!==void 0}getAttribute(t){let r=this.attributes.find(i=>i.name===t);return r?r.value:null}dataVariableExists(t){return this.header.variables.find(function(i){return i.name===t})!==void 0}getDataVariableAsString(t){let r=this.getDataVariable(t);return r?r.join(""):null}getDataVariable(t){let r;if(typeof t=="string"?r=this.header.variables.find(function(i){return i.name===t}):r=t,r===void 0){let i;throw typeof t=="string"?i=t:typeof t=="object"&&(i=JSON.stringify(t)),new Error(`NetCDF: variable not found: ${i}`)}return this.buffer.seek(r.offset),r.record?k(this.buffer,r,this.header.recordDimension):S(this.buffer,r)}toString(){let t=[];t.push("DIMENSIONS");for(let i of this.dimensions)t.push(` ${i.name.padEnd(30)} = size: ${i.size}`);t.push(""),t.push("GLOBAL ATTRIBUTES");for(let i of this.attributes)t.push(` ${i.name.padEnd(30)} = ${i.value}`);let r=JSON.parse(JSON.stringify(this.variables));t.push(""),t.push("VARIABLES:");for(let i of r){i.value=this.getDataVariable(i);let n=JSON.stringify(i.value);n.length>50&&(n=n.substring(0,50)),isNaN(i.value.length)||(n+=` (length: ${i.value.length})`),t.push(` ${i.name.padEnd(30)} = ${n}`)}return t.join(`
|
|
8
|
-
`)}};var et="4.4.0-alpha.
|
|
8
|
+
`)}};var et="4.4.0-alpha.14",rt={dataType:null,batchType:null,name:"NetCDF",id:"mvt",module:"mvt",version:et,extensions:["cdf","nc"],mimeTypes:["application/netcdf","application/x-netcdf"],category:"image",options:{netcdf:{loadVariables:!1}}},R={...rt,parse:async(e,t)=>it(e,t),binary:!0};function it(e,t){let r=new u(e),i={};if(t?.netcdf?.loadData)for(let n of r.variables)i[n.name]=r.getDataVariable(n);return{loaderData:r.header,data:i}}return j(p);})();
|
|
9
9
|
return __exports__;
|
|
10
10
|
});
|
package/dist/index.cjs
CHANGED
package/dist/netcdf-loader.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NetCDFReader } from "./netcdfjs/netcdf-reader.js";
|
|
2
2
|
// __VERSION__ is injected by babel-plugin-version-inline
|
|
3
3
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
4
|
-
const VERSION = typeof "4.4.0-alpha.
|
|
4
|
+
const VERSION = typeof "4.4.0-alpha.14" !== 'undefined' ? "4.4.0-alpha.14" : 'latest';
|
|
5
5
|
/**
|
|
6
6
|
* Worker loader for NETCDF
|
|
7
7
|
*/
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/netcdf",
|
|
3
3
|
"description": "Loader for NetCDF",
|
|
4
|
-
"version": "4.4.0-alpha.
|
|
4
|
+
"version": "4.4.0-alpha.14",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
"build-bundle-dev": "ocular-bundle ./bundle.ts --env=dev --output=dist/dist.dev.js"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@loaders.gl/loader-utils": "4.4.0-alpha.
|
|
42
|
+
"@loaders.gl/loader-utils": "4.4.0-alpha.14"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@loaders.gl/core": "4.4.0-alpha.1"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "139714d328ba86acff50738576a663917f76db80"
|
|
48
48
|
}
|