@loaders.gl/netcdf 3.4.0-alpha.2 → 3.4.0-alpha.3
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/es5/index.js.map +1 -1
- package/dist/es5/iobuffer/iobuffer.js +43 -130
- package/dist/es5/iobuffer/iobuffer.js.map +1 -1
- package/dist/es5/netcdf-loader.js +9 -15
- package/dist/es5/netcdf-loader.js.map +1 -1
- package/dist/es5/netcdfjs/netcdf-reader.js +11 -36
- package/dist/es5/netcdfjs/netcdf-reader.js.map +1 -1
- package/dist/es5/netcdfjs/read-data.js +0 -6
- package/dist/es5/netcdfjs/read-data.js.map +1 -1
- package/dist/es5/netcdfjs/read-header.js +0 -23
- package/dist/es5/netcdfjs/read-header.js.map +1 -1
- package/dist/es5/netcdfjs/read-type.js +0 -6
- package/dist/es5/netcdfjs/read-type.js.map +1 -1
- package/dist/esm/iobuffer/iobuffer.js +0 -44
- package/dist/esm/iobuffer/iobuffer.js.map +1 -1
- package/dist/esm/netcdf-loader.js +2 -7
- package/dist/esm/netcdf-loader.js.map +1 -1
- package/dist/esm/netcdfjs/netcdf-reader.js +0 -16
- package/dist/esm/netcdfjs/netcdf-reader.js.map +1 -1
- package/dist/esm/netcdfjs/read-data.js +0 -6
- package/dist/esm/netcdfjs/read-data.js.map +1 -1
- package/dist/esm/netcdfjs/read-header.js +0 -24
- package/dist/esm/netcdfjs/read-header.js.map +1 -1
- package/dist/esm/netcdfjs/read-type.js +0 -6
- package/dist/esm/netcdfjs/read-type.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
const DEFAULT_BYTE_LENGTH = 1024 * 8;
|
|
3
3
|
export class IOBuffer {
|
|
4
|
-
|
|
5
4
|
constructor() {
|
|
6
5
|
let data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : DEFAULT_BYTE_LENGTH;
|
|
7
6
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -48,56 +47,45 @@ export class IOBuffer {
|
|
|
48
47
|
this._mark = 0;
|
|
49
48
|
this._marks = [];
|
|
50
49
|
}
|
|
51
|
-
|
|
52
50
|
available() {
|
|
53
51
|
let byteLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
54
52
|
return this.offset + byteLength <= this.length;
|
|
55
53
|
}
|
|
56
|
-
|
|
57
54
|
isLittleEndian() {
|
|
58
55
|
return this.littleEndian;
|
|
59
56
|
}
|
|
60
|
-
|
|
61
57
|
setLittleEndian() {
|
|
62
58
|
this.littleEndian = true;
|
|
63
59
|
return this;
|
|
64
60
|
}
|
|
65
|
-
|
|
66
61
|
isBigEndian() {
|
|
67
62
|
return !this.littleEndian;
|
|
68
63
|
}
|
|
69
|
-
|
|
70
64
|
setBigEndian() {
|
|
71
65
|
this.littleEndian = false;
|
|
72
66
|
return this;
|
|
73
67
|
}
|
|
74
|
-
|
|
75
68
|
skip() {
|
|
76
69
|
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
77
70
|
this.offset += n;
|
|
78
71
|
return this;
|
|
79
72
|
}
|
|
80
|
-
|
|
81
73
|
seek(offset) {
|
|
82
74
|
this.offset = offset;
|
|
83
75
|
return this;
|
|
84
76
|
}
|
|
85
|
-
|
|
86
77
|
mark() {
|
|
87
78
|
this._mark = this.offset;
|
|
88
79
|
return this;
|
|
89
80
|
}
|
|
90
|
-
|
|
91
81
|
reset() {
|
|
92
82
|
this.offset = this._mark;
|
|
93
83
|
return this;
|
|
94
84
|
}
|
|
95
|
-
|
|
96
85
|
pushMark() {
|
|
97
86
|
this._marks.push(this.offset);
|
|
98
87
|
return this;
|
|
99
88
|
}
|
|
100
|
-
|
|
101
89
|
popMark() {
|
|
102
90
|
const offset = this._marks.pop();
|
|
103
91
|
if (offset === undefined) {
|
|
@@ -106,12 +94,10 @@ export class IOBuffer {
|
|
|
106
94
|
this.seek(offset);
|
|
107
95
|
return this;
|
|
108
96
|
}
|
|
109
|
-
|
|
110
97
|
rewind() {
|
|
111
98
|
this.offset = 0;
|
|
112
99
|
return this;
|
|
113
100
|
}
|
|
114
|
-
|
|
115
101
|
ensureAvailable() {
|
|
116
102
|
let byteLength = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
117
103
|
if (!this.available(byteLength)) {
|
|
@@ -125,23 +111,18 @@ export class IOBuffer {
|
|
|
125
111
|
}
|
|
126
112
|
return this;
|
|
127
113
|
}
|
|
128
|
-
|
|
129
114
|
readBoolean() {
|
|
130
115
|
return this.readUint8() !== 0;
|
|
131
116
|
}
|
|
132
|
-
|
|
133
117
|
readInt8() {
|
|
134
118
|
return this._data.getInt8(this.offset++);
|
|
135
119
|
}
|
|
136
|
-
|
|
137
120
|
readUint8() {
|
|
138
121
|
return this._data.getUint8(this.offset++);
|
|
139
122
|
}
|
|
140
|
-
|
|
141
123
|
readByte() {
|
|
142
124
|
return this.readUint8();
|
|
143
125
|
}
|
|
144
|
-
|
|
145
126
|
readBytes() {
|
|
146
127
|
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
147
128
|
const bytes = new Uint8Array(n);
|
|
@@ -150,47 +131,39 @@ export class IOBuffer {
|
|
|
150
131
|
}
|
|
151
132
|
return bytes;
|
|
152
133
|
}
|
|
153
|
-
|
|
154
134
|
readInt16() {
|
|
155
135
|
const value = this._data.getInt16(this.offset, this.littleEndian);
|
|
156
136
|
this.offset += 2;
|
|
157
137
|
return value;
|
|
158
138
|
}
|
|
159
|
-
|
|
160
139
|
readUint16() {
|
|
161
140
|
const value = this._data.getUint16(this.offset, this.littleEndian);
|
|
162
141
|
this.offset += 2;
|
|
163
142
|
return value;
|
|
164
143
|
}
|
|
165
|
-
|
|
166
144
|
readInt32() {
|
|
167
145
|
const value = this._data.getInt32(this.offset, this.littleEndian);
|
|
168
146
|
this.offset += 4;
|
|
169
147
|
return value;
|
|
170
148
|
}
|
|
171
|
-
|
|
172
149
|
readUint32() {
|
|
173
150
|
const value = this._data.getUint32(this.offset, this.littleEndian);
|
|
174
151
|
this.offset += 4;
|
|
175
152
|
return value;
|
|
176
153
|
}
|
|
177
|
-
|
|
178
154
|
readFloat32() {
|
|
179
155
|
const value = this._data.getFloat32(this.offset, this.littleEndian);
|
|
180
156
|
this.offset += 4;
|
|
181
157
|
return value;
|
|
182
158
|
}
|
|
183
|
-
|
|
184
159
|
readFloat64() {
|
|
185
160
|
const value = this._data.getFloat64(this.offset, this.littleEndian);
|
|
186
161
|
this.offset += 8;
|
|
187
162
|
return value;
|
|
188
163
|
}
|
|
189
|
-
|
|
190
164
|
readChar() {
|
|
191
165
|
return String.fromCharCode(this.readInt8());
|
|
192
166
|
}
|
|
193
|
-
|
|
194
167
|
readChars() {
|
|
195
168
|
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
196
169
|
let result = '';
|
|
@@ -199,35 +172,29 @@ export class IOBuffer {
|
|
|
199
172
|
}
|
|
200
173
|
return result;
|
|
201
174
|
}
|
|
202
|
-
|
|
203
175
|
readUtf8() {
|
|
204
176
|
let n = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
|
|
205
177
|
return this.textDecoder.decode(this.readBytes(n));
|
|
206
178
|
}
|
|
207
|
-
|
|
208
179
|
writeBoolean(value) {
|
|
209
180
|
this.writeUint8(value ? 0xff : 0x00);
|
|
210
181
|
return this;
|
|
211
182
|
}
|
|
212
|
-
|
|
213
183
|
writeInt8(value) {
|
|
214
184
|
this.ensureAvailable(1);
|
|
215
185
|
this._data.setInt8(this.offset++, value);
|
|
216
186
|
this._updateLastWrittenByte();
|
|
217
187
|
return this;
|
|
218
188
|
}
|
|
219
|
-
|
|
220
189
|
writeUint8(value) {
|
|
221
190
|
this.ensureAvailable(1);
|
|
222
191
|
this._data.setUint8(this.offset++, value);
|
|
223
192
|
this._updateLastWrittenByte();
|
|
224
193
|
return this;
|
|
225
194
|
}
|
|
226
|
-
|
|
227
195
|
writeByte(value) {
|
|
228
196
|
return this.writeUint8(value);
|
|
229
197
|
}
|
|
230
|
-
|
|
231
198
|
writeBytes(bytes) {
|
|
232
199
|
this.ensureAvailable(bytes.length);
|
|
233
200
|
for (let i = 0; i < bytes.length; i++) {
|
|
@@ -236,7 +203,6 @@ export class IOBuffer {
|
|
|
236
203
|
this._updateLastWrittenByte();
|
|
237
204
|
return this;
|
|
238
205
|
}
|
|
239
|
-
|
|
240
206
|
writeInt16(value) {
|
|
241
207
|
this.ensureAvailable(2);
|
|
242
208
|
this._data.setInt16(this.offset, value, this.littleEndian);
|
|
@@ -244,7 +210,6 @@ export class IOBuffer {
|
|
|
244
210
|
this._updateLastWrittenByte();
|
|
245
211
|
return this;
|
|
246
212
|
}
|
|
247
|
-
|
|
248
213
|
writeUint16(value) {
|
|
249
214
|
this.ensureAvailable(2);
|
|
250
215
|
this._data.setUint16(this.offset, value, this.littleEndian);
|
|
@@ -252,7 +217,6 @@ export class IOBuffer {
|
|
|
252
217
|
this._updateLastWrittenByte();
|
|
253
218
|
return this;
|
|
254
219
|
}
|
|
255
|
-
|
|
256
220
|
writeInt32(value) {
|
|
257
221
|
this.ensureAvailable(4);
|
|
258
222
|
this._data.setInt32(this.offset, value, this.littleEndian);
|
|
@@ -260,7 +224,6 @@ export class IOBuffer {
|
|
|
260
224
|
this._updateLastWrittenByte();
|
|
261
225
|
return this;
|
|
262
226
|
}
|
|
263
|
-
|
|
264
227
|
writeUint32(value) {
|
|
265
228
|
this.ensureAvailable(4);
|
|
266
229
|
this._data.setUint32(this.offset, value, this.littleEndian);
|
|
@@ -268,7 +231,6 @@ export class IOBuffer {
|
|
|
268
231
|
this._updateLastWrittenByte();
|
|
269
232
|
return this;
|
|
270
233
|
}
|
|
271
|
-
|
|
272
234
|
writeFloat32(value) {
|
|
273
235
|
this.ensureAvailable(4);
|
|
274
236
|
this._data.setFloat32(this.offset, value, this.littleEndian);
|
|
@@ -276,7 +238,6 @@ export class IOBuffer {
|
|
|
276
238
|
this._updateLastWrittenByte();
|
|
277
239
|
return this;
|
|
278
240
|
}
|
|
279
|
-
|
|
280
241
|
writeFloat64(value) {
|
|
281
242
|
this.ensureAvailable(8);
|
|
282
243
|
this._data.setFloat64(this.offset, value, this.littleEndian);
|
|
@@ -284,27 +245,22 @@ export class IOBuffer {
|
|
|
284
245
|
this._updateLastWrittenByte();
|
|
285
246
|
return this;
|
|
286
247
|
}
|
|
287
|
-
|
|
288
248
|
writeChar(str) {
|
|
289
249
|
return this.writeUint8(str.charCodeAt(0));
|
|
290
250
|
}
|
|
291
|
-
|
|
292
251
|
writeChars(str) {
|
|
293
252
|
for (let i = 0; i < str.length; i++) {
|
|
294
253
|
this.writeUint8(str.charCodeAt(i));
|
|
295
254
|
}
|
|
296
255
|
return this;
|
|
297
256
|
}
|
|
298
|
-
|
|
299
257
|
writeUtf8(str) {
|
|
300
258
|
const bytes = this.textEncoder.encode(str);
|
|
301
259
|
return this.writeBytes(bytes);
|
|
302
260
|
}
|
|
303
|
-
|
|
304
261
|
toArray() {
|
|
305
262
|
return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
|
|
306
263
|
}
|
|
307
|
-
|
|
308
264
|
_updateLastWrittenByte() {
|
|
309
265
|
if (this.offset > this.lastWrittenByte) {
|
|
310
266
|
this.lastWrittenByte = this.offset;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iobuffer.js","names":["DEFAULT_BYTE_LENGTH","IOBuffer","constructor","data","options","TextDecoder","TextEncoder","dataIsGiven","ArrayBuffer","lastWrittenByte","byteLength","offset","dvOffset","isView","buffer","byteOffset","length","littleEndian","_data","DataView","_mark","_marks","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","n","seek","mark","reset","pushMark","push","popMark","pop","undefined","Error","rewind","ensureAvailable","lengthNeeded","newLength","newArray","Uint8Array","set","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","i","readInt16","value","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","String","fromCharCode","readChars","result","readUtf8","textDecoder","decode","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","str","charCodeAt","writeChars","writeUtf8","textEncoder","encode","toArray"],"sources":["../../../src/iobuffer/iobuffer.ts"],"sourcesContent":["const DEFAULT_BYTE_LENGTH = 1024 * 8;\n\ntype InputData = number | ArrayBufferLike | ArrayBufferView | IOBuffer | Buffer;\n\ninterface IOBufferOptions {\n /**\n * Ignore the first n bytes of the ArrayBuffer.\n */\n offset?: number;\n}\n\nexport class IOBuffer {\n /**\n * Reference to the internal ArrayBuffer object.\n */\n public buffer: ArrayBufferLike;\n\n /**\n * Byte length of the internal ArrayBuffer.\n */\n public byteLength: number;\n\n /**\n * Byte offset of the internal ArrayBuffer.\n */\n public byteOffset: number;\n\n /**\n * Byte length of the internal ArrayBuffer.\n */\n public length: number;\n\n /**\n * The current offset of the buffer's pointer.\n */\n public offset: number;\n\n private lastWrittenByte: number;\n private littleEndian: boolean;\n\n private _data: DataView;\n private _mark: number;\n private _marks: number[];\n\n private textDecoder = new TextDecoder();\n private textEncoder = new TextEncoder();\n\n /**\n * @param data - The data to construct the IOBuffer with.\n * If data is a number, it will be the new buffer's length<br>\n * If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>\n * If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,\n * or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.\n * @param options\n */\n public constructor(data: InputData = DEFAULT_BYTE_LENGTH, options: IOBufferOptions = {}) {\n let dataIsGiven = false;\n if (typeof data === 'number') {\n data = new ArrayBuffer(data);\n } else {\n dataIsGiven = true;\n this.lastWrittenByte = data.byteLength;\n }\n\n const offset = options.offset ? options.offset >>> 0 : 0;\n const byteLength = data.byteLength - offset;\n let dvOffset = offset;\n if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset;\n }\n data = data.buffer;\n }\n if (dataIsGiven) {\n this.lastWrittenByte = byteLength;\n } else {\n this.lastWrittenByte = 0;\n }\n this.buffer = data;\n this.length = byteLength;\n this.byteLength = byteLength;\n this.byteOffset = dvOffset;\n this.offset = 0;\n this.littleEndian = true;\n this._data = new DataView(this.buffer, dvOffset, byteLength);\n this._mark = 0;\n this._marks = [];\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more\n * bytes after the offset.\n * @param byteLength - The needed memory in bytes.\n * @returns `true` if there is sufficient space and `false` otherwise.\n */\n public available(byteLength = 1): boolean {\n return this.offset + byteLength <= this.length;\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte\n * values.\n * @returns `true` if little-endian mode is used, `false` otherwise.\n */\n public isLittleEndian(): boolean {\n return this.littleEndian;\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values.\n */\n public setLittleEndian(): this {\n this.littleEndian = true;\n return this;\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values.\n * @returns `true` if big-endian mode is used, `false` otherwise.\n */\n public isBigEndian(): boolean {\n return !this.littleEndian;\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values.\n */\n public setBigEndian(): this {\n this.littleEndian = false;\n return this;\n }\n\n /**\n * Move the pointer n bytes forward.\n * @param n - Number of bytes to skip.\n */\n public skip(n = 1): this {\n this.offset += n;\n return this;\n }\n\n /**\n * Move the pointer to the given offset.\n * @param offset\n */\n public seek(offset: number): this {\n this.offset = offset;\n return this;\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n */\n public mark(): this {\n this._mark = this.offset;\n return this;\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark.\n * @see {@link IOBuffer#mark}\n */\n public reset(): this {\n this.offset = this._mark;\n return this;\n }\n\n /**\n * Push the current pointer offset to the mark stack.\n * @see {@link IOBuffer#popMark}\n */\n public pushMark(): this {\n this._marks.push(this.offset);\n return this;\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current\n * pointer offset to the popped value.\n * @see {@link IOBuffer#pushMark}\n */\n public popMark(): this {\n const offset = this._marks.pop();\n if (offset === undefined) {\n throw new Error('Mark stack empty');\n }\n this.seek(offset);\n return this;\n }\n\n /**\n * Move the pointer offset back to 0.\n */\n public rewind(): this {\n this.offset = 0;\n return this;\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at\n * the current pointer offset.\n * If the buffer's memory is insufficient, this method will create a new\n * buffer (a copy) with a length that is twice (byteLength + current offset).\n * @param byteLength\n */\n public ensureAvailable(byteLength = 1): this {\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength;\n const newLength = lengthNeeded * 2;\n const newArray = new Uint8Array(newLength);\n newArray.set(new Uint8Array(this.buffer));\n this.buffer = newArray.buffer;\n this.length = this.byteLength = newLength;\n this._data = new DataView(this.buffer);\n }\n return this;\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise.\n * Moves pointer forward by one byte.\n */\n public readBoolean(): boolean {\n return this.readUint8() !== 0;\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward by 1 byte.\n */\n public readInt8(): number {\n return this._data.getInt8(this.offset++);\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward by 1 byte.\n */\n public readUint8(): number {\n return this._data.getUint8(this.offset++);\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}.\n */\n public readByte(): number {\n return this.readUint8();\n }\n\n /**\n * Read `n` bytes and move pointer forward by `n` bytes.\n */\n public readBytes(n = 1): Uint8Array {\n const bytes = new Uint8Array(n);\n for (let i = 0; i < n; i++) {\n bytes[i] = this.readByte();\n }\n return bytes;\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward by 2 bytes.\n */\n public readInt16(): number {\n const value = this._data.getInt16(this.offset, this.littleEndian);\n this.offset += 2;\n return value;\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward by 2 bytes.\n */\n public readUint16(): number {\n const value = this._data.getUint16(this.offset, this.littleEndian);\n this.offset += 2;\n return value;\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward by 4 bytes.\n */\n public readInt32(): number {\n const value = this._data.getInt32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward by 4 bytes.\n */\n public readUint32(): number {\n const value = this._data.getUint32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward by 4 bytes.\n */\n public readFloat32(): number {\n const value = this._data.getFloat32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward by 8 bytes.\n */\n public readFloat64(): number {\n const value = this._data.getFloat64(this.offset, this.littleEndian);\n this.offset += 8;\n return value;\n }\n\n /**\n * Read a 1-byte ASCII character and move pointer forward by 1 byte.\n */\n public readChar(): string {\n return String.fromCharCode(this.readInt8());\n }\n\n /**\n * Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.\n */\n public readChars(n = 1): string {\n let result = '';\n for (let i = 0; i < n; i++) {\n result += this.readChar();\n }\n return result;\n }\n\n /**\n * Read the next `n` bytes, return a UTF-8 decoded string and move pointer\n * forward by `n` bytes.\n */\n public readUtf8(n = 1): string {\n return this.textDecoder.decode(this.readBytes(n));\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer\n * forward by 1 byte.\n */\n public writeBoolean(value: unknown): this {\n this.writeUint8(value ? 0xff : 0x00);\n return this;\n }\n\n /**\n * Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.\n */\n public writeInt8(value: number): this {\n this.ensureAvailable(1);\n this._data.setInt8(this.offset++, value);\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as an 8-bit unsigned integer and move pointer forward by 1\n * byte.\n */\n public writeUint8(value: number): this {\n this.ensureAvailable(1);\n this._data.setUint8(this.offset++, value);\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}.\n */\n public writeByte(value: number): this {\n return this.writeUint8(value);\n }\n\n /**\n * Write all elements of `bytes` as uint8 values and move pointer forward by\n * `bytes.length` bytes.\n */\n public writeBytes(bytes: ArrayLike<number>): this {\n this.ensureAvailable(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i]);\n }\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 16-bit signed integer and move pointer forward by 2\n * bytes.\n */\n public writeInt16(value: number): this {\n this.ensureAvailable(2);\n this._data.setInt16(this.offset, value, this.littleEndian);\n this.offset += 2;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 16-bit unsigned integer and move pointer forward by 2\n * bytes.\n */\n public writeUint16(value: number): this {\n this.ensureAvailable(2);\n this._data.setUint16(this.offset, value, this.littleEndian);\n this.offset += 2;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit signed integer and move pointer forward by 4\n * bytes.\n */\n public writeInt32(value: number): this {\n this.ensureAvailable(4);\n this._data.setInt32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit unsigned integer and move pointer forward by 4\n * bytes.\n */\n public writeUint32(value: number): this {\n this.ensureAvailable(4);\n this._data.setUint32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit floating number and move pointer forward by 4\n * bytes.\n */\n public writeFloat32(value: number): this {\n this.ensureAvailable(4);\n this._data.setFloat32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 64-bit floating number and move pointer forward by 8\n * bytes.\n */\n public writeFloat64(value: number): this {\n this.ensureAvailable(8);\n this._data.setFloat64(this.offset, value, this.littleEndian);\n this.offset += 8;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write the charCode of `str`'s first character as an 8-bit unsigned integer\n * and move pointer forward by 1 byte.\n */\n public writeChar(str: string): this {\n return this.writeUint8(str.charCodeAt(0));\n }\n\n /**\n * Write the charCodes of all `str`'s characters as 8-bit unsigned integers\n * and move pointer forward by `str.length` bytes.\n */\n public writeChars(str: string): this {\n for (let i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i));\n }\n return this;\n }\n\n /**\n * UTF-8 encode and write `str` to the current pointer offset and move pointer\n * forward according to the encoded length.\n */\n public writeUtf8(str: string): this {\n const bytes = this.textEncoder.encode(str);\n return this.writeBytes(bytes);\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n */\n public toArray(): Uint8Array {\n return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n private _updateLastWrittenByte(): void {\n if (this.offset > this.lastWrittenByte) {\n this.lastWrittenByte = this.offset;\n }\n }\n}\n"],"mappings":";AAAA,MAAMA,mBAAmB,GAAG,IAAI,GAAG,CAAC;AAWpC,OAAO,MAAMC,QAAQ,CAAC;;EA4CbC,WAAW,GAAuE;IAAA,IAAtEC,IAAe,uEAAGH,mBAAmB;IAAA,IAAEI,OAAwB,uEAAG,CAAC,CAAC;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA;IAAA,qCAXjE,IAAIC,WAAW,EAAE;IAAA,qCACjB,IAAIC,WAAW,EAAE;IAWrC,IAAIC,WAAW,GAAG,KAAK;IACvB,IAAI,OAAOJ,IAAI,KAAK,Q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B,KAAK,CAAC;EAC/B;;EAOOkD,OAAO,GAAe;IAC3B,OAAO,IAAI3D,UAAU,CAAC,IAAI,CAAC7B,MAAM,EAAE,IAAI,CAACC,UAAU,EAAE,IAAI,CAACN,eAAe,CAAC;EAC3E;;EAMQsE,sBAAsB,GAAS;IACrC,IAAI,IAAI,CAACpE,MAAM,GAAG,IAAI,CAACF,eAAe,EAAE;MACtC,IAAI,CAACA,eAAe,GAAG,IAAI,CAACE,MAAM;IACpC;EACF;AACF"}
|
|
1
|
+
{"version":3,"file":"iobuffer.js","names":["DEFAULT_BYTE_LENGTH","IOBuffer","constructor","data","arguments","length","undefined","options","_defineProperty","TextDecoder","TextEncoder","dataIsGiven","ArrayBuffer","lastWrittenByte","byteLength","offset","dvOffset","isView","buffer","byteOffset","littleEndian","_data","DataView","_mark","_marks","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","n","seek","mark","reset","pushMark","push","popMark","pop","Error","rewind","ensureAvailable","lengthNeeded","newLength","newArray","Uint8Array","set","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","i","readInt16","value","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","String","fromCharCode","readChars","result","readUtf8","textDecoder","decode","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","str","charCodeAt","writeChars","writeUtf8","textEncoder","encode","toArray"],"sources":["../../../src/iobuffer/iobuffer.ts"],"sourcesContent":["const DEFAULT_BYTE_LENGTH = 1024 * 8;\n\ntype InputData = number | ArrayBufferLike | ArrayBufferView | IOBuffer | Buffer;\n\ninterface IOBufferOptions {\n /**\n * Ignore the first n bytes of the ArrayBuffer.\n */\n offset?: number;\n}\n\nexport class IOBuffer {\n /**\n * Reference to the internal ArrayBuffer object.\n */\n public buffer: ArrayBufferLike;\n\n /**\n * Byte length of the internal ArrayBuffer.\n */\n public byteLength: number;\n\n /**\n * Byte offset of the internal ArrayBuffer.\n */\n public byteOffset: number;\n\n /**\n * Byte length of the internal ArrayBuffer.\n */\n public length: number;\n\n /**\n * The current offset of the buffer's pointer.\n */\n public offset: number;\n\n private lastWrittenByte: number;\n private littleEndian: boolean;\n\n private _data: DataView;\n private _mark: number;\n private _marks: number[];\n\n private textDecoder = new TextDecoder();\n private textEncoder = new TextEncoder();\n\n /**\n * @param data - The data to construct the IOBuffer with.\n * If data is a number, it will be the new buffer's length<br>\n * If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>\n * If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,\n * or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.\n * @param options\n */\n public constructor(data: InputData = DEFAULT_BYTE_LENGTH, options: IOBufferOptions = {}) {\n let dataIsGiven = false;\n if (typeof data === 'number') {\n data = new ArrayBuffer(data);\n } else {\n dataIsGiven = true;\n this.lastWrittenByte = data.byteLength;\n }\n\n const offset = options.offset ? options.offset >>> 0 : 0;\n const byteLength = data.byteLength - offset;\n let dvOffset = offset;\n if (ArrayBuffer.isView(data) || data instanceof IOBuffer) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset;\n }\n data = data.buffer;\n }\n if (dataIsGiven) {\n this.lastWrittenByte = byteLength;\n } else {\n this.lastWrittenByte = 0;\n }\n this.buffer = data;\n this.length = byteLength;\n this.byteLength = byteLength;\n this.byteOffset = dvOffset;\n this.offset = 0;\n this.littleEndian = true;\n this._data = new DataView(this.buffer, dvOffset, byteLength);\n this._mark = 0;\n this._marks = [];\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more\n * bytes after the offset.\n * @param byteLength - The needed memory in bytes.\n * @returns `true` if there is sufficient space and `false` otherwise.\n */\n public available(byteLength = 1): boolean {\n return this.offset + byteLength <= this.length;\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte\n * values.\n * @returns `true` if little-endian mode is used, `false` otherwise.\n */\n public isLittleEndian(): boolean {\n return this.littleEndian;\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values.\n */\n public setLittleEndian(): this {\n this.littleEndian = true;\n return this;\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values.\n * @returns `true` if big-endian mode is used, `false` otherwise.\n */\n public isBigEndian(): boolean {\n return !this.littleEndian;\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values.\n */\n public setBigEndian(): this {\n this.littleEndian = false;\n return this;\n }\n\n /**\n * Move the pointer n bytes forward.\n * @param n - Number of bytes to skip.\n */\n public skip(n = 1): this {\n this.offset += n;\n return this;\n }\n\n /**\n * Move the pointer to the given offset.\n * @param offset\n */\n public seek(offset: number): this {\n this.offset = offset;\n return this;\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n */\n public mark(): this {\n this._mark = this.offset;\n return this;\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark.\n * @see {@link IOBuffer#mark}\n */\n public reset(): this {\n this.offset = this._mark;\n return this;\n }\n\n /**\n * Push the current pointer offset to the mark stack.\n * @see {@link IOBuffer#popMark}\n */\n public pushMark(): this {\n this._marks.push(this.offset);\n return this;\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current\n * pointer offset to the popped value.\n * @see {@link IOBuffer#pushMark}\n */\n public popMark(): this {\n const offset = this._marks.pop();\n if (offset === undefined) {\n throw new Error('Mark stack empty');\n }\n this.seek(offset);\n return this;\n }\n\n /**\n * Move the pointer offset back to 0.\n */\n public rewind(): this {\n this.offset = 0;\n return this;\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at\n * the current pointer offset.\n * If the buffer's memory is insufficient, this method will create a new\n * buffer (a copy) with a length that is twice (byteLength + current offset).\n * @param byteLength\n */\n public ensureAvailable(byteLength = 1): this {\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength;\n const newLength = lengthNeeded * 2;\n const newArray = new Uint8Array(newLength);\n newArray.set(new Uint8Array(this.buffer));\n this.buffer = newArray.buffer;\n this.length = this.byteLength = newLength;\n this._data = new DataView(this.buffer);\n }\n return this;\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise.\n * Moves pointer forward by one byte.\n */\n public readBoolean(): boolean {\n return this.readUint8() !== 0;\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward by 1 byte.\n */\n public readInt8(): number {\n return this._data.getInt8(this.offset++);\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward by 1 byte.\n */\n public readUint8(): number {\n return this._data.getUint8(this.offset++);\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}.\n */\n public readByte(): number {\n return this.readUint8();\n }\n\n /**\n * Read `n` bytes and move pointer forward by `n` bytes.\n */\n public readBytes(n = 1): Uint8Array {\n const bytes = new Uint8Array(n);\n for (let i = 0; i < n; i++) {\n bytes[i] = this.readByte();\n }\n return bytes;\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward by 2 bytes.\n */\n public readInt16(): number {\n const value = this._data.getInt16(this.offset, this.littleEndian);\n this.offset += 2;\n return value;\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward by 2 bytes.\n */\n public readUint16(): number {\n const value = this._data.getUint16(this.offset, this.littleEndian);\n this.offset += 2;\n return value;\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward by 4 bytes.\n */\n public readInt32(): number {\n const value = this._data.getInt32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward by 4 bytes.\n */\n public readUint32(): number {\n const value = this._data.getUint32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward by 4 bytes.\n */\n public readFloat32(): number {\n const value = this._data.getFloat32(this.offset, this.littleEndian);\n this.offset += 4;\n return value;\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward by 8 bytes.\n */\n public readFloat64(): number {\n const value = this._data.getFloat64(this.offset, this.littleEndian);\n this.offset += 8;\n return value;\n }\n\n /**\n * Read a 1-byte ASCII character and move pointer forward by 1 byte.\n */\n public readChar(): string {\n return String.fromCharCode(this.readInt8());\n }\n\n /**\n * Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.\n */\n public readChars(n = 1): string {\n let result = '';\n for (let i = 0; i < n; i++) {\n result += this.readChar();\n }\n return result;\n }\n\n /**\n * Read the next `n` bytes, return a UTF-8 decoded string and move pointer\n * forward by `n` bytes.\n */\n public readUtf8(n = 1): string {\n return this.textDecoder.decode(this.readBytes(n));\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer\n * forward by 1 byte.\n */\n public writeBoolean(value: unknown): this {\n this.writeUint8(value ? 0xff : 0x00);\n return this;\n }\n\n /**\n * Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.\n */\n public writeInt8(value: number): this {\n this.ensureAvailable(1);\n this._data.setInt8(this.offset++, value);\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as an 8-bit unsigned integer and move pointer forward by 1\n * byte.\n */\n public writeUint8(value: number): this {\n this.ensureAvailable(1);\n this._data.setUint8(this.offset++, value);\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}.\n */\n public writeByte(value: number): this {\n return this.writeUint8(value);\n }\n\n /**\n * Write all elements of `bytes` as uint8 values and move pointer forward by\n * `bytes.length` bytes.\n */\n public writeBytes(bytes: ArrayLike<number>): this {\n this.ensureAvailable(bytes.length);\n for (let i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i]);\n }\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 16-bit signed integer and move pointer forward by 2\n * bytes.\n */\n public writeInt16(value: number): this {\n this.ensureAvailable(2);\n this._data.setInt16(this.offset, value, this.littleEndian);\n this.offset += 2;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 16-bit unsigned integer and move pointer forward by 2\n * bytes.\n */\n public writeUint16(value: number): this {\n this.ensureAvailable(2);\n this._data.setUint16(this.offset, value, this.littleEndian);\n this.offset += 2;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit signed integer and move pointer forward by 4\n * bytes.\n */\n public writeInt32(value: number): this {\n this.ensureAvailable(4);\n this._data.setInt32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit unsigned integer and move pointer forward by 4\n * bytes.\n */\n public writeUint32(value: number): this {\n this.ensureAvailable(4);\n this._data.setUint32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 32-bit floating number and move pointer forward by 4\n * bytes.\n */\n public writeFloat32(value: number): this {\n this.ensureAvailable(4);\n this._data.setFloat32(this.offset, value, this.littleEndian);\n this.offset += 4;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write `value` as a 64-bit floating number and move pointer forward by 8\n * bytes.\n */\n public writeFloat64(value: number): this {\n this.ensureAvailable(8);\n this._data.setFloat64(this.offset, value, this.littleEndian);\n this.offset += 8;\n this._updateLastWrittenByte();\n return this;\n }\n\n /**\n * Write the charCode of `str`'s first character as an 8-bit unsigned integer\n * and move pointer forward by 1 byte.\n */\n public writeChar(str: string): this {\n return this.writeUint8(str.charCodeAt(0));\n }\n\n /**\n * Write the charCodes of all `str`'s characters as 8-bit unsigned integers\n * and move pointer forward by `str.length` bytes.\n */\n public writeChars(str: string): this {\n for (let i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i));\n }\n return this;\n }\n\n /**\n * UTF-8 encode and write `str` to the current pointer offset and move pointer\n * forward according to the encoded length.\n */\n public writeUtf8(str: string): this {\n const bytes = this.textEncoder.encode(str);\n return this.writeBytes(bytes);\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n */\n public toArray(): Uint8Array {\n return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n private _updateLastWrittenByte(): void {\n if (this.offset > this.lastWrittenByte) {\n this.lastWrittenByte = this.offset;\n }\n }\n}\n"],"mappings":";AAAA,MAAMA,mBAAmB,GAAG,IAAI,GAAG,CAAC;AAWpC,OAAO,MAAMC,QAAQ,CAAC;EA4CbC,WAAWA,CAAA,EAAuE;IAAA,IAAtEC,IAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGJ,mBAAmB;IAAA,IAAEO,OAAwB,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;IAAAI,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA;IAAAA,eAAA,sBAXjE,IAAIC,WAAW,EAAE;IAAAD,eAAA,sBACjB,IAAIE,WAAW,EAAE;IAWrC,IAAIC,WAAW,GAAG,KAAK;IACvB,IAAI,OAAOR,IAAI,KAAK,QAAQ,EAAE;MAC5BA,IAAI,GAAG,IAAIS,WAAW,CAACT,IAAI,CAAC;IAC9B,CAAC,MAAM;MACLQ,WAAW,GAAG,IAAI;MAClB,IAAI,CAACE,eAAe,GAAGV,IAAI,CAACW,UAAU;IACxC;IAEA,MAAMC,MAAM,GAAGR,OAAO,CAACQ,MAAM,GAAGR,OAAO,CAACQ,MAAM,KAAK,CAAC,GAAG,CAAC;IACxD,MAAMD,UAAU,GAAGX,IAAI,CAACW,UAAU,GAAGC,MAAM;IAC3C,IAAIC,QAAQ,GAAGD,M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CAAC,CAAC,CAAC;IACpC;IACA,OAAO,IAAI;EACb;EAMO8C,SAASA,CAACH,GAAW,EAAQ;IAClC,MAAM5C,KAAK,GAAG,IAAI,CAACgD,WAAW,CAACC,MAAM,CAACL,GAAG,CAAC;IAC1C,OAAO,IAAI,CAACd,UAAU,CAAC9B,KAAK,CAAC;EAC/B;EAOOkD,OAAOA,CAAA,EAAe;IAC3B,OAAO,IAAI3D,UAAU,CAAC,IAAI,CAAC3B,MAAM,EAAE,IAAI,CAACC,UAAU,EAAE,IAAI,CAACN,eAAe,CAAC;EAC3E;EAMQoE,sBAAsBA,CAAA,EAAS;IACrC,IAAI,IAAI,CAAClE,MAAM,GAAG,IAAI,CAACF,eAAe,EAAE;MACtC,IAAI,CAACA,eAAe,GAAG,IAAI,CAACE,MAAM;IACpC;EACF;AACF"}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { NetCDFReader } from './netcdfjs/netcdf-reader';
|
|
2
|
-
|
|
3
|
-
const VERSION = typeof "3.4.0-alpha.2" !== 'undefined' ? "3.4.0-alpha.2" : 'latest';
|
|
2
|
+
const VERSION = typeof "3.4.0-alpha.3" !== 'undefined' ? "3.4.0-alpha.3" : 'latest';
|
|
4
3
|
export const NetCDFWorkerLoader = {
|
|
5
4
|
name: 'NetCDF',
|
|
6
5
|
id: 'mvt',
|
|
7
6
|
module: 'mvt',
|
|
8
7
|
version: VERSION,
|
|
9
8
|
extensions: ['cdf', 'nc'],
|
|
10
|
-
mimeTypes: ['application/netcdf', 'application/x-netcdf'
|
|
11
|
-
],
|
|
12
|
-
|
|
9
|
+
mimeTypes: ['application/netcdf', 'application/x-netcdf'],
|
|
13
10
|
category: 'image',
|
|
14
11
|
options: {
|
|
15
12
|
netcdf: {
|
|
@@ -17,7 +14,6 @@ export const NetCDFWorkerLoader = {
|
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
16
|
};
|
|
20
|
-
|
|
21
17
|
export const NetCDFLoader = {
|
|
22
18
|
...NetCDFWorkerLoader,
|
|
23
19
|
parse: async (arrayBuffer, options) => parseNetCDF(arrayBuffer, options),
|
|
@@ -37,7 +33,6 @@ function parseNetCDF(arrayBuffer, options) {
|
|
|
37
33
|
data: variables
|
|
38
34
|
};
|
|
39
35
|
}
|
|
40
|
-
|
|
41
36
|
export const _typecheckNetCDFWorkerLoader = NetCDFWorkerLoader;
|
|
42
37
|
export const _typecheckNetCDFLoader = NetCDFLoader;
|
|
43
38
|
//# sourceMappingURL=netcdf-loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netcdf-loader.js","names":["NetCDFReader","VERSION","NetCDFWorkerLoader","name","id","module","version","extensions","mimeTypes","category","options","netcdf","loadVariables","NetCDFLoader","parse","arrayBuffer","parseNetCDF","binary","reader","variables","loadData","variable","getDataVariable","loaderData","header","data","_typecheckNetCDFWorkerLoader","_typecheckNetCDFLoader"],"sources":["../../src/netcdf-loader.ts"],"sourcesContent":["import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {NetCDFHeader} from './netcdfjs/netcdf-types';\nimport {NetCDFReader} from './netcdfjs/netcdf-reader';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type NetCDF = {\n loaderData: NetCDFHeader;\n data: {[variableName: string]: any[][]};\n};\n\nexport type NetCDFLoaderOptions = LoaderOptions & {\n netcdf?: {\n loadData?: boolean;\n };\n};\n\n/**\n * Worker loader for NETCDF\n */\nexport const NetCDFWorkerLoader = {\n name: 'NetCDF',\n id: 'mvt',\n module: 'mvt',\n version: VERSION,\n extensions: ['cdf', 'nc'],\n mimeTypes: [\n 'application/netcdf',\n 'application/x-netcdf'\n // 'application/octet-stream'\n ],\n category: 'image',\n options: {\n netcdf: {\n loadVariables: false\n }\n }\n};\n\n/**\n * Loader for the NetCDF format\n */\nexport const NetCDFLoader = {\n ...NetCDFWorkerLoader,\n parse: async (arrayBuffer, options) => parseNetCDF(arrayBuffer, options),\n binary: true\n};\n\nfunction parseNetCDF(arrayBuffer: ArrayBuffer, options?: NetCDFLoaderOptions): NetCDF {\n const reader = new NetCDFReader(arrayBuffer);\n const variables: {[variableName: string]: any[][]} = {};\n if (options?.netcdf?.loadData) {\n for (const variable of reader.variables) {\n variables[variable.name] = reader.getDataVariable(variable);\n }\n }\n return {\n loaderData: reader.header,\n data: variables\n };\n}\n\n// Type tests\nexport const _typecheckNetCDFWorkerLoader: Loader = NetCDFWorkerLoader;\nexport const _typecheckNetCDFLoader: LoaderWithParser = NetCDFLoader;\n"],"mappings":"AAEA,SAAQA,YAAY,QAAO,0BAA0B
|
|
1
|
+
{"version":3,"file":"netcdf-loader.js","names":["NetCDFReader","VERSION","NetCDFWorkerLoader","name","id","module","version","extensions","mimeTypes","category","options","netcdf","loadVariables","NetCDFLoader","parse","arrayBuffer","parseNetCDF","binary","_options$netcdf","reader","variables","loadData","variable","getDataVariable","loaderData","header","data","_typecheckNetCDFWorkerLoader","_typecheckNetCDFLoader"],"sources":["../../src/netcdf-loader.ts"],"sourcesContent":["import type {Loader, LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport type {NetCDFHeader} from './netcdfjs/netcdf-types';\nimport {NetCDFReader} from './netcdfjs/netcdf-reader';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type NetCDF = {\n loaderData: NetCDFHeader;\n data: {[variableName: string]: any[][]};\n};\n\nexport type NetCDFLoaderOptions = LoaderOptions & {\n netcdf?: {\n loadData?: boolean;\n };\n};\n\n/**\n * Worker loader for NETCDF\n */\nexport const NetCDFWorkerLoader = {\n name: 'NetCDF',\n id: 'mvt',\n module: 'mvt',\n version: VERSION,\n extensions: ['cdf', 'nc'],\n mimeTypes: [\n 'application/netcdf',\n 'application/x-netcdf'\n // 'application/octet-stream'\n ],\n category: 'image',\n options: {\n netcdf: {\n loadVariables: false\n }\n }\n};\n\n/**\n * Loader for the NetCDF format\n */\nexport const NetCDFLoader = {\n ...NetCDFWorkerLoader,\n parse: async (arrayBuffer, options) => parseNetCDF(arrayBuffer, options),\n binary: true\n};\n\nfunction parseNetCDF(arrayBuffer: ArrayBuffer, options?: NetCDFLoaderOptions): NetCDF {\n const reader = new NetCDFReader(arrayBuffer);\n const variables: {[variableName: string]: any[][]} = {};\n if (options?.netcdf?.loadData) {\n for (const variable of reader.variables) {\n variables[variable.name] = reader.getDataVariable(variable);\n }\n }\n return {\n loaderData: reader.header,\n data: variables\n };\n}\n\n// Type tests\nexport const _typecheckNetCDFWorkerLoader: Loader = NetCDFWorkerLoader;\nexport const _typecheckNetCDFLoader: LoaderWithParser = NetCDFLoader;\n"],"mappings":"AAEA,SAAQA,YAAY,QAAO,0BAA0B;AAIrD,MAAMC,OAAO,GAAG,sBAAkB,KAAK,WAAW,qBAAiB,QAAQ;AAgB3E,OAAO,MAAMC,kBAAkB,GAAG;EAChCC,IAAI,EAAE,QAAQ;EACdC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,KAAK;EACbC,OAAO,EAAEL,OAAO;EAChBM,UAAU,EAAE,CAAC,KAAK,EAAE,IAAI,CAAC;EACzBC,SAAS,EAAE,CACT,oBAAoB,EACpB,sBAAsB,CAEvB;EACDC,QAAQ,EAAE,OAAO;EACjBC,OAAO,EAAE;IACPC,MAAM,EAAE;MACNC,aAAa,EAAE;IACjB;EACF;AACF,CAAC;AAKD,OAAO,MAAMC,YAAY,GAAG;EAC1B,GAAGX,kBAAkB;EACrBY,KAAK,EAAE,MAAAA,CAAOC,WAAW,EAAEL,OAAO,KAAKM,WAAW,CAACD,WAAW,EAAEL,OAAO,CAAC;EACxEO,MAAM,EAAE;AACV,CAAC;AAED,SAASD,WAAWA,CAACD,WAAwB,EAAEL,OAA6B,EAAU;EAAA,IAAAQ,eAAA;EACpF,MAAMC,MAAM,GAAG,IAAInB,YAAY,CAACe,WAAW,CAAC;EAC5C,MAAMK,SAA4C,GAAG,CAAC,CAAC;EACvD,IAAIV,OAAO,aAAPA,OAAO,gBAAAQ,eAAA,GAAPR,OAAO,CAAEC,MAAM,cAAAO,eAAA,eAAfA,eAAA,CAAiBG,QAAQ,EAAE;IAC7B,KAAK,MAAMC,QAAQ,IAAIH,MAAM,CAACC,SAAS,EAAE;MACvCA,SAAS,CAACE,QAAQ,CAACnB,IAAI,CAAC,GAAGgB,MAAM,CAACI,eAAe,CAACD,QAAQ,CAAC;IAC7D;EACF;EACA,OAAO;IACLE,UAAU,EAAEL,MAAM,CAACM,MAAM;IACzBC,IAAI,EAAEN;EACR,CAAC;AACH;AAGA,OAAO,MAAMO,4BAAoC,GAAGzB,kBAAkB;AACtE,OAAO,MAAM0B,sBAAwC,GAAGf,YAAY"}
|
|
@@ -2,75 +2,61 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
2
2
|
import { IOBuffer } from '../iobuffer/iobuffer';
|
|
3
3
|
import { readNetCDFHeader } from './read-header';
|
|
4
4
|
import { readRecord, readNonRecord } from './read-data';
|
|
5
|
-
|
|
6
5
|
export class NetCDFReader {
|
|
7
6
|
constructor(data) {
|
|
8
7
|
_defineProperty(this, "header", void 0);
|
|
9
8
|
_defineProperty(this, "buffer", void 0);
|
|
10
9
|
const buffer = new IOBuffer(data);
|
|
11
10
|
buffer.setBigEndian();
|
|
12
|
-
|
|
13
11
|
const magic = buffer.readChars(3);
|
|
14
12
|
if (magic !== 'CDF') {
|
|
15
13
|
throw new Error("NetCDF: file should start with 'CDF', found ".concat(magic));
|
|
16
14
|
}
|
|
17
|
-
|
|
18
15
|
const version = buffer.readByte();
|
|
19
16
|
if (version > 2) {
|
|
20
17
|
throw new Error("NetCDF: unsupported version ".concat(version));
|
|
21
18
|
}
|
|
22
|
-
|
|
23
19
|
this.header = readNetCDFHeader(buffer, version);
|
|
24
20
|
this.buffer = buffer;
|
|
25
21
|
}
|
|
26
|
-
|
|
27
22
|
get version() {
|
|
28
23
|
if (this.header.version === 1) {
|
|
29
24
|
return 'classic format';
|
|
30
25
|
}
|
|
31
26
|
return '64-bit offset format';
|
|
32
27
|
}
|
|
33
|
-
|
|
34
28
|
get recordDimension() {
|
|
35
29
|
return this.header.recordDimension;
|
|
36
30
|
}
|
|
37
|
-
|
|
38
31
|
get dimensions() {
|
|
39
32
|
return this.header.dimensions;
|
|
40
33
|
}
|
|
41
|
-
|
|
42
34
|
get attributes() {
|
|
43
35
|
return this.header.attributes;
|
|
44
36
|
}
|
|
45
|
-
|
|
46
37
|
get variables() {
|
|
47
38
|
return this.header.variables;
|
|
48
39
|
}
|
|
49
|
-
|
|
50
40
|
attributeExists(attributeName) {
|
|
51
41
|
const attribute = this.attributes.find(val => val.name === attributeName);
|
|
52
42
|
return attribute !== undefined;
|
|
53
43
|
}
|
|
54
|
-
|
|
55
44
|
getAttribute(attributeName) {
|
|
56
45
|
const attribute = this.attributes.find(val => val.name === attributeName);
|
|
57
46
|
if (attribute) return attribute.value;
|
|
58
47
|
return null;
|
|
59
48
|
}
|
|
60
|
-
|
|
61
49
|
dataVariableExists(variableName) {
|
|
62
50
|
const variable = this.header.variables.find(function (val) {
|
|
63
51
|
return val.name === variableName;
|
|
64
52
|
});
|
|
65
53
|
return variable !== undefined;
|
|
66
54
|
}
|
|
67
|
-
|
|
68
55
|
getDataVariableAsString(variableName) {
|
|
69
56
|
const variable = this.getDataVariable(variableName);
|
|
70
57
|
if (variable) return variable.join('');
|
|
71
58
|
return null;
|
|
72
59
|
}
|
|
73
|
-
|
|
74
60
|
getDataVariable(variableName) {
|
|
75
61
|
let variable;
|
|
76
62
|
if (typeof variableName === 'string') {
|
|
@@ -80,11 +66,9 @@ export class NetCDFReader {
|
|
|
80
66
|
} else {
|
|
81
67
|
variable = variableName;
|
|
82
68
|
}
|
|
83
|
-
|
|
84
69
|
if (variable === undefined) {
|
|
85
70
|
throw new Error("NetCDF: variable not found: ".concat(variableName));
|
|
86
71
|
}
|
|
87
|
-
|
|
88
72
|
this.buffer.seek(variable.offset);
|
|
89
73
|
if (variable.record) {
|
|
90
74
|
return readRecord(this.buffer, variable, this.header.recordDimension);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netcdf-reader.js","names":["IOBuffer","readNetCDFHeader","readRecord","readNonRecord","NetCDFReader","constructor","data","buffer","setBigEndian","magic","readChars","Error","version","readByte","header","recordDimension","dimensions","attributes","variables","attributeExists","attributeName","attribute","find","val","name","undefined","getAttribute","value","dataVariableExists","variableName","variable","getDataVariableAsString","getDataVariable","join","seek","offset","record","toString","result","push","dimension","padEnd","size","JSON","parse","stringify","length","substring","isNaN"],"sources":["../../../src/netcdfjs/netcdf-reader.ts"],"sourcesContent":["import {IOBuffer} from '../iobuffer/iobuffer';\nimport type {\n NetCDFHeader,\n NetCDFDimension,\n NetCDFRecordDimension,\n NetCDFAttribute,\n NetCDFVariable\n} from './netcdf-types';\nimport {readNetCDFHeader} from './read-header';\nimport {readRecord, readNonRecord} from './read-data';\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data\n * @constructor\n */\nexport class NetCDFReader {\n public header: NetCDFHeader;\n public buffer: IOBuffer;\n\n constructor(data) {\n const buffer = new IOBuffer(data);\n buffer.setBigEndian();\n\n // Validate that it's a NetCDF file\n const magic = buffer.readChars(3);\n if (magic !== 'CDF') {\n throw new Error(`NetCDF: file should start with 'CDF', found ${magic}`);\n }\n\n // Check the NetCDF format\n const version = buffer.readByte();\n if (version > 2) {\n throw new Error(`NetCDF: unsupported version ${version}`);\n }\n\n // Read the header\n this.header = readNetCDFHeader(buffer, version);\n this.buffer = buffer;\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version() {\n if (this.header.version === 1) {\n return 'classic format';\n }\n return '64-bit offset format';\n }\n\n /**\n * Get metadata for the record dimension\n */\n get recordDimension(): NetCDFRecordDimension {\n return this.header.recordDimension;\n }\n\n /**\n * Get list of dimensions (each with `name` and `size`)\n */\n get dimensions(): NetCDFDimension[] {\n return this.header.dimensions;\n }\n\n /**\n * Get list of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get attributes(): NetCDFAttribute[] {\n return this.header.attributes;\n }\n\n /**\n * Get list of variables\n */\n get variables(): NetCDFVariable[] {\n return this.header.variables;\n }\n\n /**\n * Check if an attribute exists\n * @param attributeName - Name of the attribute to find\n * @return\n */\n attributeExists(attributeName: string): boolean {\n const attribute = this.attributes.find((val) => val.name === attributeName);\n return attribute !== undefined;\n }\n\n /**\n * Returns the value of an attribute\n * @param attributeName\n * @return Value of the attributeName or null\n */\n getAttribute(attributeName: string): string | null {\n const attribute = this.attributes.find((val) => val.name === attributeName);\n if (attribute) return attribute.value;\n return null;\n }\n\n /**\n * Check if a dataVariable exists\n * @param variableName - Name of the variable to find\n * @return\n */\n dataVariableExists(variableName: string): boolean {\n const variable = this.header.variables.find(function (val) {\n return val.name === variableName;\n });\n return variable !== undefined;\n }\n\n /**\n * Returns the value of a variable as a string\n * @param variableName\n * @return Value of the variable as a string or null\n */\n getDataVariableAsString(variableName: string): string | null {\n const variable = this.getDataVariable(variableName);\n if (variable) return variable.join('');\n return null;\n }\n\n /**\n * Retrieves the data for a given variable\n * @param variableName - Name of the variable to search or variable object\n * @return List with the variable values\n */\n getDataVariable(variableName: string | object): any[] {\n let variable;\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables.find(function (val) {\n return val.name === variableName;\n });\n } else {\n variable = variableName;\n }\n\n // throws if variable not found\n if (variable === undefined) {\n throw new Error(`NetCDF: variable not found: ${variableName}`);\n }\n\n // go to the offset position\n this.buffer.seek(variable.offset);\n\n if (variable.record) {\n // record variable case\n return readRecord(this.buffer, variable, this.header.recordDimension);\n }\n // non-record variable case\n return readNonRecord(this.buffer, variable);\n }\n\n toString(): string {\n const result: string[] = [];\n\n result.push('DIMENSIONS');\n for (const dimension of this.dimensions) {\n result.push(` ${dimension.name.padEnd(30)} = size: ${dimension.size}`);\n }\n\n result.push('');\n result.push('GLOBAL ATTRIBUTES');\n for (const attribute of this.attributes) {\n result.push(` ${attribute.name.padEnd(30)} = ${attribute.value}`);\n }\n\n const variables = JSON.parse(JSON.stringify(this.variables));\n result.push('');\n result.push('VARIABLES:');\n for (const variable of variables) {\n variable.value = this.getDataVariable(variable);\n let stringify = JSON.stringify(variable.value);\n if (stringify.length > 50) stringify = stringify.substring(0, 50);\n if (!isNaN(variable.value.length)) {\n stringify += ` (length: ${variable.value.length})`;\n }\n result.push(` ${variable.name.padEnd(30)} = ${stringify}`);\n }\n return result.join('\\n');\n }\n}\n"],"mappings":";AAAA,SAAQA,QAAQ,QAAO,sBAAsB;AAQ7C,SAAQC,gBAAgB,QAAO,eAAe;AAC9C,SAAQC,UAAU,EAAEC,aAAa,QAAO,aAAa
|
|
1
|
+
{"version":3,"file":"netcdf-reader.js","names":["IOBuffer","readNetCDFHeader","readRecord","readNonRecord","NetCDFReader","constructor","data","_defineProperty","buffer","setBigEndian","magic","readChars","Error","concat","version","readByte","header","recordDimension","dimensions","attributes","variables","attributeExists","attributeName","attribute","find","val","name","undefined","getAttribute","value","dataVariableExists","variableName","variable","getDataVariableAsString","getDataVariable","join","seek","offset","record","toString","result","push","dimension","padEnd","size","JSON","parse","stringify","length","substring","isNaN"],"sources":["../../../src/netcdfjs/netcdf-reader.ts"],"sourcesContent":["import {IOBuffer} from '../iobuffer/iobuffer';\nimport type {\n NetCDFHeader,\n NetCDFDimension,\n NetCDFRecordDimension,\n NetCDFAttribute,\n NetCDFVariable\n} from './netcdf-types';\nimport {readNetCDFHeader} from './read-header';\nimport {readRecord, readNonRecord} from './read-data';\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array (including Node.js' Buffer from v4) with the data\n * @constructor\n */\nexport class NetCDFReader {\n public header: NetCDFHeader;\n public buffer: IOBuffer;\n\n constructor(data) {\n const buffer = new IOBuffer(data);\n buffer.setBigEndian();\n\n // Validate that it's a NetCDF file\n const magic = buffer.readChars(3);\n if (magic !== 'CDF') {\n throw new Error(`NetCDF: file should start with 'CDF', found ${magic}`);\n }\n\n // Check the NetCDF format\n const version = buffer.readByte();\n if (version > 2) {\n throw new Error(`NetCDF: unsupported version ${version}`);\n }\n\n // Read the header\n this.header = readNetCDFHeader(buffer, version);\n this.buffer = buffer;\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version() {\n if (this.header.version === 1) {\n return 'classic format';\n }\n return '64-bit offset format';\n }\n\n /**\n * Get metadata for the record dimension\n */\n get recordDimension(): NetCDFRecordDimension {\n return this.header.recordDimension;\n }\n\n /**\n * Get list of dimensions (each with `name` and `size`)\n */\n get dimensions(): NetCDFDimension[] {\n return this.header.dimensions;\n }\n\n /**\n * Get list of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get attributes(): NetCDFAttribute[] {\n return this.header.attributes;\n }\n\n /**\n * Get list of variables\n */\n get variables(): NetCDFVariable[] {\n return this.header.variables;\n }\n\n /**\n * Check if an attribute exists\n * @param attributeName - Name of the attribute to find\n * @return\n */\n attributeExists(attributeName: string): boolean {\n const attribute = this.attributes.find((val) => val.name === attributeName);\n return attribute !== undefined;\n }\n\n /**\n * Returns the value of an attribute\n * @param attributeName\n * @return Value of the attributeName or null\n */\n getAttribute(attributeName: string): string | null {\n const attribute = this.attributes.find((val) => val.name === attributeName);\n if (attribute) return attribute.value;\n return null;\n }\n\n /**\n * Check if a dataVariable exists\n * @param variableName - Name of the variable to find\n * @return\n */\n dataVariableExists(variableName: string): boolean {\n const variable = this.header.variables.find(function (val) {\n return val.name === variableName;\n });\n return variable !== undefined;\n }\n\n /**\n * Returns the value of a variable as a string\n * @param variableName\n * @return Value of the variable as a string or null\n */\n getDataVariableAsString(variableName: string): string | null {\n const variable = this.getDataVariable(variableName);\n if (variable) return variable.join('');\n return null;\n }\n\n /**\n * Retrieves the data for a given variable\n * @param variableName - Name of the variable to search or variable object\n * @return List with the variable values\n */\n getDataVariable(variableName: string | object): any[] {\n let variable;\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables.find(function (val) {\n return val.name === variableName;\n });\n } else {\n variable = variableName;\n }\n\n // throws if variable not found\n if (variable === undefined) {\n throw new Error(`NetCDF: variable not found: ${variableName}`);\n }\n\n // go to the offset position\n this.buffer.seek(variable.offset);\n\n if (variable.record) {\n // record variable case\n return readRecord(this.buffer, variable, this.header.recordDimension);\n }\n // non-record variable case\n return readNonRecord(this.buffer, variable);\n }\n\n toString(): string {\n const result: string[] = [];\n\n result.push('DIMENSIONS');\n for (const dimension of this.dimensions) {\n result.push(` ${dimension.name.padEnd(30)} = size: ${dimension.size}`);\n }\n\n result.push('');\n result.push('GLOBAL ATTRIBUTES');\n for (const attribute of this.attributes) {\n result.push(` ${attribute.name.padEnd(30)} = ${attribute.value}`);\n }\n\n const variables = JSON.parse(JSON.stringify(this.variables));\n result.push('');\n result.push('VARIABLES:');\n for (const variable of variables) {\n variable.value = this.getDataVariable(variable);\n let stringify = JSON.stringify(variable.value);\n if (stringify.length > 50) stringify = stringify.substring(0, 50);\n if (!isNaN(variable.value.length)) {\n stringify += ` (length: ${variable.value.length})`;\n }\n result.push(` ${variable.name.padEnd(30)} = ${stringify}`);\n }\n return result.join('\\n');\n }\n}\n"],"mappings":";AAAA,SAAQA,QAAQ,QAAO,sBAAsB;AAQ7C,SAAQC,gBAAgB,QAAO,eAAe;AAC9C,SAAQC,UAAU,EAAEC,aAAa,QAAO,aAAa;AAQrD,OAAO,MAAMC,YAAY,CAAC;EAIxBC,WAAWA,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EAAE,CAAC;MACjE,IAAI,CAACC,KAAK,CAAClB,QAAQ,CAACH,KAAK,CAACmB,MAAM,CAAC,EAAE;QACjCD,SAAS,iBAAAlC,MAAA,CAAiBmB,QAAQ,CAACH,KAAK,CAACmB,MAAM,MAAG;MACpD;MACAR,MAAM,CAACC,IAAI,MAAA5B,MAAA,CAAMmB,QAAQ,CAACN,IAAI,CAACiB,MAAM,CAAC,EAAE,CAAC,SAAA9B,MAAA,CAAMkC,SAAS,EAAG;IAC7D;IACA,OAAOP,MAAM,CAACL,IAAI,CAAC,IAAI,CAAC;EAC1B;AACF"}
|
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
import { readType, str2num, num2bytes } from './read-type';
|
|
2
|
-
|
|
3
2
|
export function readNonRecord(buffer, variable) {
|
|
4
3
|
const type = str2num(variable.type);
|
|
5
|
-
|
|
6
4
|
const size = variable.size / num2bytes(type);
|
|
7
|
-
|
|
8
5
|
const data = new Array(size);
|
|
9
6
|
for (let i = 0; i < size; i++) {
|
|
10
7
|
data[i] = readType(buffer, type, 1);
|
|
11
8
|
}
|
|
12
9
|
return data;
|
|
13
10
|
}
|
|
14
|
-
|
|
15
11
|
export function readRecord(buffer, variable, recordDimension) {
|
|
16
12
|
const type = str2num(variable.type);
|
|
17
13
|
const width = variable.size ? variable.size / num2bytes(type) : 1;
|
|
18
|
-
|
|
19
14
|
const size = recordDimension.length;
|
|
20
|
-
|
|
21
15
|
const data = new Array(size);
|
|
22
16
|
const step = recordDimension.recordStep;
|
|
23
17
|
for (let i = 0; i < size; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read-data.js","names":["readType","str2num","num2bytes","readNonRecord","buffer","variable","type","size","data","Array","i","readRecord","recordDimension","width","length","step","recordStep","currentOffset","offset","seek"],"sources":["../../../src/netcdfjs/read-data.ts"],"sourcesContent":["import type {IOBuffer} from '../iobuffer/iobuffer';\nimport type {NetCDFRecordDimension, NetCDFVariable} from './netcdf-types';\nimport {readType, str2num, num2bytes} from './read-type';\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @param buffer - Buffer for the file data\n * @param variable - Variable metadata\n * @return Data of the element\n */\nexport function readNonRecord(\n buffer: IOBuffer,\n variable: NetCDFVariable\n): (string | number | number[] | Uint8Array)[] {\n // variable type\n const type = str2num(variable.type);\n\n // size of the data\n const size = variable.size / num2bytes(type);\n\n // iterates over the data\n const data = new Array(size);\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1);\n }\n\n return data;\n}\n\n/**\n * Read data for the given record variable\n * @param buffer - Buffer for the file data\n * @param variable - Variable metadata\n * @param recordDimension - Record dimension metadata\n * @return - Data of the element\n */\nexport function readRecord(\n buffer: IOBuffer,\n variable: NetCDFVariable,\n recordDimension: NetCDFRecordDimension\n): (string | number | number[] | Uint8Array)[] {\n // variable type\n const type = str2num(variable.type);\n const width = variable.size ? variable.size / num2bytes(type) : 1;\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length;\n\n // iterates over the data\n const data = new Array(size);\n const step = recordDimension.recordStep;\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset;\n data[i] = readType(buffer, type, width);\n buffer.seek(currentOffset + step);\n }\n\n return data;\n}\n"],"mappings":"AAEA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,SAAS,QAAO,aAAa
|
|
1
|
+
{"version":3,"file":"read-data.js","names":["readType","str2num","num2bytes","readNonRecord","buffer","variable","type","size","data","Array","i","readRecord","recordDimension","width","length","step","recordStep","currentOffset","offset","seek"],"sources":["../../../src/netcdfjs/read-data.ts"],"sourcesContent":["import type {IOBuffer} from '../iobuffer/iobuffer';\nimport type {NetCDFRecordDimension, NetCDFVariable} from './netcdf-types';\nimport {readType, str2num, num2bytes} from './read-type';\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @param buffer - Buffer for the file data\n * @param variable - Variable metadata\n * @return Data of the element\n */\nexport function readNonRecord(\n buffer: IOBuffer,\n variable: NetCDFVariable\n): (string | number | number[] | Uint8Array)[] {\n // variable type\n const type = str2num(variable.type);\n\n // size of the data\n const size = variable.size / num2bytes(type);\n\n // iterates over the data\n const data = new Array(size);\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1);\n }\n\n return data;\n}\n\n/**\n * Read data for the given record variable\n * @param buffer - Buffer for the file data\n * @param variable - Variable metadata\n * @param recordDimension - Record dimension metadata\n * @return - Data of the element\n */\nexport function readRecord(\n buffer: IOBuffer,\n variable: NetCDFVariable,\n recordDimension: NetCDFRecordDimension\n): (string | number | number[] | Uint8Array)[] {\n // variable type\n const type = str2num(variable.type);\n const width = variable.size ? variable.size / num2bytes(type) : 1;\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length;\n\n // iterates over the data\n const data = new Array(size);\n const step = recordDimension.recordStep;\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset;\n data[i] = readType(buffer, type, width);\n buffer.seek(currentOffset + step);\n }\n\n return data;\n}\n"],"mappings":"AAEA,SAAQA,QAAQ,EAAEC,OAAO,EAAEC,SAAS,QAAO,aAAa;AAUxD,OAAO,SAASC,aAAaA,CAC3BC,MAAgB,EAChBC,QAAwB,EACqB;EAE7C,MAAMC,IAAI,GAAGL,OAAO,CAACI,QAAQ,CAACC,IAAI,CAAC;EAGnC,MAAMC,IAAI,GAAGF,QAAQ,CAACE,IAAI,GAAGL,SAAS,CAACI,IAAI,CAAC;EAG5C,MAAME,IAAI,GAAG,IAAIC,KAAK,CAACF,IAAI,CAAC;EAC5B,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGH,IAAI,EAAEG,CAAC,EAAE,EAAE;IAC7BF,IAAI,CAACE,CAAC,CAAC,GAAGV,QAAQ,CAACI,MAAM,EAAEE,IAAI,EAAE,CAAC,CAAC;EACrC;EAEA,OAAOE,IAAI;AACb;AASA,OAAO,SAASG,UAAUA,CACxBP,MAAgB,EAChBC,QAAwB,EACxBO,eAAs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