@loaders.gl/scientific 5.0.0-beta.1 → 5.0.0-beta.11
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/README.md +11 -4
- package/dist/hdf5/http-range-reader.d.ts.map +1 -1
- package/dist/hdf5/http-range-reader.js +2 -12
- package/dist/hdf5/http-range-reader.js.map +1 -1
- package/dist/hdf5/index.cjs +2 -11
- package/dist/hdf5/index.cjs.map +2 -2
- package/dist/index.cjs +136 -4152
- package/dist/index.cjs.map +4 -3
- package/dist/index.d.ts +14 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/lib/parsers/parse-npy.d.ts +15 -0
- package/dist/lib/parsers/parse-npy.d.ts.map +1 -0
- package/dist/lib/parsers/parse-npy.js +81 -0
- package/dist/lib/parsers/parse-npy.js.map +1 -0
- package/dist/netcdf/bundled.cjs +47 -46
- package/dist/netcdf/index.cjs +47 -46
- package/dist/netcdf/index.cjs.map +3 -3
- package/dist/netcdf/index.d.ts +2 -1
- package/dist/netcdf/index.d.ts.map +1 -1
- package/dist/netcdf/index.js +2 -1
- package/dist/netcdf/index.js.map +1 -1
- package/dist/netcdf/netcdf-loader-with-parser.cjs +396 -2
- package/dist/netcdf/netcdf-loader-with-parser.d.ts +10 -0
- package/dist/netcdf/netcdf-loader-with-parser.d.ts.map +1 -1
- package/dist/netcdf/netcdf-loader-with-parser.js +3 -1
- package/dist/netcdf/netcdf-loader-with-parser.js.map +1 -1
- package/dist/netcdf/netcdf-loader.cjs +12 -9
- package/dist/netcdf/netcdf-loader.cjs.map +7 -0
- package/dist/netcdf/netcdf-loader.d.ts +10 -21
- package/dist/netcdf/netcdf-loader.d.ts.map +1 -1
- package/dist/netcdf/netcdf-loader.js +6 -3
- package/dist/netcdf/netcdf-loader.js.map +1 -1
- package/dist/netcdf/netcdf-source-loader.cjs +17 -31
- package/dist/netcdf/netcdf-source-loader.d.ts +2 -20
- package/dist/netcdf/netcdf-source-loader.d.ts.map +1 -1
- package/dist/netcdf/netcdf-source-loader.js +22 -20
- package/dist/netcdf/netcdf-source-loader.js.map +1 -1
- package/dist/netcdf/unbundled.cjs +47 -46
- package/dist/netcdf.dev.js +3097 -2654
- package/dist/netcdf.min.js +4 -4
- package/dist/npy-format.d.ts +12 -0
- package/dist/npy-format.d.ts.map +1 -0
- package/dist/npy-format.js +15 -0
- package/dist/npy-format.js.map +1 -0
- package/dist/{netcdf/netcdf-source-loader-types.cjs → npy-loader-types.cjs} +34 -35
- package/dist/npy-loader-types.cjs.map +7 -0
- package/dist/npy-loader-types.d.ts +53 -0
- package/dist/npy-loader-types.d.ts.map +1 -0
- package/dist/npy-loader-types.js +32 -0
- package/dist/npy-loader-types.js.map +1 -0
- package/dist/npy-loader.cjs +273 -0
- package/dist/npy-loader.cjs.map +6 -0
- package/dist/npy-loader.d.ts +27 -0
- package/dist/npy-loader.d.ts.map +1 -0
- package/dist/npy-loader.js +15 -0
- package/dist/npy-loader.js.map +1 -0
- package/dist/npy-worker.d.ts +2 -0
- package/dist/npy-worker.d.ts.map +1 -0
- package/dist/npy-worker.js +1285 -0
- package/dist/npy-worker.js.map +1 -0
- package/dist/nrrd/parse-nrrd.d.ts +22 -0
- package/dist/nrrd/parse-nrrd.d.ts.map +1 -0
- package/dist/nrrd/parse-nrrd.js +228 -0
- package/dist/nrrd/parse-nrrd.js.map +1 -0
- package/dist/nrrd-loader-types.cjs +58 -0
- package/dist/nrrd-loader-types.cjs.map +7 -0
- package/dist/nrrd-loader-types.d.ts +31 -0
- package/dist/nrrd-loader-types.d.ts.map +1 -0
- package/dist/nrrd-loader-types.js +25 -0
- package/dist/nrrd-loader-types.js.map +1 -0
- package/dist/nrrd-loader.cjs +252 -0
- package/dist/nrrd-loader.cjs.map +6 -0
- package/dist/nrrd-loader.d.ts +16 -0
- package/dist/nrrd-loader.d.ts.map +1 -0
- package/dist/nrrd-loader.js +8 -0
- package/dist/nrrd-loader.js.map +1 -0
- package/dist/vtk/index.cjs +26 -4117
- package/dist/vtk/index.cjs.map +3 -3
- package/dist/vtk/vtk-xml.js +4 -4
- package/dist/vtk/vtk-xml.js.map +1 -1
- package/dist/vtk/vtk.d.ts.map +1 -1
- package/dist/vtk/vtk.js +19 -1
- package/dist/vtk/vtk.js.map +1 -1
- package/dist/vtk-loader-types.cjs +58 -0
- package/dist/vtk-loader-types.cjs.map +7 -0
- package/dist/vtk-loader-types.d.ts +34 -0
- package/dist/vtk-loader-types.d.ts.map +1 -0
- package/dist/vtk-loader-types.js +25 -0
- package/dist/vtk-loader-types.js.map +1 -0
- package/dist/vtk-loader.cjs +384 -0
- package/dist/vtk-loader.cjs.map +6 -0
- package/dist/vtk-loader.d.ts +21 -0
- package/dist/vtk-loader.d.ts.map +1 -0
- package/dist/vtk-loader.js +21 -0
- package/dist/vtk-loader.js.map +1 -0
- package/dist/workers/npy-worker.d.ts +2 -0
- package/dist/workers/npy-worker.d.ts.map +1 -0
- package/dist/workers/npy-worker.js +7 -0
- package/dist/workers/npy-worker.js.map +1 -0
- package/dist/zarr/{geo-zarr-source-loader.d.ts → geo-zarr-loader.d.ts} +9 -9
- package/dist/zarr/geo-zarr-loader.d.ts.map +1 -0
- package/dist/zarr/{geo-zarr-source-loader.js → geo-zarr-loader.js} +167 -48
- package/dist/zarr/geo-zarr-loader.js.map +1 -0
- package/dist/zarr/index.cjs +221 -70
- package/dist/zarr/index.cjs.map +3 -3
- package/dist/zarr/index.d.ts +8 -8
- package/dist/zarr/index.d.ts.map +1 -1
- package/dist/zarr/index.js +4 -4
- package/dist/zarr/index.js.map +1 -1
- package/dist/zarr/lib/spatial-multiscales.d.ts +13 -2
- package/dist/zarr/lib/spatial-multiscales.d.ts.map +1 -1
- package/dist/zarr/lib/spatial-multiscales.js +94 -8
- package/dist/zarr/lib/spatial-multiscales.js.map +1 -1
- package/dist/zarr/{ome-zarr-source-loader.d.ts → ome-zarr-loader.d.ts} +9 -9
- package/dist/zarr/ome-zarr-loader.d.ts.map +1 -0
- package/dist/zarr/{ome-zarr-source-loader.js → ome-zarr-loader.js} +5 -5
- package/dist/zarr/ome-zarr-loader.js.map +1 -0
- package/dist/zarr/{spatial-data-source.d.ts → spatial-data-loader.d.ts} +11 -11
- package/dist/zarr/spatial-data-loader.d.ts.map +1 -0
- package/dist/zarr/{spatial-data-source.js → spatial-data-loader.js} +7 -7
- package/dist/zarr/spatial-data-loader.js.map +1 -0
- package/dist/zarr/{zarr-array-source.d.ts → zarr-array-loader.d.ts} +9 -9
- package/dist/zarr/{zarr-array-source.d.ts.map → zarr-array-loader.d.ts.map} +1 -1
- package/dist/zarr/{zarr-array-source.js → zarr-array-loader.js} +5 -5
- package/dist/zarr/{zarr-array-source.js.map → zarr-array-loader.js.map} +1 -1
- package/dist/zarr/zarr-loader-types.cjs +161 -0
- package/dist/zarr/zarr-loader-types.cjs.map +7 -0
- package/dist/zarr/zarr-loader-types.d.ts +32 -32
- package/dist/zarr/zarr-loader-types.d.ts.map +1 -1
- package/dist/zarr/zarr-loader-types.js +24 -24
- package/dist/zarr/zarr-loader-types.js.map +1 -1
- package/dist/zarr.dev.js +296 -80
- package/dist/zarr.min.js +40 -40
- package/package.json +54 -7
- package/src/hdf5/http-range-reader.ts +3 -11
- package/src/index.ts +27 -16
- package/src/lib/parsers/parse-npy.ts +123 -0
- package/src/netcdf/index.ts +2 -5
- package/src/netcdf/netcdf-loader-with-parser.ts +3 -1
- package/src/netcdf/netcdf-loader.ts +5 -3
- package/src/netcdf/netcdf-source-loader.ts +32 -24
- package/src/npy-format.ts +17 -0
- package/src/npy-loader-types.ts +47 -0
- package/src/npy-loader.ts +21 -0
- package/src/npy-worker.ts +6 -0
- package/src/nrrd/parse-nrrd.ts +267 -0
- package/src/nrrd-loader-types.ts +25 -0
- package/src/nrrd-loader.ts +7 -0
- package/src/vtk/vtk-xml.ts +4 -4
- package/src/vtk/vtk.ts +28 -1
- package/src/vtk-loader-types.ts +25 -0
- package/src/vtk-loader.ts +19 -0
- package/src/workers/npy-worker.ts +8 -0
- package/src/zarr/{geo-zarr-source-loader.ts → geo-zarr-loader.ts} +206 -55
- package/src/zarr/index.ts +17 -17
- package/src/zarr/lib/spatial-multiscales.ts +104 -8
- package/src/zarr/{ome-zarr-source-loader.ts → ome-zarr-loader.ts} +11 -11
- package/src/zarr/{spatial-data-source.ts → spatial-data-loader.ts} +16 -16
- package/src/zarr/{zarr-array-source.ts → zarr-array-loader.ts} +10 -10
- package/src/zarr/zarr-loader-types.ts +35 -35
- package/dist/netcdf/netcdf-source-loader-types.d.ts +0 -28
- package/dist/netcdf/netcdf-source-loader-types.d.ts.map +0 -1
- package/dist/netcdf/netcdf-source-loader-types.js +0 -32
- package/dist/netcdf/netcdf-source-loader-types.js.map +0 -1
- package/dist/zarr/geo-zarr-source-loader.d.ts.map +0 -1
- package/dist/zarr/geo-zarr-source-loader.js.map +0 -1
- package/dist/zarr/ome-zarr-source-loader.d.ts.map +0 -1
- package/dist/zarr/ome-zarr-source-loader.js.map +0 -1
- package/dist/zarr/spatial-data-source.d.ts.map +0 -1
- package/dist/zarr/spatial-data-source.js.map +0 -1
- package/src/netcdf/netcdf-source-loader-types.ts +0 -45
package/dist/index.cjs
CHANGED
|
@@ -5,14 +5,6 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __esm = (fn, res, err) => function __init() {
|
|
9
|
-
if (err) throw err[0];
|
|
10
|
-
try {
|
|
11
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
-
} catch (e) {
|
|
13
|
-
throw err = [e], e;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
8
|
var __export = (target, all) => {
|
|
17
9
|
for (var name in all)
|
|
18
10
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -35,4096 +27,19 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
35
27
|
));
|
|
36
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
37
29
|
|
|
38
|
-
// src/netcdf/iobuffer/iobuffer.ts
|
|
39
|
-
var DEFAULT_BYTE_LENGTH, IOBuffer;
|
|
40
|
-
var init_iobuffer = __esm({
|
|
41
|
-
"src/netcdf/iobuffer/iobuffer.ts"() {
|
|
42
|
-
"use strict";
|
|
43
|
-
DEFAULT_BYTE_LENGTH = 1024 * 8;
|
|
44
|
-
IOBuffer = class _IOBuffer {
|
|
45
|
-
/**
|
|
46
|
-
* Reference to the internal ArrayBuffer object.
|
|
47
|
-
*/
|
|
48
|
-
buffer;
|
|
49
|
-
/**
|
|
50
|
-
* Byte length of the internal ArrayBuffer.
|
|
51
|
-
*/
|
|
52
|
-
byteLength;
|
|
53
|
-
/**
|
|
54
|
-
* Byte offset of the internal ArrayBuffer.
|
|
55
|
-
*/
|
|
56
|
-
byteOffset;
|
|
57
|
-
/**
|
|
58
|
-
* Byte length of the internal ArrayBuffer.
|
|
59
|
-
*/
|
|
60
|
-
length;
|
|
61
|
-
/**
|
|
62
|
-
* The current offset of the buffer's pointer.
|
|
63
|
-
*/
|
|
64
|
-
offset;
|
|
65
|
-
lastWrittenByte;
|
|
66
|
-
littleEndian;
|
|
67
|
-
_data;
|
|
68
|
-
_mark;
|
|
69
|
-
_marks;
|
|
70
|
-
textDecoder = new TextDecoder();
|
|
71
|
-
textEncoder = new TextEncoder();
|
|
72
|
-
/**
|
|
73
|
-
* @param data - The data to construct the IOBuffer with.
|
|
74
|
-
* If data is a number, it will be the new buffer's length<br>
|
|
75
|
-
* If data is `undefined`, the buffer will be initialized with a default length of 8Kb<br>
|
|
76
|
-
* If data is an ArrayBuffer, SharedArrayBuffer, an ArrayBufferView (Typed Array), an IOBuffer instance,
|
|
77
|
-
* or a Node.js Buffer, a view will be created over the underlying ArrayBuffer.
|
|
78
|
-
* @param options
|
|
79
|
-
*/
|
|
80
|
-
constructor(data = DEFAULT_BYTE_LENGTH, options = {}) {
|
|
81
|
-
let dataIsGiven = false;
|
|
82
|
-
if (typeof data === "number") {
|
|
83
|
-
data = new ArrayBuffer(data);
|
|
84
|
-
} else {
|
|
85
|
-
dataIsGiven = true;
|
|
86
|
-
this.lastWrittenByte = data.byteLength;
|
|
87
|
-
}
|
|
88
|
-
const offset = options.offset ? options.offset >>> 0 : 0;
|
|
89
|
-
const byteLength = data.byteLength - offset;
|
|
90
|
-
let dvOffset = offset;
|
|
91
|
-
if (ArrayBuffer.isView(data) || data instanceof _IOBuffer) {
|
|
92
|
-
if (data.byteLength !== data.buffer.byteLength) {
|
|
93
|
-
dvOffset = data.byteOffset + offset;
|
|
94
|
-
}
|
|
95
|
-
data = data.buffer;
|
|
96
|
-
}
|
|
97
|
-
if (dataIsGiven) {
|
|
98
|
-
this.lastWrittenByte = byteLength;
|
|
99
|
-
} else {
|
|
100
|
-
this.lastWrittenByte = 0;
|
|
101
|
-
}
|
|
102
|
-
this.buffer = data;
|
|
103
|
-
this.length = byteLength;
|
|
104
|
-
this.byteLength = byteLength;
|
|
105
|
-
this.byteOffset = dvOffset;
|
|
106
|
-
this.offset = 0;
|
|
107
|
-
this.littleEndian = true;
|
|
108
|
-
this._data = new DataView(this.buffer, dvOffset, byteLength);
|
|
109
|
-
this._mark = 0;
|
|
110
|
-
this._marks = [];
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Checks if the memory allocated to the buffer is sufficient to store more
|
|
114
|
-
* bytes after the offset.
|
|
115
|
-
* @param byteLength - The needed memory in bytes.
|
|
116
|
-
* @returns `true` if there is sufficient space and `false` otherwise.
|
|
117
|
-
*/
|
|
118
|
-
available(byteLength = 1) {
|
|
119
|
-
return this.offset + byteLength <= this.length;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Check if little-endian mode is used for reading and writing multi-byte
|
|
123
|
-
* values.
|
|
124
|
-
* @returns `true` if little-endian mode is used, `false` otherwise.
|
|
125
|
-
*/
|
|
126
|
-
isLittleEndian() {
|
|
127
|
-
return this.littleEndian;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Set little-endian mode for reading and writing multi-byte values.
|
|
131
|
-
*/
|
|
132
|
-
setLittleEndian() {
|
|
133
|
-
this.littleEndian = true;
|
|
134
|
-
return this;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Check if big-endian mode is used for reading and writing multi-byte values.
|
|
138
|
-
* @returns `true` if big-endian mode is used, `false` otherwise.
|
|
139
|
-
*/
|
|
140
|
-
isBigEndian() {
|
|
141
|
-
return !this.littleEndian;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Switches to big-endian mode for reading and writing multi-byte values.
|
|
145
|
-
*/
|
|
146
|
-
setBigEndian() {
|
|
147
|
-
this.littleEndian = false;
|
|
148
|
-
return this;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Move the pointer n bytes forward.
|
|
152
|
-
* @param n - Number of bytes to skip.
|
|
153
|
-
*/
|
|
154
|
-
skip(n = 1) {
|
|
155
|
-
this.offset += n;
|
|
156
|
-
return this;
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Move the pointer to the given offset.
|
|
160
|
-
* @param offset
|
|
161
|
-
*/
|
|
162
|
-
seek(offset) {
|
|
163
|
-
this.offset = offset;
|
|
164
|
-
return this;
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Store the current pointer offset.
|
|
168
|
-
* @see {@link IOBuffer#reset}
|
|
169
|
-
*/
|
|
170
|
-
mark() {
|
|
171
|
-
this._mark = this.offset;
|
|
172
|
-
return this;
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Move the pointer back to the last pointer offset set by mark.
|
|
176
|
-
* @see {@link IOBuffer#mark}
|
|
177
|
-
*/
|
|
178
|
-
reset() {
|
|
179
|
-
this.offset = this._mark;
|
|
180
|
-
return this;
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Push the current pointer offset to the mark stack.
|
|
184
|
-
* @see {@link IOBuffer#popMark}
|
|
185
|
-
*/
|
|
186
|
-
pushMark() {
|
|
187
|
-
this._marks.push(this.offset);
|
|
188
|
-
return this;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Pop the last pointer offset from the mark stack, and set the current
|
|
192
|
-
* pointer offset to the popped value.
|
|
193
|
-
* @see {@link IOBuffer#pushMark}
|
|
194
|
-
*/
|
|
195
|
-
popMark() {
|
|
196
|
-
const offset = this._marks.pop();
|
|
197
|
-
if (offset === void 0) {
|
|
198
|
-
throw new Error("Mark stack empty");
|
|
199
|
-
}
|
|
200
|
-
this.seek(offset);
|
|
201
|
-
return this;
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Move the pointer offset back to 0.
|
|
205
|
-
*/
|
|
206
|
-
rewind() {
|
|
207
|
-
this.offset = 0;
|
|
208
|
-
return this;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Make sure the buffer has sufficient memory to write a given byteLength at
|
|
212
|
-
* the current pointer offset.
|
|
213
|
-
* If the buffer's memory is insufficient, this method will create a new
|
|
214
|
-
* buffer (a copy) with a length that is twice (byteLength + current offset).
|
|
215
|
-
* @param byteLength
|
|
216
|
-
*/
|
|
217
|
-
ensureAvailable(byteLength = 1) {
|
|
218
|
-
if (!this.available(byteLength)) {
|
|
219
|
-
const lengthNeeded = this.offset + byteLength;
|
|
220
|
-
const newLength = lengthNeeded * 2;
|
|
221
|
-
const newArray = new Uint8Array(newLength);
|
|
222
|
-
newArray.set(new Uint8Array(this.buffer));
|
|
223
|
-
this.buffer = newArray.buffer;
|
|
224
|
-
this.length = this.byteLength = newLength;
|
|
225
|
-
this._data = new DataView(this.buffer);
|
|
226
|
-
}
|
|
227
|
-
return this;
|
|
228
|
-
}
|
|
229
|
-
/**
|
|
230
|
-
* Read a byte and return false if the byte's value is 0, or true otherwise.
|
|
231
|
-
* Moves pointer forward by one byte.
|
|
232
|
-
*/
|
|
233
|
-
readBoolean() {
|
|
234
|
-
return this.readUint8() !== 0;
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Read a signed 8-bit integer and move pointer forward by 1 byte.
|
|
238
|
-
*/
|
|
239
|
-
readInt8() {
|
|
240
|
-
return this._data.getInt8(this.offset++);
|
|
241
|
-
}
|
|
242
|
-
/**
|
|
243
|
-
* Read an unsigned 8-bit integer and move pointer forward by 1 byte.
|
|
244
|
-
*/
|
|
245
|
-
readUint8() {
|
|
246
|
-
return this._data.getUint8(this.offset++);
|
|
247
|
-
}
|
|
248
|
-
/**
|
|
249
|
-
* Alias for {@link IOBuffer#readUint8}.
|
|
250
|
-
*/
|
|
251
|
-
readByte() {
|
|
252
|
-
return this.readUint8();
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* Read `n` bytes and move pointer forward by `n` bytes.
|
|
256
|
-
*/
|
|
257
|
-
readBytes(n = 1) {
|
|
258
|
-
const bytes = new Uint8Array(n);
|
|
259
|
-
for (let i = 0; i < n; i++) {
|
|
260
|
-
bytes[i] = this.readByte();
|
|
261
|
-
}
|
|
262
|
-
return bytes;
|
|
263
|
-
}
|
|
264
|
-
/**
|
|
265
|
-
* Read a 16-bit signed integer and move pointer forward by 2 bytes.
|
|
266
|
-
*/
|
|
267
|
-
readInt16() {
|
|
268
|
-
const value = this._data.getInt16(this.offset, this.littleEndian);
|
|
269
|
-
this.offset += 2;
|
|
270
|
-
return value;
|
|
271
|
-
}
|
|
272
|
-
/**
|
|
273
|
-
* Read a 16-bit unsigned integer and move pointer forward by 2 bytes.
|
|
274
|
-
*/
|
|
275
|
-
readUint16() {
|
|
276
|
-
const value = this._data.getUint16(this.offset, this.littleEndian);
|
|
277
|
-
this.offset += 2;
|
|
278
|
-
return value;
|
|
279
|
-
}
|
|
280
|
-
/**
|
|
281
|
-
* Read a 32-bit signed integer and move pointer forward by 4 bytes.
|
|
282
|
-
*/
|
|
283
|
-
readInt32() {
|
|
284
|
-
const value = this._data.getInt32(this.offset, this.littleEndian);
|
|
285
|
-
this.offset += 4;
|
|
286
|
-
return value;
|
|
287
|
-
}
|
|
288
|
-
/**
|
|
289
|
-
* Read a 32-bit unsigned integer and move pointer forward by 4 bytes.
|
|
290
|
-
*/
|
|
291
|
-
readUint32() {
|
|
292
|
-
const value = this._data.getUint32(this.offset, this.littleEndian);
|
|
293
|
-
this.offset += 4;
|
|
294
|
-
return value;
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Read a 32-bit floating number and move pointer forward by 4 bytes.
|
|
298
|
-
*/
|
|
299
|
-
readFloat32() {
|
|
300
|
-
const value = this._data.getFloat32(this.offset, this.littleEndian);
|
|
301
|
-
this.offset += 4;
|
|
302
|
-
return value;
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Read a 64-bit floating number and move pointer forward by 8 bytes.
|
|
306
|
-
*/
|
|
307
|
-
readFloat64() {
|
|
308
|
-
const value = this._data.getFloat64(this.offset, this.littleEndian);
|
|
309
|
-
this.offset += 8;
|
|
310
|
-
return value;
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Read a 1-byte ASCII character and move pointer forward by 1 byte.
|
|
314
|
-
*/
|
|
315
|
-
readChar() {
|
|
316
|
-
return String.fromCharCode(this.readInt8());
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Read `n` 1-byte ASCII characters and move pointer forward by `n` bytes.
|
|
320
|
-
*/
|
|
321
|
-
readChars(n = 1) {
|
|
322
|
-
let result = "";
|
|
323
|
-
for (let i = 0; i < n; i++) {
|
|
324
|
-
result += this.readChar();
|
|
325
|
-
}
|
|
326
|
-
return result;
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Read the next `n` bytes, return a UTF-8 decoded string and move pointer
|
|
330
|
-
* forward by `n` bytes.
|
|
331
|
-
*/
|
|
332
|
-
readUtf8(n = 1) {
|
|
333
|
-
return this.textDecoder.decode(this.readBytes(n));
|
|
334
|
-
}
|
|
335
|
-
/**
|
|
336
|
-
* Write 0xff if the passed value is truthy, 0x00 otherwise and move pointer
|
|
337
|
-
* forward by 1 byte.
|
|
338
|
-
*/
|
|
339
|
-
writeBoolean(value) {
|
|
340
|
-
this.writeUint8(value ? 255 : 0);
|
|
341
|
-
return this;
|
|
342
|
-
}
|
|
343
|
-
/**
|
|
344
|
-
* Write `value` as an 8-bit signed integer and move pointer forward by 1 byte.
|
|
345
|
-
*/
|
|
346
|
-
writeInt8(value) {
|
|
347
|
-
this.ensureAvailable(1);
|
|
348
|
-
this._data.setInt8(this.offset++, value);
|
|
349
|
-
this._updateLastWrittenByte();
|
|
350
|
-
return this;
|
|
351
|
-
}
|
|
352
|
-
/**
|
|
353
|
-
* Write `value` as an 8-bit unsigned integer and move pointer forward by 1
|
|
354
|
-
* byte.
|
|
355
|
-
*/
|
|
356
|
-
writeUint8(value) {
|
|
357
|
-
this.ensureAvailable(1);
|
|
358
|
-
this._data.setUint8(this.offset++, value);
|
|
359
|
-
this._updateLastWrittenByte();
|
|
360
|
-
return this;
|
|
361
|
-
}
|
|
362
|
-
/**
|
|
363
|
-
* An alias for {@link IOBuffer#writeUint8}.
|
|
364
|
-
*/
|
|
365
|
-
writeByte(value) {
|
|
366
|
-
return this.writeUint8(value);
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* Write all elements of `bytes` as uint8 values and move pointer forward by
|
|
370
|
-
* `bytes.length` bytes.
|
|
371
|
-
*/
|
|
372
|
-
writeBytes(bytes) {
|
|
373
|
-
this.ensureAvailable(bytes.length);
|
|
374
|
-
for (let i = 0; i < bytes.length; i++) {
|
|
375
|
-
this._data.setUint8(this.offset++, bytes[i]);
|
|
376
|
-
}
|
|
377
|
-
this._updateLastWrittenByte();
|
|
378
|
-
return this;
|
|
379
|
-
}
|
|
380
|
-
/**
|
|
381
|
-
* Write `value` as a 16-bit signed integer and move pointer forward by 2
|
|
382
|
-
* bytes.
|
|
383
|
-
*/
|
|
384
|
-
writeInt16(value) {
|
|
385
|
-
this.ensureAvailable(2);
|
|
386
|
-
this._data.setInt16(this.offset, value, this.littleEndian);
|
|
387
|
-
this.offset += 2;
|
|
388
|
-
this._updateLastWrittenByte();
|
|
389
|
-
return this;
|
|
390
|
-
}
|
|
391
|
-
/**
|
|
392
|
-
* Write `value` as a 16-bit unsigned integer and move pointer forward by 2
|
|
393
|
-
* bytes.
|
|
394
|
-
*/
|
|
395
|
-
writeUint16(value) {
|
|
396
|
-
this.ensureAvailable(2);
|
|
397
|
-
this._data.setUint16(this.offset, value, this.littleEndian);
|
|
398
|
-
this.offset += 2;
|
|
399
|
-
this._updateLastWrittenByte();
|
|
400
|
-
return this;
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Write `value` as a 32-bit signed integer and move pointer forward by 4
|
|
404
|
-
* bytes.
|
|
405
|
-
*/
|
|
406
|
-
writeInt32(value) {
|
|
407
|
-
this.ensureAvailable(4);
|
|
408
|
-
this._data.setInt32(this.offset, value, this.littleEndian);
|
|
409
|
-
this.offset += 4;
|
|
410
|
-
this._updateLastWrittenByte();
|
|
411
|
-
return this;
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* Write `value` as a 32-bit unsigned integer and move pointer forward by 4
|
|
415
|
-
* bytes.
|
|
416
|
-
*/
|
|
417
|
-
writeUint32(value) {
|
|
418
|
-
this.ensureAvailable(4);
|
|
419
|
-
this._data.setUint32(this.offset, value, this.littleEndian);
|
|
420
|
-
this.offset += 4;
|
|
421
|
-
this._updateLastWrittenByte();
|
|
422
|
-
return this;
|
|
423
|
-
}
|
|
424
|
-
/**
|
|
425
|
-
* Write `value` as a 32-bit floating number and move pointer forward by 4
|
|
426
|
-
* bytes.
|
|
427
|
-
*/
|
|
428
|
-
writeFloat32(value) {
|
|
429
|
-
this.ensureAvailable(4);
|
|
430
|
-
this._data.setFloat32(this.offset, value, this.littleEndian);
|
|
431
|
-
this.offset += 4;
|
|
432
|
-
this._updateLastWrittenByte();
|
|
433
|
-
return this;
|
|
434
|
-
}
|
|
435
|
-
/**
|
|
436
|
-
* Write `value` as a 64-bit floating number and move pointer forward by 8
|
|
437
|
-
* bytes.
|
|
438
|
-
*/
|
|
439
|
-
writeFloat64(value) {
|
|
440
|
-
this.ensureAvailable(8);
|
|
441
|
-
this._data.setFloat64(this.offset, value, this.littleEndian);
|
|
442
|
-
this.offset += 8;
|
|
443
|
-
this._updateLastWrittenByte();
|
|
444
|
-
return this;
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Write the charCode of `str`'s first character as an 8-bit unsigned integer
|
|
448
|
-
* and move pointer forward by 1 byte.
|
|
449
|
-
*/
|
|
450
|
-
writeChar(str) {
|
|
451
|
-
return this.writeUint8(str.charCodeAt(0));
|
|
452
|
-
}
|
|
453
|
-
/**
|
|
454
|
-
* Write the charCodes of all `str`'s characters as 8-bit unsigned integers
|
|
455
|
-
* and move pointer forward by `str.length` bytes.
|
|
456
|
-
*/
|
|
457
|
-
writeChars(str) {
|
|
458
|
-
for (let i = 0; i < str.length; i++) {
|
|
459
|
-
this.writeUint8(str.charCodeAt(i));
|
|
460
|
-
}
|
|
461
|
-
return this;
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* UTF-8 encode and write `str` to the current pointer offset and move pointer
|
|
465
|
-
* forward according to the encoded length.
|
|
466
|
-
*/
|
|
467
|
-
writeUtf8(str) {
|
|
468
|
-
const bytes = this.textEncoder.encode(str);
|
|
469
|
-
return this.writeBytes(bytes);
|
|
470
|
-
}
|
|
471
|
-
/**
|
|
472
|
-
* Export a Uint8Array view of the internal buffer.
|
|
473
|
-
* The view starts at the byte offset and its length
|
|
474
|
-
* is calculated to stop at the last written byte or the original length.
|
|
475
|
-
*/
|
|
476
|
-
toArray() {
|
|
477
|
-
return new Uint8Array(this.buffer, this.byteOffset, this.lastWrittenByte);
|
|
478
|
-
}
|
|
479
|
-
/**
|
|
480
|
-
* Update the last written byte offset
|
|
481
|
-
* @private
|
|
482
|
-
*/
|
|
483
|
-
_updateLastWrittenByte() {
|
|
484
|
-
if (this.offset > this.lastWrittenByte) {
|
|
485
|
-
this.lastWrittenByte = this.offset;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
});
|
|
491
|
-
|
|
492
|
-
// src/netcdf/netcdfjs/read-type.ts
|
|
493
|
-
function readType(buffer, type, size) {
|
|
494
|
-
switch (type) {
|
|
495
|
-
case TYPES.BYTE:
|
|
496
|
-
return buffer.readBytes(size);
|
|
497
|
-
case TYPES.CHAR:
|
|
498
|
-
return trimNull(buffer.readChars(size));
|
|
499
|
-
case TYPES.SHORT:
|
|
500
|
-
return readNumber(size, buffer.readInt16.bind(buffer));
|
|
501
|
-
case TYPES.INT:
|
|
502
|
-
return readNumber(size, buffer.readInt32.bind(buffer));
|
|
503
|
-
case TYPES.FLOAT:
|
|
504
|
-
return readNumber(size, buffer.readFloat32.bind(buffer));
|
|
505
|
-
case TYPES.DOUBLE:
|
|
506
|
-
return readNumber(size, buffer.readFloat64.bind(buffer));
|
|
507
|
-
/* istanbul ignore next */
|
|
508
|
-
default:
|
|
509
|
-
throw new Error(`NetCDF: non valid type ${type}`);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
function num2str(type) {
|
|
513
|
-
switch (Number(type)) {
|
|
514
|
-
case TYPES.BYTE:
|
|
515
|
-
return "byte";
|
|
516
|
-
case TYPES.CHAR:
|
|
517
|
-
return "char";
|
|
518
|
-
case TYPES.SHORT:
|
|
519
|
-
return "short";
|
|
520
|
-
case TYPES.INT:
|
|
521
|
-
return "int";
|
|
522
|
-
case TYPES.FLOAT:
|
|
523
|
-
return "float";
|
|
524
|
-
case TYPES.DOUBLE:
|
|
525
|
-
return "double";
|
|
526
|
-
/* istanbul ignore next */
|
|
527
|
-
default:
|
|
528
|
-
return "undefined";
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
function num2bytes(type) {
|
|
532
|
-
switch (Number(type)) {
|
|
533
|
-
case TYPES.BYTE:
|
|
534
|
-
return 1;
|
|
535
|
-
case TYPES.CHAR:
|
|
536
|
-
return 1;
|
|
537
|
-
case TYPES.SHORT:
|
|
538
|
-
return 2;
|
|
539
|
-
case TYPES.INT:
|
|
540
|
-
return 4;
|
|
541
|
-
case TYPES.FLOAT:
|
|
542
|
-
return 4;
|
|
543
|
-
case TYPES.DOUBLE:
|
|
544
|
-
return 8;
|
|
545
|
-
/* istanbul ignore next */
|
|
546
|
-
default:
|
|
547
|
-
return -1;
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
function str2num(type) {
|
|
551
|
-
switch (String(type)) {
|
|
552
|
-
case "byte":
|
|
553
|
-
return TYPES.BYTE;
|
|
554
|
-
case "char":
|
|
555
|
-
return TYPES.CHAR;
|
|
556
|
-
case "short":
|
|
557
|
-
return TYPES.SHORT;
|
|
558
|
-
case "int":
|
|
559
|
-
return TYPES.INT;
|
|
560
|
-
case "float":
|
|
561
|
-
return TYPES.FLOAT;
|
|
562
|
-
case "double":
|
|
563
|
-
return TYPES.DOUBLE;
|
|
564
|
-
/* istanbul ignore next */
|
|
565
|
-
default:
|
|
566
|
-
return -1;
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
function readNumber(size, bufferReader) {
|
|
570
|
-
if (size !== 1) {
|
|
571
|
-
const numbers = new Array(size);
|
|
572
|
-
for (let i = 0; i < size; i++) {
|
|
573
|
-
numbers[i] = bufferReader();
|
|
574
|
-
}
|
|
575
|
-
return numbers;
|
|
576
|
-
}
|
|
577
|
-
return bufferReader();
|
|
578
|
-
}
|
|
579
|
-
function trimNull(value) {
|
|
580
|
-
if (value.charCodeAt(value.length - 1) === 0) {
|
|
581
|
-
return value.substring(0, value.length - 1);
|
|
582
|
-
}
|
|
583
|
-
return value;
|
|
584
|
-
}
|
|
585
|
-
var TYPES;
|
|
586
|
-
var init_read_type = __esm({
|
|
587
|
-
"src/netcdf/netcdfjs/read-type.ts"() {
|
|
588
|
-
"use strict";
|
|
589
|
-
TYPES = {
|
|
590
|
-
BYTE: 1,
|
|
591
|
-
CHAR: 2,
|
|
592
|
-
SHORT: 3,
|
|
593
|
-
INT: 4,
|
|
594
|
-
FLOAT: 5,
|
|
595
|
-
DOUBLE: 6
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
});
|
|
599
|
-
|
|
600
|
-
// src/netcdf/netcdfjs/read-header.ts
|
|
601
|
-
function readNetCDFHeader(buffer, version2) {
|
|
602
|
-
const recordDimensionLength = buffer.readUint32();
|
|
603
|
-
const dimList = readDimensionsList(buffer);
|
|
604
|
-
const attributes = readAttributesList(buffer);
|
|
605
|
-
const variableList = readVariablesList(buffer, dimList.recordId, version2);
|
|
606
|
-
const header = {
|
|
607
|
-
version: version2,
|
|
608
|
-
recordDimension: {
|
|
609
|
-
length: recordDimensionLength,
|
|
610
|
-
id: dimList.recordId,
|
|
611
|
-
// id of the unlimited dimension
|
|
612
|
-
name: dimList.recordName,
|
|
613
|
-
// name of the unlimited dimension
|
|
614
|
-
recordStep: variableList.recordStep
|
|
615
|
-
},
|
|
616
|
-
dimensions: dimList.dimensions,
|
|
617
|
-
variables: variableList.variables,
|
|
618
|
-
attributes
|
|
619
|
-
};
|
|
620
|
-
return header;
|
|
621
|
-
}
|
|
622
|
-
function readDimensionsList(buffer) {
|
|
623
|
-
const dimList = buffer.readUint32();
|
|
624
|
-
if (dimList === ZERO) {
|
|
625
|
-
if (buffer.readUint32() !== ZERO) {
|
|
626
|
-
throw new Error("NetCDF: wrong empty tag for list of dimensions");
|
|
627
|
-
}
|
|
628
|
-
return {
|
|
629
|
-
recordId: 0,
|
|
630
|
-
recordName: "",
|
|
631
|
-
dimensions: []
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
if (dimList !== NC_DIMENSION) {
|
|
635
|
-
throw new Error("NetCDF: wrong tag for list of dimensions");
|
|
636
|
-
}
|
|
637
|
-
const dimensionSize = buffer.readUint32();
|
|
638
|
-
const dimensions = new Array(dimensionSize);
|
|
639
|
-
let recordId;
|
|
640
|
-
let recordName;
|
|
641
|
-
for (let dim = 0; dim < dimensionSize; dim++) {
|
|
642
|
-
const name = readName(buffer);
|
|
643
|
-
const size = buffer.readUint32();
|
|
644
|
-
if (size === NC_UNLIMITED) {
|
|
645
|
-
recordId = dim;
|
|
646
|
-
recordName = name;
|
|
647
|
-
}
|
|
648
|
-
dimensions[dim] = {
|
|
649
|
-
name,
|
|
650
|
-
size
|
|
651
|
-
};
|
|
652
|
-
}
|
|
653
|
-
return {
|
|
654
|
-
dimensions,
|
|
655
|
-
recordId,
|
|
656
|
-
recordName
|
|
657
|
-
};
|
|
658
|
-
}
|
|
659
|
-
function readAttributesList(buffer) {
|
|
660
|
-
const gAttList = buffer.readUint32();
|
|
661
|
-
if (gAttList === ZERO) {
|
|
662
|
-
if (buffer.readUint32() !== ZERO) {
|
|
663
|
-
throw new Error("NetCDF: wrong empty tag for list of attributes");
|
|
664
|
-
}
|
|
665
|
-
return [];
|
|
666
|
-
}
|
|
667
|
-
if (gAttList !== NC_ATTRIBUTE) {
|
|
668
|
-
throw new Error("NetCDF: wrong tag for list of attributes");
|
|
669
|
-
}
|
|
670
|
-
const attributeSize = buffer.readUint32();
|
|
671
|
-
const attributes = new Array(attributeSize);
|
|
672
|
-
for (let gAtt = 0; gAtt < attributeSize; gAtt++) {
|
|
673
|
-
const name = readName(buffer);
|
|
674
|
-
const type = buffer.readUint32();
|
|
675
|
-
if (type < 1 || type > 6) {
|
|
676
|
-
throw new Error(`NetCDF: non valid type ${type}`);
|
|
677
|
-
}
|
|
678
|
-
const size = buffer.readUint32();
|
|
679
|
-
const value = readType(buffer, type, size);
|
|
680
|
-
padding(buffer);
|
|
681
|
-
attributes[gAtt] = {
|
|
682
|
-
name,
|
|
683
|
-
type: num2str(type),
|
|
684
|
-
value
|
|
685
|
-
};
|
|
686
|
-
}
|
|
687
|
-
return attributes;
|
|
688
|
-
}
|
|
689
|
-
function readVariablesList(buffer, recordId, version2) {
|
|
690
|
-
const varList = buffer.readUint32();
|
|
691
|
-
let recordStep = 0;
|
|
692
|
-
if (varList === ZERO) {
|
|
693
|
-
if (buffer.readUint32() !== ZERO) {
|
|
694
|
-
throw new Error("NetCDF: wrong empty tag for list of variables");
|
|
695
|
-
}
|
|
696
|
-
return {
|
|
697
|
-
recordStep,
|
|
698
|
-
variables: []
|
|
699
|
-
};
|
|
700
|
-
}
|
|
701
|
-
if (varList !== NC_VARIABLE) {
|
|
702
|
-
throw new Error("NetCDF: wrong tag for list of variables");
|
|
703
|
-
}
|
|
704
|
-
const variableSize = buffer.readUint32();
|
|
705
|
-
const variables = new Array(variableSize);
|
|
706
|
-
for (let v = 0; v < variableSize; v++) {
|
|
707
|
-
const name = readName(buffer);
|
|
708
|
-
const dimensionality = buffer.readUint32();
|
|
709
|
-
const dimensionsIds = new Array(dimensionality);
|
|
710
|
-
for (let dim = 0; dim < dimensionality; dim++) {
|
|
711
|
-
dimensionsIds[dim] = buffer.readUint32();
|
|
712
|
-
}
|
|
713
|
-
const attributes = readAttributesList(buffer);
|
|
714
|
-
const type = buffer.readUint32();
|
|
715
|
-
if (type < 1 && type > 6) {
|
|
716
|
-
throw new Error(`NetCDF: non valid type ${type}`);
|
|
717
|
-
}
|
|
718
|
-
const varSize = buffer.readUint32();
|
|
719
|
-
let offset = buffer.readUint32();
|
|
720
|
-
if (version2 === 2) {
|
|
721
|
-
if (offset > 0) {
|
|
722
|
-
throw new Error("NetCDF: offsets larger than 4GB not supported");
|
|
723
|
-
}
|
|
724
|
-
offset = buffer.readUint32();
|
|
725
|
-
}
|
|
726
|
-
let record = false;
|
|
727
|
-
if (typeof recordId !== "undefined" && dimensionsIds[0] === recordId) {
|
|
728
|
-
recordStep += varSize;
|
|
729
|
-
record = true;
|
|
730
|
-
}
|
|
731
|
-
variables[v] = {
|
|
732
|
-
name,
|
|
733
|
-
dimensions: dimensionsIds,
|
|
734
|
-
attributes,
|
|
735
|
-
type: num2str(type),
|
|
736
|
-
size: varSize,
|
|
737
|
-
offset,
|
|
738
|
-
record
|
|
739
|
-
};
|
|
740
|
-
}
|
|
741
|
-
return {
|
|
742
|
-
variables,
|
|
743
|
-
recordStep
|
|
744
|
-
};
|
|
745
|
-
}
|
|
746
|
-
function readName(buffer) {
|
|
747
|
-
const nameLength = buffer.readUint32();
|
|
748
|
-
const name = buffer.readChars(nameLength);
|
|
749
|
-
padding(buffer);
|
|
750
|
-
return name;
|
|
751
|
-
}
|
|
752
|
-
function padding(buffer) {
|
|
753
|
-
if (buffer.offset % 4 !== 0) {
|
|
754
|
-
buffer.skip(4 - buffer.offset % 4);
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
var ZERO, NC_DIMENSION, NC_VARIABLE, NC_ATTRIBUTE, NC_UNLIMITED;
|
|
758
|
-
var init_read_header = __esm({
|
|
759
|
-
"src/netcdf/netcdfjs/read-header.ts"() {
|
|
760
|
-
"use strict";
|
|
761
|
-
init_read_type();
|
|
762
|
-
ZERO = 0;
|
|
763
|
-
NC_DIMENSION = 10;
|
|
764
|
-
NC_VARIABLE = 11;
|
|
765
|
-
NC_ATTRIBUTE = 12;
|
|
766
|
-
NC_UNLIMITED = 0;
|
|
767
|
-
}
|
|
768
|
-
});
|
|
769
|
-
|
|
770
|
-
// src/netcdf/netcdfjs/read-data.ts
|
|
771
|
-
function readNonRecord(buffer, variable) {
|
|
772
|
-
const type = str2num(variable.type);
|
|
773
|
-
const size = variable.size / num2bytes(type);
|
|
774
|
-
const data = new Array(size);
|
|
775
|
-
for (let i = 0; i < size; i++) {
|
|
776
|
-
data[i] = readType(buffer, type, 1);
|
|
777
|
-
}
|
|
778
|
-
return data;
|
|
779
|
-
}
|
|
780
|
-
function readRecord(buffer, variable, recordDimension, dimensions) {
|
|
781
|
-
const type = str2num(variable.type);
|
|
782
|
-
const width = variable.dimensions.filter((dimensionId) => dimensionId !== recordDimension.id).reduce((elementCount, dimensionId) => elementCount * dimensions[dimensionId].size, 1);
|
|
783
|
-
const size = recordDimension.length;
|
|
784
|
-
const data = new Array(size);
|
|
785
|
-
const step = recordDimension.recordStep;
|
|
786
|
-
for (let i = 0; i < size; i++) {
|
|
787
|
-
const currentOffset = buffer.offset;
|
|
788
|
-
data[i] = readType(buffer, type, width);
|
|
789
|
-
buffer.seek(currentOffset + step);
|
|
790
|
-
}
|
|
791
|
-
return data;
|
|
792
|
-
}
|
|
793
|
-
var init_read_data = __esm({
|
|
794
|
-
"src/netcdf/netcdfjs/read-data.ts"() {
|
|
795
|
-
"use strict";
|
|
796
|
-
init_read_type();
|
|
797
|
-
}
|
|
798
|
-
});
|
|
799
|
-
|
|
800
|
-
// src/netcdf/netcdfjs/netcdf-reader.ts
|
|
801
|
-
var NetCDFReader;
|
|
802
|
-
var init_netcdf_reader = __esm({
|
|
803
|
-
"src/netcdf/netcdfjs/netcdf-reader.ts"() {
|
|
804
|
-
"use strict";
|
|
805
|
-
init_iobuffer();
|
|
806
|
-
init_read_header();
|
|
807
|
-
init_read_data();
|
|
808
|
-
NetCDFReader = class {
|
|
809
|
-
header;
|
|
810
|
-
buffer;
|
|
811
|
-
constructor(data) {
|
|
812
|
-
const buffer = new IOBuffer(data);
|
|
813
|
-
buffer.setBigEndian();
|
|
814
|
-
const magic = buffer.readChars(3);
|
|
815
|
-
if (magic !== "CDF") {
|
|
816
|
-
throw new Error(`NetCDF: file should start with 'CDF', found ${magic}`);
|
|
817
|
-
}
|
|
818
|
-
const version2 = buffer.readByte();
|
|
819
|
-
if (version2 > 2) {
|
|
820
|
-
throw new Error(`NetCDF: unsupported version ${version2}`);
|
|
821
|
-
}
|
|
822
|
-
this.header = readNetCDFHeader(buffer, version2);
|
|
823
|
-
this.buffer = buffer;
|
|
824
|
-
}
|
|
825
|
-
/**
|
|
826
|
-
* @return {string} - Version for the NetCDF format
|
|
827
|
-
*/
|
|
828
|
-
get version() {
|
|
829
|
-
if (this.header.version === 1) {
|
|
830
|
-
return "classic format";
|
|
831
|
-
}
|
|
832
|
-
return "64-bit offset format";
|
|
833
|
-
}
|
|
834
|
-
/**
|
|
835
|
-
* Get metadata for the record dimension
|
|
836
|
-
*/
|
|
837
|
-
get recordDimension() {
|
|
838
|
-
return this.header.recordDimension;
|
|
839
|
-
}
|
|
840
|
-
/**
|
|
841
|
-
* Get list of dimensions (each with `name` and `size`)
|
|
842
|
-
*/
|
|
843
|
-
get dimensions() {
|
|
844
|
-
return this.header.dimensions;
|
|
845
|
-
}
|
|
846
|
-
/**
|
|
847
|
-
* Get list of global attributes with:
|
|
848
|
-
* * `name`: String with the name of the attribute
|
|
849
|
-
* * `type`: String with the type of the attribute
|
|
850
|
-
* * `value`: A number or string with the value of the attribute
|
|
851
|
-
*/
|
|
852
|
-
get attributes() {
|
|
853
|
-
return this.header.attributes;
|
|
854
|
-
}
|
|
855
|
-
/**
|
|
856
|
-
* Get list of variables
|
|
857
|
-
*/
|
|
858
|
-
get variables() {
|
|
859
|
-
return this.header.variables;
|
|
860
|
-
}
|
|
861
|
-
/**
|
|
862
|
-
* Check if an attribute exists
|
|
863
|
-
* @param attributeName - Name of the attribute to find
|
|
864
|
-
* @return
|
|
865
|
-
*/
|
|
866
|
-
attributeExists(attributeName) {
|
|
867
|
-
const attribute = this.attributes.find((val) => val.name === attributeName);
|
|
868
|
-
return attribute !== void 0;
|
|
869
|
-
}
|
|
870
|
-
/**
|
|
871
|
-
* Returns the value of an attribute
|
|
872
|
-
* @param attributeName
|
|
873
|
-
* @return Value of the attributeName or null
|
|
874
|
-
*/
|
|
875
|
-
getAttribute(attributeName) {
|
|
876
|
-
const attribute = this.attributes.find((val) => val.name === attributeName);
|
|
877
|
-
if (attribute) return attribute.value;
|
|
878
|
-
return null;
|
|
879
|
-
}
|
|
880
|
-
/**
|
|
881
|
-
* Check if a dataVariable exists
|
|
882
|
-
* @param variableName - Name of the variable to find
|
|
883
|
-
* @return
|
|
884
|
-
*/
|
|
885
|
-
dataVariableExists(variableName) {
|
|
886
|
-
const variable = this.header.variables.find(function(val) {
|
|
887
|
-
return val.name === variableName;
|
|
888
|
-
});
|
|
889
|
-
return variable !== void 0;
|
|
890
|
-
}
|
|
891
|
-
/**
|
|
892
|
-
* Returns the value of a variable as a string
|
|
893
|
-
* @param variableName
|
|
894
|
-
* @return Value of the variable as a string or null
|
|
895
|
-
*/
|
|
896
|
-
getDataVariableAsString(variableName) {
|
|
897
|
-
const variable = this.getDataVariable(variableName);
|
|
898
|
-
if (variable) return variable.join("");
|
|
899
|
-
return null;
|
|
900
|
-
}
|
|
901
|
-
/**
|
|
902
|
-
* Retrieves the data for a given variable
|
|
903
|
-
* @param variableName - Name of the variable to search or variable object
|
|
904
|
-
* @return List with the variable values
|
|
905
|
-
*/
|
|
906
|
-
getDataVariable(variableName) {
|
|
907
|
-
let variable;
|
|
908
|
-
if (typeof variableName === "string") {
|
|
909
|
-
variable = this.header.variables.find(function(val) {
|
|
910
|
-
return val.name === variableName;
|
|
911
|
-
});
|
|
912
|
-
} else {
|
|
913
|
-
variable = variableName;
|
|
914
|
-
}
|
|
915
|
-
if (variable === void 0) {
|
|
916
|
-
let errorOutput;
|
|
917
|
-
if (typeof variableName === "string") {
|
|
918
|
-
errorOutput = variableName;
|
|
919
|
-
} else if (typeof variableName === "object") {
|
|
920
|
-
errorOutput = JSON.stringify(variableName);
|
|
921
|
-
}
|
|
922
|
-
throw new Error(`NetCDF: variable not found: ${errorOutput}`);
|
|
923
|
-
}
|
|
924
|
-
this.buffer.seek(variable.offset);
|
|
925
|
-
if (variable.record) {
|
|
926
|
-
return readRecord(this.buffer, variable, this.header.recordDimension, this.header.dimensions);
|
|
927
|
-
}
|
|
928
|
-
return readNonRecord(this.buffer, variable);
|
|
929
|
-
}
|
|
930
|
-
toString() {
|
|
931
|
-
const result = [];
|
|
932
|
-
result.push("DIMENSIONS");
|
|
933
|
-
for (const dimension of this.dimensions) {
|
|
934
|
-
result.push(` ${dimension.name.padEnd(30)} = size: ${dimension.size}`);
|
|
935
|
-
}
|
|
936
|
-
result.push("");
|
|
937
|
-
result.push("GLOBAL ATTRIBUTES");
|
|
938
|
-
for (const attribute of this.attributes) {
|
|
939
|
-
result.push(` ${attribute.name.padEnd(30)} = ${attribute.value}`);
|
|
940
|
-
}
|
|
941
|
-
const variables = JSON.parse(JSON.stringify(this.variables));
|
|
942
|
-
result.push("");
|
|
943
|
-
result.push("VARIABLES:");
|
|
944
|
-
for (const variable of variables) {
|
|
945
|
-
variable.value = this.getDataVariable(variable);
|
|
946
|
-
let stringify = JSON.stringify(variable.value);
|
|
947
|
-
if (stringify.length > 50) stringify = stringify.substring(0, 50);
|
|
948
|
-
if (!Number.isNaN(variable.value.length)) {
|
|
949
|
-
stringify += ` (length: ${variable.value.length})`;
|
|
950
|
-
}
|
|
951
|
-
result.push(` ${variable.name.padEnd(30)} = ${stringify}`);
|
|
952
|
-
}
|
|
953
|
-
return result.join("\n");
|
|
954
|
-
}
|
|
955
|
-
};
|
|
956
|
-
}
|
|
957
|
-
});
|
|
958
|
-
|
|
959
|
-
// src/netcdf/netcdf-format.ts
|
|
960
|
-
var NetCDFFormat2;
|
|
961
|
-
var init_netcdf_format = __esm({
|
|
962
|
-
"src/netcdf/netcdf-format.ts"() {
|
|
963
|
-
"use strict";
|
|
964
|
-
NetCDFFormat2 = {
|
|
965
|
-
name: "NetCDF",
|
|
966
|
-
id: "netcdf",
|
|
967
|
-
module: "netcdf",
|
|
968
|
-
encoding: "binary",
|
|
969
|
-
format: "netcdf",
|
|
970
|
-
extensions: ["cdf", "nc"],
|
|
971
|
-
mimeTypes: ["application/x-netcdf"],
|
|
972
|
-
binary: true
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
});
|
|
976
|
-
|
|
977
|
-
// src/netcdf/netcdf-loader.ts
|
|
978
|
-
async function preload() {
|
|
979
|
-
const { NetCDFLoaderWithParser: NetCDFLoaderWithParser2 } = await Promise.resolve().then(() => (init_netcdf_loader_with_parser(), netcdf_loader_with_parser_exports));
|
|
980
|
-
return NetCDFLoaderWithParser2;
|
|
981
|
-
}
|
|
982
|
-
var VERSION, NetCDFLoader, NetCDFWorkerLoader;
|
|
983
|
-
var init_netcdf_loader = __esm({
|
|
984
|
-
"src/netcdf/netcdf-loader.ts"() {
|
|
985
|
-
"use strict";
|
|
986
|
-
init_netcdf_format();
|
|
987
|
-
VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
988
|
-
NetCDFLoader = {
|
|
989
|
-
...NetCDFFormat2,
|
|
990
|
-
dataType: null,
|
|
991
|
-
batchType: null,
|
|
992
|
-
name: "NetCDF",
|
|
993
|
-
id: "mvt",
|
|
994
|
-
module: "scientific",
|
|
995
|
-
version: VERSION,
|
|
996
|
-
extensions: ["cdf", "nc"],
|
|
997
|
-
mimeTypes: [
|
|
998
|
-
"application/netcdf",
|
|
999
|
-
"application/x-netcdf"
|
|
1000
|
-
// 'application/octet-stream'
|
|
1001
|
-
],
|
|
1002
|
-
category: "image",
|
|
1003
|
-
binary: true,
|
|
1004
|
-
options: {
|
|
1005
|
-
netcdf: {
|
|
1006
|
-
loadVariables: false
|
|
1007
|
-
}
|
|
1008
|
-
},
|
|
1009
|
-
preload
|
|
1010
|
-
};
|
|
1011
|
-
NetCDFWorkerLoader = NetCDFLoader;
|
|
1012
|
-
}
|
|
1013
|
-
});
|
|
1014
|
-
|
|
1015
|
-
// src/netcdf/netcdf-loader-with-parser.ts
|
|
1016
|
-
var netcdf_loader_with_parser_exports = {};
|
|
1017
|
-
__export(netcdf_loader_with_parser_exports, {
|
|
1018
|
-
NetCDFLoaderWithParser: () => NetCDFLoaderWithParser,
|
|
1019
|
-
NetCDFWorkerLoaderWithParser: () => NetCDFWorkerLoaderWithParser
|
|
1020
|
-
});
|
|
1021
|
-
function parseNetCDF(arrayBuffer, options) {
|
|
1022
|
-
var _a;
|
|
1023
|
-
const reader = new NetCDFReader(arrayBuffer);
|
|
1024
|
-
const variables = {};
|
|
1025
|
-
if ((_a = options == null ? void 0 : options.netcdf) == null ? void 0 : _a.loadData) {
|
|
1026
|
-
for (const variable of reader.variables) {
|
|
1027
|
-
variables[variable.name] = reader.getDataVariable(variable);
|
|
1028
|
-
}
|
|
1029
|
-
}
|
|
1030
|
-
return {
|
|
1031
|
-
loaderData: reader.header,
|
|
1032
|
-
data: variables
|
|
1033
|
-
};
|
|
1034
|
-
}
|
|
1035
|
-
var _NetCDFWorkerLoaderPreload, NetCDFWorkerLoaderMetadataWithoutPreload, _NetCDFLoaderPreload, NetCDFLoaderMetadataWithoutPreload, NetCDFWorkerLoaderWithParser, NetCDFLoaderWithParser;
|
|
1036
|
-
var init_netcdf_loader_with_parser = __esm({
|
|
1037
|
-
"src/netcdf/netcdf-loader-with-parser.ts"() {
|
|
1038
|
-
"use strict";
|
|
1039
|
-
init_netcdf_reader();
|
|
1040
|
-
init_netcdf_loader();
|
|
1041
|
-
init_netcdf_loader();
|
|
1042
|
-
({ preload: _NetCDFWorkerLoaderPreload, ...NetCDFWorkerLoaderMetadataWithoutPreload } = NetCDFWorkerLoader);
|
|
1043
|
-
({ preload: _NetCDFLoaderPreload, ...NetCDFLoaderMetadataWithoutPreload } = NetCDFLoader);
|
|
1044
|
-
NetCDFWorkerLoaderWithParser = {
|
|
1045
|
-
...NetCDFWorkerLoaderMetadataWithoutPreload
|
|
1046
|
-
};
|
|
1047
|
-
NetCDFLoaderWithParser = {
|
|
1048
|
-
...NetCDFLoaderMetadataWithoutPreload,
|
|
1049
|
-
parse: async (arrayBuffer, options) => parseNetCDF(arrayBuffer, options)
|
|
1050
|
-
};
|
|
1051
|
-
}
|
|
1052
|
-
});
|
|
1053
|
-
|
|
1054
|
-
// ../core/src/loader-utils/lib/log-utils/log.ts
|
|
1055
|
-
function createLog() {
|
|
1056
|
-
const log2 = new import_log.Log({ id: "loaders.gl" });
|
|
1057
|
-
globalThis.loaders ||= {};
|
|
1058
|
-
globalThis.loaders.log = log2;
|
|
1059
|
-
globalThis.loaders.version = version;
|
|
1060
|
-
globalThis.probe ||= {};
|
|
1061
|
-
globalThis.probe.loaders = log2;
|
|
1062
|
-
return log2;
|
|
1063
|
-
}
|
|
1064
|
-
var import_log, VERSION3, version, log;
|
|
1065
|
-
var init_log = __esm({
|
|
1066
|
-
"../core/src/loader-utils/lib/log-utils/log.ts"() {
|
|
1067
|
-
"use strict";
|
|
1068
|
-
import_log = require("probe.gl/log");
|
|
1069
|
-
VERSION3 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
1070
|
-
version = VERSION3[0] >= "0" && VERSION3[0] <= "9" ? `v${VERSION3}` : "";
|
|
1071
|
-
log = createLog();
|
|
1072
|
-
}
|
|
1073
|
-
});
|
|
1074
|
-
|
|
1075
|
-
// ../core/src/loader-utils/lib/javascript-utils/is-type.ts
|
|
1076
|
-
var isObject, isPureObject;
|
|
1077
|
-
var init_is_type = __esm({
|
|
1078
|
-
"../core/src/loader-utils/lib/javascript-utils/is-type.ts"() {
|
|
1079
|
-
"use strict";
|
|
1080
|
-
isObject = (value) => value !== null && typeof value === "object";
|
|
1081
|
-
isPureObject = (value) => isObject(value) && value.constructor === {}.constructor;
|
|
1082
|
-
}
|
|
1083
|
-
});
|
|
1084
|
-
|
|
1085
|
-
// ../core/src/loader-utils/lib/option-utils/merge-options.ts
|
|
1086
|
-
function mergeOptions(baseOptions, newOptions) {
|
|
1087
|
-
return mergeOptionsRecursively(baseOptions || {}, newOptions);
|
|
1088
|
-
}
|
|
1089
|
-
function mergeOptionsRecursively(baseOptions, newOptions, level = 0) {
|
|
1090
|
-
if (level > 3) {
|
|
1091
|
-
return newOptions;
|
|
1092
|
-
}
|
|
1093
|
-
const options = { ...baseOptions };
|
|
1094
|
-
for (const [key, newValue] of Object.entries(newOptions)) {
|
|
1095
|
-
if (isPureObject(newValue)) {
|
|
1096
|
-
options[key] = mergeOptionsRecursively(
|
|
1097
|
-
options[key] || {},
|
|
1098
|
-
newOptions[key],
|
|
1099
|
-
level + 1
|
|
1100
|
-
);
|
|
1101
|
-
} else {
|
|
1102
|
-
options[key] = newOptions[key];
|
|
1103
|
-
}
|
|
1104
|
-
}
|
|
1105
|
-
return options;
|
|
1106
|
-
}
|
|
1107
|
-
var init_merge_options = __esm({
|
|
1108
|
-
"../core/src/loader-utils/lib/option-utils/merge-options.ts"() {
|
|
1109
|
-
"use strict";
|
|
1110
|
-
init_is_type();
|
|
1111
|
-
}
|
|
1112
|
-
});
|
|
1113
|
-
|
|
1114
|
-
// ../core/src/loader-utils/lib/request-utils/authentication.ts
|
|
1115
|
-
function resolveCredentials(credentials, authentications = []) {
|
|
1116
|
-
if (credentials.every(isAuthentication)) return credentials;
|
|
1117
|
-
return credentials.map((credential, index) => {
|
|
1118
|
-
if (isAuthentication(credential)) return credential;
|
|
1119
|
-
const AuthenticationClass = authentications.find(
|
|
1120
|
-
(authentication2) => authentication2.type === (credential == null ? void 0 : credential.type)
|
|
1121
|
-
);
|
|
1122
|
-
if (!AuthenticationClass) {
|
|
1123
|
-
throw new Error(`No authentication class registered for credential at index ${index}.`);
|
|
1124
|
-
}
|
|
1125
|
-
let authentication;
|
|
1126
|
-
try {
|
|
1127
|
-
authentication = new AuthenticationClass(credential);
|
|
1128
|
-
} catch {
|
|
1129
|
-
throw new Error(`Invalid authentication configuration at index ${index}.`);
|
|
1130
|
-
}
|
|
1131
|
-
if (!isAuthentication(authentication)) {
|
|
1132
|
-
throw new Error(`Authentication class returned an invalid credential at index ${index}.`);
|
|
1133
|
-
}
|
|
1134
|
-
return authentication;
|
|
1135
|
-
});
|
|
1136
|
-
}
|
|
1137
|
-
function resolveAuthenticationOptions(options) {
|
|
1138
|
-
var _a, _b;
|
|
1139
|
-
if (!((_b = (_a = options.core) == null ? void 0 : _a.credentials) == null ? void 0 : _b.length)) return options;
|
|
1140
|
-
const credentials = resolveCredentials(options.core.credentials, options.core.authentications);
|
|
1141
|
-
if (credentials === options.core.credentials) return options;
|
|
1142
|
-
return { ...options, core: { ...options.core, credentials } };
|
|
1143
|
-
}
|
|
1144
|
-
function isAuthentication(credential) {
|
|
1145
|
-
if (!credential || typeof credential !== "object") return false;
|
|
1146
|
-
if (typeof credential.id !== "string" || !Array.isArray(credential.origins)) return false;
|
|
1147
|
-
if (credential.type === "request") return typeof credential.authenticate === "function";
|
|
1148
|
-
return (credential.type === "header" || credential.type === "query-parameter") && typeof credential.name === "string" && (typeof credential.token === "string" || typeof credential.token === "function") && Array.isArray(credential.refreshStatusCodes);
|
|
1149
|
-
}
|
|
1150
|
-
var init_authentication = __esm({
|
|
1151
|
-
"../core/src/loader-utils/lib/request-utils/authentication.ts"() {
|
|
1152
|
-
"use strict";
|
|
1153
|
-
}
|
|
1154
|
-
});
|
|
1155
|
-
|
|
1156
|
-
// ../core/src/loader-utils/lib/request-utils/request-credentials.ts
|
|
1157
|
-
function createAuthenticatedFetch(options) {
|
|
1158
|
-
const suppliedFetch = options.fetch || ((url, requestOptions) => fetch(url, requestOptions));
|
|
1159
|
-
const existingMetadata = suppliedFetch[AUTHENTICATED_FETCH];
|
|
1160
|
-
const credentialResolutions = new Map(existingMetadata == null ? void 0 : existingMetadata.credentialResolutions);
|
|
1161
|
-
const resolvedCredentials = resolveCredentials(
|
|
1162
|
-
options.credentials.map((credential) => credentialResolutions.get(credential) || credential),
|
|
1163
|
-
options.authentications
|
|
1164
|
-
);
|
|
1165
|
-
options.credentials.forEach((credential, index) => {
|
|
1166
|
-
credentialResolutions.set(credential, resolvedCredentials[index]);
|
|
1167
|
-
});
|
|
1168
|
-
if (!options.fetchOptions && (!resolvedCredentials.length || (existingMetadata == null ? void 0 : existingMetadata.credentials.length) === resolvedCredentials.length && resolvedCredentials.every(
|
|
1169
|
-
(credential, index) => credential === existingMetadata.credentials[index]
|
|
1170
|
-
)))
|
|
1171
|
-
return suppliedFetch;
|
|
1172
|
-
const baseFetch = (existingMetadata == null ? void 0 : existingMetadata.fetch) || suppliedFetch;
|
|
1173
|
-
const credentials = existingMetadata ? [.../* @__PURE__ */ new Set([...resolvedCredentials, ...existingMetadata.credentials])] : resolvedCredentials;
|
|
1174
|
-
const fetchOptions = mergeFetchOptions(
|
|
1175
|
-
(existingMetadata == null ? void 0 : existingMetadata.fetchOptions) || {},
|
|
1176
|
-
options.fetchOptions
|
|
1177
|
-
);
|
|
1178
|
-
const tokenCredentials = credentials.filter(
|
|
1179
|
-
(credential) => credential.type !== "request"
|
|
1180
|
-
);
|
|
1181
|
-
const requestCredentials = credentials.filter(
|
|
1182
|
-
(credential) => credential.type === "request"
|
|
1183
|
-
);
|
|
1184
|
-
for (const credential of requestCredentials) normalizeRequestOrigins(credential.origins);
|
|
1185
|
-
const authenticatedFetch = async (url, requestOptions = {}) => {
|
|
1186
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
1187
|
-
requestOptions = mergeFetchOptions(fetchOptions, requestOptions);
|
|
1188
|
-
(_a = requestOptions.signal) == null ? void 0 : _a.throwIfAborted();
|
|
1189
|
-
if (!credentials.length) return baseFetch(url, requestOptions);
|
|
1190
|
-
const resolvedURL = parseHTTPURL(url);
|
|
1191
|
-
const authorization = resolvedURL ? await authorizeRequest(resolvedURL, requestOptions, tokenCredentials) : { url, options: requestOptions, credentials: [] };
|
|
1192
|
-
const signedRequest = await authenticateRequest(authorization, requestCredentials, "request");
|
|
1193
|
-
const response = await baseFetch(signedRequest.url, signedRequest.options);
|
|
1194
|
-
const refreshableCredentials = [];
|
|
1195
|
-
for (const resolvedCredential of authorization.credentials) {
|
|
1196
|
-
const { credential } = resolvedCredential;
|
|
1197
|
-
if (typeof credential.token === "function" && (isReplayableRequest(requestOptions) || ((_b = credential.canReplayRequest) == null ? void 0 : _b.call(credential, url, requestOptions))) && (isReplayableRequest(signedRequest.options) || ((_c = credential.canReplayRequest) == null ? void 0 : _c.call(credential, signedRequest.url, signedRequest.options))) && (credential.refreshStatusCodes.includes(response.status) || await ((_d = credential.shouldRefresh) == null ? void 0 : _d.call(credential, response))))
|
|
1198
|
-
refreshableCredentials.push(resolvedCredential);
|
|
1199
|
-
}
|
|
1200
|
-
const shouldRetrySignature = isReplayableRequest(requestOptions) && isReplayableRequest(signedRequest.options) && signedRequest.credentials.some(
|
|
1201
|
-
(credential) => {
|
|
1202
|
-
var _a2;
|
|
1203
|
-
return (_a2 = credential.refreshStatusCodes) == null ? void 0 : _a2.includes(response.status);
|
|
1204
|
-
}
|
|
1205
|
-
);
|
|
1206
|
-
if (!refreshableCredentials.length && !shouldRetrySignature) return response;
|
|
1207
|
-
(_e = requestOptions.signal) == null ? void 0 : _e.throwIfAborted();
|
|
1208
|
-
const refreshedTokens = /* @__PURE__ */ new Map();
|
|
1209
|
-
await Promise.all(
|
|
1210
|
-
refreshableCredentials.map(async ({ credential }) => {
|
|
1211
|
-
const token = await refreshCredential(credential, url, response);
|
|
1212
|
-
if (token) refreshedTokens.set(credential, token);
|
|
1213
|
-
})
|
|
1214
|
-
);
|
|
1215
|
-
if (!refreshedTokens.size && !shouldRetrySignature) return response;
|
|
1216
|
-
await ((_f = response.body) == null ? void 0 : _f.cancel().catch(() => {
|
|
1217
|
-
}));
|
|
1218
|
-
(_g = requestOptions.signal) == null ? void 0 : _g.throwIfAborted();
|
|
1219
|
-
const replayAuthorization = resolvedURL ? await authorizeRequest(
|
|
1220
|
-
resolvedURL,
|
|
1221
|
-
requestOptions,
|
|
1222
|
-
tokenCredentials,
|
|
1223
|
-
refreshedTokens,
|
|
1224
|
-
authorization.credentials
|
|
1225
|
-
) : { url, options: requestOptions };
|
|
1226
|
-
const replayRequest = await authenticateRequest(
|
|
1227
|
-
replayAuthorization,
|
|
1228
|
-
requestCredentials,
|
|
1229
|
-
"retry",
|
|
1230
|
-
response
|
|
1231
|
-
);
|
|
1232
|
-
return baseFetch(replayRequest.url, replayRequest.options);
|
|
1233
|
-
};
|
|
1234
|
-
Object.defineProperty(authenticatedFetch, AUTHENTICATED_FETCH, {
|
|
1235
|
-
value: {
|
|
1236
|
-
fetch: baseFetch,
|
|
1237
|
-
credentials,
|
|
1238
|
-
credentialResolutions,
|
|
1239
|
-
fetchOptions
|
|
1240
|
-
}
|
|
1241
|
-
});
|
|
1242
|
-
return authenticatedFetch;
|
|
1243
|
-
}
|
|
1244
|
-
function getAuthenticatedFetch(options = {}) {
|
|
1245
|
-
var _a, _b, _c;
|
|
1246
|
-
const fetchOption = options.fetch ?? ((_a = options.core) == null ? void 0 : _a.fetch);
|
|
1247
|
-
let fetchFunction;
|
|
1248
|
-
if (typeof fetchOption === "function") {
|
|
1249
|
-
fetchFunction = fetchOption;
|
|
1250
|
-
} else {
|
|
1251
|
-
fetchFunction = (url, requestOptions) => fetch(url, requestOptions);
|
|
1252
|
-
}
|
|
1253
|
-
const fetchOptions = typeof fetchOption === "object" && fetchOption ? fetchOption : void 0;
|
|
1254
|
-
return createAuthenticatedFetch({
|
|
1255
|
-
fetch: fetchFunction,
|
|
1256
|
-
fetchOptions: options.signal ? { ...fetchOptions, signal: options.signal } : fetchOptions,
|
|
1257
|
-
credentials: ((_b = options.core) == null ? void 0 : _b.credentials) || [],
|
|
1258
|
-
authentications: (_c = options.core) == null ? void 0 : _c.authentications
|
|
1259
|
-
});
|
|
1260
|
-
}
|
|
1261
|
-
function mergeFetchOptions(defaultOptions, requestOptions) {
|
|
1262
|
-
const mergedOptions = { ...defaultOptions, ...requestOptions };
|
|
1263
|
-
if (defaultOptions.headers || (requestOptions == null ? void 0 : requestOptions.headers)) {
|
|
1264
|
-
const headers = new Headers(defaultOptions.headers);
|
|
1265
|
-
new Headers(requestOptions == null ? void 0 : requestOptions.headers).forEach((value, key) => headers.set(key, value));
|
|
1266
|
-
mergedOptions.headers = headers;
|
|
1267
|
-
}
|
|
1268
|
-
return mergedOptions;
|
|
1269
|
-
}
|
|
1270
|
-
async function authenticateRequest(request, credentials, reason, response) {
|
|
1271
|
-
const appliedCredentials = [];
|
|
1272
|
-
const signal = request.options.signal;
|
|
1273
|
-
for (const credential of credentials) {
|
|
1274
|
-
const origin = getRequestOrigin(request.url);
|
|
1275
|
-
if (!origin || !normalizeRequestOrigins(credential.origins).includes(origin)) continue;
|
|
1276
|
-
signal == null ? void 0 : signal.throwIfAborted();
|
|
1277
|
-
const authenticatedRequest = await credential.authenticate({
|
|
1278
|
-
url: request.url,
|
|
1279
|
-
options: { ...request.options, headers: new Headers(request.options.headers) },
|
|
1280
|
-
reason,
|
|
1281
|
-
response: response ? { status: response.status, headers: new Headers(response.headers) } : void 0
|
|
1282
|
-
});
|
|
1283
|
-
if (!authenticatedRequest || typeof authenticatedRequest.url !== "string" || !authenticatedRequest.options || typeof authenticatedRequest.options !== "object") {
|
|
1284
|
-
throw new Error("Authentication callback returned an invalid request.");
|
|
1285
|
-
}
|
|
1286
|
-
request = {
|
|
1287
|
-
url: authenticatedRequest.url,
|
|
1288
|
-
options: { ...authenticatedRequest.options, ...signal ? { signal } : {} }
|
|
1289
|
-
};
|
|
1290
|
-
appliedCredentials.push(credential);
|
|
1291
|
-
}
|
|
1292
|
-
signal == null ? void 0 : signal.throwIfAborted();
|
|
1293
|
-
return { ...request, credentials: appliedCredentials };
|
|
1294
|
-
}
|
|
1295
|
-
function getRequestOrigin(url) {
|
|
1296
|
-
try {
|
|
1297
|
-
const parsedURL = new URL(url);
|
|
1298
|
-
if (!parsedURL.host || parsedURL.username || parsedURL.password) return null;
|
|
1299
|
-
return parsedURL.origin !== "null" ? parsedURL.origin : `${parsedURL.protocol}//${parsedURL.host}`;
|
|
1300
|
-
} catch {
|
|
1301
|
-
return null;
|
|
1302
|
-
}
|
|
1303
|
-
}
|
|
1304
|
-
function normalizeRequestOrigins(origins) {
|
|
1305
|
-
if (!origins.length)
|
|
1306
|
-
throw new Error("Request authentication requires at least one exact origin.");
|
|
1307
|
-
return origins.map((origin) => {
|
|
1308
|
-
const resolvedOrigin = getRequestOrigin(origin);
|
|
1309
|
-
let url;
|
|
1310
|
-
try {
|
|
1311
|
-
url = new URL(origin);
|
|
1312
|
-
} catch {
|
|
1313
|
-
throw new Error("Invalid request authentication origin.");
|
|
1314
|
-
}
|
|
1315
|
-
if (!resolvedOrigin || url.pathname && url.pathname !== "/" || url.search || url.hash) {
|
|
1316
|
-
throw new Error("Invalid request authentication origin.");
|
|
1317
|
-
}
|
|
1318
|
-
return resolvedOrigin;
|
|
1319
|
-
});
|
|
1320
|
-
}
|
|
1321
|
-
async function authorizeRequest(sourceURL, requestOptions, credentials, tokenOverrides = /* @__PURE__ */ new Map(), previousCredentials = []) {
|
|
1322
|
-
const url = new URL(sourceURL);
|
|
1323
|
-
const headers = new Headers(requestOptions.headers);
|
|
1324
|
-
const resolvedCredentials = [];
|
|
1325
|
-
const previousTokens = new Map(
|
|
1326
|
-
previousCredentials.map(({ credential, token }) => [credential, token])
|
|
1327
|
-
);
|
|
1328
|
-
for (const credential of credentials) {
|
|
1329
|
-
if (!credential.origins.includes(url.origin)) continue;
|
|
1330
|
-
const overrideToken = tokenOverrides.get(credential);
|
|
1331
|
-
const previousToken = previousTokens.get(credential);
|
|
1332
|
-
const ownsQueryParameter = credential.type === "query-parameter" && previousToken !== void 0;
|
|
1333
|
-
const ownsHeader = credential.type === "header" && previousToken !== void 0;
|
|
1334
|
-
if (credential.type === "query-parameter" && url.searchParams.has(credential.name) && !ownsQueryParameter || credential.type === "header" && headers.has(credential.name) && !ownsHeader) {
|
|
1335
|
-
continue;
|
|
1336
|
-
}
|
|
1337
|
-
const token = overrideToken ?? previousToken ?? await resolveToken(credential.token, { url: sourceURL.toString(), reason: "request" });
|
|
1338
|
-
if (!token) continue;
|
|
1339
|
-
if (credential.type === "query-parameter") {
|
|
1340
|
-
url.searchParams.set(credential.name, token);
|
|
1341
|
-
} else {
|
|
1342
|
-
headers.set(credential.name, `${credential.prefix || ""}${token}`);
|
|
1343
|
-
}
|
|
1344
|
-
resolvedCredentials.push({ credential, token });
|
|
1345
|
-
}
|
|
1346
|
-
return {
|
|
1347
|
-
url: url.toString(),
|
|
1348
|
-
options: { ...requestOptions, headers },
|
|
1349
|
-
credentials: resolvedCredentials
|
|
1350
|
-
};
|
|
1351
|
-
}
|
|
1352
|
-
async function refreshCredential(credential, url, response) {
|
|
1353
|
-
const existingPromise = refreshPromises.get(credential);
|
|
1354
|
-
if (existingPromise) return existingPromise;
|
|
1355
|
-
const tokenProvider = credential.token;
|
|
1356
|
-
const promise = Promise.resolve(
|
|
1357
|
-
tokenProvider({
|
|
1358
|
-
url,
|
|
1359
|
-
reason: "refresh",
|
|
1360
|
-
response: { status: response.status, headers: response.headers }
|
|
1361
|
-
})
|
|
1362
|
-
).finally(() => refreshPromises.delete(credential));
|
|
1363
|
-
refreshPromises.set(credential, promise);
|
|
1364
|
-
return promise;
|
|
1365
|
-
}
|
|
1366
|
-
async function resolveToken(token, context) {
|
|
1367
|
-
return typeof token === "function" ? token(context) : token;
|
|
1368
|
-
}
|
|
1369
|
-
function parseHTTPURL(url) {
|
|
1370
|
-
try {
|
|
1371
|
-
const parsedURL = new URL(url);
|
|
1372
|
-
return ["http:", "https:"].includes(parsedURL.protocol) ? parsedURL : null;
|
|
1373
|
-
} catch {
|
|
1374
|
-
return null;
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
function isReplayableRequest(options) {
|
|
1378
|
-
const method = (options.method || "GET").toUpperCase();
|
|
1379
|
-
if (!["GET", "HEAD", "OPTIONS", "PUT", "DELETE"].includes(method)) return false;
|
|
1380
|
-
return !(options.body && typeof ReadableStream !== "undefined" && options.body instanceof ReadableStream);
|
|
1381
|
-
}
|
|
1382
|
-
var AUTHENTICATED_FETCH, refreshPromises;
|
|
1383
|
-
var init_request_credentials = __esm({
|
|
1384
|
-
"../core/src/loader-utils/lib/request-utils/request-credentials.ts"() {
|
|
1385
|
-
"use strict";
|
|
1386
|
-
init_authentication();
|
|
1387
|
-
AUTHENTICATED_FETCH = /* @__PURE__ */ Symbol("loaders.gl.authenticated-fetch");
|
|
1388
|
-
refreshPromises = /* @__PURE__ */ new WeakMap();
|
|
1389
|
-
}
|
|
1390
|
-
});
|
|
1391
|
-
|
|
1392
|
-
// ../core/src/loader-utils/lib/path-utils/file-aliases.ts
|
|
1393
|
-
function resolvePath(filename) {
|
|
1394
|
-
for (const alias in fileAliases) {
|
|
1395
|
-
if (filename.startsWith(alias)) {
|
|
1396
|
-
const replacement = fileAliases[alias];
|
|
1397
|
-
filename = filename.replace(alias, replacement);
|
|
1398
|
-
}
|
|
1399
|
-
}
|
|
1400
|
-
if (!filename.startsWith("http://") && !filename.startsWith("https://")) {
|
|
1401
|
-
filename = `${pathPrefix}${filename}`;
|
|
1402
|
-
}
|
|
1403
|
-
return filename;
|
|
1404
|
-
}
|
|
1405
|
-
var pathPrefix, fileAliases;
|
|
1406
|
-
var init_file_aliases = __esm({
|
|
1407
|
-
"../core/src/loader-utils/lib/path-utils/file-aliases.ts"() {
|
|
1408
|
-
"use strict";
|
|
1409
|
-
pathPrefix = "";
|
|
1410
|
-
fileAliases = {};
|
|
1411
|
-
}
|
|
1412
|
-
});
|
|
1413
|
-
|
|
1414
|
-
// ../core/src/loader-utils/lib/sources/data-source.ts
|
|
1415
|
-
function getFetchFunction(options) {
|
|
1416
|
-
return getAuthenticatedFetch(options);
|
|
1417
|
-
}
|
|
1418
|
-
function getSourceLoaderOptions(options) {
|
|
1419
|
-
var _a;
|
|
1420
|
-
if (options.loadOptions !== void 0 || ((_a = options.core) == null ? void 0 : _a.loadOptions) !== void 0) {
|
|
1421
|
-
throw new Error(
|
|
1422
|
-
"Source loadOptions and core.loadOptions were removed. Use core and root loader namespaces directly."
|
|
1423
|
-
);
|
|
1424
|
-
}
|
|
1425
|
-
const loadOptions = { ...options };
|
|
1426
|
-
if (options == null ? void 0 : options.core) {
|
|
1427
|
-
loadOptions.core = { ...options.core };
|
|
1428
|
-
const parserCore = loadOptions.core;
|
|
1429
|
-
for (const key of ["type", "attributions", "loaders", "onError", "loadOptions"]) {
|
|
1430
|
-
delete parserCore[key];
|
|
1431
|
-
}
|
|
1432
|
-
if (Object.keys(parserCore).length === 0) {
|
|
1433
|
-
delete loadOptions.core;
|
|
1434
|
-
}
|
|
1435
|
-
}
|
|
1436
|
-
const topLevelBaseUri = typeof loadOptions.baseUri === "string" ? loadOptions.baseUri : void 0;
|
|
1437
|
-
const topLevelBaseUrl = typeof loadOptions.baseUrl === "string" ? loadOptions.baseUrl : void 0;
|
|
1438
|
-
if (topLevelBaseUri !== void 0 || topLevelBaseUrl !== void 0) {
|
|
1439
|
-
loadOptions.core ||= {};
|
|
1440
|
-
if (loadOptions.core.baseUrl === void 0) {
|
|
1441
|
-
loadOptions.core.baseUrl = topLevelBaseUrl ?? topLevelBaseUri;
|
|
1442
|
-
}
|
|
1443
|
-
delete loadOptions.baseUri;
|
|
1444
|
-
delete loadOptions.baseUrl;
|
|
1445
|
-
}
|
|
1446
|
-
return loadOptions;
|
|
1447
|
-
}
|
|
1448
|
-
function normalizeError(error, message) {
|
|
1449
|
-
if (error instanceof Error) {
|
|
1450
|
-
return error;
|
|
1451
|
-
}
|
|
1452
|
-
if (typeof error === "string") {
|
|
1453
|
-
return new Error(error);
|
|
1454
|
-
}
|
|
1455
|
-
return new Error(message);
|
|
1456
|
-
}
|
|
1457
|
-
function unavailableCoreApiMethod(methodName) {
|
|
1458
|
-
return () => {
|
|
1459
|
-
throw new Error(
|
|
1460
|
-
`CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.createDataSource().`
|
|
1461
|
-
);
|
|
1462
|
-
};
|
|
1463
|
-
}
|
|
1464
|
-
var UNAVAILABLE_CORE_API, DataSource;
|
|
1465
|
-
var init_data_source = __esm({
|
|
1466
|
-
"../core/src/loader-utils/lib/sources/data-source.ts"() {
|
|
1467
|
-
"use strict";
|
|
1468
|
-
init_merge_options();
|
|
1469
|
-
init_file_aliases();
|
|
1470
|
-
init_log();
|
|
1471
|
-
init_request_credentials();
|
|
1472
|
-
init_authentication();
|
|
1473
|
-
UNAVAILABLE_CORE_API = {
|
|
1474
|
-
fetchFile: unavailableCoreApiMethod("fetchFile"),
|
|
1475
|
-
parse: unavailableCoreApiMethod("parse"),
|
|
1476
|
-
parseFile: unavailableCoreApiMethod("parseFile"),
|
|
1477
|
-
parseSync: unavailableCoreApiMethod("parseSync"),
|
|
1478
|
-
parseInBatches: unavailableCoreApiMethod("parseInBatches"),
|
|
1479
|
-
load: unavailableCoreApiMethod("load"),
|
|
1480
|
-
loadInBatches: unavailableCoreApiMethod("loadInBatches")
|
|
1481
|
-
};
|
|
1482
|
-
DataSource = class _DataSource {
|
|
1483
|
-
static defaultOptions = {
|
|
1484
|
-
core: {
|
|
1485
|
-
type: "auto",
|
|
1486
|
-
attributions: [],
|
|
1487
|
-
loaders: [],
|
|
1488
|
-
onError: void 0
|
|
1489
|
-
}
|
|
1490
|
-
};
|
|
1491
|
-
optionsType;
|
|
1492
|
-
options;
|
|
1493
|
-
data;
|
|
1494
|
-
url;
|
|
1495
|
-
/** Shared parser options derived from the source options, excluding source-only core controls. */
|
|
1496
|
-
loadOptions;
|
|
1497
|
-
/** A resolved fetch function extracted from the shared core options. */
|
|
1498
|
-
fetch;
|
|
1499
|
-
/** Shared source-level runtime hooks, when supplied by the source factory. */
|
|
1500
|
-
coreApi;
|
|
1501
|
-
/** Whether a real CoreAPI instance was injected by the integration layer. */
|
|
1502
|
-
hasCoreApi;
|
|
1503
|
-
_needsRefresh = true;
|
|
1504
|
-
constructor(data, options, defaultOptions, coreApi) {
|
|
1505
|
-
this.options = mergeOptions(
|
|
1506
|
-
mergeOptions(_DataSource.defaultOptions, defaultOptions || {}),
|
|
1507
|
-
options
|
|
1508
|
-
);
|
|
1509
|
-
this.data = data;
|
|
1510
|
-
this.url = typeof data === "string" ? resolvePath(data) : "";
|
|
1511
|
-
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
|
|
1512
|
-
this.loadOptions = loadOptions;
|
|
1513
|
-
const fetch2 = getFetchFunction(loadOptions);
|
|
1514
|
-
this.coreApi = coreApi || UNAVAILABLE_CORE_API;
|
|
1515
|
-
this.hasCoreApi = Boolean(coreApi);
|
|
1516
|
-
this.fetch = fetch2;
|
|
1517
|
-
}
|
|
1518
|
-
setProps(options) {
|
|
1519
|
-
const mergedOptions = mergeOptions(this.options, options);
|
|
1520
|
-
const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
|
|
1521
|
-
this.options = mergedOptions;
|
|
1522
|
-
this.loadOptions = loadOptions;
|
|
1523
|
-
this.fetch = getFetchFunction(loadOptions);
|
|
1524
|
-
this.setNeedsRefresh();
|
|
1525
|
-
}
|
|
1526
|
-
/** Mark this data source as needing a refresh (redraw) */
|
|
1527
|
-
setNeedsRefresh() {
|
|
1528
|
-
this._needsRefresh = true;
|
|
1529
|
-
}
|
|
1530
|
-
/**
|
|
1531
|
-
* Does this data source need refreshing?
|
|
1532
|
-
* @note The specifics of the refresh mechanism depends on type of data source
|
|
1533
|
-
*/
|
|
1534
|
-
getNeedsRefresh(clear = true) {
|
|
1535
|
-
const needsRefresh = this._needsRefresh;
|
|
1536
|
-
if (clear) {
|
|
1537
|
-
this._needsRefresh = false;
|
|
1538
|
-
}
|
|
1539
|
-
return needsRefresh;
|
|
1540
|
-
}
|
|
1541
|
-
/** Reports a source-level failure through the configured callback or the shared logger. */
|
|
1542
|
-
reportError(error, message) {
|
|
1543
|
-
var _a;
|
|
1544
|
-
const normalizedError = normalizeError(error, message);
|
|
1545
|
-
const callback = (_a = this.options.core) == null ? void 0 : _a.onError;
|
|
1546
|
-
if (callback) {
|
|
1547
|
-
callback(normalizedError, this);
|
|
1548
|
-
} else {
|
|
1549
|
-
log.warn(`${this.constructor.name}: ${normalizedError.message}`)();
|
|
1550
|
-
}
|
|
1551
|
-
return normalizedError;
|
|
1552
|
-
}
|
|
1553
|
-
};
|
|
1554
|
-
}
|
|
1555
|
-
});
|
|
1556
|
-
|
|
1557
|
-
// ../core/src/loader-utils/lib/scan-utils/scan-query-metadata.ts
|
|
1558
|
-
function createScanQueryMetadata(options) {
|
|
1559
|
-
validateScanExecutionSupport(options.queryType, options.execution);
|
|
1560
|
-
const schema = Object.freeze({
|
|
1561
|
-
fields: Object.freeze(
|
|
1562
|
-
options.schema.fields.map(
|
|
1563
|
-
(field) => Object.freeze({ ...field, metadata: Object.freeze({ ...field.metadata }) })
|
|
1564
|
-
)
|
|
1565
|
-
),
|
|
1566
|
-
metadata: Object.freeze({ ...options.schema.metadata })
|
|
1567
|
-
});
|
|
1568
|
-
const columns = schema.fields.map(
|
|
1569
|
-
(field) => {
|
|
1570
|
-
var _a;
|
|
1571
|
-
return Object.freeze({
|
|
1572
|
-
name: field.name,
|
|
1573
|
-
type: field.type,
|
|
1574
|
-
nullable: field.nullable !== false,
|
|
1575
|
-
role: ((_a = options.columnRoles) == null ? void 0 : _a[field.name]) || "attribute",
|
|
1576
|
-
title: getNonEmptyMetadataValue(field.metadata, "title"),
|
|
1577
|
-
description: getNonEmptyMetadataValue(field.metadata, "description"),
|
|
1578
|
-
metadata: field.metadata || Object.freeze({})
|
|
1579
|
-
});
|
|
1580
|
-
}
|
|
1581
|
-
);
|
|
1582
|
-
return Object.freeze({
|
|
1583
|
-
sourceType: options.sourceType,
|
|
1584
|
-
queryType: options.queryType,
|
|
1585
|
-
execution: Object.freeze({ ...options.execution }),
|
|
1586
|
-
name: options.name,
|
|
1587
|
-
description: options.description,
|
|
1588
|
-
schema,
|
|
1589
|
-
columns: Object.freeze(columns),
|
|
1590
|
-
capabilities: Object.freeze({ ...options.capabilities }),
|
|
1591
|
-
spatial: options.spatial ? Object.freeze({
|
|
1592
|
-
...options.spatial,
|
|
1593
|
-
bounds: options.spatial.bounds ? Object.freeze({
|
|
1594
|
-
minimum: Object.freeze([...options.spatial.bounds.minimum]),
|
|
1595
|
-
maximum: Object.freeze([...options.spatial.bounds.maximum])
|
|
1596
|
-
}) : void 0,
|
|
1597
|
-
coordinateReferenceSystems: options.spatial.coordinateReferenceSystems ? Object.freeze([...options.spatial.coordinateReferenceSystems]) : void 0,
|
|
1598
|
-
spatialReference: options.spatial.spatialReference ? (0, import_crs.createSpatialReference)(options.spatial.spatialReference) : void 0
|
|
1599
|
-
}) : void 0,
|
|
1600
|
-
statistics: options.statistics ? Object.freeze({ ...options.statistics }) : void 0,
|
|
1601
|
-
levels: options.levels ? Object.freeze(
|
|
1602
|
-
options.levels.map(
|
|
1603
|
-
(level) => Object.freeze({
|
|
1604
|
-
...level,
|
|
1605
|
-
scale: level.scale ? Object.freeze([...level.scale]) : void 0
|
|
1606
|
-
})
|
|
1607
|
-
)
|
|
1608
|
-
) : void 0
|
|
1609
|
-
});
|
|
1610
|
-
}
|
|
1611
|
-
function validateScanExecutionSupport(queryType, execution) {
|
|
1612
|
-
if (execution.status === "metadata-only") {
|
|
1613
|
-
if (!execution.reason.trim()) {
|
|
1614
|
-
throw new Error("Metadata-only scan support requires a concrete reason");
|
|
1615
|
-
}
|
|
1616
|
-
return;
|
|
1617
|
-
}
|
|
1618
|
-
const validMethods = {
|
|
1619
|
-
table: ["read", "query"],
|
|
1620
|
-
raster: ["getRaster"],
|
|
1621
|
-
"point-cloud": ["scan"]
|
|
1622
|
-
};
|
|
1623
|
-
if (!validMethods[queryType].includes(execution.method)) {
|
|
1624
|
-
throw new Error(
|
|
1625
|
-
`Scan execution method "${execution.method}" is not valid for ${queryType} queries`
|
|
1626
|
-
);
|
|
1627
|
-
}
|
|
1628
|
-
}
|
|
1629
|
-
function getNonEmptyMetadataValue(metadata, key) {
|
|
1630
|
-
const value = metadata == null ? void 0 : metadata[key];
|
|
1631
|
-
return value || void 0;
|
|
1632
|
-
}
|
|
1633
|
-
var import_crs;
|
|
1634
|
-
var init_scan_query_metadata = __esm({
|
|
1635
|
-
"../core/src/loader-utils/lib/scan-utils/scan-query-metadata.ts"() {
|
|
1636
|
-
"use strict";
|
|
1637
|
-
import_crs = require("@math.gl/geospatial/crs");
|
|
1638
|
-
}
|
|
1639
|
-
});
|
|
1640
|
-
|
|
1641
|
-
// ../core/src/loader-utils/lib/scan-utils/raster-query.ts
|
|
1642
|
-
function validateRasterQueryOptions(options) {
|
|
1643
|
-
if (options.width !== void 0) validatePositiveInteger(options.width, "width");
|
|
1644
|
-
if (options.height !== void 0) validatePositiveInteger(options.height, "height");
|
|
1645
|
-
if (options.level !== void 0) validateNonNegativeInteger(options.level, "level");
|
|
1646
|
-
if (options.bounds) {
|
|
1647
|
-
for (let axis = 0; axis < 2; axis++) {
|
|
1648
|
-
const minimum = options.bounds[0][axis];
|
|
1649
|
-
const maximum = options.bounds[1][axis];
|
|
1650
|
-
if (!Number.isFinite(minimum) || !Number.isFinite(maximum) || minimum > maximum) {
|
|
1651
|
-
throw new Error("Raster query bounds must contain finite, ordered coordinates.");
|
|
1652
|
-
}
|
|
1653
|
-
}
|
|
1654
|
-
}
|
|
1655
|
-
for (const channel of options.channels || []) {
|
|
1656
|
-
validateNonNegativeInteger(channel, "channel");
|
|
1657
|
-
}
|
|
1658
|
-
for (const [name, slice4] of Object.entries(options.slices || {})) {
|
|
1659
|
-
if (!name) throw new Error("Raster query slice names must be non-empty.");
|
|
1660
|
-
if (Array.isArray(slice4)) {
|
|
1661
|
-
if (slice4.length !== 2 || !slice4.every(Number.isFinite) || slice4[0] > slice4[1]) {
|
|
1662
|
-
throw new Error(`Raster query slice ${name} must be an ordered finite range.`);
|
|
1663
|
-
}
|
|
1664
|
-
} else if (!Number.isFinite(slice4)) {
|
|
1665
|
-
throw new Error(`Raster query slice ${name} must be finite.`);
|
|
1666
|
-
}
|
|
1667
|
-
}
|
|
1668
|
-
}
|
|
1669
|
-
function validatePositiveInteger(value, name) {
|
|
1670
|
-
if (!Number.isSafeInteger(value) || value < 1) {
|
|
1671
|
-
throw new Error(`Raster query ${name} must be a positive safe integer.`);
|
|
1672
|
-
}
|
|
1673
|
-
}
|
|
1674
|
-
function validateNonNegativeInteger(value, name) {
|
|
1675
|
-
if (!Number.isSafeInteger(value) || value < 0) {
|
|
1676
|
-
throw new Error(`Raster query ${name} must be a non-negative safe integer.`);
|
|
1677
|
-
}
|
|
1678
|
-
}
|
|
1679
|
-
var init_raster_query = __esm({
|
|
1680
|
-
"../core/src/loader-utils/lib/scan-utils/raster-query.ts"() {
|
|
1681
|
-
"use strict";
|
|
1682
|
-
}
|
|
1683
|
-
});
|
|
1684
|
-
|
|
1685
|
-
// ../core/src/loader-utils/lib/sources/tile-grid.ts
|
|
1686
|
-
function createTileGrid(crs, matrices) {
|
|
1687
|
-
var _a, _b, _c;
|
|
1688
|
-
const tileMatrixSet = getTileMatrixSet(crs, matrices);
|
|
1689
|
-
if (tileMatrixSet) {
|
|
1690
|
-
const levels = tileMatrixSet.matrices;
|
|
1691
|
-
return {
|
|
1692
|
-
crs,
|
|
1693
|
-
tileSize: [levels[0].tileSize[0], levels[0].tileSize[1]],
|
|
1694
|
-
// The grid-wide origin is documented as top-left, so a bottom-left origin is per-level only.
|
|
1695
|
-
origin: levels[0].cornerOfOrigin === "topLeft" ? [levels[0].origin[0], levels[0].origin[1]] : void 0,
|
|
1696
|
-
resolutions: levels.map((matrix) => matrix.resolution),
|
|
1697
|
-
matrixIds: levels.map((matrix) => matrix.id),
|
|
1698
|
-
matrixSizes: levels.map((matrix) => [matrix.matrixSize[0], matrix.matrixSize[1]]),
|
|
1699
|
-
tileMatrixSet,
|
|
1700
|
-
matrices
|
|
1701
|
-
};
|
|
1702
|
-
}
|
|
1703
|
-
return {
|
|
1704
|
-
crs,
|
|
1705
|
-
tileSize: (_a = matrices[0]) == null ? void 0 : _a.tileSize,
|
|
1706
|
-
// The grid-wide origin is documented as top-left, so a bottom-left origin is per-level only.
|
|
1707
|
-
origin: ((_b = matrices[0]) == null ? void 0 : _b.cornerOfOrigin) === "bottomLeft" ? void 0 : (_c = matrices[0]) == null ? void 0 : _c.origin,
|
|
1708
|
-
...matrices.length && matrices.every((matrix) => matrix.resolution !== void 0) ? { resolutions: matrices.map((matrix) => matrix.resolution) } : {},
|
|
1709
|
-
matrixIds: matrices.map((matrix) => matrix.id),
|
|
1710
|
-
matrixSizes: matrices.every((matrix) => matrix.matrixSize) ? matrices.map((matrix) => matrix.matrixSize) : void 0,
|
|
1711
|
-
matrices
|
|
1712
|
-
};
|
|
1713
|
-
}
|
|
1714
|
-
function getTileMatrixSet(crs, matrices) {
|
|
1715
|
-
if (!crs || !matrices.length) return void 0;
|
|
1716
|
-
if (new Set(matrices.map((matrix) => matrix.id)).size !== matrices.length) return void 0;
|
|
1717
|
-
const tileMatrices = [];
|
|
1718
|
-
for (const matrix of matrices) {
|
|
1719
|
-
const tileMatrix = toTileMatrix(matrix);
|
|
1720
|
-
if (!tileMatrix) return void 0;
|
|
1721
|
-
tileMatrices.push(tileMatrix);
|
|
1722
|
-
}
|
|
1723
|
-
return { crs, matrices: tileMatrices };
|
|
1724
|
-
}
|
|
1725
|
-
function toTileMatrix(matrix) {
|
|
1726
|
-
const { id, resolution, resolutionY, origin, tileSize, matrixSize } = matrix;
|
|
1727
|
-
if (matrix.variableMatrixWidths !== void 0 && !Array.isArray(matrix.variableMatrixWidths))
|
|
1728
|
-
return null;
|
|
1729
|
-
if (resolution === void 0 || !origin || !tileSize || !matrixSize) return null;
|
|
1730
|
-
const tileMatrix = {
|
|
1731
|
-
id,
|
|
1732
|
-
resolution,
|
|
1733
|
-
...resolutionY !== void 0 ? { resolutionY } : {},
|
|
1734
|
-
origin: [origin[0], origin[1]],
|
|
1735
|
-
cornerOfOrigin: matrix.cornerOfOrigin === void 0 ? "topLeft" : matrix.cornerOfOrigin,
|
|
1736
|
-
tileSize: [tileSize[0], tileSize[1]],
|
|
1737
|
-
matrixSize: [matrixSize[0], matrixSize[1]],
|
|
1738
|
-
...matrix.variableMatrixWidths !== void 0 ? { variableMatrixWidths: matrix.variableMatrixWidths } : {}
|
|
1739
|
-
};
|
|
1740
|
-
try {
|
|
1741
|
-
(0, import_geospatial.validateTileMatrix)(tileMatrix);
|
|
1742
|
-
} catch {
|
|
1743
|
-
return null;
|
|
1744
|
-
}
|
|
1745
|
-
return tileMatrix;
|
|
1746
|
-
}
|
|
1747
|
-
var import_geospatial;
|
|
1748
|
-
var init_tile_grid = __esm({
|
|
1749
|
-
"../core/src/loader-utils/lib/sources/tile-grid.ts"() {
|
|
1750
|
-
"use strict";
|
|
1751
|
-
import_geospatial = require("@math.gl/geospatial");
|
|
1752
|
-
}
|
|
1753
|
-
});
|
|
1754
|
-
|
|
1755
|
-
// ../core/src/loader-utils/lib/sources/raster-source.ts
|
|
1756
|
-
function getRasterViewportBoundingBox(viewport) {
|
|
1757
|
-
if (viewport.bounds) {
|
|
1758
|
-
return viewport.bounds;
|
|
1759
|
-
}
|
|
1760
|
-
if (viewport.getBounds) {
|
|
1761
|
-
const [west, south, east, north] = viewport.getBounds();
|
|
1762
|
-
return [
|
|
1763
|
-
[west, south],
|
|
1764
|
-
[east, north]
|
|
1765
|
-
];
|
|
1766
|
-
}
|
|
1767
|
-
throw new Error("Raster viewport must provide bounds or getBounds().");
|
|
1768
|
-
}
|
|
1769
|
-
var init_raster_source = __esm({
|
|
1770
|
-
"../core/src/loader-utils/lib/sources/raster-source.ts"() {
|
|
1771
|
-
"use strict";
|
|
1772
|
-
}
|
|
1773
|
-
});
|
|
1774
|
-
|
|
1775
|
-
// ../core/src/loader-utils/index.ts
|
|
1776
|
-
var init_loader_utils = __esm({
|
|
1777
|
-
"../core/src/loader-utils/index.ts"() {
|
|
1778
|
-
"use strict";
|
|
1779
|
-
init_data_source();
|
|
1780
|
-
init_raster_query();
|
|
1781
|
-
init_scan_query_metadata();
|
|
1782
|
-
init_raster_source();
|
|
1783
|
-
init_tile_grid();
|
|
1784
|
-
}
|
|
1785
|
-
});
|
|
1786
|
-
|
|
1787
|
-
// src/netcdf/netcdf-source-loader.ts
|
|
1788
|
-
var netcdf_source_loader_exports = {};
|
|
1789
|
-
__export(netcdf_source_loader_exports, {
|
|
1790
|
-
NetCDFSource: () => NetCDFSource,
|
|
1791
|
-
NetCDFSourceLoaderWithParser: () => NetCDFSourceLoaderWithParser
|
|
1792
|
-
});
|
|
1793
|
-
function getNetCDFDataType(type) {
|
|
1794
|
-
switch (type.toLowerCase()) {
|
|
1795
|
-
case "byte":
|
|
1796
|
-
return "int8";
|
|
1797
|
-
case "ubyte":
|
|
1798
|
-
return "uint8";
|
|
1799
|
-
case "short":
|
|
1800
|
-
return "int16";
|
|
1801
|
-
case "ushort":
|
|
1802
|
-
return "uint16";
|
|
1803
|
-
case "int":
|
|
1804
|
-
return "int32";
|
|
1805
|
-
case "uint":
|
|
1806
|
-
return "uint32";
|
|
1807
|
-
case "int64":
|
|
1808
|
-
return "int64";
|
|
1809
|
-
case "uint64":
|
|
1810
|
-
return "uint64";
|
|
1811
|
-
case "float":
|
|
1812
|
-
return "float32";
|
|
1813
|
-
case "double":
|
|
1814
|
-
return "float64";
|
|
1815
|
-
case "char":
|
|
1816
|
-
case "string":
|
|
1817
|
-
return "utf8";
|
|
1818
|
-
default:
|
|
1819
|
-
return "binary";
|
|
1820
|
-
}
|
|
1821
|
-
}
|
|
1822
|
-
function validateNetCDFUnsupportedRasterOptions(options) {
|
|
1823
|
-
var _a;
|
|
1824
|
-
if (options.bounds) throw new Error("NetCDF raster bounds are not supported.");
|
|
1825
|
-
if (options.level !== void 0) throw new Error("NetCDF raster levels are not supported.");
|
|
1826
|
-
if (options.width !== void 0 || options.height !== void 0) {
|
|
1827
|
-
throw new Error("NetCDF raster resampling is not supported.");
|
|
1828
|
-
}
|
|
1829
|
-
if ((_a = options.channels) == null ? void 0 : _a.length) {
|
|
1830
|
-
throw new Error("NetCDF uses named variables instead of numeric channels.");
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
function selectNetCDFVariables(header, requestedVariableNames) {
|
|
1834
|
-
const defaultVariable = header.variables.find(
|
|
1835
|
-
(variable) => variable.dimensions.length > 0 && isNetCDFRasterDataType(variable.type)
|
|
1836
|
-
);
|
|
1837
|
-
const variableNames = (requestedVariableNames == null ? void 0 : requestedVariableNames.length) ? [...requestedVariableNames] : defaultVariable ? [defaultVariable.name] : [];
|
|
1838
|
-
if (variableNames.length === 0) {
|
|
1839
|
-
throw new Error("NetCDF contains no numeric variables that can be read as raster data.");
|
|
1840
|
-
}
|
|
1841
|
-
if (new Set(variableNames).size !== variableNames.length) {
|
|
1842
|
-
throw new Error("NetCDF raster variables must not contain duplicates.");
|
|
1843
|
-
}
|
|
1844
|
-
return variableNames.map((variableName) => {
|
|
1845
|
-
const variable = header.variables.find((candidate) => candidate.name === variableName);
|
|
1846
|
-
if (!variable) throw new Error(`NetCDF variable not found: ${variableName}`);
|
|
1847
|
-
getNetCDFRasterDataType(variable.type);
|
|
1848
|
-
return variable;
|
|
1849
|
-
});
|
|
1850
|
-
}
|
|
1851
|
-
function validateNetCDFSliceNames(header, slices) {
|
|
1852
|
-
const dimensionNames = new Set(header.dimensions.map((dimension) => dimension.name));
|
|
1853
|
-
for (const dimensionName of Object.keys(slices || {})) {
|
|
1854
|
-
if (!dimensionNames.has(dimensionName)) {
|
|
1855
|
-
throw new Error(`NetCDF dimension not found: ${dimensionName}`);
|
|
1856
|
-
}
|
|
1857
|
-
}
|
|
1858
|
-
}
|
|
1859
|
-
function selectNetCDFValues(values, dimensionNames, dimensionSizes, slices, signal) {
|
|
1860
|
-
const selectors = dimensionNames.map((dimensionName, dimensionIndex) => {
|
|
1861
|
-
const size = dimensionSizes[dimensionIndex];
|
|
1862
|
-
const slice4 = slices[dimensionName];
|
|
1863
|
-
if (slice4 === void 0) return { start: 0, stop: size, remove: false };
|
|
1864
|
-
if (typeof slice4 !== "number") {
|
|
1865
|
-
const [start, stop] = slice4;
|
|
1866
|
-
if (!Number.isSafeInteger(start) || !Number.isSafeInteger(stop) || start < 0 || stop < start || stop > size) {
|
|
1867
|
-
throw new Error(
|
|
1868
|
-
`NetCDF slice ${dimensionName} must be a valid half-open range within 0..${size}.`
|
|
1869
|
-
);
|
|
1870
|
-
}
|
|
1871
|
-
return { start, stop, remove: false };
|
|
1872
|
-
}
|
|
1873
|
-
if (!Number.isSafeInteger(slice4) || slice4 < 0 || slice4 >= size) {
|
|
1874
|
-
throw new Error(`NetCDF slice ${dimensionName} must be an index within 0..${size - 1}.`);
|
|
1875
|
-
}
|
|
1876
|
-
return { start: slice4, stop: slice4 + 1, remove: true };
|
|
1877
|
-
});
|
|
1878
|
-
const strides = dimensionSizes.map(
|
|
1879
|
-
(_, dimensionIndex) => dimensionSizes.slice(dimensionIndex + 1).reduce((product, dimensionSize) => product * dimensionSize, 1)
|
|
1880
|
-
);
|
|
1881
|
-
const selectedValues = [];
|
|
1882
|
-
const visitDimension = (dimensionIndex, flatOffset) => {
|
|
1883
|
-
throwIfAborted(signal);
|
|
1884
|
-
if (dimensionIndex === selectors.length) {
|
|
1885
|
-
const value = values[flatOffset];
|
|
1886
|
-
if (typeof value !== "number") {
|
|
1887
|
-
throw new Error("NetCDF raster variables must contain numeric values.");
|
|
1888
|
-
}
|
|
1889
|
-
selectedValues.push(value);
|
|
1890
|
-
return;
|
|
1891
|
-
}
|
|
1892
|
-
const selector = selectors[dimensionIndex];
|
|
1893
|
-
for (let index = selector.start; index < selector.stop; index++) {
|
|
1894
|
-
visitDimension(dimensionIndex + 1, flatOffset + index * strides[dimensionIndex]);
|
|
1895
|
-
}
|
|
1896
|
-
};
|
|
1897
|
-
visitDimension(0, 0);
|
|
1898
|
-
return {
|
|
1899
|
-
values: selectedValues,
|
|
1900
|
-
dimensionNames: dimensionNames.filter((_, index) => !selectors[index].remove),
|
|
1901
|
-
shape: selectors.map((selector) => selector.stop - selector.start).filter((_, index) => !selectors[index].remove)
|
|
1902
|
-
};
|
|
1903
|
-
}
|
|
1904
|
-
function flattenNetCDFValues(values) {
|
|
1905
|
-
if (Array.isArray(values)) return values.flatMap(flattenNetCDFValues);
|
|
1906
|
-
if (ArrayBuffer.isView(values)) {
|
|
1907
|
-
return Array.from(values);
|
|
1908
|
-
}
|
|
1909
|
-
return [values];
|
|
1910
|
-
}
|
|
1911
|
-
function isNetCDFRasterDataType(type) {
|
|
1912
|
-
try {
|
|
1913
|
-
getNetCDFRasterDataType(type);
|
|
1914
|
-
return true;
|
|
1915
|
-
} catch {
|
|
1916
|
-
return false;
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
|
-
function getNetCDFRasterDataType(type) {
|
|
1920
|
-
switch (type.toLowerCase()) {
|
|
1921
|
-
case "byte":
|
|
1922
|
-
return "int8";
|
|
1923
|
-
case "ubyte":
|
|
1924
|
-
return "uint8";
|
|
1925
|
-
case "short":
|
|
1926
|
-
return "int16";
|
|
1927
|
-
case "ushort":
|
|
1928
|
-
return "uint16";
|
|
1929
|
-
case "int":
|
|
1930
|
-
return "int32";
|
|
1931
|
-
case "uint":
|
|
1932
|
-
return "uint32";
|
|
1933
|
-
case "float":
|
|
1934
|
-
return "float32";
|
|
1935
|
-
case "double":
|
|
1936
|
-
return "float64";
|
|
1937
|
-
default:
|
|
1938
|
-
throw new Error(`NetCDF variable type is not supported as raster data: ${type}`);
|
|
1939
|
-
}
|
|
1940
|
-
}
|
|
1941
|
-
function createNetCDFTypedArray(values, dtype) {
|
|
1942
|
-
switch (dtype) {
|
|
1943
|
-
case "int8":
|
|
1944
|
-
return Int8Array.from(values);
|
|
1945
|
-
case "uint8":
|
|
1946
|
-
return Uint8Array.from(values);
|
|
1947
|
-
case "int16":
|
|
1948
|
-
return Int16Array.from(values);
|
|
1949
|
-
case "uint16":
|
|
1950
|
-
return Uint16Array.from(values);
|
|
1951
|
-
case "int32":
|
|
1952
|
-
return Int32Array.from(values);
|
|
1953
|
-
case "uint32":
|
|
1954
|
-
return Uint32Array.from(values);
|
|
1955
|
-
case "float32":
|
|
1956
|
-
return Float32Array.from(values);
|
|
1957
|
-
case "float64":
|
|
1958
|
-
return Float64Array.from(values);
|
|
1959
|
-
}
|
|
1960
|
-
}
|
|
1961
|
-
function getNetCDFNoDataValue(variable) {
|
|
1962
|
-
const attribute = variable.attributes.find(
|
|
1963
|
-
(candidate) => candidate.name === "_FillValue" || candidate.name === "missing_value"
|
|
1964
|
-
);
|
|
1965
|
-
const value = Number(attribute == null ? void 0 : attribute.value);
|
|
1966
|
-
return attribute && Number.isFinite(value) ? value : null;
|
|
1967
|
-
}
|
|
1968
|
-
function arraysEqual(left, right) {
|
|
1969
|
-
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
1970
|
-
}
|
|
1971
|
-
function createVariableField(variable, header) {
|
|
1972
|
-
const dimensions = variable.dimensions.map((dimensionId) => header.dimensions[dimensionId]).filter(Boolean).map(
|
|
1973
|
-
(dimension, index) => `${dimension.name}[${getDimensionSize(header, variable.dimensions[index])}]`
|
|
1974
|
-
).join(",");
|
|
1975
|
-
const metadata = { dimensions };
|
|
1976
|
-
for (const attribute of variable.attributes) {
|
|
1977
|
-
metadata[attribute.name] = String(attribute.value);
|
|
1978
|
-
}
|
|
1979
|
-
return { name: variable.name, type: getNetCDFDataType(variable.type), nullable: true, metadata };
|
|
1980
|
-
}
|
|
1981
|
-
function createDimensionMetadata(header) {
|
|
1982
|
-
const metadata = {};
|
|
1983
|
-
for (const [dimensionId, dimension] of header.dimensions.entries()) {
|
|
1984
|
-
metadata[`dimension:${dimension.name}`] = String(getDimensionSize(header, dimensionId));
|
|
1985
|
-
}
|
|
1986
|
-
return metadata;
|
|
1987
|
-
}
|
|
1988
|
-
function getDimensionSize(header, dimensionId) {
|
|
1989
|
-
const dimension = header.dimensions[dimensionId];
|
|
1990
|
-
return dimensionId === header.recordDimension.id ? header.recordDimension.length : (dimension == null ? void 0 : dimension.size) || 0;
|
|
1991
|
-
}
|
|
1992
|
-
function getResponseByteLength(response, fallback) {
|
|
1993
|
-
var _a;
|
|
1994
|
-
const contentRange = response.headers.get("content-range");
|
|
1995
|
-
const total = (_a = contentRange == null ? void 0 : contentRange.match(/\/([0-9]+)$/)) == null ? void 0 : _a[1];
|
|
1996
|
-
return Number(total || response.headers.get("content-length") || fallback);
|
|
1997
|
-
}
|
|
1998
|
-
function throwIfAborted(signal) {
|
|
1999
|
-
if (signal == null ? void 0 : signal.aborted) {
|
|
2000
|
-
throw new DOMException("The operation was aborted", "AbortError");
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
var VERSION4, NetCDFSource, NetCDFSourceLoaderWithParser;
|
|
2004
|
-
var init_netcdf_source_loader = __esm({
|
|
2005
|
-
"src/netcdf/netcdf-source-loader.ts"() {
|
|
2006
|
-
"use strict";
|
|
2007
|
-
init_loader_utils();
|
|
2008
|
-
init_netcdf_format();
|
|
2009
|
-
init_netcdf_reader();
|
|
2010
|
-
VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2011
|
-
NetCDFSource = class _NetCDFSource extends DataSource {
|
|
2012
|
-
static HEADER_RANGE_SIZE = 64 * 1024;
|
|
2013
|
-
static MAX_HEADER_RANGE_SIZE = 4 * 1024 * 1024;
|
|
2014
|
-
headerPromise = null;
|
|
2015
|
-
/** Capabilities of the NetCDF variable and dimension-slice executor. */
|
|
2016
|
-
rasterQueryCapabilities = Object.freeze({
|
|
2017
|
-
bounds: "unsupported",
|
|
2018
|
-
level: "unsupported",
|
|
2019
|
-
variables: "pushdown",
|
|
2020
|
-
slices: "residual",
|
|
2021
|
-
streaming: false,
|
|
2022
|
-
cancellation: true
|
|
2023
|
-
});
|
|
2024
|
-
/** Creates a source over a NetCDF URL or Blob. */
|
|
2025
|
-
constructor(data, options = {}) {
|
|
2026
|
-
super(data, options);
|
|
2027
|
-
}
|
|
2028
|
-
/** Discovers variables and dimensions without decoding data arrays. */
|
|
2029
|
-
async getQueryMetadata(options = {}) {
|
|
2030
|
-
throwIfAborted(options.signal);
|
|
2031
|
-
const { header, byteLength } = await this.getHeader(options.signal);
|
|
2032
|
-
throwIfAborted(options.signal);
|
|
2033
|
-
const fields = header.variables.map((variable) => createVariableField(variable, header));
|
|
2034
|
-
const schema = { fields, metadata: createDimensionMetadata(header) };
|
|
2035
|
-
return createScanQueryMetadata({
|
|
2036
|
-
sourceType: "netcdf",
|
|
2037
|
-
queryType: "raster",
|
|
2038
|
-
execution: { status: "supported", method: "getRaster" },
|
|
2039
|
-
name: typeof this.data === "string" ? this.data.split("/").pop() : void 0,
|
|
2040
|
-
schema,
|
|
2041
|
-
capabilities: {
|
|
2042
|
-
bounds: "unsupported",
|
|
2043
|
-
levelOfDetail: "unsupported",
|
|
2044
|
-
raster: this.rasterQueryCapabilities
|
|
2045
|
-
},
|
|
2046
|
-
statistics: {
|
|
2047
|
-
byteLength,
|
|
2048
|
-
rowCount: header.recordDimension.length || void 0
|
|
2049
|
-
}
|
|
2050
|
-
});
|
|
2051
|
-
}
|
|
2052
|
-
/**
|
|
2053
|
-
* Reads selected numeric variables and applies named dimension slices.
|
|
2054
|
-
*
|
|
2055
|
-
* Multiple variables must retain the same shape and numeric type so they can be returned as
|
|
2056
|
-
* ordinary raster bands. Leading dimensions are folded into height and the final dimension is
|
|
2057
|
-
* exposed as width; the original dimension names and shape remain in result metadata.
|
|
2058
|
-
*/
|
|
2059
|
-
async getRaster(options = {}) {
|
|
2060
|
-
validateRasterQueryOptions(options);
|
|
2061
|
-
validateNetCDFUnsupportedRasterOptions(options);
|
|
2062
|
-
throwIfAborted(options.signal);
|
|
2063
|
-
const reader = await this.loadReader(options.signal);
|
|
2064
|
-
throwIfAborted(options.signal);
|
|
2065
|
-
validateNetCDFSliceNames(reader.header, options.slices);
|
|
2066
|
-
const variables = selectNetCDFVariables(reader.header, options.variables);
|
|
2067
|
-
const results = variables.map((variable) => {
|
|
2068
|
-
throwIfAborted(options.signal);
|
|
2069
|
-
const dimensionNames = variable.dimensions.map(
|
|
2070
|
-
(dimensionId) => {
|
|
2071
|
-
var _a;
|
|
2072
|
-
return ((_a = reader.header.dimensions[dimensionId]) == null ? void 0 : _a.name) || `dimension_${dimensionId}`;
|
|
2073
|
-
}
|
|
2074
|
-
);
|
|
2075
|
-
const dimensionSizes = variable.dimensions.map(
|
|
2076
|
-
(dimensionId) => getDimensionSize(reader.header, dimensionId)
|
|
2077
|
-
);
|
|
2078
|
-
const values = flattenNetCDFValues(reader.getDataVariable(variable));
|
|
2079
|
-
const selection = selectNetCDFValues(
|
|
2080
|
-
values,
|
|
2081
|
-
dimensionNames,
|
|
2082
|
-
dimensionSizes,
|
|
2083
|
-
options.slices || {},
|
|
2084
|
-
options.signal
|
|
2085
|
-
);
|
|
2086
|
-
const dtype = getNetCDFRasterDataType(variable.type);
|
|
2087
|
-
return {
|
|
2088
|
-
variable,
|
|
2089
|
-
dimensionNames: selection.dimensionNames,
|
|
2090
|
-
shape: selection.shape,
|
|
2091
|
-
data: createNetCDFTypedArray(selection.values, dtype),
|
|
2092
|
-
dtype
|
|
2093
|
-
};
|
|
2094
|
-
});
|
|
2095
|
-
const reference = results[0];
|
|
2096
|
-
for (const result of results.slice(1)) {
|
|
2097
|
-
if (result.dtype !== reference.dtype || !arraysEqual(result.shape, reference.shape)) {
|
|
2098
|
-
throw new Error(
|
|
2099
|
-
"NetCDF raster variables must retain the same shape and numeric type after slicing."
|
|
2100
|
-
);
|
|
2101
|
-
}
|
|
2102
|
-
}
|
|
2103
|
-
const width = reference.shape.at(-1) ?? 1;
|
|
2104
|
-
const height = reference.shape.length < 2 ? 1 : reference.shape.slice(0, -1).reduce((product, size) => product * size, 1);
|
|
2105
|
-
const noData = getNetCDFNoDataValue(reference.variable);
|
|
2106
|
-
return {
|
|
2107
|
-
data: results.length === 1 ? reference.data : results.map((result) => result.data),
|
|
2108
|
-
width,
|
|
2109
|
-
height,
|
|
2110
|
-
bandCount: results.length,
|
|
2111
|
-
dtype: reference.dtype,
|
|
2112
|
-
interleaved: false,
|
|
2113
|
-
noData,
|
|
2114
|
-
metadata: {
|
|
2115
|
-
variables: results.map((result) => result.variable.name),
|
|
2116
|
-
dimensions: reference.dimensionNames,
|
|
2117
|
-
shape: reference.shape,
|
|
2118
|
-
slices: { ...options.slices }
|
|
2119
|
-
}
|
|
2120
|
-
};
|
|
2121
|
-
}
|
|
2122
|
-
/** Loads a complete NetCDF reader for selected-variable execution. */
|
|
2123
|
-
async loadReader(signal) {
|
|
2124
|
-
let arrayBuffer;
|
|
2125
|
-
if (typeof this.data === "string") {
|
|
2126
|
-
const response = await this.fetch(this.url, { signal });
|
|
2127
|
-
if (!response.ok) throw new Error(`NetCDF request failed with status ${response.status}.`);
|
|
2128
|
-
arrayBuffer = await response.arrayBuffer();
|
|
2129
|
-
} else {
|
|
2130
|
-
arrayBuffer = await this.data.arrayBuffer();
|
|
2131
|
-
}
|
|
2132
|
-
throwIfAborted(signal);
|
|
2133
|
-
return new NetCDFReader(arrayBuffer);
|
|
2134
|
-
}
|
|
2135
|
-
/** Reads and caches the NetCDF header, preserving abort behavior for each caller. */
|
|
2136
|
-
async getHeader(signal) {
|
|
2137
|
-
throwIfAborted(signal);
|
|
2138
|
-
if (!this.headerPromise) {
|
|
2139
|
-
this.headerPromise = this.loadHeader().catch((error) => {
|
|
2140
|
-
this.headerPromise = null;
|
|
2141
|
-
throw error;
|
|
2142
|
-
});
|
|
2143
|
-
}
|
|
2144
|
-
const result = await this.headerPromise;
|
|
2145
|
-
throwIfAborted(signal);
|
|
2146
|
-
return result;
|
|
2147
|
-
}
|
|
2148
|
-
/** Loads enough leading bytes to parse a remote header, growing ranges when required. */
|
|
2149
|
-
async loadHeader() {
|
|
2150
|
-
if (typeof this.data !== "string") {
|
|
2151
|
-
const arrayBuffer2 = await this.data.arrayBuffer();
|
|
2152
|
-
return { header: new NetCDFReader(arrayBuffer2).header, byteLength: arrayBuffer2.byteLength };
|
|
2153
|
-
}
|
|
2154
|
-
let rangeSize = _NetCDFSource.HEADER_RANGE_SIZE;
|
|
2155
|
-
let response = null;
|
|
2156
|
-
let arrayBuffer = null;
|
|
2157
|
-
let lastError;
|
|
2158
|
-
while (rangeSize <= _NetCDFSource.MAX_HEADER_RANGE_SIZE) {
|
|
2159
|
-
response = await this.fetch(this.url, {
|
|
2160
|
-
headers: { Range: `bytes=0-${rangeSize - 1}` }
|
|
2161
|
-
});
|
|
2162
|
-
if (!response.ok) throw new Error(`NetCDF request failed with status ${response.status}.`);
|
|
2163
|
-
arrayBuffer = await response.arrayBuffer();
|
|
2164
|
-
const byteLength = getResponseByteLength(response, arrayBuffer.byteLength);
|
|
2165
|
-
try {
|
|
2166
|
-
return { header: new NetCDFReader(arrayBuffer).header, byteLength };
|
|
2167
|
-
} catch (error) {
|
|
2168
|
-
lastError = error;
|
|
2169
|
-
if (response.status !== 206 || arrayBuffer.byteLength < rangeSize) throw error;
|
|
2170
|
-
rangeSize *= 2;
|
|
2171
|
-
}
|
|
2172
|
-
}
|
|
2173
|
-
throw lastError || new Error("NetCDF header exceeds the maximum metadata range.");
|
|
2174
|
-
}
|
|
2175
|
-
};
|
|
2176
|
-
NetCDFSourceLoaderWithParser = {
|
|
2177
|
-
dataType: null,
|
|
2178
|
-
batchType: null,
|
|
2179
|
-
...NetCDFFormat2,
|
|
2180
|
-
module: "scientific",
|
|
2181
|
-
name: "NetCDFSourceLoader",
|
|
2182
|
-
version: VERSION4,
|
|
2183
|
-
type: "netcdf-source",
|
|
2184
|
-
fromUrl: true,
|
|
2185
|
-
fromBlob: true,
|
|
2186
|
-
options: {},
|
|
2187
|
-
defaultOptions: {},
|
|
2188
|
-
testURL: (url) => /\.(?:cdf|nc)(?:$|[?#])/i.test(url),
|
|
2189
|
-
createDataSource: (data, options) => new NetCDFSource(data, options)
|
|
2190
|
-
};
|
|
2191
|
-
}
|
|
2192
|
-
});
|
|
2193
|
-
|
|
2194
|
-
// src/zarr/lib/utils.ts
|
|
2195
|
-
function getDims(labels) {
|
|
2196
|
-
const lookup = new Map(labels.map((name, i) => [name, i]));
|
|
2197
|
-
if (lookup.size !== labels.length) {
|
|
2198
|
-
throw Error("Labels must be unique, found duplicated label.");
|
|
2199
|
-
}
|
|
2200
|
-
return (name) => {
|
|
2201
|
-
const index = lookup.get(name);
|
|
2202
|
-
if (index === void 0) {
|
|
2203
|
-
throw Error("Invalid dimension.");
|
|
2204
|
-
}
|
|
2205
|
-
return index;
|
|
2206
|
-
};
|
|
2207
|
-
}
|
|
2208
|
-
function prevPowerOf2(x) {
|
|
2209
|
-
return 2 ** Math.floor(Math.log2(x));
|
|
2210
|
-
}
|
|
2211
|
-
function isInterleaved(shape) {
|
|
2212
|
-
const lastDimSize = shape[shape.length - 1];
|
|
2213
|
-
return lastDimSize === 3 || lastDimSize === 4;
|
|
2214
|
-
}
|
|
2215
|
-
function guessTileSize(arr, labels) {
|
|
2216
|
-
const interleaved = labels ? labels[labels.length - 1] === "_c" : isInterleaved(arr.shape);
|
|
2217
|
-
const [yChunk, xChunk] = arr.chunks.slice(interleaved ? -3 : -2);
|
|
2218
|
-
const size = Math.min(yChunk, xChunk);
|
|
2219
|
-
return prevPowerOf2(size);
|
|
2220
|
-
}
|
|
2221
|
-
function guessLabels(rootAttrs) {
|
|
2222
|
-
var _a;
|
|
2223
|
-
if ("omero" in rootAttrs && rootAttrs.omero) {
|
|
2224
|
-
return ["t", "c", "z", "y", "x"];
|
|
2225
|
-
}
|
|
2226
|
-
if ("ome" in rootAttrs && ((_a = rootAttrs.ome) == null ? void 0 : _a.omero)) {
|
|
2227
|
-
return ["t", "c", "z", "y", "x"];
|
|
2228
|
-
}
|
|
2229
|
-
throw new Error(
|
|
2230
|
-
"Could not infer dimension labels for Zarr source. Must provide dimension labels."
|
|
2231
|
-
);
|
|
2232
|
-
}
|
|
2233
|
-
function getIndexer(labels) {
|
|
2234
|
-
const size = labels.length;
|
|
2235
|
-
const dims = getDims(labels);
|
|
2236
|
-
return (sel) => {
|
|
2237
|
-
if (Array.isArray(sel)) {
|
|
2238
|
-
return [...sel];
|
|
2239
|
-
}
|
|
2240
|
-
const selection = Array(size).fill(0);
|
|
2241
|
-
for (const [key, value] of Object.entries(sel)) {
|
|
2242
|
-
selection[dims(key)] = value;
|
|
2243
|
-
}
|
|
2244
|
-
return selection;
|
|
2245
|
-
};
|
|
2246
|
-
}
|
|
2247
|
-
function validLabels(labels, shape) {
|
|
2248
|
-
if (labels.length !== shape.length) {
|
|
2249
|
-
throw new Error("Labels do not match Zarr array shape.");
|
|
2250
|
-
}
|
|
2251
|
-
const n = labels.length;
|
|
2252
|
-
if (labels[n - 1] === "_c") {
|
|
2253
|
-
return labels[n - 3] === "y" && labels[n - 2] === "x" && labels[n - 1] === "_c";
|
|
2254
|
-
}
|
|
2255
|
-
return labels[n - 2] === "y" && labels[n - 1] === "x";
|
|
2256
|
-
}
|
|
2257
|
-
var import_zarr;
|
|
2258
|
-
var init_utils = __esm({
|
|
2259
|
-
"src/zarr/lib/utils.ts"() {
|
|
2260
|
-
"use strict";
|
|
2261
|
-
import_zarr = require("zarr");
|
|
2262
|
-
}
|
|
2263
|
-
});
|
|
2264
|
-
|
|
2265
|
-
// src/zarr/lib/zarr-data-cache.ts
|
|
2266
|
-
function getCachedZarrSelection(array, key, read, signal) {
|
|
2267
|
-
let cache = cacheByArray.get(array);
|
|
2268
|
-
if (!cache) {
|
|
2269
|
-
cache = /* @__PURE__ */ new Map();
|
|
2270
|
-
cacheByArray.set(array, cache);
|
|
2271
|
-
}
|
|
2272
|
-
const cached = cache.get(key);
|
|
2273
|
-
if (cached) {
|
|
2274
|
-
cache.delete(key);
|
|
2275
|
-
cache.set(key, cached);
|
|
2276
|
-
return awaitWithAbort(cached, signal);
|
|
2277
|
-
}
|
|
2278
|
-
const request = read().catch((error) => {
|
|
2279
|
-
if ((cache == null ? void 0 : cache.get(key)) === request) {
|
|
2280
|
-
cache.delete(key);
|
|
2281
|
-
}
|
|
2282
|
-
throw error;
|
|
2283
|
-
});
|
|
2284
|
-
cache.set(key, request);
|
|
2285
|
-
while (cache.size > MAX_CACHED_SELECTIONS) {
|
|
2286
|
-
const oldestKey = cache.keys().next().value;
|
|
2287
|
-
if (oldestKey === void 0) break;
|
|
2288
|
-
cache.delete(oldestKey);
|
|
2289
|
-
}
|
|
2290
|
-
return awaitWithAbort(request, signal);
|
|
2291
|
-
}
|
|
2292
|
-
function cloneZarrSelection(selection) {
|
|
2293
|
-
return {
|
|
2294
|
-
...selection,
|
|
2295
|
-
data: selection.data.slice(),
|
|
2296
|
-
shape: [...selection.shape]
|
|
2297
|
-
};
|
|
2298
|
-
}
|
|
2299
|
-
function awaitWithAbort(promise, signal) {
|
|
2300
|
-
if (!signal) return promise;
|
|
2301
|
-
if (signal.aborted)
|
|
2302
|
-
return Promise.reject(signal.reason || new Error("The operation was aborted."));
|
|
2303
|
-
return new Promise((resolve, reject) => {
|
|
2304
|
-
const abort = () => {
|
|
2305
|
-
cleanup();
|
|
2306
|
-
reject(signal.reason || new Error("The operation was aborted."));
|
|
2307
|
-
};
|
|
2308
|
-
const cleanup = () => signal.removeEventListener("abort", abort);
|
|
2309
|
-
signal.addEventListener("abort", abort, { once: true });
|
|
2310
|
-
promise.then(
|
|
2311
|
-
(value) => {
|
|
2312
|
-
cleanup();
|
|
2313
|
-
resolve(value);
|
|
2314
|
-
},
|
|
2315
|
-
(error) => {
|
|
2316
|
-
cleanup();
|
|
2317
|
-
reject(error);
|
|
2318
|
-
}
|
|
2319
|
-
);
|
|
2320
|
-
});
|
|
2321
|
-
}
|
|
2322
|
-
function getZarrSelectionKey(selection) {
|
|
2323
|
-
return JSON.stringify(
|
|
2324
|
-
selection,
|
|
2325
|
-
(_key, value) => value && typeof value === "object" && "start" in value && "stop" in value && "step" in value ? { start: value.start ?? null, stop: value.stop ?? null, step: value.step ?? null } : value
|
|
2326
|
-
);
|
|
2327
|
-
}
|
|
2328
|
-
var MAX_CACHED_SELECTIONS, cacheByArray;
|
|
2329
|
-
var init_zarr_data_cache = __esm({
|
|
2330
|
-
"src/zarr/lib/zarr-data-cache.ts"() {
|
|
2331
|
-
"use strict";
|
|
2332
|
-
MAX_CACHED_SELECTIONS = 32;
|
|
2333
|
-
cacheByArray = /* @__PURE__ */ new WeakMap();
|
|
2334
|
-
}
|
|
2335
|
-
});
|
|
2336
|
-
|
|
2337
|
-
// src/zarr/lib/zarrita-pixel-source.ts
|
|
2338
|
-
var zarrita, ZarritaPixelSource;
|
|
2339
|
-
var init_zarrita_pixel_source = __esm({
|
|
2340
|
-
"src/zarr/lib/zarrita-pixel-source.ts"() {
|
|
2341
|
-
"use strict";
|
|
2342
|
-
zarrita = __toESM(require("zarrita"), 1);
|
|
2343
|
-
init_utils();
|
|
2344
|
-
init_zarr_data_cache();
|
|
2345
|
-
ZarritaPixelSource = class {
|
|
2346
|
-
/** Dimension labels for the backing array. */
|
|
2347
|
-
labels;
|
|
2348
|
-
/** Square power-of-two tile size used by legacy tile consumers. */
|
|
2349
|
-
tileSize;
|
|
2350
|
-
/** Native chunk width. */
|
|
2351
|
-
tileWidth;
|
|
2352
|
-
/** Native chunk height. */
|
|
2353
|
-
tileHeight;
|
|
2354
|
-
/** Backing Zarrita array. */
|
|
2355
|
-
data;
|
|
2356
|
-
/** Converts named selections to positional Zarrita selections. */
|
|
2357
|
-
indexer;
|
|
2358
|
-
/** Creates a pixel source for one Zarr pyramid level. */
|
|
2359
|
-
constructor(data, labels, tileSize) {
|
|
2360
|
-
this.indexer = getIndexer(labels);
|
|
2361
|
-
this.data = data;
|
|
2362
|
-
this.labels = labels;
|
|
2363
|
-
this.tileSize = tileSize;
|
|
2364
|
-
const interleaved = labels[labels.length - 1] === "_c";
|
|
2365
|
-
[this.tileHeight, this.tileWidth] = data.chunks.slice(interleaved ? -3 : -2);
|
|
2366
|
-
}
|
|
2367
|
-
/** Array dimensions. */
|
|
2368
|
-
get shape() {
|
|
2369
|
-
return this.data.shape;
|
|
2370
|
-
}
|
|
2371
|
-
/** Chunk dimensions. */
|
|
2372
|
-
get chunks() {
|
|
2373
|
-
return this.data.chunks;
|
|
2374
|
-
}
|
|
2375
|
-
/** Zarrita dtype identifier. */
|
|
2376
|
-
get dtype() {
|
|
2377
|
-
return this.data.dtype;
|
|
2378
|
-
}
|
|
2379
|
-
/** Positional index of the x dimension. */
|
|
2380
|
-
get xIndex() {
|
|
2381
|
-
const interleaved = this.labels[this.labels.length - 1] === "_c";
|
|
2382
|
-
return this.data.shape.length - (interleaved ? 2 : 1);
|
|
2383
|
-
}
|
|
2384
|
-
/** Inserts x and y selectors into a named or positional selection. */
|
|
2385
|
-
chunkIndex(selection, x, y) {
|
|
2386
|
-
const sel = this.indexer(selection);
|
|
2387
|
-
sel[this.xIndex] = x;
|
|
2388
|
-
sel[this.xIndex - 1] = y;
|
|
2389
|
-
return sel;
|
|
2390
|
-
}
|
|
2391
|
-
/** Reads a complete 2D plane from the backing array. */
|
|
2392
|
-
async getRaster({
|
|
2393
|
-
selection,
|
|
2394
|
-
signal
|
|
2395
|
-
}) {
|
|
2396
|
-
const sel = this.chunkIndex(selection, null, null);
|
|
2397
|
-
if (this.labels[this.labels.length - 1] === "_c") {
|
|
2398
|
-
sel[sel.length - 1] = null;
|
|
2399
|
-
}
|
|
2400
|
-
const chunk = await getCachedZarrSelection(
|
|
2401
|
-
this.data,
|
|
2402
|
-
getZarrSelectionKey(sel),
|
|
2403
|
-
() => zarrita.get(this.data, sel),
|
|
2404
|
-
signal
|
|
2405
|
-
);
|
|
2406
|
-
if (!chunk || typeof chunk !== "object" || !("data" in chunk) || !("shape" in chunk)) {
|
|
2407
|
-
throw new Error("Failed to read Zarr raster selection.");
|
|
2408
|
-
}
|
|
2409
|
-
const shape = chunk.shape;
|
|
2410
|
-
const interleaved = this.labels[this.labels.length - 1] === "_c";
|
|
2411
|
-
const [height, width] = shape.slice(interleaved ? -3 : -2);
|
|
2412
|
-
return { data: cloneZarrSelection(chunk).data, width, height };
|
|
2413
|
-
}
|
|
2414
|
-
/** Reads one square tile from the backing array. */
|
|
2415
|
-
async getTile({ x, y, selection, signal }) {
|
|
2416
|
-
const interleaved = this.labels[this.labels.length - 1] === "_c";
|
|
2417
|
-
const [height, width] = this.data.shape.slice(interleaved ? -3 : -2);
|
|
2418
|
-
const xStart = x * this.tileSize;
|
|
2419
|
-
const xStop = Math.min((x + 1) * this.tileSize, width);
|
|
2420
|
-
const yStart = y * this.tileSize;
|
|
2421
|
-
const yStop = Math.min((y + 1) * this.tileSize, height);
|
|
2422
|
-
if (xStart === xStop || yStart === yStop) {
|
|
2423
|
-
throw new Error("Tile slice is zero-sized.");
|
|
2424
|
-
}
|
|
2425
|
-
const sel = this.chunkIndex(
|
|
2426
|
-
selection,
|
|
2427
|
-
zarrita.slice(xStart, xStop),
|
|
2428
|
-
zarrita.slice(yStart, yStop)
|
|
2429
|
-
);
|
|
2430
|
-
const chunk = await getCachedZarrSelection(
|
|
2431
|
-
this.data,
|
|
2432
|
-
getZarrSelectionKey(sel),
|
|
2433
|
-
() => zarrita.get(this.data, sel),
|
|
2434
|
-
signal
|
|
2435
|
-
);
|
|
2436
|
-
if (!chunk || typeof chunk !== "object" || !("data" in chunk) || !("shape" in chunk)) {
|
|
2437
|
-
throw new Error("Failed to read Zarr tile selection.");
|
|
2438
|
-
}
|
|
2439
|
-
const shape = chunk.shape;
|
|
2440
|
-
const [tileHeight, tileWidth] = shape.slice(interleaved ? -3 : -2);
|
|
2441
|
-
return {
|
|
2442
|
-
data: cloneZarrSelection(chunk).data,
|
|
2443
|
-
width: tileWidth,
|
|
2444
|
-
height: tileHeight
|
|
2445
|
-
};
|
|
2446
|
-
}
|
|
2447
|
-
};
|
|
2448
|
-
}
|
|
2449
|
-
});
|
|
2450
|
-
|
|
2451
|
-
// src/zarr/lib/consolidated-zarr.ts
|
|
2452
|
-
async function loadConsolidatedMetadata(url, fetcher, options = {}) {
|
|
2453
|
-
var _a;
|
|
2454
|
-
const metadataPaths = getMetadataPaths(options.metadataPath);
|
|
2455
|
-
let urlEnd = url.length;
|
|
2456
|
-
while (urlEnd > 0 && url[urlEnd - 1] === "/") {
|
|
2457
|
-
urlEnd--;
|
|
2458
|
-
}
|
|
2459
|
-
const normalizedUrl = url.slice(0, urlEnd);
|
|
2460
|
-
const errors = [];
|
|
2461
|
-
for (const metadataPath of metadataPaths) {
|
|
2462
|
-
const metadataUrl = `${normalizedUrl}/${metadataPath}`;
|
|
2463
|
-
const response = await fetcher(metadataUrl, { signal: options.signal });
|
|
2464
|
-
if (response.status === 404) {
|
|
2465
|
-
errors.push(`${metadataPath}: 404`);
|
|
2466
|
-
continue;
|
|
2467
|
-
}
|
|
2468
|
-
if (!response.ok) {
|
|
2469
|
-
errors.push(`${metadataPath}: ${response.status} ${response.statusText}`);
|
|
2470
|
-
continue;
|
|
2471
|
-
}
|
|
2472
|
-
try {
|
|
2473
|
-
const json = await response.json();
|
|
2474
|
-
return normalizeConsolidatedMetadata(json, metadataPath);
|
|
2475
|
-
} catch (error) {
|
|
2476
|
-
if (((_a = options.signal) == null ? void 0 : _a.aborted) || options.metadataPath !== void 0 && options.metadataPath !== "auto") {
|
|
2477
|
-
throw error;
|
|
2478
|
-
}
|
|
2479
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
2480
|
-
errors.push(`${metadataPath}: ${message}`);
|
|
2481
|
-
}
|
|
2482
|
-
}
|
|
2483
|
-
throw new Error(
|
|
2484
|
-
`Could not load consolidated Zarr metadata for ${url}. Tried ${metadataPaths.join(", ")}. ${errors.join("; ")}`
|
|
2485
|
-
);
|
|
2486
|
-
}
|
|
2487
|
-
function getMetadataPaths(metadataPath = "auto") {
|
|
2488
|
-
if (metadataPath === "auto") {
|
|
2489
|
-
return ["zarr.json", ".zmetadata", "zmetadata"];
|
|
2490
|
-
}
|
|
2491
|
-
return [metadataPath];
|
|
2492
|
-
}
|
|
2493
|
-
function normalizeConsolidatedMetadata(metadata, metadataPath) {
|
|
2494
|
-
var _a;
|
|
2495
|
-
if (metadataPath === "zarr.json") {
|
|
2496
|
-
const normalizedMetadata2 = (_a = metadata.consolidated_metadata) == null ? void 0 : _a.metadata;
|
|
2497
|
-
if (!normalizedMetadata2 || typeof normalizedMetadata2 !== "object") {
|
|
2498
|
-
throw new Error("Invalid zarr.json: missing consolidated_metadata.metadata object.");
|
|
2499
|
-
}
|
|
2500
|
-
return {
|
|
2501
|
-
format: "v3",
|
|
2502
|
-
metadataPath,
|
|
2503
|
-
metadata: normalizedMetadata2,
|
|
2504
|
-
rootAttributes: { ...metadata.attributes || {} },
|
|
2505
|
-
topLevelGroups: extractV3TopLevelNodes(normalizedMetadata2, "group"),
|
|
2506
|
-
topLevelArrays: extractV3TopLevelNodes(normalizedMetadata2, "array")
|
|
2507
|
-
};
|
|
2508
|
-
}
|
|
2509
|
-
const normalizedMetadata = metadata.metadata;
|
|
2510
|
-
if (!normalizedMetadata || typeof normalizedMetadata !== "object") {
|
|
2511
|
-
throw new Error(`Invalid ${metadataPath}: missing metadata object.`);
|
|
2512
|
-
}
|
|
2513
|
-
return {
|
|
2514
|
-
format: "v2",
|
|
2515
|
-
metadataPath,
|
|
2516
|
-
metadata: normalizedMetadata,
|
|
2517
|
-
rootAttributes: getV2RootAttributes(normalizedMetadata),
|
|
2518
|
-
topLevelGroups: extractV2TopLevelNodes(Object.keys(normalizedMetadata), "zgroup"),
|
|
2519
|
-
topLevelArrays: extractV2TopLevelNodes(Object.keys(normalizedMetadata), "zarray")
|
|
2520
|
-
};
|
|
2521
|
-
}
|
|
2522
|
-
function getV2RootAttributes(metadata) {
|
|
2523
|
-
const attributes = metadata[".zattrs"];
|
|
2524
|
-
return attributes && typeof attributes === "object" ? { ...attributes } : {};
|
|
2525
|
-
}
|
|
2526
|
-
function extractV2TopLevelNodes(paths, nodeType) {
|
|
2527
|
-
const suffix = `.${nodeType}`;
|
|
2528
|
-
const nodePaths = paths.filter((path) => path === suffix || path.endsWith(`/${suffix}`)).map((path) => path.slice(0, -suffix.length).replace(/\/+$/, ""));
|
|
2529
|
-
return extractDirectChildren(nodePaths);
|
|
2530
|
-
}
|
|
2531
|
-
function extractV3TopLevelNodes(metadata, nodeType) {
|
|
2532
|
-
const nodePaths = Object.entries(metadata).filter(
|
|
2533
|
-
([, value]) => Boolean(
|
|
2534
|
-
value && typeof value === "object" && value.node_type === nodeType
|
|
2535
|
-
)
|
|
2536
|
-
).map(([path]) => path);
|
|
2537
|
-
return extractDirectChildren(nodePaths);
|
|
2538
|
-
}
|
|
2539
|
-
function extractDirectChildren(paths) {
|
|
2540
|
-
const directChildren = /* @__PURE__ */ new Set();
|
|
2541
|
-
for (const path of paths) {
|
|
2542
|
-
const normalizedPath = path.replace(/^\/+|\/+$/g, "");
|
|
2543
|
-
if (!normalizedPath || normalizedPath.includes("/")) {
|
|
2544
|
-
continue;
|
|
2545
|
-
}
|
|
2546
|
-
directChildren.add(normalizedPath);
|
|
2547
|
-
}
|
|
2548
|
-
return [...directChildren].sort();
|
|
2549
|
-
}
|
|
2550
|
-
var init_consolidated_zarr = __esm({
|
|
2551
|
-
"src/zarr/lib/consolidated-zarr.ts"() {
|
|
2552
|
-
"use strict";
|
|
2553
|
-
}
|
|
2554
|
-
});
|
|
2555
|
-
|
|
2556
|
-
// src/zarr/ome-zarr-source-loader.ts
|
|
2557
|
-
var ome_zarr_source_loader_exports = {};
|
|
2558
|
-
__export(ome_zarr_source_loader_exports, {
|
|
2559
|
-
OMEZarrImageSource: () => OMEZarrImageSource,
|
|
2560
|
-
OMEZarrSourceLoaderWithParser: () => OMEZarrSourceLoaderWithParser,
|
|
2561
|
-
ZarrSource: () => ZarrSource,
|
|
2562
|
-
loadZarrConsolidatedMetadata: () => loadZarrConsolidatedMetadata
|
|
2563
|
-
});
|
|
2564
|
-
async function loadZarrConsolidatedMetadata(url, options = {}) {
|
|
2565
|
-
const fetcher = options.fetch || fetch;
|
|
2566
|
-
return await loadConsolidatedMetadata(url, fetcher, options);
|
|
2567
|
-
}
|
|
2568
|
-
function normalizeRootAttrs(attrs) {
|
|
2569
|
-
var _a;
|
|
2570
|
-
const omeAttrs = "ome" in attrs && attrs.ome ? attrs.ome : null;
|
|
2571
|
-
const multiscales = ("multiscales" in attrs ? attrs.multiscales : void 0) || (omeAttrs == null ? void 0 : omeAttrs.multiscales) || [];
|
|
2572
|
-
const legacyCoordinateTransformations = "coordinateTransformations" in attrs ? attrs.coordinateTransformations : void 0;
|
|
2573
|
-
return {
|
|
2574
|
-
multiscales,
|
|
2575
|
-
omero: ("omero" in attrs ? attrs.omero : void 0) || (omeAttrs == null ? void 0 : omeAttrs.omero) || {},
|
|
2576
|
-
coordinateTransformations: ((_a = multiscales[0]) == null ? void 0 : _a.coordinateTransformations) || legacyCoordinateTransformations || (omeAttrs == null ? void 0 : omeAttrs.coordinateTransformations)
|
|
2577
|
-
};
|
|
2578
|
-
}
|
|
2579
|
-
function inferLabels(attrs, array, optionLabels) {
|
|
2580
|
-
var _a, _b;
|
|
2581
|
-
const labels = optionLabels || normalizeDimensionNames(array.dimensionNames) || getAxisNames((_b = (_a = attrs.multiscales) == null ? void 0 : _a[0]) == null ? void 0 : _b.axes) || guessLabels(attrs);
|
|
2582
|
-
if (!validLabels(labels, array.shape)) {
|
|
2583
|
-
throw new Error("Invalid labels for OME-Zarr array dimensions.");
|
|
2584
|
-
}
|
|
2585
|
-
return labels;
|
|
2586
|
-
}
|
|
2587
|
-
function normalizeDimensionNames(dimensionNames) {
|
|
2588
|
-
if (!(dimensionNames == null ? void 0 : dimensionNames.length)) {
|
|
2589
|
-
return null;
|
|
2590
|
-
}
|
|
2591
|
-
return [...dimensionNames];
|
|
2592
|
-
}
|
|
2593
|
-
function getAxisNames(axes) {
|
|
2594
|
-
if (!(axes == null ? void 0 : axes.length)) {
|
|
2595
|
-
return null;
|
|
2596
|
-
}
|
|
2597
|
-
const labels = axes.map((axis) => typeof axis === "string" ? axis : axis.name).filter((axisName) => Boolean(axisName));
|
|
2598
|
-
return labels.length ? labels : null;
|
|
2599
|
-
}
|
|
2600
|
-
function normalizeOMEZarrMetadata(data, attrs, sources) {
|
|
2601
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2602
|
-
const baseSource = sources[0];
|
|
2603
|
-
const interleaved = baseSource.labels[baseSource.labels.length - 1] === "_c";
|
|
2604
|
-
const [height, width] = baseSource.shape.slice(interleaved ? -3 : -2);
|
|
2605
|
-
const labels = [...baseSource.labels];
|
|
2606
|
-
const dtype = normalizeDtype(baseSource.dtype);
|
|
2607
|
-
const bandCount = getAxisSize(baseSource.shape, labels, "_c") || getAxisSize(baseSource.shape, labels, "c") || ((_b = (_a = attrs.omero) == null ? void 0 : _a.channels) == null ? void 0 : _b.length) || 1;
|
|
2608
|
-
const levels = sources.map((source, level) => {
|
|
2609
|
-
var _a2;
|
|
2610
|
-
const levelInterleaved = source.labels[source.labels.length - 1] === "_c";
|
|
2611
|
-
const [levelHeight, levelWidth] = source.shape.slice(levelInterleaved ? -3 : -2);
|
|
2612
|
-
const dataset = (_a2 = attrs.multiscales[0]) == null ? void 0 : _a2.datasets[level];
|
|
2613
|
-
return {
|
|
2614
|
-
level,
|
|
2615
|
-
path: (dataset == null ? void 0 : dataset.path) || String(level),
|
|
2616
|
-
width: levelWidth,
|
|
2617
|
-
height: levelHeight,
|
|
2618
|
-
coordinateTransformations: dataset == null ? void 0 : dataset.coordinateTransformations,
|
|
2619
|
-
scale: [width / levelWidth, height / levelHeight]
|
|
2620
|
-
};
|
|
2621
|
-
});
|
|
2622
|
-
return {
|
|
2623
|
-
name: ((_c = attrs.omero) == null ? void 0 : _c.name) || getOMEZarrName(data),
|
|
2624
|
-
width,
|
|
2625
|
-
height,
|
|
2626
|
-
bandCount,
|
|
2627
|
-
dtype,
|
|
2628
|
-
sizeT: getAxisSize(baseSource.shape, labels, "t") || 1,
|
|
2629
|
-
sizeZ: getAxisSize(baseSource.shape, labels, "z") || 1,
|
|
2630
|
-
sizeC: getAxisSize(baseSource.shape, labels, "c") || getAxisSize(baseSource.shape, labels, "_c") || ((_e = (_d = attrs.omero) == null ? void 0 : _d.channels) == null ? void 0 : _e.length) || 1,
|
|
2631
|
-
defaultT: ((_g = (_f = attrs.omero) == null ? void 0 : _f.rdefs) == null ? void 0 : _g.defaultT) ?? 0,
|
|
2632
|
-
defaultZ: ((_i = (_h = attrs.omero) == null ? void 0 : _h.rdefs) == null ? void 0 : _i.defaultZ) ?? 0,
|
|
2633
|
-
labels,
|
|
2634
|
-
tileSize: { width: baseSource.tileWidth, height: baseSource.tileHeight },
|
|
2635
|
-
levels,
|
|
2636
|
-
channels: (((_j = attrs.omero) == null ? void 0 : _j.channels) || []).map(normalizeChannel),
|
|
2637
|
-
metadata: attrs,
|
|
2638
|
-
coordinateTransformations: attrs.coordinateTransformations
|
|
2639
|
-
};
|
|
2640
|
-
}
|
|
2641
|
-
function selectOMEZarrLevel(levels, parameters) {
|
|
2642
|
-
if (typeof parameters.level === "number") {
|
|
2643
|
-
return parameters.level;
|
|
2644
|
-
}
|
|
2645
|
-
if (parameters.level !== "auto" || !parameters.width || !parameters.height) {
|
|
2646
|
-
return 0;
|
|
2647
|
-
}
|
|
2648
|
-
const suitable = levels.filter((level) => level.width >= parameters.width && level.height >= parameters.height).sort((first, second) => first.width * first.height - second.width * second.height);
|
|
2649
|
-
return (suitable[0] || levels[0]).level;
|
|
2650
|
-
}
|
|
2651
|
-
function normalizeChannel(channel, index) {
|
|
2652
|
-
return {
|
|
2653
|
-
index,
|
|
2654
|
-
name: channel.label,
|
|
2655
|
-
color: channel.color,
|
|
2656
|
-
active: channel.active
|
|
2657
|
-
};
|
|
2658
|
-
}
|
|
2659
|
-
function getAxisSize(shape, labels, label) {
|
|
2660
|
-
const index = labels.indexOf(label);
|
|
2661
|
-
return index >= 0 ? shape[index] : null;
|
|
2662
|
-
}
|
|
2663
|
-
function normalizeDtype(dtype) {
|
|
2664
|
-
switch (dtype) {
|
|
2665
|
-
case "uint8":
|
|
2666
|
-
case "uint16":
|
|
2667
|
-
case "uint32":
|
|
2668
|
-
case "int8":
|
|
2669
|
-
case "int16":
|
|
2670
|
-
case "int32":
|
|
2671
|
-
case "float32":
|
|
2672
|
-
case "float64":
|
|
2673
|
-
return dtype;
|
|
2674
|
-
default:
|
|
2675
|
-
throw new Error(`OME-Zarr dtype ${dtype} is not currently supported.`);
|
|
2676
|
-
}
|
|
2677
|
-
}
|
|
2678
|
-
function normalizeChannelSelection(requestedChannels, bandCount, defaultChannels) {
|
|
2679
|
-
const channelSelection = requestedChannels || defaultChannels || Array.from({ length: bandCount }, (_, index) => index);
|
|
2680
|
-
if (channelSelection.length === 0) {
|
|
2681
|
-
throw new Error("OME-Zarr channel selection must include at least one channel.");
|
|
2682
|
-
}
|
|
2683
|
-
for (const channel of channelSelection) {
|
|
2684
|
-
if (!Number.isInteger(channel) || channel < 0 || channel >= bandCount) {
|
|
2685
|
-
throw new Error(`Channel ${channel} is out of bounds for OME-Zarr with ${bandCount} bands.`);
|
|
2686
|
-
}
|
|
2687
|
-
}
|
|
2688
|
-
return [...channelSelection];
|
|
2689
|
-
}
|
|
2690
|
-
function normalizeAxisSelection(requestedIndex, defaultIndex, size, axisName) {
|
|
2691
|
-
const index = requestedIndex ?? defaultIndex;
|
|
2692
|
-
if (!Number.isInteger(index) || index < 0 || index >= size) {
|
|
2693
|
-
throw new Error(`OME-Zarr ${axisName} index ${index} is out of bounds for axis size ${size}.`);
|
|
2694
|
-
}
|
|
2695
|
-
return index;
|
|
2696
|
-
}
|
|
2697
|
-
function getOMEZarrName(data) {
|
|
2698
|
-
const normalizedData = data.replace(/[?#].*$/, "").replace(/\/+$/, "");
|
|
2699
|
-
return normalizedData.split("/").pop() || normalizedData;
|
|
2700
|
-
}
|
|
2701
|
-
function getFetchableUrl(url) {
|
|
2702
|
-
if (!url.startsWith("file:")) {
|
|
2703
|
-
return url;
|
|
2704
|
-
}
|
|
2705
|
-
return decodeURIComponent(new URL(url).pathname);
|
|
2706
|
-
}
|
|
2707
|
-
function getZarritaStoreUrl(url) {
|
|
2708
|
-
var _a;
|
|
2709
|
-
if (typeof ((_a = globalThis.location) == null ? void 0 : _a.href) !== "string") {
|
|
2710
|
-
return url;
|
|
2711
|
-
}
|
|
2712
|
-
return new URL(url, globalThis.location.href).href;
|
|
2713
|
-
}
|
|
2714
|
-
function interleaveTypedArrays(data, dtype) {
|
|
2715
|
-
var _a;
|
|
2716
|
-
const TypedArrayConstructor = getTypedArrayConstructor(dtype);
|
|
2717
|
-
const length = ((_a = data[0]) == null ? void 0 : _a.length) || 0;
|
|
2718
|
-
const channelCount = data.length;
|
|
2719
|
-
const interleaved = new TypedArrayConstructor(length * channelCount);
|
|
2720
|
-
for (let index = 0; index < length; index++) {
|
|
2721
|
-
for (let channelIndex = 0; channelIndex < channelCount; channelIndex++) {
|
|
2722
|
-
interleaved[index * channelCount + channelIndex] = data[channelIndex][index];
|
|
2723
|
-
}
|
|
2724
|
-
}
|
|
2725
|
-
return interleaved;
|
|
2726
|
-
}
|
|
2727
|
-
function selectInterleavedChannels(data, bandCount, channels, interleaved) {
|
|
2728
|
-
if (channels.length === bandCount && interleaved && channels.every((channel, index) => channel === index)) {
|
|
2729
|
-
return data;
|
|
2730
|
-
}
|
|
2731
|
-
const TypedArrayConstructor = data.constructor;
|
|
2732
|
-
const pixelCount = data.length / bandCount;
|
|
2733
|
-
const channelData = channels.map(() => new TypedArrayConstructor(pixelCount));
|
|
2734
|
-
for (let pixelIndex = 0; pixelIndex < pixelCount; pixelIndex++) {
|
|
2735
|
-
for (let channelSelectionIndex = 0; channelSelectionIndex < channels.length; channelSelectionIndex++) {
|
|
2736
|
-
channelData[channelSelectionIndex][pixelIndex] = data[pixelIndex * bandCount + channels[channelSelectionIndex]];
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
if (interleaved) {
|
|
2740
|
-
return interleaveTypedArrays(channelData, getTypedArrayDtype(TypedArrayConstructor));
|
|
2741
|
-
}
|
|
2742
|
-
return channelData.length === 1 ? channelData[0] : channelData;
|
|
2743
|
-
}
|
|
2744
|
-
function getTypedArrayConstructor(dtype) {
|
|
2745
|
-
switch (dtype) {
|
|
2746
|
-
case "uint8":
|
|
2747
|
-
return Uint8Array;
|
|
2748
|
-
case "uint16":
|
|
2749
|
-
return Uint16Array;
|
|
2750
|
-
case "uint32":
|
|
2751
|
-
return Uint32Array;
|
|
2752
|
-
case "int8":
|
|
2753
|
-
return Int8Array;
|
|
2754
|
-
case "int16":
|
|
2755
|
-
return Int16Array;
|
|
2756
|
-
case "int32":
|
|
2757
|
-
return Int32Array;
|
|
2758
|
-
case "float32":
|
|
2759
|
-
return Float32Array;
|
|
2760
|
-
case "float64":
|
|
2761
|
-
return Float64Array;
|
|
2762
|
-
default:
|
|
2763
|
-
throw new Error(`Unsupported dtype ${dtype}.`);
|
|
2764
|
-
}
|
|
2765
|
-
}
|
|
2766
|
-
function getTypedArrayDtype(TypedArrayConstructor) {
|
|
2767
|
-
switch (TypedArrayConstructor) {
|
|
2768
|
-
case Uint8Array:
|
|
2769
|
-
return "uint8";
|
|
2770
|
-
case Uint16Array:
|
|
2771
|
-
return "uint16";
|
|
2772
|
-
case Uint32Array:
|
|
2773
|
-
return "uint32";
|
|
2774
|
-
case Int8Array:
|
|
2775
|
-
return "int8";
|
|
2776
|
-
case Int16Array:
|
|
2777
|
-
return "int16";
|
|
2778
|
-
case Int32Array:
|
|
2779
|
-
return "int32";
|
|
2780
|
-
case Float32Array:
|
|
2781
|
-
return "float32";
|
|
2782
|
-
case Float64Array:
|
|
2783
|
-
return "float64";
|
|
2784
|
-
default:
|
|
2785
|
-
throw new Error("Unsupported TypedArray constructor.");
|
|
2786
|
-
}
|
|
2787
|
-
}
|
|
2788
|
-
var zarrita2, VERSION6, ZarrSource, OMEZarrSourceLoaderWithParser, OMEZarrImageSource;
|
|
2789
|
-
var init_ome_zarr_source_loader = __esm({
|
|
2790
|
-
"src/zarr/ome-zarr-source-loader.ts"() {
|
|
2791
|
-
"use strict";
|
|
2792
|
-
zarrita2 = __toESM(require("zarrita"), 1);
|
|
2793
|
-
init_loader_utils();
|
|
2794
|
-
init_utils();
|
|
2795
|
-
init_zarrita_pixel_source();
|
|
2796
|
-
init_consolidated_zarr();
|
|
2797
|
-
VERSION6 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
2798
|
-
ZarrSource = class extends DataSource {
|
|
2799
|
-
/** Common raster-query capabilities shared by Zarr-backed sources. */
|
|
2800
|
-
rasterQueryCapabilities = Object.freeze({
|
|
2801
|
-
bounds: "pushdown",
|
|
2802
|
-
level: "pushdown",
|
|
2803
|
-
variables: "pushdown",
|
|
2804
|
-
slices: "pushdown",
|
|
2805
|
-
streaming: false,
|
|
2806
|
-
cancellation: true
|
|
2807
|
-
});
|
|
2808
|
-
/** Zarrita store used for metadata and chunk reads. */
|
|
2809
|
-
store;
|
|
2810
|
-
/** Selected group path within the store root. */
|
|
2811
|
-
path;
|
|
2812
|
-
/** Shared consolidated metadata request. */
|
|
2813
|
-
consolidatedMetadataPromise = null;
|
|
2814
|
-
/** Creates a Zarr-backed source. */
|
|
2815
|
-
constructor(data, options, coreApi) {
|
|
2816
|
-
var _a;
|
|
2817
|
-
super(
|
|
2818
|
-
data,
|
|
2819
|
-
options,
|
|
2820
|
-
{
|
|
2821
|
-
zarr: {
|
|
2822
|
-
metadataPath: "auto",
|
|
2823
|
-
path: null,
|
|
2824
|
-
labels: void 0,
|
|
2825
|
-
requireConsolidatedMetadata: true
|
|
2826
|
-
},
|
|
2827
|
-
omezarr: {
|
|
2828
|
-
interleaved: false,
|
|
2829
|
-
defaultChannels: void 0
|
|
2830
|
-
}
|
|
2831
|
-
},
|
|
2832
|
-
coreApi
|
|
2833
|
-
);
|
|
2834
|
-
this.path = ((_a = this.options.zarr) == null ? void 0 : _a.path) || null;
|
|
2835
|
-
this.store = new zarrita2.FetchStore(getZarritaStoreUrl(this.url), {
|
|
2836
|
-
fetch: async (request) => {
|
|
2837
|
-
const headers = Object.fromEntries(request.headers.entries());
|
|
2838
|
-
return await this.fetchZarrFile(request.url, {
|
|
2839
|
-
method: request.method,
|
|
2840
|
-
headers,
|
|
2841
|
-
signal: request.signal
|
|
2842
|
-
});
|
|
2843
|
-
}
|
|
2844
|
-
});
|
|
2845
|
-
}
|
|
2846
|
-
/** Returns raster-query capabilities without reading array chunks. */
|
|
2847
|
-
getRasterQueryCapabilities() {
|
|
2848
|
-
return this.rasterQueryCapabilities;
|
|
2849
|
-
}
|
|
2850
|
-
/** Fetches Zarr metadata or chunk data through the injected core API when available. */
|
|
2851
|
-
async fetchZarrFile(url, requestOptions) {
|
|
2852
|
-
const fetchUrl = getFetchableUrl(url);
|
|
2853
|
-
const response = this.hasCoreApi ? await this.coreApi.fetchFile(fetchUrl, requestOptions) : await this.fetch(fetchUrl, requestOptions);
|
|
2854
|
-
if (response.status === 400 && response.statusText.includes("ENOENT")) {
|
|
2855
|
-
return new Response(null, { status: 404, statusText: "Not Found" });
|
|
2856
|
-
}
|
|
2857
|
-
return response;
|
|
2858
|
-
}
|
|
2859
|
-
/** Loads normalized consolidated metadata for the backing Zarr store. */
|
|
2860
|
-
async getConsolidatedMetadata(signal) {
|
|
2861
|
-
var _a;
|
|
2862
|
-
if (!this.consolidatedMetadataPromise) {
|
|
2863
|
-
this.consolidatedMetadataPromise = loadConsolidatedMetadata(
|
|
2864
|
-
this.url,
|
|
2865
|
-
(url, requestOptions) => this.fetchZarrFile(url, requestOptions),
|
|
2866
|
-
{
|
|
2867
|
-
metadataPath: (_a = this.options.zarr) == null ? void 0 : _a.metadataPath,
|
|
2868
|
-
signal
|
|
2869
|
-
}
|
|
2870
|
-
);
|
|
2871
|
-
}
|
|
2872
|
-
const consolidatedMetadataPromise = this.consolidatedMetadataPromise;
|
|
2873
|
-
try {
|
|
2874
|
-
return await consolidatedMetadataPromise;
|
|
2875
|
-
} catch (error) {
|
|
2876
|
-
if (this.consolidatedMetadataPromise === consolidatedMetadataPromise) {
|
|
2877
|
-
this.consolidatedMetadataPromise = null;
|
|
2878
|
-
}
|
|
2879
|
-
throw error;
|
|
2880
|
-
}
|
|
2881
|
-
}
|
|
2882
|
-
/** Opens the selected Zarr group after the configured metadata preflight. */
|
|
2883
|
-
async openGroup(signal) {
|
|
2884
|
-
var _a;
|
|
2885
|
-
if ((_a = this.options.zarr) == null ? void 0 : _a.requireConsolidatedMetadata) {
|
|
2886
|
-
await this.getConsolidatedMetadata(signal);
|
|
2887
|
-
}
|
|
2888
|
-
const location = this.path ? zarrita2.root(this.store).resolve(this.path) : this.store;
|
|
2889
|
-
return await zarrita2.open(location, { kind: "group", signal });
|
|
2890
|
-
}
|
|
2891
|
-
};
|
|
2892
|
-
OMEZarrSourceLoaderWithParser = {
|
|
2893
|
-
dataType: null,
|
|
2894
|
-
/** Runtime source type marker used by `createDataSource()` type inference. */
|
|
2895
|
-
dataSource: null,
|
|
2896
|
-
batchType: null,
|
|
2897
|
-
name: "OMEZarrSourceLoader",
|
|
2898
|
-
id: "omezarr",
|
|
2899
|
-
module: "scientific",
|
|
2900
|
-
version: VERSION6,
|
|
2901
|
-
extensions: ["zarr"],
|
|
2902
|
-
mimeTypes: [],
|
|
2903
|
-
type: "omezarr",
|
|
2904
|
-
fromUrl: true,
|
|
2905
|
-
fromBlob: false,
|
|
2906
|
-
options: {
|
|
2907
|
-
zarr: {
|
|
2908
|
-
metadataPath: "auto",
|
|
2909
|
-
path: null,
|
|
2910
|
-
labels: void 0,
|
|
2911
|
-
requireConsolidatedMetadata: true
|
|
2912
|
-
},
|
|
2913
|
-
omezarr: {
|
|
2914
|
-
interleaved: false,
|
|
2915
|
-
defaultChannels: void 0
|
|
2916
|
-
}
|
|
2917
|
-
},
|
|
2918
|
-
defaultOptions: {
|
|
2919
|
-
zarr: {
|
|
2920
|
-
metadataPath: "auto",
|
|
2921
|
-
path: null,
|
|
2922
|
-
labels: void 0,
|
|
2923
|
-
requireConsolidatedMetadata: true
|
|
2924
|
-
},
|
|
2925
|
-
omezarr: {
|
|
2926
|
-
interleaved: false,
|
|
2927
|
-
defaultChannels: void 0
|
|
2928
|
-
}
|
|
2929
|
-
},
|
|
2930
|
-
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
2931
|
-
createDataSource: (data, options, coreApi) => new OMEZarrImageSource(data, options, coreApi)
|
|
2932
|
-
};
|
|
2933
|
-
OMEZarrImageSource = class extends ZarrSource {
|
|
2934
|
-
/** Shared source initialization request. */
|
|
2935
|
-
initPromise = null;
|
|
2936
|
-
/** Returns normalized OME-Zarr image and pyramid metadata. */
|
|
2937
|
-
async getMetadata(signal) {
|
|
2938
|
-
const { metadata } = await this.getInitPromise(signal);
|
|
2939
|
-
return metadata;
|
|
2940
|
-
}
|
|
2941
|
-
/** Discovers the raster pyramid through the common scan metadata contract. */
|
|
2942
|
-
async getQueryMetadata(options = {}) {
|
|
2943
|
-
const metadata = await this.getMetadata(options.signal);
|
|
2944
|
-
return createScanQueryMetadata({
|
|
2945
|
-
sourceType: "omezarr",
|
|
2946
|
-
queryType: "raster",
|
|
2947
|
-
execution: { status: "supported", method: "getRaster" },
|
|
2948
|
-
name: metadata.name,
|
|
2949
|
-
description: "OME-Zarr multiscale image",
|
|
2950
|
-
schema: { fields: [], metadata: {} },
|
|
2951
|
-
capabilities: {
|
|
2952
|
-
levelOfDetail: metadata.levels.length > 1 ? "pushdown" : "unsupported"
|
|
2953
|
-
},
|
|
2954
|
-
levels: metadata.levels.map((level) => ({
|
|
2955
|
-
index: level.level,
|
|
2956
|
-
width: level.width,
|
|
2957
|
-
height: level.height,
|
|
2958
|
-
scale: level.scale
|
|
2959
|
-
}))
|
|
2960
|
-
});
|
|
2961
|
-
}
|
|
2962
|
-
/** Loads one 2D OME-Zarr plane or channel composite. */
|
|
2963
|
-
async getRaster(parameters = {}) {
|
|
2964
|
-
var _a, _b;
|
|
2965
|
-
const { data, metadata } = await this.getInitPromise(parameters.signal);
|
|
2966
|
-
const level = selectOMEZarrLevel(metadata.levels, parameters);
|
|
2967
|
-
const pixelSource = data[level];
|
|
2968
|
-
if (!pixelSource) {
|
|
2969
|
-
throw new Error(`OME-Zarr pyramid level ${level} is not available.`);
|
|
2970
|
-
}
|
|
2971
|
-
const interleavedSource = metadata.labels.includes("_c");
|
|
2972
|
-
const interleaved = parameters.interleaved ?? ((_a = this.options.omezarr) == null ? void 0 : _a.interleaved) ?? interleavedSource;
|
|
2973
|
-
const selection = {};
|
|
2974
|
-
const timeIndex = normalizeAxisSelection(
|
|
2975
|
-
parameters.t,
|
|
2976
|
-
metadata.defaultT,
|
|
2977
|
-
metadata.sizeT,
|
|
2978
|
-
"time"
|
|
2979
|
-
);
|
|
2980
|
-
const zIndex = normalizeAxisSelection(parameters.z, metadata.defaultZ, metadata.sizeZ, "z");
|
|
2981
|
-
if (metadata.labels.includes("t")) {
|
|
2982
|
-
selection.t = timeIndex;
|
|
2983
|
-
}
|
|
2984
|
-
if (metadata.labels.includes("z")) {
|
|
2985
|
-
selection.z = zIndex;
|
|
2986
|
-
}
|
|
2987
|
-
const channels = normalizeChannelSelection(
|
|
2988
|
-
parameters.channels,
|
|
2989
|
-
metadata.bandCount,
|
|
2990
|
-
(_b = this.options.omezarr) == null ? void 0 : _b.defaultChannels
|
|
2991
|
-
);
|
|
2992
|
-
if (interleavedSource) {
|
|
2993
|
-
const raster = await pixelSource.getRaster({ selection, signal: parameters.signal });
|
|
2994
|
-
const rawData = raster.data;
|
|
2995
|
-
const channelData2 = selectInterleavedChannels(
|
|
2996
|
-
rawData,
|
|
2997
|
-
metadata.bandCount,
|
|
2998
|
-
channels,
|
|
2999
|
-
interleaved
|
|
3000
|
-
);
|
|
3001
|
-
return {
|
|
3002
|
-
data: channelData2,
|
|
3003
|
-
width: raster.width,
|
|
3004
|
-
height: raster.height,
|
|
3005
|
-
bandCount: channels.length,
|
|
3006
|
-
dtype: metadata.dtype,
|
|
3007
|
-
interleaved,
|
|
3008
|
-
metadata: { selection, channels, level, sourceLabels: metadata.labels }
|
|
3009
|
-
};
|
|
3010
|
-
}
|
|
3011
|
-
const rasters = await Promise.all(
|
|
3012
|
-
channels.map(
|
|
3013
|
-
(channel) => pixelSource.getRaster({
|
|
3014
|
-
selection: { ...selection, c: channel },
|
|
3015
|
-
signal: parameters.signal
|
|
3016
|
-
})
|
|
3017
|
-
)
|
|
3018
|
-
);
|
|
3019
|
-
const { width, height } = rasters[0];
|
|
3020
|
-
const channelData = rasters.map((raster) => raster.data);
|
|
3021
|
-
return {
|
|
3022
|
-
data: interleaved ? interleaveTypedArrays(channelData, metadata.dtype) : channelData.length === 1 ? channelData[0] : channelData,
|
|
3023
|
-
width,
|
|
3024
|
-
height,
|
|
3025
|
-
bandCount: channelData.length,
|
|
3026
|
-
dtype: metadata.dtype,
|
|
3027
|
-
interleaved,
|
|
3028
|
-
metadata: { selection, channels, level, sourceLabels: metadata.labels }
|
|
3029
|
-
};
|
|
3030
|
-
}
|
|
3031
|
-
/** Returns the shared initialization request for this source. */
|
|
3032
|
-
async getInitPromise(signal) {
|
|
3033
|
-
if (!this.initPromise) {
|
|
3034
|
-
this.initPromise = this.initialize(signal);
|
|
3035
|
-
}
|
|
3036
|
-
const initPromise = this.initPromise;
|
|
3037
|
-
try {
|
|
3038
|
-
return await initPromise;
|
|
3039
|
-
} catch (error) {
|
|
3040
|
-
if (this.initPromise === initPromise) {
|
|
3041
|
-
this.initPromise = null;
|
|
3042
|
-
}
|
|
3043
|
-
throw error;
|
|
3044
|
-
}
|
|
3045
|
-
}
|
|
3046
|
-
/** Opens the image group and creates one pixel source per pyramid level. */
|
|
3047
|
-
async initialize(signal) {
|
|
3048
|
-
var _a, _b, _c;
|
|
3049
|
-
const group = await this.openGroup(signal);
|
|
3050
|
-
const attrs = normalizeRootAttrs(group.attrs);
|
|
3051
|
-
const datasets = (_b = (_a = attrs.multiscales) == null ? void 0 : _a[0]) == null ? void 0 : _b.datasets;
|
|
3052
|
-
if (!(datasets == null ? void 0 : datasets.length)) {
|
|
3053
|
-
throw new Error("OMEZarrImageSource requires multiscales metadata on the selected group.");
|
|
3054
|
-
}
|
|
3055
|
-
const arrays = await Promise.all(
|
|
3056
|
-
datasets.map((dataset) => zarrita2.open(group.resolve(dataset.path), { kind: "array", signal }))
|
|
3057
|
-
);
|
|
3058
|
-
const labels = inferLabels(attrs, arrays[0], (_c = this.options.zarr) == null ? void 0 : _c.labels);
|
|
3059
|
-
const tileSize = guessTileSize({ shape: arrays[0].shape, chunks: arrays[0].chunks }, labels);
|
|
3060
|
-
const data = arrays.map((array) => new ZarritaPixelSource(array, labels, tileSize));
|
|
3061
|
-
return {
|
|
3062
|
-
data,
|
|
3063
|
-
metadata: normalizeOMEZarrMetadata(this.path || this.data, attrs, data)
|
|
3064
|
-
};
|
|
3065
|
-
}
|
|
3066
|
-
};
|
|
3067
|
-
}
|
|
3068
|
-
});
|
|
3069
|
-
|
|
3070
|
-
// src/zarr/lib/spatial-multiscales.ts
|
|
3071
|
-
function getSpatialMultiscaleLevels(attributes, array) {
|
|
3072
|
-
const multiscales = attributes == null ? void 0 : attributes.multiscales;
|
|
3073
|
-
const layout = multiscales == null ? void 0 : multiscales.layout;
|
|
3074
|
-
if (!Array.isArray(layout) || !layout.length) return [];
|
|
3075
|
-
const entries = layout;
|
|
3076
|
-
if (entries.some((entry) => !entry || !isChildPath(entry.asset))) {
|
|
3077
|
-
throw new Error("Spatial multiscales assets must be relative child paths.");
|
|
3078
|
-
}
|
|
3079
|
-
const assets = entries.map((entry) => entry.asset);
|
|
3080
|
-
if (new Set(assets).size !== assets.length) throw new Error("Duplicate spatial multiscales asset.");
|
|
3081
|
-
const matches = assets.filter((asset) => array === asset || array.startsWith(`${asset}/`));
|
|
3082
|
-
if (matches.length !== 1) return [];
|
|
3083
|
-
const suffix = array.slice(matches[0].length);
|
|
3084
|
-
return entries.map((entry, index) => ({
|
|
3085
|
-
id: assets[index],
|
|
3086
|
-
array: `${assets[index]}${suffix}`,
|
|
3087
|
-
...suffix ? { group: assets[index] } : {},
|
|
3088
|
-
attributes: entry
|
|
3089
|
-
}));
|
|
3090
|
-
}
|
|
3091
|
-
function isChildPath(value) {
|
|
3092
|
-
return typeof value === "string" && value.length > 0 && !/[\\%:?#\u0000-\u0020]/.test(value) && value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
3093
|
-
}
|
|
3094
|
-
var init_spatial_multiscales = __esm({
|
|
3095
|
-
"src/zarr/lib/spatial-multiscales.ts"() {
|
|
3096
|
-
"use strict";
|
|
3097
|
-
}
|
|
3098
|
-
});
|
|
3099
|
-
|
|
3100
|
-
// src/zarr/geo-zarr-source-loader.ts
|
|
3101
|
-
var geo_zarr_source_loader_exports = {};
|
|
3102
|
-
__export(geo_zarr_source_loader_exports, {
|
|
3103
|
-
GeoZarrRasterSource: () => GeoZarrRasterSource,
|
|
3104
|
-
GeoZarrSourceLoaderWithParser: () => GeoZarrSourceLoaderWithParser
|
|
3105
|
-
});
|
|
3106
|
-
function normalizeAttributes(attributes) {
|
|
3107
|
-
return attributes && typeof attributes === "object" ? attributes : {};
|
|
3108
|
-
}
|
|
3109
|
-
function getDimensionNames(array, attributes) {
|
|
3110
|
-
var _a;
|
|
3111
|
-
const dimensions = ((_a = array.dimensionNames) == null ? void 0 : _a.length) ? [...array.dimensionNames] : normalizeStringArray(attributes._ARRAY_DIMENSIONS);
|
|
3112
|
-
if (!dimensions || dimensions.length !== array.shape.length || new Set(dimensions).size !== dimensions.length) {
|
|
3113
|
-
throw new Error(
|
|
3114
|
-
"GeoZarrRasterSource requires unique Zarr dimension_names or xarray _ARRAY_DIMENSIONS matching the array shape."
|
|
3115
|
-
);
|
|
3116
|
-
}
|
|
3117
|
-
return dimensions;
|
|
3118
|
-
}
|
|
3119
|
-
function getSpatialDimensions(dimensions, attributes, optionDimensions) {
|
|
3120
|
-
const declaredDimensions = optionDimensions || normalizeSpatialDimensions(attributes["spatial:dimensions"]);
|
|
3121
|
-
const spatialDimensions = declaredDimensions || [
|
|
3122
|
-
findDimension(dimensions, ["y", "lat", "latitude"]),
|
|
3123
|
-
findDimension(dimensions, ["x", "lon", "longitude"])
|
|
3124
|
-
];
|
|
3125
|
-
if (spatialDimensions.length !== 2 || !spatialDimensions[0] || !spatialDimensions[1] || !dimensions.includes(spatialDimensions[0]) || !dimensions.includes(spatialDimensions[1]) || spatialDimensions[0] === spatialDimensions[1]) {
|
|
3126
|
-
throw new Error(
|
|
3127
|
-
"GeoZarrRasterSource could not resolve two spatial dimensions. Set spatial:dimensions or geozarr.spatialDimensions."
|
|
3128
|
-
);
|
|
3129
|
-
}
|
|
3130
|
-
return spatialDimensions;
|
|
3131
|
-
}
|
|
3132
|
-
function findDimension(dimensions, candidates) {
|
|
3133
|
-
return dimensions.find((dimension) => candidates.includes(dimension.toLowerCase())) || "";
|
|
3134
|
-
}
|
|
3135
|
-
function normalizeSpatialDimensions(value) {
|
|
3136
|
-
return Array.isArray(value) && value.length === 2 && value.every((item) => typeof item === "string") ? [value[0], value[1]] : null;
|
|
3137
|
-
}
|
|
3138
|
-
function normalizeAffineTransform(value) {
|
|
3139
|
-
return Array.isArray(value) && value.length === 6 && value.every(Number.isFinite) ? value : null;
|
|
3140
|
-
}
|
|
3141
|
-
function normalizeBoundingBox(value) {
|
|
3142
|
-
return Array.isArray(value) && value.length === 4 && value.every(Number.isFinite) ? value : null;
|
|
3143
|
-
}
|
|
3144
|
-
function toRasterBoundingBox(boundingBox) {
|
|
3145
|
-
return [
|
|
3146
|
-
[boundingBox[0], boundingBox[1]],
|
|
3147
|
-
[boundingBox[2], boundingBox[3]]
|
|
3148
|
-
];
|
|
3149
|
-
}
|
|
3150
|
-
function normalizeRegistration(value) {
|
|
3151
|
-
return value === "node" ? "node" : "pixel";
|
|
3152
|
-
}
|
|
3153
|
-
function convertNodeTransformToPixelTransform(transform) {
|
|
3154
|
-
const [scaleX, rotationX, translateX, rotationY, scaleY, translateY] = transform;
|
|
3155
|
-
return [
|
|
3156
|
-
scaleX,
|
|
3157
|
-
rotationX,
|
|
3158
|
-
translateX - (scaleX + rotationX) / 2,
|
|
3159
|
-
rotationY,
|
|
3160
|
-
scaleY,
|
|
3161
|
-
translateY - (rotationY + scaleY) / 2
|
|
3162
|
-
];
|
|
3163
|
-
}
|
|
3164
|
-
async function loadCFCoordinateTransform(group, spatialDimensions, signal) {
|
|
3165
|
-
try {
|
|
3166
|
-
const [yCoordinates, xCoordinates] = await Promise.all([
|
|
3167
|
-
loadCoordinateValues(group, spatialDimensions[0], signal),
|
|
3168
|
-
loadCoordinateValues(group, spatialDimensions[1], signal)
|
|
3169
|
-
]);
|
|
3170
|
-
const scaleX = getRegularCoordinateSpacing(xCoordinates, spatialDimensions[1]);
|
|
3171
|
-
const scaleY = getRegularCoordinateSpacing(yCoordinates, spatialDimensions[0]);
|
|
3172
|
-
return [scaleX, 0, xCoordinates[0] - scaleX / 2, 0, scaleY, yCoordinates[0] - scaleY / 2];
|
|
3173
|
-
} catch {
|
|
3174
|
-
return null;
|
|
3175
|
-
}
|
|
3176
|
-
}
|
|
3177
|
-
async function loadCoordinateValues(group, coordinateName, signal) {
|
|
3178
|
-
const coordinateArray = await zarrita3.open(group.resolve(coordinateName), {
|
|
3179
|
-
kind: "array",
|
|
3180
|
-
signal
|
|
3181
|
-
});
|
|
3182
|
-
if (coordinateArray.shape.length !== 1 || coordinateArray.shape[0] < 2) {
|
|
3183
|
-
throw new Error(
|
|
3184
|
-
`Coordinate ${coordinateName} must be a one-dimensional array with at least two values.`
|
|
3185
|
-
);
|
|
3186
|
-
}
|
|
3187
|
-
const coordinateChunk = await zarrita3.get(coordinateArray, [null], { signal });
|
|
3188
|
-
if (!coordinateChunk || typeof coordinateChunk !== "object" || !("data" in coordinateChunk)) {
|
|
3189
|
-
throw new Error(`Could not read coordinate ${coordinateName}.`);
|
|
3190
|
-
}
|
|
3191
|
-
return Array.from(coordinateChunk.data);
|
|
3192
|
-
}
|
|
3193
|
-
function getRegularCoordinateSpacing(coordinates, coordinateName) {
|
|
3194
|
-
const spacing = (coordinates.at(-1) - coordinates[0]) / (coordinates.length - 1);
|
|
3195
|
-
if (!Number.isFinite(spacing) || spacing === 0) {
|
|
3196
|
-
throw new Error(`Coordinate ${coordinateName} does not have finite non-zero spacing.`);
|
|
3197
|
-
}
|
|
3198
|
-
const tolerance = Math.max(Math.abs(spacing) * 1e-6, Number.EPSILON);
|
|
3199
|
-
for (let index = 0; index < coordinates.length; index++) {
|
|
3200
|
-
const expectedCoordinate = coordinates[0] + spacing * index;
|
|
3201
|
-
if (!Number.isFinite(coordinates[index]) || Math.abs(coordinates[index] - expectedCoordinate) > tolerance) {
|
|
3202
|
-
throw new Error(`Coordinate ${coordinateName} is not regularly spaced.`);
|
|
3203
|
-
}
|
|
3204
|
-
}
|
|
3205
|
-
return spacing;
|
|
3206
|
-
}
|
|
3207
|
-
async function loadCFCoordinateReferenceSystem(group, attributes, spatialDimensions, signal) {
|
|
3208
|
-
const gridMapping = normalizeString(attributes.grid_mapping);
|
|
3209
|
-
if (gridMapping) {
|
|
3210
|
-
const gridMappingName = gridMapping.trim().split(/[\s:]/, 1)[0];
|
|
3211
|
-
try {
|
|
3212
|
-
const gridMappingArray = await zarrita3.open(group.resolve(gridMappingName), {
|
|
3213
|
-
kind: "array",
|
|
3214
|
-
signal
|
|
3215
|
-
});
|
|
3216
|
-
const gridMappingAttributes = normalizeAttributes(gridMappingArray.attrs);
|
|
3217
|
-
const coordinateReferenceSystem = normalizeString(gridMappingAttributes.crs_wkt) || normalizeString(gridMappingAttributes.spatial_ref) || normalizeString(gridMappingAttributes["proj:wkt2"]) || normalizeString(gridMappingAttributes["proj:code"]);
|
|
3218
|
-
if (coordinateReferenceSystem) {
|
|
3219
|
-
return coordinateReferenceSystem;
|
|
3220
|
-
}
|
|
3221
|
-
} catch {
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
|
-
const normalizedDimensions = spatialDimensions.map((dimension) => dimension.toLowerCase());
|
|
3225
|
-
if (["lat", "latitude"].includes(normalizedDimensions[0]) && ["lon", "longitude"].includes(normalizedDimensions[1])) {
|
|
3226
|
-
return "EPSG:4326";
|
|
3227
|
-
}
|
|
3228
|
-
return void 0;
|
|
3229
|
-
}
|
|
3230
|
-
function getTransformBoundingBox(transform, width, height) {
|
|
3231
|
-
const corners = [
|
|
3232
|
-
transformPosition(transform, 0, 0),
|
|
3233
|
-
transformPosition(transform, width, 0),
|
|
3234
|
-
transformPosition(transform, 0, height),
|
|
3235
|
-
transformPosition(transform, width, height)
|
|
3236
|
-
];
|
|
3237
|
-
const xCoordinates = corners.map((position) => position[0]);
|
|
3238
|
-
const yCoordinates = corners.map((position) => position[1]);
|
|
3239
|
-
return [
|
|
3240
|
-
[Math.min(...xCoordinates), Math.min(...yCoordinates)],
|
|
3241
|
-
[Math.max(...xCoordinates), Math.max(...yCoordinates)]
|
|
3242
|
-
];
|
|
3243
|
-
}
|
|
3244
|
-
function transformPosition(transform, column, row) {
|
|
3245
|
-
const [scaleX, rotationX, translateX, rotationY, scaleY, translateY] = transform;
|
|
3246
|
-
return [
|
|
3247
|
-
scaleX * column + rotationX * row + translateX,
|
|
3248
|
-
rotationY * column + scaleY * row + translateY
|
|
3249
|
-
];
|
|
3250
|
-
}
|
|
3251
|
-
function intersectBoundingBoxes(leftBoundingBox, rightBoundingBox) {
|
|
3252
|
-
if (!rightBoundingBox) {
|
|
3253
|
-
return null;
|
|
3254
|
-
}
|
|
3255
|
-
const minimumX = Math.max(leftBoundingBox[0][0], rightBoundingBox[0][0]);
|
|
3256
|
-
const minimumY = Math.max(leftBoundingBox[0][1], rightBoundingBox[0][1]);
|
|
3257
|
-
const maximumX = Math.min(leftBoundingBox[1][0], rightBoundingBox[1][0]);
|
|
3258
|
-
const maximumY = Math.min(leftBoundingBox[1][1], rightBoundingBox[1][1]);
|
|
3259
|
-
return maximumX > minimumX && maximumY > minimumY ? [
|
|
3260
|
-
[minimumX, minimumY],
|
|
3261
|
-
[maximumX, maximumY]
|
|
3262
|
-
] : null;
|
|
3263
|
-
}
|
|
3264
|
-
function getPixelWindow(boundingBox, metadata) {
|
|
3265
|
-
const [scaleX, rotationX, translateX, rotationY, scaleY, translateY] = metadata.transform;
|
|
3266
|
-
if (rotationX !== 0 || rotationY !== 0) {
|
|
3267
|
-
throw new Error("GeoZarrRasterSource does not yet support rotated affine window reads.");
|
|
3268
|
-
}
|
|
3269
|
-
const columnCoordinates = [
|
|
3270
|
-
(boundingBox[0][0] - translateX) / scaleX,
|
|
3271
|
-
(boundingBox[1][0] - translateX) / scaleX
|
|
3272
|
-
];
|
|
3273
|
-
const rowCoordinates = [
|
|
3274
|
-
(boundingBox[0][1] - translateY) / scaleY,
|
|
3275
|
-
(boundingBox[1][1] - translateY) / scaleY
|
|
3276
|
-
];
|
|
3277
|
-
return {
|
|
3278
|
-
columnStart: clamp(Math.floor(Math.min(...columnCoordinates)), 0, metadata.width),
|
|
3279
|
-
columnStop: clamp(Math.ceil(Math.max(...columnCoordinates)), 0, metadata.width),
|
|
3280
|
-
rowStart: clamp(Math.floor(Math.min(...rowCoordinates)), 0, metadata.height),
|
|
3281
|
-
rowStop: clamp(Math.ceil(Math.max(...rowCoordinates)), 0, metadata.height)
|
|
3282
|
-
};
|
|
3283
|
-
}
|
|
3284
|
-
function getPixelWindowBoundingBox(pixelWindow, transform) {
|
|
3285
|
-
return getTransformBoundingBox(
|
|
3286
|
-
[
|
|
3287
|
-
transform[0],
|
|
3288
|
-
transform[1],
|
|
3289
|
-
transformPosition(transform, pixelWindow.columnStart, pixelWindow.rowStart)[0],
|
|
3290
|
-
transform[3],
|
|
3291
|
-
transform[4],
|
|
3292
|
-
transformPosition(transform, pixelWindow.columnStart, pixelWindow.rowStart)[1]
|
|
3293
|
-
],
|
|
3294
|
-
pixelWindow.columnStop - pixelWindow.columnStart,
|
|
3295
|
-
pixelWindow.rowStop - pixelWindow.rowStart
|
|
3296
|
-
);
|
|
3297
|
-
}
|
|
3298
|
-
function normalizeSelection(requestedSelection, dimensions) {
|
|
3299
|
-
const knownDimensions = new Set(dimensions.map((dimension) => dimension.name));
|
|
3300
|
-
for (const requestedDimension of Object.keys(requestedSelection || {})) {
|
|
3301
|
-
if (!knownDimensions.has(requestedDimension)) {
|
|
3302
|
-
throw new Error(`Unknown GeoZarr selection dimension ${requestedDimension}.`);
|
|
3303
|
-
}
|
|
3304
|
-
}
|
|
3305
|
-
return Object.fromEntries(
|
|
3306
|
-
dimensions.map((dimension) => {
|
|
3307
|
-
const index = (requestedSelection == null ? void 0 : requestedSelection[dimension.name]) ?? dimension.defaultIndex;
|
|
3308
|
-
if (!Number.isInteger(index) || index < 0 || index >= dimension.size) {
|
|
3309
|
-
throw new Error(
|
|
3310
|
-
`GeoZarr ${dimension.name} index ${index} is out of bounds for dimension size ${dimension.size}.`
|
|
3311
|
-
);
|
|
3312
|
-
}
|
|
3313
|
-
return [dimension.name, index];
|
|
3314
|
-
})
|
|
3315
|
-
);
|
|
3316
|
-
}
|
|
3317
|
-
function transposeRaster(source, width, height) {
|
|
3318
|
-
const TypedArrayConstructor = source.constructor;
|
|
3319
|
-
const target = new TypedArrayConstructor(source.length);
|
|
3320
|
-
for (let row = 0; row < height; row++) {
|
|
3321
|
-
for (let column = 0; column < width; column++) {
|
|
3322
|
-
target[row * width + column] = source[column * height + row];
|
|
3323
|
-
}
|
|
3324
|
-
}
|
|
3325
|
-
return target;
|
|
3326
|
-
}
|
|
3327
|
-
function createEmptyRaster(metadata, boundingBox) {
|
|
3328
|
-
const TypedArrayConstructor = getTypedArrayConstructor2(metadata.dtype);
|
|
3329
|
-
return {
|
|
3330
|
-
data: new TypedArrayConstructor(0),
|
|
3331
|
-
width: 0,
|
|
3332
|
-
height: 0,
|
|
3333
|
-
bandCount: 1,
|
|
3334
|
-
dtype: metadata.dtype,
|
|
3335
|
-
interleaved: false,
|
|
3336
|
-
noData: metadata.noData,
|
|
3337
|
-
boundingBox,
|
|
3338
|
-
crs: metadata.crs,
|
|
3339
|
-
metadata: metadata.metadata
|
|
3340
|
-
};
|
|
3341
|
-
}
|
|
3342
|
-
function normalizeDtype2(dtype) {
|
|
3343
|
-
switch (dtype) {
|
|
3344
|
-
case "uint8":
|
|
3345
|
-
case "uint16":
|
|
3346
|
-
case "uint32":
|
|
3347
|
-
case "int8":
|
|
3348
|
-
case "int16":
|
|
3349
|
-
case "int32":
|
|
3350
|
-
case "float32":
|
|
3351
|
-
case "float64":
|
|
3352
|
-
return dtype;
|
|
3353
|
-
default:
|
|
3354
|
-
throw new Error(`GeoZarr dtype ${dtype} is not currently supported.`);
|
|
3355
|
-
}
|
|
3356
|
-
}
|
|
3357
|
-
function getTypedArrayConstructor2(dtype) {
|
|
3358
|
-
switch (dtype) {
|
|
3359
|
-
case "uint8":
|
|
3360
|
-
return Uint8Array;
|
|
3361
|
-
case "uint16":
|
|
3362
|
-
return Uint16Array;
|
|
3363
|
-
case "uint32":
|
|
3364
|
-
return Uint32Array;
|
|
3365
|
-
case "int8":
|
|
3366
|
-
return Int8Array;
|
|
3367
|
-
case "int16":
|
|
3368
|
-
return Int16Array;
|
|
3369
|
-
case "int32":
|
|
3370
|
-
return Int32Array;
|
|
3371
|
-
case "float32":
|
|
3372
|
-
return Float32Array;
|
|
3373
|
-
case "float64":
|
|
3374
|
-
return Float64Array;
|
|
3375
|
-
default:
|
|
3376
|
-
throw new Error(`Unsupported GeoZarr dtype ${dtype}.`);
|
|
3377
|
-
}
|
|
3378
|
-
}
|
|
3379
|
-
function normalizeNumber(value) {
|
|
3380
|
-
return typeof value === "number" && Number.isFinite(value) ? value : void 0;
|
|
3381
|
-
}
|
|
3382
|
-
function normalizeString(value) {
|
|
3383
|
-
return typeof value === "string" && value.length ? value : void 0;
|
|
3384
|
-
}
|
|
3385
|
-
function normalizeStringArray(value) {
|
|
3386
|
-
return Array.isArray(value) && value.every((item) => typeof item === "string") ? [...value] : void 0;
|
|
3387
|
-
}
|
|
3388
|
-
function clamp(value, minimum, maximum) {
|
|
3389
|
-
return Math.min(maximum, Math.max(minimum, value));
|
|
3390
|
-
}
|
|
3391
|
-
function getSpatialChunkMatrix(id, metadata) {
|
|
3392
|
-
if (!metadata) return { id };
|
|
3393
|
-
const { transform, tileSize, width, height } = metadata;
|
|
3394
|
-
const [scaleX, rotationX, translateX, rotationY, scaleY, translateY] = transform;
|
|
3395
|
-
if (rotationX !== 0 || rotationY !== 0 || scaleX <= 0 || scaleY === 0 || !transform.every(Number.isFinite) || !tileSize || !width || !height) {
|
|
3396
|
-
return { id };
|
|
3397
|
-
}
|
|
3398
|
-
return {
|
|
3399
|
-
id,
|
|
3400
|
-
resolution: scaleX,
|
|
3401
|
-
resolutionY: Math.abs(scaleY),
|
|
3402
|
-
origin: [translateX, translateY],
|
|
3403
|
-
cornerOfOrigin: scaleY < 0 ? "topLeft" : "bottomLeft",
|
|
3404
|
-
tileSize: [tileSize.width, tileSize.height],
|
|
3405
|
-
matrixSize: [Math.ceil(width / tileSize.width), Math.ceil(height / tileSize.height)]
|
|
3406
|
-
};
|
|
3407
|
-
}
|
|
3408
|
-
function normalizeDeclaredCoordinateReferenceSystem(attributes) {
|
|
3409
|
-
const wellKnownText = normalizeString(attributes["proj:wkt2"]);
|
|
3410
|
-
if (wellKnownText) return wellKnownText;
|
|
3411
|
-
const code = normalizeString(attributes["proj:code"]);
|
|
3412
|
-
if (code) return code;
|
|
3413
|
-
const epsg = attributes["proj:epsg"];
|
|
3414
|
-
if (typeof epsg === "number" && Number.isSafeInteger(epsg) && epsg > 0) return `EPSG:${epsg}`;
|
|
3415
|
-
const projection = attributes["proj:projjson"];
|
|
3416
|
-
return projection && typeof projection === "object" && !Array.isArray(projection) ? projection : void 0;
|
|
3417
|
-
}
|
|
3418
|
-
var zarrita3, VERSION7, GeoZarrSourceLoaderWithParser, GeoZarrRasterSource;
|
|
3419
|
-
var init_geo_zarr_source_loader = __esm({
|
|
3420
|
-
"src/zarr/geo-zarr-source-loader.ts"() {
|
|
3421
|
-
"use strict";
|
|
3422
|
-
zarrita3 = __toESM(require("zarrita"), 1);
|
|
3423
|
-
init_loader_utils();
|
|
3424
|
-
init_spatial_multiscales();
|
|
3425
|
-
init_ome_zarr_source_loader();
|
|
3426
|
-
init_zarr_data_cache();
|
|
3427
|
-
VERSION7 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
3428
|
-
GeoZarrSourceLoaderWithParser = {
|
|
3429
|
-
dataType: null,
|
|
3430
|
-
/** Runtime source type marker used by `createDataSource()` type inference. */
|
|
3431
|
-
dataSource: null,
|
|
3432
|
-
batchType: null,
|
|
3433
|
-
name: "GeoZarrSourceLoader",
|
|
3434
|
-
id: "geozarr",
|
|
3435
|
-
module: "scientific",
|
|
3436
|
-
version: VERSION7,
|
|
3437
|
-
extensions: ["zarr"],
|
|
3438
|
-
mimeTypes: [],
|
|
3439
|
-
type: "geozarr",
|
|
3440
|
-
fromUrl: true,
|
|
3441
|
-
fromBlob: false,
|
|
3442
|
-
options: {
|
|
3443
|
-
zarr: {
|
|
3444
|
-
metadataPath: "auto",
|
|
3445
|
-
path: null,
|
|
3446
|
-
labels: void 0,
|
|
3447
|
-
requireConsolidatedMetadata: true
|
|
3448
|
-
},
|
|
3449
|
-
geozarr: {
|
|
3450
|
-
array: void 0,
|
|
3451
|
-
spatialDimensions: void 0,
|
|
3452
|
-
transform: void 0,
|
|
3453
|
-
coordinateReferenceSystem: void 0,
|
|
3454
|
-
defaultSelection: void 0
|
|
3455
|
-
}
|
|
3456
|
-
},
|
|
3457
|
-
defaultOptions: {
|
|
3458
|
-
zarr: {
|
|
3459
|
-
metadataPath: "auto",
|
|
3460
|
-
path: null,
|
|
3461
|
-
labels: void 0,
|
|
3462
|
-
requireConsolidatedMetadata: true
|
|
3463
|
-
},
|
|
3464
|
-
geozarr: {
|
|
3465
|
-
array: void 0,
|
|
3466
|
-
spatialDimensions: void 0,
|
|
3467
|
-
transform: void 0,
|
|
3468
|
-
coordinateReferenceSystem: void 0,
|
|
3469
|
-
defaultSelection: void 0
|
|
3470
|
-
}
|
|
3471
|
-
},
|
|
3472
|
-
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
3473
|
-
createDataSource: (data, options, coreApi) => new GeoZarrRasterSource(data, options, coreApi)
|
|
3474
|
-
};
|
|
3475
|
-
GeoZarrRasterSource = class _GeoZarrRasterSource extends ZarrSource {
|
|
3476
|
-
/** Shared source initialization request. */
|
|
3477
|
-
initializationPromise = null;
|
|
3478
|
-
/** Shared metadata-only multiscale discovery request. */
|
|
3479
|
-
metadataPromise = null;
|
|
3480
|
-
/** Creates a GeoZarr raster source. */
|
|
3481
|
-
constructor(data, options, coreApi) {
|
|
3482
|
-
super(data, options, coreApi);
|
|
3483
|
-
}
|
|
3484
|
-
/** Returns normalized geospatial, array, and selectable-dimension metadata. */
|
|
3485
|
-
async getMetadata() {
|
|
3486
|
-
if (!this.metadataPromise) {
|
|
3487
|
-
this.metadataPromise = this.loadGridMetadata().catch((error) => {
|
|
3488
|
-
this.metadataPromise = null;
|
|
3489
|
-
throw error;
|
|
3490
|
-
});
|
|
3491
|
-
}
|
|
3492
|
-
return await this.metadataPromise;
|
|
3493
|
-
}
|
|
3494
|
-
/** Opens sibling array metadata without selecting or decoding their samples. */
|
|
3495
|
-
async loadGridMetadata() {
|
|
3496
|
-
var _a;
|
|
3497
|
-
const { metadata, group } = await this.getInitializationPromise();
|
|
3498
|
-
const groupAttributes = (_a = metadata.metadata) == null ? void 0 : _a.groupAttributes;
|
|
3499
|
-
const layout = getSpatialMultiscaleLevels(groupAttributes, metadata.array);
|
|
3500
|
-
const levels = [];
|
|
3501
|
-
for (const level of layout) {
|
|
3502
|
-
if (level.array === metadata.array) {
|
|
3503
|
-
levels.push({ id: level.id, array: level.array, metadata });
|
|
3504
|
-
continue;
|
|
3505
|
-
}
|
|
3506
|
-
const options = this.options;
|
|
3507
|
-
const source = new _GeoZarrRasterSource(
|
|
3508
|
-
this.data,
|
|
3509
|
-
{
|
|
3510
|
-
...options,
|
|
3511
|
-
geozarr: { ...options.geozarr, array: level.array, transform: void 0 }
|
|
3512
|
-
},
|
|
3513
|
-
this.hasCoreApi ? this.coreApi : void 0
|
|
3514
|
-
);
|
|
3515
|
-
try {
|
|
3516
|
-
const initialization = await source.initialize(void 0, true, group);
|
|
3517
|
-
levels.push({ id: level.id, array: level.array, metadata: initialization.metadata });
|
|
3518
|
-
} catch {
|
|
3519
|
-
levels.push({ id: level.id, array: level.array });
|
|
3520
|
-
}
|
|
3521
|
-
}
|
|
3522
|
-
const normalizedLevels = levels.length ? levels : [{ id: metadata.array, array: metadata.array, metadata }];
|
|
3523
|
-
const matrices = normalizedLevels.map((level) => getSpatialChunkMatrix(level.id, level.metadata));
|
|
3524
|
-
const commonCoordinateReferenceSystem = typeof metadata.crs === "string" && normalizedLevels.every((level) => {
|
|
3525
|
-
var _a2;
|
|
3526
|
-
return ((_a2 = level.metadata) == null ? void 0 : _a2.crs) === metadata.crs;
|
|
3527
|
-
}) ? metadata.crs : void 0;
|
|
3528
|
-
return {
|
|
3529
|
-
...metadata,
|
|
3530
|
-
...levels.length ? { levels } : {},
|
|
3531
|
-
tileGrid: createTileGrid(commonCoordinateReferenceSystem, matrices)
|
|
3532
|
-
};
|
|
3533
|
-
}
|
|
3534
|
-
/** Discovers GeoZarr variables, spatial bounds, and selectable dimensions. */
|
|
3535
|
-
async getQueryMetadata(options = {}) {
|
|
3536
|
-
var _a, _b;
|
|
3537
|
-
if ((_a = options.signal) == null ? void 0 : _a.aborted) throw new DOMException("The operation was aborted", "AbortError");
|
|
3538
|
-
const metadata = await this.getMetadata();
|
|
3539
|
-
if ((_b = options.signal) == null ? void 0 : _b.aborted) throw new DOMException("The operation was aborted", "AbortError");
|
|
3540
|
-
const fields = [{ name: metadata.array, type: metadata.dtype, nullable: true, metadata: {} }];
|
|
3541
|
-
return createScanQueryMetadata({
|
|
3542
|
-
sourceType: "geozarr",
|
|
3543
|
-
queryType: "raster",
|
|
3544
|
-
execution: { status: "supported", method: "getRaster" },
|
|
3545
|
-
name: metadata.name,
|
|
3546
|
-
schema: { fields, metadata: {} },
|
|
3547
|
-
capabilities: {
|
|
3548
|
-
bounds: "pushdown",
|
|
3549
|
-
levelOfDetail: "unsupported"
|
|
3550
|
-
},
|
|
3551
|
-
spatial: metadata.boundingBox ? {
|
|
3552
|
-
bounds: { minimum: metadata.boundingBox[0], maximum: metadata.boundingBox[1] },
|
|
3553
|
-
coordinateReferenceSystems: typeof metadata.crs === "string" ? [metadata.crs] : void 0
|
|
3554
|
-
} : void 0
|
|
3555
|
-
});
|
|
3556
|
-
}
|
|
3557
|
-
/** Loads a clipped native-resolution 2D window for the requested viewport and named selection. */
|
|
3558
|
-
async getRaster(parameters) {
|
|
3559
|
-
const initialization = await this.getInitializationPromise(parameters.signal);
|
|
3560
|
-
const { array, metadata, xDimensionIndex, yDimensionIndex } = initialization;
|
|
3561
|
-
const requestedBoundingBox = getRasterViewportBoundingBox(parameters.viewport);
|
|
3562
|
-
const viewportCoordinateReferenceSystem = parameters.viewport.crs;
|
|
3563
|
-
if (metadata.crs && viewportCoordinateReferenceSystem && metadata.crs !== viewportCoordinateReferenceSystem) {
|
|
3564
|
-
throw new Error(
|
|
3565
|
-
`GeoZarrRasterSource does not support reprojection. Requested ${viewportCoordinateReferenceSystem}, source ${metadata.crs}.`
|
|
3566
|
-
);
|
|
3567
|
-
}
|
|
3568
|
-
if (parameters.resampleMethod === "bilinear") {
|
|
3569
|
-
throw new Error(
|
|
3570
|
-
"GeoZarrRasterSource currently supports native nearest-neighbor windows only."
|
|
3571
|
-
);
|
|
3572
|
-
}
|
|
3573
|
-
const clippedBoundingBox = intersectBoundingBoxes(requestedBoundingBox, metadata.boundingBox);
|
|
3574
|
-
if (!clippedBoundingBox) {
|
|
3575
|
-
return createEmptyRaster(metadata, requestedBoundingBox);
|
|
3576
|
-
}
|
|
3577
|
-
const pixelWindow = getPixelWindow(clippedBoundingBox, metadata);
|
|
3578
|
-
if (pixelWindow.columnStart === pixelWindow.columnStop || pixelWindow.rowStart === pixelWindow.rowStop) {
|
|
3579
|
-
return createEmptyRaster(metadata, clippedBoundingBox);
|
|
3580
|
-
}
|
|
3581
|
-
const selection = normalizeSelection(parameters.selection, metadata.selectionDimensions);
|
|
3582
|
-
const zarritaSelection = metadata.dimensions.map((dimensionName, dimensionIndex) => {
|
|
3583
|
-
if (dimensionIndex === xDimensionIndex) {
|
|
3584
|
-
return zarrita3.slice(pixelWindow.columnStart, pixelWindow.columnStop);
|
|
3585
|
-
}
|
|
3586
|
-
if (dimensionIndex === yDimensionIndex) {
|
|
3587
|
-
return zarrita3.slice(pixelWindow.rowStart, pixelWindow.rowStop);
|
|
3588
|
-
}
|
|
3589
|
-
return selection[dimensionName];
|
|
3590
|
-
});
|
|
3591
|
-
const chunk = await getCachedZarrSelection(
|
|
3592
|
-
array,
|
|
3593
|
-
getZarrSelectionKey(zarritaSelection),
|
|
3594
|
-
() => zarrita3.get(array, zarritaSelection),
|
|
3595
|
-
parameters.signal
|
|
3596
|
-
);
|
|
3597
|
-
if (!chunk || typeof chunk !== "object" || !("data" in chunk) || !("shape" in chunk)) {
|
|
3598
|
-
throw new Error("Failed to read GeoZarr raster selection.");
|
|
3599
|
-
}
|
|
3600
|
-
const width = pixelWindow.columnStop - pixelWindow.columnStart;
|
|
3601
|
-
const height = pixelWindow.rowStop - pixelWindow.rowStart;
|
|
3602
|
-
const typedData = cloneZarrSelection(chunk).data;
|
|
3603
|
-
const data = xDimensionIndex < yDimensionIndex ? transposeRaster(typedData, width, height) : typedData;
|
|
3604
|
-
const outputBoundingBox = getPixelWindowBoundingBox(pixelWindow, metadata.transform);
|
|
3605
|
-
return {
|
|
3606
|
-
data,
|
|
3607
|
-
width,
|
|
3608
|
-
height,
|
|
3609
|
-
bandCount: 1,
|
|
3610
|
-
dtype: metadata.dtype,
|
|
3611
|
-
interleaved: false,
|
|
3612
|
-
noData: metadata.noData,
|
|
3613
|
-
boundingBox: outputBoundingBox,
|
|
3614
|
-
crs: metadata.crs,
|
|
3615
|
-
metadata: {
|
|
3616
|
-
...metadata.metadata,
|
|
3617
|
-
array: metadata.array,
|
|
3618
|
-
dimensions: metadata.dimensions,
|
|
3619
|
-
selection,
|
|
3620
|
-
pixelWindow
|
|
3621
|
-
}
|
|
3622
|
-
};
|
|
3623
|
-
}
|
|
3624
|
-
/** Returns the shared initialization request for this source. */
|
|
3625
|
-
async getInitializationPromise(signal) {
|
|
3626
|
-
if (!this.initializationPromise) {
|
|
3627
|
-
this.initializationPromise = this.initialize(signal);
|
|
3628
|
-
}
|
|
3629
|
-
const initializationPromise = this.initializationPromise;
|
|
3630
|
-
try {
|
|
3631
|
-
return await initializationPromise;
|
|
3632
|
-
} catch (error) {
|
|
3633
|
-
if (this.initializationPromise === initializationPromise) {
|
|
3634
|
-
this.initializationPromise = null;
|
|
3635
|
-
}
|
|
3636
|
-
throw error;
|
|
3637
|
-
}
|
|
3638
|
-
}
|
|
3639
|
-
/** Opens the selected data array and resolves GeoZarr or CF/xarray geospatial metadata. */
|
|
3640
|
-
async initialize(signal, metadataOnly = false, validatedGroup) {
|
|
3641
|
-
var _a;
|
|
3642
|
-
const group = validatedGroup || await this.openGroup(signal);
|
|
3643
|
-
const options = this.options.geozarr;
|
|
3644
|
-
const arrayPath = options == null ? void 0 : options.array;
|
|
3645
|
-
if (!arrayPath) {
|
|
3646
|
-
throw new Error("GeoZarrRasterSource requires a geozarr.array data-variable path.");
|
|
3647
|
-
}
|
|
3648
|
-
const array = await zarrita3.open(group.resolve(arrayPath), { kind: "array", signal });
|
|
3649
|
-
const groupAttributes = normalizeAttributes(group.attrs);
|
|
3650
|
-
const arrayAttributes = normalizeAttributes(array.attrs);
|
|
3651
|
-
const layout = getSpatialMultiscaleLevels(groupAttributes, arrayPath);
|
|
3652
|
-
const level = layout.find((candidate) => candidate.array === arrayPath);
|
|
3653
|
-
const levelGroupAttributes = (level == null ? void 0 : level.group) ? normalizeAttributes(
|
|
3654
|
-
(await zarrita3.open(group.resolve(level.group), { kind: "group", signal })).attrs
|
|
3655
|
-
) : {};
|
|
3656
|
-
const attributes = {
|
|
3657
|
-
...groupAttributes,
|
|
3658
|
-
...levelGroupAttributes,
|
|
3659
|
-
...level == null ? void 0 : level.attributes,
|
|
3660
|
-
...arrayAttributes
|
|
3661
|
-
};
|
|
3662
|
-
const coordinateReferenceSystemKeys = ["proj:code", "proj:wkt2", "proj:projjson", "proj:epsg"];
|
|
3663
|
-
const coordinateReferenceSystemAttributes = [
|
|
3664
|
-
arrayAttributes,
|
|
3665
|
-
level == null ? void 0 : level.attributes,
|
|
3666
|
-
levelGroupAttributes
|
|
3667
|
-
].find((candidate) => candidate && coordinateReferenceSystemKeys.some((key) => Object.hasOwn(candidate, key)));
|
|
3668
|
-
if (coordinateReferenceSystemAttributes) {
|
|
3669
|
-
for (const key of coordinateReferenceSystemKeys) {
|
|
3670
|
-
delete attributes[key];
|
|
3671
|
-
if (Object.hasOwn(coordinateReferenceSystemAttributes, key)) {
|
|
3672
|
-
attributes[key] = coordinateReferenceSystemAttributes[key];
|
|
3673
|
-
}
|
|
3674
|
-
}
|
|
3675
|
-
}
|
|
3676
|
-
if (level) {
|
|
3677
|
-
attributes["spatial:transform"] = arrayAttributes["spatial:transform"] ?? level.attributes["spatial:transform"] ?? levelGroupAttributes["spatial:transform"];
|
|
3678
|
-
}
|
|
3679
|
-
const dimensions = getDimensionNames(array, attributes);
|
|
3680
|
-
const spatialDimensions = getSpatialDimensions(
|
|
3681
|
-
dimensions,
|
|
3682
|
-
attributes,
|
|
3683
|
-
options == null ? void 0 : options.spatialDimensions
|
|
3684
|
-
);
|
|
3685
|
-
const yDimensionIndex = dimensions.indexOf(spatialDimensions[0]);
|
|
3686
|
-
const xDimensionIndex = dimensions.indexOf(spatialDimensions[1]);
|
|
3687
|
-
const width = array.shape[xDimensionIndex];
|
|
3688
|
-
const height = array.shape[yDimensionIndex];
|
|
3689
|
-
const coordinateTransform = (options == null ? void 0 : options.transform) || normalizeAffineTransform(attributes["spatial:transform"]) || (!metadataOnly ? await loadCFCoordinateTransform(group, spatialDimensions, signal) : null);
|
|
3690
|
-
if (!coordinateTransform) {
|
|
3691
|
-
throw new Error(
|
|
3692
|
-
"GeoZarrRasterSource requires spatial:transform metadata, explicit geozarr.transform, or regular 1D CF coordinate arrays."
|
|
3693
|
-
);
|
|
3694
|
-
}
|
|
3695
|
-
const declaredRegistration = normalizeRegistration(attributes["spatial:registration"]);
|
|
3696
|
-
const transform = declaredRegistration === "node" ? convertNodeTransformToPixelTransform(coordinateTransform) : coordinateTransform;
|
|
3697
|
-
const declaredBoundingBox = normalizeBoundingBox(attributes["spatial:bbox"]);
|
|
3698
|
-
const boundingBox = declaredRegistration === "pixel" && declaredBoundingBox ? toRasterBoundingBox(declaredBoundingBox) : getTransformBoundingBox(transform, width, height);
|
|
3699
|
-
const coordinateReferenceSystem = (options == null ? void 0 : options.coordinateReferenceSystem) || normalizeDeclaredCoordinateReferenceSystem(attributes) || await loadCFCoordinateReferenceSystem(group, attributes, spatialDimensions, signal);
|
|
3700
|
-
const defaultSelection = (options == null ? void 0 : options.defaultSelection) || {};
|
|
3701
|
-
const selectionDimensions = dimensions.map((dimensionName, dimensionIndex) => ({
|
|
3702
|
-
name: dimensionName,
|
|
3703
|
-
size: array.shape[dimensionIndex],
|
|
3704
|
-
defaultIndex: defaultSelection[dimensionName] ?? 0
|
|
3705
|
-
})).filter((dimension) => !spatialDimensions.includes(dimension.name));
|
|
3706
|
-
normalizeSelection(void 0, selectionDimensions);
|
|
3707
|
-
const dtype = normalizeDtype2(array.dtype);
|
|
3708
|
-
const noData = normalizeNumber(attributes._FillValue) ?? normalizeNumber(attributes.missing_value);
|
|
3709
|
-
const metadata = {
|
|
3710
|
-
name: normalizeString(attributes.long_name) || normalizeString(attributes.title) || arrayPath,
|
|
3711
|
-
title: normalizeString(attributes.title) || normalizeString(groupAttributes.title),
|
|
3712
|
-
abstract: normalizeString(attributes.description) || normalizeString(groupAttributes.description),
|
|
3713
|
-
keywords: normalizeStringArray(groupAttributes.keywords),
|
|
3714
|
-
attributions: ((_a = this.options.core) == null ? void 0 : _a.attributions) || [],
|
|
3715
|
-
crs: coordinateReferenceSystem,
|
|
3716
|
-
boundingBox,
|
|
3717
|
-
width,
|
|
3718
|
-
height,
|
|
3719
|
-
bandCount: 1,
|
|
3720
|
-
dtype,
|
|
3721
|
-
tileSize: {
|
|
3722
|
-
width: array.chunks[xDimensionIndex],
|
|
3723
|
-
height: array.chunks[yDimensionIndex]
|
|
3724
|
-
},
|
|
3725
|
-
noData,
|
|
3726
|
-
metadata: {
|
|
3727
|
-
groupAttributes,
|
|
3728
|
-
arrayAttributes,
|
|
3729
|
-
sourceTransform: coordinateTransform,
|
|
3730
|
-
sourceBoundingBox: declaredBoundingBox
|
|
3731
|
-
},
|
|
3732
|
-
array: arrayPath,
|
|
3733
|
-
dimensions,
|
|
3734
|
-
spatialDimensions,
|
|
3735
|
-
selectionDimensions,
|
|
3736
|
-
transform,
|
|
3737
|
-
registration: declaredRegistration
|
|
3738
|
-
};
|
|
3739
|
-
return { group, array, metadata, xDimensionIndex, yDimensionIndex };
|
|
3740
|
-
}
|
|
3741
|
-
};
|
|
3742
|
-
}
|
|
3743
|
-
});
|
|
3744
|
-
|
|
3745
|
-
// src/zarr/zarr-array-source.ts
|
|
3746
|
-
var zarr_array_source_exports = {};
|
|
3747
|
-
__export(zarr_array_source_exports, {
|
|
3748
|
-
ZarrArraySource: () => ZarrArraySource,
|
|
3749
|
-
ZarrArraySourceLoaderWithParser: () => ZarrArraySourceLoaderWithParser
|
|
3750
|
-
});
|
|
3751
|
-
function createNamedSelection(selectionByDimension, metadata) {
|
|
3752
|
-
const selection = metadata.shape.map(() => null);
|
|
3753
|
-
for (const [dimension, selector] of Object.entries(selectionByDimension || {})) {
|
|
3754
|
-
const dimensionIndex = metadata.dimensions.indexOf(dimension);
|
|
3755
|
-
if (dimensionIndex < 0) {
|
|
3756
|
-
throw new Error(`Unknown Zarr array dimension ${dimension}.`);
|
|
3757
|
-
}
|
|
3758
|
-
selection[dimensionIndex] = selector;
|
|
3759
|
-
}
|
|
3760
|
-
return selection;
|
|
3761
|
-
}
|
|
3762
|
-
function isZarrArraySlice(selector) {
|
|
3763
|
-
return typeof selector === "object" && selector !== null;
|
|
3764
|
-
}
|
|
3765
|
-
var zarrita4, ZarrArraySourceLoaderWithParser, ZarrArraySource;
|
|
3766
|
-
var init_zarr_array_source = __esm({
|
|
3767
|
-
"src/zarr/zarr-array-source.ts"() {
|
|
3768
|
-
"use strict";
|
|
3769
|
-
zarrita4 = __toESM(require("zarrita"), 1);
|
|
3770
|
-
init_ome_zarr_source_loader();
|
|
3771
|
-
init_zarr_data_cache();
|
|
3772
|
-
ZarrArraySourceLoaderWithParser = {
|
|
3773
|
-
dataType: null,
|
|
3774
|
-
dataSource: null,
|
|
3775
|
-
batchType: null,
|
|
3776
|
-
name: "ZarrArraySourceLoader",
|
|
3777
|
-
id: "zarr-array",
|
|
3778
|
-
module: "scientific",
|
|
3779
|
-
version: "latest",
|
|
3780
|
-
extensions: ["zarr"],
|
|
3781
|
-
mimeTypes: [],
|
|
3782
|
-
type: "zarr-array",
|
|
3783
|
-
fromUrl: true,
|
|
3784
|
-
fromBlob: false,
|
|
3785
|
-
options: {
|
|
3786
|
-
zarr: {
|
|
3787
|
-
metadataPath: "auto",
|
|
3788
|
-
path: null,
|
|
3789
|
-
labels: void 0,
|
|
3790
|
-
requireConsolidatedMetadata: true
|
|
3791
|
-
},
|
|
3792
|
-
zarrArray: { path: void 0, dimensions: void 0 }
|
|
3793
|
-
},
|
|
3794
|
-
defaultOptions: {
|
|
3795
|
-
zarr: {
|
|
3796
|
-
metadataPath: "auto",
|
|
3797
|
-
path: null,
|
|
3798
|
-
labels: void 0,
|
|
3799
|
-
requireConsolidatedMetadata: true
|
|
3800
|
-
},
|
|
3801
|
-
zarrArray: { path: void 0, dimensions: void 0 }
|
|
3802
|
-
},
|
|
3803
|
-
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
3804
|
-
createDataSource: (data, options, coreApi) => new ZarrArraySource(data, options, coreApi)
|
|
3805
|
-
};
|
|
3806
|
-
ZarrArraySource = class extends ZarrSource {
|
|
3807
|
-
/** Cached array initialization. */
|
|
3808
|
-
initializationPromise = null;
|
|
3809
|
-
/** Opens a Zarr array source. */
|
|
3810
|
-
constructor(data, options, coreApi) {
|
|
3811
|
-
super(data, options, coreApi);
|
|
3812
|
-
}
|
|
3813
|
-
/** Returns array shape, chunks, dtype, and dimension labels. */
|
|
3814
|
-
async getMetadata(signal) {
|
|
3815
|
-
return (await this.getInitializationPromise(signal)).metadata;
|
|
3816
|
-
}
|
|
3817
|
-
/** Reads the selected array values. */
|
|
3818
|
-
async getArray(parameters = {}) {
|
|
3819
|
-
const { array, metadata } = await this.getInitializationPromise(parameters.signal);
|
|
3820
|
-
if (parameters.selection && parameters.selectionByDimension) {
|
|
3821
|
-
throw new Error("Zarr array requests cannot combine positional and named selections.");
|
|
3822
|
-
}
|
|
3823
|
-
const selection = parameters.selection || createNamedSelection(parameters.selectionByDimension, metadata);
|
|
3824
|
-
if (selection.length !== metadata.shape.length) {
|
|
3825
|
-
throw new Error(`Zarr array selection must have ${metadata.shape.length} dimensions.`);
|
|
3826
|
-
}
|
|
3827
|
-
const zarritaSelection = selection.map(
|
|
3828
|
-
(selector) => isZarrArraySlice(selector) ? zarrita4.slice(selector.start ?? null, selector.stop ?? null, selector.step ?? null) : selector
|
|
3829
|
-
);
|
|
3830
|
-
const chunk = await getCachedZarrSelection(
|
|
3831
|
-
array,
|
|
3832
|
-
getZarrSelectionKey(selection),
|
|
3833
|
-
() => zarrita4.get(array, zarritaSelection),
|
|
3834
|
-
parameters.signal
|
|
3835
|
-
);
|
|
3836
|
-
if (!chunk || typeof chunk !== "object" || !("data" in chunk) || !("shape" in chunk)) {
|
|
3837
|
-
throw new Error("Failed to read Zarr array selection.");
|
|
3838
|
-
}
|
|
3839
|
-
return cloneZarrSelection(chunk);
|
|
3840
|
-
}
|
|
3841
|
-
/** Opens the configured array and resolves its normalized metadata. */
|
|
3842
|
-
async getInitializationPromise(signal) {
|
|
3843
|
-
if (!this.initializationPromise) {
|
|
3844
|
-
this.initializationPromise = this.initialize(signal);
|
|
3845
|
-
}
|
|
3846
|
-
const initializationPromise = this.initializationPromise;
|
|
3847
|
-
try {
|
|
3848
|
-
return await initializationPromise;
|
|
3849
|
-
} catch (error) {
|
|
3850
|
-
if (this.initializationPromise === initializationPromise) {
|
|
3851
|
-
this.initializationPromise = null;
|
|
3852
|
-
}
|
|
3853
|
-
throw error;
|
|
3854
|
-
}
|
|
3855
|
-
}
|
|
3856
|
-
/** Opens the array selected by the source options. */
|
|
3857
|
-
async initialize(signal) {
|
|
3858
|
-
var _a;
|
|
3859
|
-
const group = await this.openGroup(signal);
|
|
3860
|
-
const options = this.options.zarrArray;
|
|
3861
|
-
const path = (options == null ? void 0 : options.path) || "";
|
|
3862
|
-
const location = path ? group.resolve(path) : group;
|
|
3863
|
-
const array = await zarrita4.open(location, { kind: "array", signal });
|
|
3864
|
-
const dimensions = (options == null ? void 0 : options.dimensions) || ((_a = this.options.zarr) == null ? void 0 : _a.labels) || array.shape.map((_size, index) => `dim_${index}`);
|
|
3865
|
-
if (dimensions.length !== array.shape.length) {
|
|
3866
|
-
throw new Error(`Zarr array dimensions must have length ${array.shape.length}.`);
|
|
3867
|
-
}
|
|
3868
|
-
return {
|
|
3869
|
-
array,
|
|
3870
|
-
metadata: {
|
|
3871
|
-
path,
|
|
3872
|
-
shape: [...array.shape],
|
|
3873
|
-
chunks: [...array.chunks],
|
|
3874
|
-
dtype: String(array.dtype),
|
|
3875
|
-
fillValue: array.fillValue,
|
|
3876
|
-
attributes: { ...array.attrs },
|
|
3877
|
-
dimensions: [...dimensions]
|
|
3878
|
-
}
|
|
3879
|
-
};
|
|
3880
|
-
}
|
|
3881
|
-
};
|
|
3882
|
-
}
|
|
3883
|
-
});
|
|
3884
|
-
|
|
3885
|
-
// src/zarr/spatial-data-source.ts
|
|
3886
|
-
var spatial_data_source_exports = {};
|
|
3887
|
-
__export(spatial_data_source_exports, {
|
|
3888
|
-
SpatialDataSource: () => SpatialDataSource,
|
|
3889
|
-
SpatialDataSourceLoaderWithParser: () => SpatialDataSourceLoaderWithParser
|
|
3890
|
-
});
|
|
3891
|
-
function discoverSpatialDataElements(rootUrl, consolidated, spatialDataPath) {
|
|
3892
|
-
const elements = [];
|
|
3893
|
-
for (const definition of SPATIAL_DATA_NAMESPACES) {
|
|
3894
|
-
const namespacePath = joinZarrPath(spatialDataPath, definition.namespace);
|
|
3895
|
-
const paths = getDirectGroupChildren(consolidated, namespacePath);
|
|
3896
|
-
for (const fullPath of paths) {
|
|
3897
|
-
const name = fullPath.slice(namespacePath.length + 1);
|
|
3898
|
-
const path = `${definition.namespace}/${name}`;
|
|
3899
|
-
const attributes = getGroupAttributes(consolidated, fullPath);
|
|
3900
|
-
const spatialDataAttributes = getObject(attributes.spatialdata_attrs);
|
|
3901
|
-
elements.push(
|
|
3902
|
-
Object.freeze({
|
|
3903
|
-
kind: definition.kind,
|
|
3904
|
-
name,
|
|
3905
|
-
path,
|
|
3906
|
-
url: getElementUrl(rootUrl, fullPath, definition.format),
|
|
3907
|
-
format: definition.format,
|
|
3908
|
-
version: getString(spatialDataAttributes == null ? void 0 : spatialDataAttributes.version) || getString(attributes.version),
|
|
3909
|
-
axes: getAxes(attributes),
|
|
3910
|
-
coordinateTransformations: getCoordinateTransformations(attributes),
|
|
3911
|
-
attributes: Object.freeze({ ...attributes })
|
|
3912
|
-
})
|
|
3913
|
-
);
|
|
3914
|
-
}
|
|
3915
|
-
}
|
|
3916
|
-
return elements;
|
|
3917
|
-
}
|
|
3918
|
-
function joinZarrPath(...paths) {
|
|
3919
|
-
return paths.map(normalizeZarrPath).filter(Boolean).join("/");
|
|
3920
|
-
}
|
|
3921
|
-
function normalizeZarrPath(path) {
|
|
3922
|
-
return (path == null ? void 0 : path.replace(/^\/+|\/+$/g, "")) || "";
|
|
3923
|
-
}
|
|
3924
|
-
function getDirectGroupChildren(consolidated, namespace) {
|
|
3925
|
-
const prefix = `${namespace}/`;
|
|
3926
|
-
const paths = /* @__PURE__ */ new Set();
|
|
3927
|
-
for (const [metadataPath, value] of Object.entries(consolidated.metadata)) {
|
|
3928
|
-
const path = consolidated.format === "v2" ? metadataPath.endsWith("/.zgroup") ? metadataPath.slice(0, -8) : "" : value && typeof value === "object" && value.node_type === "group" ? metadataPath : "";
|
|
3929
|
-
if (!path.startsWith(prefix) || path.slice(prefix.length).includes("/")) continue;
|
|
3930
|
-
paths.add(path);
|
|
3931
|
-
}
|
|
3932
|
-
return [...paths].sort();
|
|
3933
|
-
}
|
|
3934
|
-
function getGroupAttributes(consolidated, path) {
|
|
3935
|
-
if (consolidated.format === "v2") {
|
|
3936
|
-
return { ...getObject(consolidated.metadata[`${path}/.zattrs`]) || {} };
|
|
3937
|
-
}
|
|
3938
|
-
const node = getObject(consolidated.metadata[path]);
|
|
3939
|
-
return { ...getObject(node == null ? void 0 : node.attributes) || {} };
|
|
3940
|
-
}
|
|
3941
|
-
function getElementUrl(rootUrl, path, format) {
|
|
3942
|
-
const baseUrl = `${rootUrl.replace(/\/+$/, "")}/${path}`;
|
|
3943
|
-
if (format === "parquet-dataset") return `${baseUrl}/points.parquet`;
|
|
3944
|
-
if (format === "geoparquet") return `${baseUrl}/shapes.parquet`;
|
|
3945
|
-
return baseUrl;
|
|
3946
|
-
}
|
|
3947
|
-
function getAxes(attributes) {
|
|
3948
|
-
const directAxes = normalizeAxes(attributes.axes);
|
|
3949
|
-
if (directAxes) return Object.freeze(directAxes);
|
|
3950
|
-
const ome = getObject(attributes.ome);
|
|
3951
|
-
const multiscales = Array.isArray(ome == null ? void 0 : ome.multiscales) ? ome.multiscales : [];
|
|
3952
|
-
const multiscale = getObject(multiscales[0]);
|
|
3953
|
-
const axes = normalizeAxes(multiscale == null ? void 0 : multiscale.axes);
|
|
3954
|
-
return axes ? Object.freeze(axes) : void 0;
|
|
3955
|
-
}
|
|
3956
|
-
function normalizeAxes(value) {
|
|
3957
|
-
if (!Array.isArray(value)) return void 0;
|
|
3958
|
-
const axes = value.map((axis) => {
|
|
3959
|
-
var _a;
|
|
3960
|
-
return typeof axis === "string" ? axis : getString((_a = getObject(axis)) == null ? void 0 : _a.name);
|
|
3961
|
-
}).filter((axis) => Boolean(axis));
|
|
3962
|
-
return axes.length ? axes : void 0;
|
|
3963
|
-
}
|
|
3964
|
-
function getCoordinateTransformations(attributes) {
|
|
3965
|
-
if (Array.isArray(attributes.coordinateTransformations)) {
|
|
3966
|
-
return Object.freeze([...attributes.coordinateTransformations]);
|
|
3967
|
-
}
|
|
3968
|
-
const ome = getObject(attributes.ome);
|
|
3969
|
-
const multiscales = Array.isArray(ome == null ? void 0 : ome.multiscales) ? ome.multiscales : [];
|
|
3970
|
-
const multiscale = getObject(multiscales[0]);
|
|
3971
|
-
return Array.isArray(multiscale == null ? void 0 : multiscale.coordinateTransformations) ? Object.freeze([...multiscale.coordinateTransformations]) : void 0;
|
|
3972
|
-
}
|
|
3973
|
-
function getElementsByKind(elements, kind) {
|
|
3974
|
-
return Object.freeze(elements.filter((element) => element.kind === kind));
|
|
3975
|
-
}
|
|
3976
|
-
function getObject(value) {
|
|
3977
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
3978
|
-
}
|
|
3979
|
-
function getString(value) {
|
|
3980
|
-
return typeof value === "string" && value ? value : void 0;
|
|
3981
|
-
}
|
|
3982
|
-
var SpatialDataSourceLoaderWithParser, SpatialDataSource, SPATIAL_DATA_NAMESPACES;
|
|
3983
|
-
var init_spatial_data_source = __esm({
|
|
3984
|
-
"src/zarr/spatial-data-source.ts"() {
|
|
3985
|
-
"use strict";
|
|
3986
|
-
init_ome_zarr_source_loader();
|
|
3987
|
-
init_zarr_array_source();
|
|
3988
|
-
SpatialDataSourceLoaderWithParser = {
|
|
3989
|
-
dataType: null,
|
|
3990
|
-
dataSource: null,
|
|
3991
|
-
batchType: null,
|
|
3992
|
-
name: "SpatialDataSourceLoader",
|
|
3993
|
-
id: "spatial-data",
|
|
3994
|
-
module: "scientific",
|
|
3995
|
-
version: OMEZarrSourceLoaderWithParser.version,
|
|
3996
|
-
extensions: ["zarr"],
|
|
3997
|
-
mimeTypes: [],
|
|
3998
|
-
type: "spatial-data",
|
|
3999
|
-
fromUrl: true,
|
|
4000
|
-
fromBlob: false,
|
|
4001
|
-
options: {
|
|
4002
|
-
zarr: {
|
|
4003
|
-
metadataPath: "auto",
|
|
4004
|
-
path: null,
|
|
4005
|
-
labels: void 0,
|
|
4006
|
-
requireConsolidatedMetadata: true
|
|
4007
|
-
}
|
|
4008
|
-
},
|
|
4009
|
-
defaultOptions: {
|
|
4010
|
-
zarr: {
|
|
4011
|
-
metadataPath: "auto",
|
|
4012
|
-
path: null,
|
|
4013
|
-
labels: void 0,
|
|
4014
|
-
requireConsolidatedMetadata: true
|
|
4015
|
-
}
|
|
4016
|
-
},
|
|
4017
|
-
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
4018
|
-
createDataSource: (data, options, coreApi) => new SpatialDataSource(data, options, coreApi)
|
|
4019
|
-
};
|
|
4020
|
-
SpatialDataSource = class extends ZarrSource {
|
|
4021
|
-
/** Shared normalized metadata discovery request. */
|
|
4022
|
-
metadataPromise = null;
|
|
4023
|
-
/** Creates a SpatialData container source. */
|
|
4024
|
-
constructor(data, options = {}, coreApi) {
|
|
4025
|
-
super(data, options, coreApi);
|
|
4026
|
-
}
|
|
4027
|
-
/** Discovers images, labels, points, shapes, and tables without reading payload chunks. */
|
|
4028
|
-
async getMetadata(signal) {
|
|
4029
|
-
this.metadataPromise ||= this.discoverMetadata(signal);
|
|
4030
|
-
try {
|
|
4031
|
-
return await this.metadataPromise;
|
|
4032
|
-
} catch (error) {
|
|
4033
|
-
this.metadataPromise = null;
|
|
4034
|
-
throw error;
|
|
4035
|
-
}
|
|
4036
|
-
}
|
|
4037
|
-
/** Returns one named element, throwing when the kind or name is absent. */
|
|
4038
|
-
async getElement(kind, name, signal) {
|
|
4039
|
-
const metadata = await this.getMetadata(signal);
|
|
4040
|
-
const element = metadata.elements.find(
|
|
4041
|
-
(candidate) => candidate.kind === kind && candidate.name === name
|
|
4042
|
-
);
|
|
4043
|
-
if (!element) {
|
|
4044
|
-
throw new Error(`SpatialData ${kind} element ${name} is not available.`);
|
|
4045
|
-
}
|
|
4046
|
-
return element;
|
|
4047
|
-
}
|
|
4048
|
-
/** Opens an image or label element as an OME-Zarr raster source. */
|
|
4049
|
-
async createRasterSource(kind, name, signal) {
|
|
4050
|
-
const element = await this.getElement(kind, name, signal);
|
|
4051
|
-
return new OMEZarrImageSource(
|
|
4052
|
-
this.data,
|
|
4053
|
-
{
|
|
4054
|
-
...this.options,
|
|
4055
|
-
zarr: { ...this.options.zarr, path: joinZarrPath(this.path, element.path) }
|
|
4056
|
-
},
|
|
4057
|
-
this.hasCoreApi ? this.coreApi : void 0
|
|
4058
|
-
);
|
|
4059
|
-
}
|
|
4060
|
-
/** Opens an array below an AnnData table element through the generic Zarr array source. */
|
|
4061
|
-
async createTableArraySource(name, arrayPath, options = {}, signal) {
|
|
4062
|
-
const element = await this.getElement("table", name, signal);
|
|
4063
|
-
let pathStart = 0;
|
|
4064
|
-
let pathEnd = arrayPath.length;
|
|
4065
|
-
while (pathStart < pathEnd && arrayPath[pathStart] === "/") {
|
|
4066
|
-
pathStart++;
|
|
4067
|
-
}
|
|
4068
|
-
while (pathEnd > pathStart && arrayPath[pathEnd - 1] === "/") {
|
|
4069
|
-
pathEnd--;
|
|
4070
|
-
}
|
|
4071
|
-
const normalizedArrayPath = arrayPath.slice(pathStart, pathEnd);
|
|
4072
|
-
if (!normalizedArrayPath) {
|
|
4073
|
-
throw new Error("SpatialData table array path must not be empty.");
|
|
4074
|
-
}
|
|
4075
|
-
return new ZarrArraySource(
|
|
4076
|
-
this.data,
|
|
4077
|
-
{
|
|
4078
|
-
...this.options,
|
|
4079
|
-
zarr: { ...this.options.zarr, path: joinZarrPath(this.path, element.path) },
|
|
4080
|
-
zarrArray: { ...options, path: normalizedArrayPath }
|
|
4081
|
-
},
|
|
4082
|
-
this.hasCoreApi ? this.coreApi : void 0
|
|
4083
|
-
);
|
|
4084
|
-
}
|
|
4085
|
-
/** Loads and normalizes the consolidated SpatialData element catalog. */
|
|
4086
|
-
async discoverMetadata(signal) {
|
|
4087
|
-
const consolidated = await this.getConsolidatedMetadata(signal);
|
|
4088
|
-
const spatialDataPath = normalizeZarrPath(this.path);
|
|
4089
|
-
const attributes = spatialDataPath ? getGroupAttributes(consolidated, spatialDataPath) : consolidated.rootAttributes;
|
|
4090
|
-
const elements = Object.freeze(
|
|
4091
|
-
discoverSpatialDataElements(this.url, consolidated, spatialDataPath)
|
|
4092
|
-
);
|
|
4093
|
-
const rootSpatialDataAttributes = getObject(attributes.spatialdata_attrs);
|
|
4094
|
-
const metadata = {
|
|
4095
|
-
version: getString(rootSpatialDataAttributes == null ? void 0 : rootSpatialDataAttributes.version),
|
|
4096
|
-
elements,
|
|
4097
|
-
images: getElementsByKind(elements, "image"),
|
|
4098
|
-
labels: getElementsByKind(elements, "labels"),
|
|
4099
|
-
points: getElementsByKind(elements, "points"),
|
|
4100
|
-
shapes: getElementsByKind(elements, "shapes"),
|
|
4101
|
-
tables: getElementsByKind(elements, "table"),
|
|
4102
|
-
attributes: Object.freeze({ ...attributes })
|
|
4103
|
-
};
|
|
4104
|
-
return Object.freeze(metadata);
|
|
4105
|
-
}
|
|
4106
|
-
};
|
|
4107
|
-
SPATIAL_DATA_NAMESPACES = Object.freeze([
|
|
4108
|
-
{ namespace: "images", kind: "image", format: "ome-zarr" },
|
|
4109
|
-
{ namespace: "labels", kind: "labels", format: "ome-zarr" },
|
|
4110
|
-
{ namespace: "points", kind: "points", format: "parquet-dataset" },
|
|
4111
|
-
{ namespace: "shapes", kind: "shapes", format: "geoparquet" },
|
|
4112
|
-
{ namespace: "tables", kind: "table", format: "anndata-zarr" }
|
|
4113
|
-
]);
|
|
4114
|
-
}
|
|
4115
|
-
});
|
|
4116
|
-
|
|
4117
30
|
// dist/index.js
|
|
4118
31
|
var index_exports = {};
|
|
4119
32
|
__export(index_exports, {
|
|
4120
|
-
|
|
33
|
+
GeoZarrLoader: () => GeoZarrLoader,
|
|
34
|
+
NPYFormat: () => NPYFormat,
|
|
35
|
+
NPYLoader: () => NPYLoader,
|
|
36
|
+
NRRDLoader: () => NRRDLoader,
|
|
4121
37
|
NetCDFFormat: () => NetCDFFormat,
|
|
4122
|
-
NetCDFLoader: () =>
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
|
|
4126
|
-
|
|
4127
|
-
ZarrArraySourceLoader: () => ZarrArraySourceLoader
|
|
38
|
+
NetCDFLoader: () => NetCDFLoader,
|
|
39
|
+
OMEZarrLoader: () => OMEZarrLoader,
|
|
40
|
+
SpatialDataLoader: () => SpatialDataLoader,
|
|
41
|
+
VTKLoader: () => VTKLoader,
|
|
42
|
+
ZarrArrayLoader: () => ZarrArrayLoader
|
|
4128
43
|
});
|
|
4129
44
|
module.exports = __toCommonJS(index_exports);
|
|
4130
45
|
|
|
@@ -4141,19 +56,24 @@ var NetCDFFormat = {
|
|
|
4141
56
|
};
|
|
4142
57
|
|
|
4143
58
|
// dist/netcdf/netcdf-loader.js
|
|
4144
|
-
var
|
|
4145
|
-
async function
|
|
4146
|
-
const { NetCDFLoaderWithParser
|
|
4147
|
-
return
|
|
59
|
+
var VERSION = true ? "5.0.0-beta.11" : "latest";
|
|
60
|
+
async function preload() {
|
|
61
|
+
const { NetCDFLoaderWithParser } = await import("@loaders.gl/scientific/netcdf/netcdf-loader-with-parser");
|
|
62
|
+
return NetCDFLoaderWithParser;
|
|
4148
63
|
}
|
|
4149
|
-
var
|
|
64
|
+
var NetCDFLoader = {
|
|
65
|
+
/** Matches input for source selection. */
|
|
66
|
+
testURL: (url) => /\.(?:cdf|nc)(?:$|[?#])/i.test(url),
|
|
67
|
+
fromUrl: true,
|
|
68
|
+
fromBlob: true,
|
|
69
|
+
type: "netcdf",
|
|
4150
70
|
...NetCDFFormat,
|
|
4151
71
|
dataType: null,
|
|
4152
72
|
batchType: null,
|
|
4153
73
|
name: "NetCDF",
|
|
4154
74
|
id: "mvt",
|
|
4155
75
|
module: "scientific",
|
|
4156
|
-
version:
|
|
76
|
+
version: VERSION,
|
|
4157
77
|
extensions: ["cdf", "nc"],
|
|
4158
78
|
mimeTypes: [
|
|
4159
79
|
"application/netcdf",
|
|
@@ -4167,44 +87,18 @@ var NetCDFLoader2 = {
|
|
|
4167
87
|
loadVariables: false
|
|
4168
88
|
}
|
|
4169
89
|
},
|
|
4170
|
-
preload
|
|
4171
|
-
};
|
|
4172
|
-
var NetCDFWorkerLoader2 = NetCDFLoader2;
|
|
4173
|
-
|
|
4174
|
-
// dist/netcdf/netcdf-source-loader-types.js
|
|
4175
|
-
var VERSION5 = true ? "5.0.0-beta.1" : "latest";
|
|
4176
|
-
async function preloadNetCDFSourceLoader() {
|
|
4177
|
-
const { NetCDFSourceLoaderWithParser: NetCDFSourceLoaderWithParser2 } = await Promise.resolve().then(() => (init_netcdf_source_loader(), netcdf_source_loader_exports));
|
|
4178
|
-
return NetCDFSourceLoaderWithParser2;
|
|
4179
|
-
}
|
|
4180
|
-
var NetCDFSourceLoader = {
|
|
4181
|
-
...NetCDFFormat,
|
|
4182
|
-
module: "scientific",
|
|
4183
|
-
dataType: null,
|
|
4184
|
-
batchType: null,
|
|
4185
|
-
name: "NetCDFSourceLoader",
|
|
4186
|
-
version: VERSION5,
|
|
4187
|
-
type: "netcdf-source",
|
|
4188
|
-
fromUrl: true,
|
|
4189
|
-
fromBlob: true,
|
|
4190
|
-
options: {},
|
|
4191
|
-
defaultOptions: {},
|
|
4192
|
-
testURL: (url) => /\.(?:cdf|nc)(?:$|[?#])/i.test(url),
|
|
4193
|
-
preload: preloadNetCDFSourceLoader,
|
|
4194
|
-
createDataSource(_data, _options, _coreApi) {
|
|
4195
|
-
throw new Error("NetCDFSourceLoader requires async load() or an explicit @loaders.gl/scientific/netcdf/netcdf-source-loader import");
|
|
4196
|
-
}
|
|
90
|
+
preload
|
|
4197
91
|
};
|
|
4198
92
|
|
|
4199
93
|
// dist/zarr/zarr-loader-types.js
|
|
4200
|
-
var
|
|
4201
|
-
var
|
|
94
|
+
var VERSION2 = true ? "5.0.0-beta.11" : "latest";
|
|
95
|
+
var OMEZarrLoader = {
|
|
4202
96
|
dataType: null,
|
|
4203
97
|
batchType: null,
|
|
4204
|
-
name: "
|
|
98
|
+
name: "OMEZarrLoader",
|
|
4205
99
|
id: "omezarr",
|
|
4206
100
|
module: "scientific",
|
|
4207
|
-
version:
|
|
101
|
+
version: VERSION2,
|
|
4208
102
|
extensions: ["zarr"],
|
|
4209
103
|
mimeTypes: [],
|
|
4210
104
|
type: "omezarr",
|
|
@@ -4219,18 +113,18 @@ var OMEZarrSourceLoader = {
|
|
|
4219
113
|
omezarr: { interleaved: false, defaultChannels: void 0 }
|
|
4220
114
|
},
|
|
4221
115
|
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
4222
|
-
preload: async () => (await
|
|
4223
|
-
|
|
4224
|
-
throw new Error("
|
|
116
|
+
preload: async () => (await import("@loaders.gl/scientific/zarr/ome-zarr-loader")).OMEZarrLoaderWithParser,
|
|
117
|
+
createDataSourceSync(_data, _options, _coreApi) {
|
|
118
|
+
throw new Error("OMEZarrLoader requires async createDataSource() or an explicit @loaders.gl/scientific/zarr/ome-zarr-loader import");
|
|
4225
119
|
}
|
|
4226
120
|
};
|
|
4227
|
-
var
|
|
121
|
+
var GeoZarrLoader = {
|
|
4228
122
|
dataType: null,
|
|
4229
123
|
batchType: null,
|
|
4230
|
-
name: "
|
|
124
|
+
name: "GeoZarrLoader",
|
|
4231
125
|
id: "geozarr",
|
|
4232
126
|
module: "scientific",
|
|
4233
|
-
version:
|
|
127
|
+
version: VERSION2,
|
|
4234
128
|
extensions: ["zarr"],
|
|
4235
129
|
mimeTypes: [],
|
|
4236
130
|
type: "geozarr",
|
|
@@ -4257,18 +151,18 @@ var GeoZarrSourceLoader = {
|
|
|
4257
151
|
}
|
|
4258
152
|
},
|
|
4259
153
|
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
4260
|
-
preload: async () => (await
|
|
4261
|
-
|
|
4262
|
-
throw new Error("
|
|
154
|
+
preload: async () => (await import("@loaders.gl/scientific/zarr/geo-zarr-loader")).GeoZarrLoaderWithParser,
|
|
155
|
+
createDataSourceSync(_data, _options, _coreApi) {
|
|
156
|
+
throw new Error("GeoZarrLoader requires async createDataSource() or an explicit @loaders.gl/scientific/zarr/geo-zarr-loader import");
|
|
4263
157
|
}
|
|
4264
158
|
};
|
|
4265
|
-
var
|
|
159
|
+
var ZarrArrayLoader = {
|
|
4266
160
|
dataType: null,
|
|
4267
161
|
batchType: null,
|
|
4268
|
-
name: "
|
|
162
|
+
name: "ZarrArrayLoader",
|
|
4269
163
|
id: "zarr-array",
|
|
4270
164
|
module: "scientific",
|
|
4271
|
-
version:
|
|
165
|
+
version: VERSION2,
|
|
4272
166
|
extensions: ["zarr"],
|
|
4273
167
|
mimeTypes: [],
|
|
4274
168
|
type: "zarr-array",
|
|
@@ -4283,18 +177,18 @@ var ZarrArraySourceLoader = {
|
|
|
4283
177
|
zarrArray: { path: void 0, dimensions: void 0 }
|
|
4284
178
|
},
|
|
4285
179
|
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
4286
|
-
preload: async () => (await
|
|
4287
|
-
|
|
4288
|
-
throw new Error("
|
|
180
|
+
preload: async () => (await import("@loaders.gl/scientific/zarr/zarr-array-loader")).ZarrArrayLoaderWithParser,
|
|
181
|
+
createDataSourceSync(_data, _options, _coreApi) {
|
|
182
|
+
throw new Error("ZarrArrayLoader requires async createDataSource() or an explicit @loaders.gl/scientific/zarr/zarr-array-loader import");
|
|
4289
183
|
}
|
|
4290
184
|
};
|
|
4291
|
-
var
|
|
185
|
+
var SpatialDataLoader = {
|
|
4292
186
|
dataType: null,
|
|
4293
187
|
batchType: null,
|
|
4294
|
-
name: "
|
|
188
|
+
name: "SpatialDataLoader",
|
|
4295
189
|
id: "spatial-data",
|
|
4296
190
|
module: "scientific",
|
|
4297
|
-
version:
|
|
191
|
+
version: VERSION2,
|
|
4298
192
|
extensions: ["zarr"],
|
|
4299
193
|
mimeTypes: [],
|
|
4300
194
|
type: "spatial-data",
|
|
@@ -4307,9 +201,99 @@ var SpatialDataSourceLoader = {
|
|
|
4307
201
|
zarr: { metadataPath: "auto", path: null, labels: void 0, requireConsolidatedMetadata: true }
|
|
4308
202
|
},
|
|
4309
203
|
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
4310
|
-
preload: async () => (await
|
|
4311
|
-
|
|
4312
|
-
throw new Error("
|
|
204
|
+
preload: async () => (await import("@loaders.gl/scientific/zarr/spatial-data-loader")).SpatialDataLoaderWithParser,
|
|
205
|
+
createDataSourceSync(_data, _options, _coreApi) {
|
|
206
|
+
throw new Error("SpatialDataLoader requires async createDataSource() or an explicit @loaders.gl/scientific/zarr/spatial-data-loader import");
|
|
4313
207
|
}
|
|
4314
208
|
};
|
|
209
|
+
|
|
210
|
+
// dist/npy-format.js
|
|
211
|
+
var NPYFormat = {
|
|
212
|
+
name: "NPY",
|
|
213
|
+
id: "npy",
|
|
214
|
+
module: "scientific",
|
|
215
|
+
encoding: "binary",
|
|
216
|
+
format: "npy",
|
|
217
|
+
extensions: ["npy"],
|
|
218
|
+
mimeTypes: [],
|
|
219
|
+
binary: true
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
// dist/npy-loader-types.js
|
|
223
|
+
var VERSION3 = true ? "5.0.0-beta.11" : "latest";
|
|
224
|
+
var NPY_MAGIC_NUMBER = new Uint8Array([147, 78, 85, 77, 80, 89]);
|
|
225
|
+
async function preload2() {
|
|
226
|
+
const { NPYLoaderWithParser } = await import("@loaders.gl/scientific/npy-loader");
|
|
227
|
+
return NPYLoaderWithParser;
|
|
228
|
+
}
|
|
229
|
+
var NPYLoader = {
|
|
230
|
+
...NPYFormat,
|
|
231
|
+
dataType: null,
|
|
232
|
+
batchType: null,
|
|
233
|
+
name: "NPY",
|
|
234
|
+
id: "npy",
|
|
235
|
+
module: "scientific",
|
|
236
|
+
version: VERSION3,
|
|
237
|
+
worker: true,
|
|
238
|
+
extensions: ["npy"],
|
|
239
|
+
mimeTypes: [],
|
|
240
|
+
tests: [NPY_MAGIC_NUMBER.buffer],
|
|
241
|
+
options: {
|
|
242
|
+
npy: {}
|
|
243
|
+
},
|
|
244
|
+
preload: preload2
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
// dist/nrrd-loader-types.js
|
|
248
|
+
var VERSION4 = true ? "5.0.0-beta.11" : "latest";
|
|
249
|
+
async function preload3() {
|
|
250
|
+
const { NRRDLoaderWithParser } = await import("@loaders.gl/scientific/nrrd-loader");
|
|
251
|
+
return NRRDLoaderWithParser;
|
|
252
|
+
}
|
|
253
|
+
var NRRDLoader = {
|
|
254
|
+
name: "NRRD",
|
|
255
|
+
id: "nrrd",
|
|
256
|
+
module: "scientific",
|
|
257
|
+
version: VERSION4,
|
|
258
|
+
extensions: ["nrrd"],
|
|
259
|
+
mimeTypes: ["application/x-nrrd"],
|
|
260
|
+
binary: true,
|
|
261
|
+
dataType: null,
|
|
262
|
+
batchType: null,
|
|
263
|
+
options: {},
|
|
264
|
+
preload: preload3
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
// dist/vtk-loader-types.js
|
|
268
|
+
var VERSION5 = true ? "5.0.0-beta.11" : "latest";
|
|
269
|
+
async function preload4() {
|
|
270
|
+
const { VTKLoaderWithParser } = await import("@loaders.gl/scientific/vtk-loader");
|
|
271
|
+
return VTKLoaderWithParser;
|
|
272
|
+
}
|
|
273
|
+
var VTKLoader = {
|
|
274
|
+
name: "VTK",
|
|
275
|
+
id: "vtk",
|
|
276
|
+
module: "scientific",
|
|
277
|
+
version: VERSION5,
|
|
278
|
+
extensions: ["vtk", "vti", "vtu", "vtp", "vtr", "vts"],
|
|
279
|
+
mimeTypes: ["application/vnd.vtk"],
|
|
280
|
+
text: true,
|
|
281
|
+
dataType: null,
|
|
282
|
+
batchType: null,
|
|
283
|
+
options: {},
|
|
284
|
+
preload: preload4
|
|
285
|
+
};
|
|
286
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
287
|
+
0 && (module.exports = {
|
|
288
|
+
GeoZarrLoader,
|
|
289
|
+
NPYFormat,
|
|
290
|
+
NPYLoader,
|
|
291
|
+
NRRDLoader,
|
|
292
|
+
NetCDFFormat,
|
|
293
|
+
NetCDFLoader,
|
|
294
|
+
OMEZarrLoader,
|
|
295
|
+
SpatialDataLoader,
|
|
296
|
+
VTKLoader,
|
|
297
|
+
ZarrArrayLoader
|
|
298
|
+
});
|
|
4315
299
|
//# sourceMappingURL=index.cjs.map
|