@loaders.gl/scientific 5.0.0-beta.1 → 5.0.0-beta.10
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 +3095 -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 +294 -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/zarr/index.cjs
CHANGED
|
@@ -2531,14 +2531,14 @@ var init_zstd = __esm({
|
|
|
2531
2531
|
// src/zarr/index.ts
|
|
2532
2532
|
var index_exports = {};
|
|
2533
2533
|
__export(index_exports, {
|
|
2534
|
+
GeoZarrLoader: () => GeoZarrLoaderWithParser,
|
|
2534
2535
|
GeoZarrRasterSource: () => GeoZarrRasterSource,
|
|
2535
|
-
GeoZarrSourceLoader: () => GeoZarrSourceLoaderWithParser,
|
|
2536
2536
|
OMEZarrImageSource: () => OMEZarrImageSource,
|
|
2537
|
-
|
|
2537
|
+
OMEZarrLoader: () => OMEZarrLoaderWithParser,
|
|
2538
|
+
SpatialDataLoader: () => SpatialDataLoaderWithParser,
|
|
2538
2539
|
SpatialDataSource: () => SpatialDataSource,
|
|
2539
|
-
|
|
2540
|
+
ZarrArrayLoader: () => ZarrArrayLoaderWithParser,
|
|
2540
2541
|
ZarrArraySource: () => ZarrArraySource,
|
|
2541
|
-
ZarrArraySourceLoader: () => ZarrArraySourceLoaderWithParser,
|
|
2542
2542
|
ZarrPixelSource: () => zarr_pixel_source_default,
|
|
2543
2543
|
loadZarr: () => loadZarr,
|
|
2544
2544
|
loadZarrConsolidatedMetadata: () => loadZarrConsolidatedMetadata
|
|
@@ -10837,6 +10837,11 @@ var UnsupportedError = class extends ZarritaError {
|
|
|
10837
10837
|
this.feature = feature;
|
|
10838
10838
|
}
|
|
10839
10839
|
};
|
|
10840
|
+
function isZarritaError(err2, ...tags) {
|
|
10841
|
+
if (!(err2 instanceof ZarritaError))
|
|
10842
|
+
return false;
|
|
10843
|
+
return tags.length === 0 || tags.includes(err2._tag);
|
|
10844
|
+
}
|
|
10840
10845
|
|
|
10841
10846
|
// ../../node_modules/zarrita/dist/src/codecs/_shared.js
|
|
10842
10847
|
function unimplementedEncode(codecName) {
|
|
@@ -12979,7 +12984,7 @@ function setFromChunkBinary(dest, src, bytesPerElement2, projections) {
|
|
|
12979
12984
|
}
|
|
12980
12985
|
}
|
|
12981
12986
|
|
|
12982
|
-
// src/zarr/ome-zarr-
|
|
12987
|
+
// src/zarr/ome-zarr-loader.ts
|
|
12983
12988
|
var import_loader_utils = require("@loaders.gl/core/loader-utils");
|
|
12984
12989
|
|
|
12985
12990
|
// src/zarr/lib/zarr-data-cache.ts
|
|
@@ -13251,7 +13256,7 @@ function extractDirectChildren(paths) {
|
|
|
13251
13256
|
return [...directChildren].sort();
|
|
13252
13257
|
}
|
|
13253
13258
|
|
|
13254
|
-
// src/zarr/ome-zarr-
|
|
13259
|
+
// src/zarr/ome-zarr-loader.ts
|
|
13255
13260
|
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
13256
13261
|
async function loadZarrConsolidatedMetadata(url, options = {}) {
|
|
13257
13262
|
const fetcher = options.fetch || fetch;
|
|
@@ -13348,12 +13353,12 @@ var ZarrSource = class extends import_loader_utils.DataSource {
|
|
|
13348
13353
|
return await open(location, { kind: "group", signal });
|
|
13349
13354
|
}
|
|
13350
13355
|
};
|
|
13351
|
-
var
|
|
13356
|
+
var OMEZarrLoaderWithParser = {
|
|
13352
13357
|
dataType: null,
|
|
13353
13358
|
/** Runtime source type marker used by `createDataSource()` type inference. */
|
|
13354
13359
|
dataSource: null,
|
|
13355
13360
|
batchType: null,
|
|
13356
|
-
name: "
|
|
13361
|
+
name: "OMEZarrLoader",
|
|
13357
13362
|
id: "omezarr",
|
|
13358
13363
|
module: "scientific",
|
|
13359
13364
|
version: VERSION,
|
|
@@ -13387,7 +13392,7 @@ var OMEZarrSourceLoaderWithParser = {
|
|
|
13387
13392
|
}
|
|
13388
13393
|
},
|
|
13389
13394
|
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
13390
|
-
|
|
13395
|
+
createDataSourceSync: (data, options, coreApi) => new OMEZarrImageSource(data, options, coreApi)
|
|
13391
13396
|
};
|
|
13392
13397
|
var OMEZarrImageSource = class extends ZarrSource {
|
|
13393
13398
|
/** Shared source initialization request. */
|
|
@@ -13736,11 +13741,13 @@ function getTypedArrayDtype(TypedArrayConstructor) {
|
|
|
13736
13741
|
}
|
|
13737
13742
|
}
|
|
13738
13743
|
|
|
13739
|
-
// src/zarr/geo-zarr-
|
|
13744
|
+
// src/zarr/geo-zarr-loader.ts
|
|
13740
13745
|
var import_loader_utils2 = require("@loaders.gl/core/loader-utils");
|
|
13741
13746
|
|
|
13742
13747
|
// src/zarr/lib/spatial-multiscales.ts
|
|
13743
|
-
function getSpatialMultiscaleLevels(attributes, array2) {
|
|
13748
|
+
function getSpatialMultiscaleLevels(attributes, array2, { spatialOME = false } = {}) {
|
|
13749
|
+
const omeMultiscales = spatialOME ? getOMEMultiscales(attributes) : null;
|
|
13750
|
+
if (omeMultiscales) return getOMEMultiscaleLevels(omeMultiscales, array2);
|
|
13744
13751
|
const multiscales = attributes?.multiscales;
|
|
13745
13752
|
const layout = multiscales?.layout;
|
|
13746
13753
|
if (!Array.isArray(layout) || !layout.length) return [];
|
|
@@ -13750,28 +13757,88 @@ function getSpatialMultiscaleLevels(attributes, array2) {
|
|
|
13750
13757
|
}
|
|
13751
13758
|
const assets = entries.map((entry) => entry.asset);
|
|
13752
13759
|
if (new Set(assets).size !== assets.length) throw new Error("Duplicate spatial multiscales asset.");
|
|
13760
|
+
return resolveLevels(assets, array2, entries);
|
|
13761
|
+
}
|
|
13762
|
+
function getOMEMultiscales(attributes) {
|
|
13763
|
+
if (Array.isArray(attributes?.multiscales)) return attributes.multiscales;
|
|
13764
|
+
const ome = attributes?.ome;
|
|
13765
|
+
return Array.isArray(ome?.multiscales) ? ome.multiscales : null;
|
|
13766
|
+
}
|
|
13767
|
+
function getOMEMultiscaleLevels(multiscales, array2) {
|
|
13768
|
+
const candidates = multiscales.filter((multiscale2) => {
|
|
13769
|
+
const datasets2 = multiscale2?.datasets;
|
|
13770
|
+
return Array.isArray(datasets2) && datasets2.some((dataset) => isChildPath(dataset?.path) && (array2 === dataset.path || array2.startsWith(`${dataset.path}/`)));
|
|
13771
|
+
});
|
|
13772
|
+
if (!candidates.length) return [];
|
|
13773
|
+
if (candidates.length > 1) throw new Error("Array belongs to more than one OME-NGFF multiscale.");
|
|
13774
|
+
const multiscale = candidates[0];
|
|
13775
|
+
const datasets = multiscale.datasets;
|
|
13776
|
+
if (datasets.some((dataset) => !dataset || !isChildPath(dataset.path))) {
|
|
13777
|
+
throw new Error("OME-NGFF dataset paths must be relative child paths.");
|
|
13778
|
+
}
|
|
13779
|
+
const paths = datasets.map((dataset) => dataset.path);
|
|
13780
|
+
if (new Set(paths).size !== paths.length) throw new Error("Duplicate OME-NGFF dataset path.");
|
|
13781
|
+
const axes = getOMEAxisNames(multiscale.axes);
|
|
13782
|
+
return resolveLevels(paths, array2, datasets.map(() => ({}))).map((level, index) => ({
|
|
13783
|
+
...level,
|
|
13784
|
+
scale: getOMEScale(axes, [
|
|
13785
|
+
datasets[index].coordinateTransformations,
|
|
13786
|
+
multiscale.coordinateTransformations
|
|
13787
|
+
])
|
|
13788
|
+
}));
|
|
13789
|
+
}
|
|
13790
|
+
function resolveLevels(assets, array2, attributes) {
|
|
13753
13791
|
const matches = assets.filter((asset) => array2 === asset || array2.startsWith(`${asset}/`));
|
|
13754
13792
|
if (matches.length !== 1) return [];
|
|
13755
13793
|
const suffix = array2.slice(matches[0].length);
|
|
13756
|
-
return
|
|
13757
|
-
id:
|
|
13758
|
-
array: `${
|
|
13759
|
-
...suffix ? { group:
|
|
13760
|
-
attributes:
|
|
13794
|
+
return assets.map((asset, index) => ({
|
|
13795
|
+
id: asset,
|
|
13796
|
+
array: `${asset}${suffix}`,
|
|
13797
|
+
...suffix ? { group: asset } : {},
|
|
13798
|
+
attributes: attributes[index]
|
|
13761
13799
|
}));
|
|
13762
13800
|
}
|
|
13801
|
+
function getOMEAxisNames(axes) {
|
|
13802
|
+
const names = Array.isArray(axes) ? axes.map((axis) => typeof axis === "string" ? axis : axis?.name) : [];
|
|
13803
|
+
if (!names.length || names.some((name) => typeof name !== "string" || !name)) {
|
|
13804
|
+
throw new Error("OME-NGFF multiscales require named axes.");
|
|
13805
|
+
}
|
|
13806
|
+
if (new Set(names).size !== names.length) throw new Error("Duplicate OME-NGFF axis name.");
|
|
13807
|
+
return names;
|
|
13808
|
+
}
|
|
13809
|
+
function getOMEScale(axes, transformLists) {
|
|
13810
|
+
const scale = axes.map(() => 1);
|
|
13811
|
+
for (const transforms of transformLists) {
|
|
13812
|
+
if (transforms === void 0) continue;
|
|
13813
|
+
if (!Array.isArray(transforms)) {
|
|
13814
|
+
throw new Error("OME-NGFF coordinateTransformations must be a list.");
|
|
13815
|
+
}
|
|
13816
|
+
for (const transform of transforms) {
|
|
13817
|
+
if (transform?.type === "identity" || transform?.type === "translation") continue;
|
|
13818
|
+
if (transform?.type !== "scale") {
|
|
13819
|
+
throw new Error(`Unsupported OME-NGFF coordinate transformation ${String(transform?.type)}.`);
|
|
13820
|
+
}
|
|
13821
|
+
const values = transform.scale;
|
|
13822
|
+
if (!Array.isArray(values) || values.length !== axes.length || values.some((value) => typeof value !== "number" || !Number.isFinite(value) || value === 0)) {
|
|
13823
|
+
throw new Error("OME-NGFF scale must give one finite non-zero value per axis.");
|
|
13824
|
+
}
|
|
13825
|
+
values.forEach((value, index) => scale[index] *= value);
|
|
13826
|
+
}
|
|
13827
|
+
}
|
|
13828
|
+
return Object.fromEntries(axes.map((axis, index) => [axis, scale[index]]));
|
|
13829
|
+
}
|
|
13763
13830
|
function isChildPath(value) {
|
|
13764
|
-
return typeof value === "string" && value.length > 0 && !/[\\%:?#\u0000
|
|
13831
|
+
return typeof value === "string" && value.length > 0 && !/[\\%:?#\u0000- ]/.test(value) && value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
13765
13832
|
}
|
|
13766
13833
|
|
|
13767
|
-
// src/zarr/geo-zarr-
|
|
13834
|
+
// src/zarr/geo-zarr-loader.ts
|
|
13768
13835
|
var VERSION2 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
13769
|
-
var
|
|
13836
|
+
var GeoZarrLoaderWithParser = {
|
|
13770
13837
|
dataType: null,
|
|
13771
13838
|
/** Runtime source type marker used by `createDataSource()` type inference. */
|
|
13772
13839
|
dataSource: null,
|
|
13773
13840
|
batchType: null,
|
|
13774
|
-
name: "
|
|
13841
|
+
name: "GeoZarrLoader",
|
|
13775
13842
|
id: "geozarr",
|
|
13776
13843
|
module: "scientific",
|
|
13777
13844
|
version: VERSION2,
|
|
@@ -13811,7 +13878,7 @@ var GeoZarrSourceLoaderWithParser = {
|
|
|
13811
13878
|
}
|
|
13812
13879
|
},
|
|
13813
13880
|
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
13814
|
-
|
|
13881
|
+
createDataSourceSync: (data, options, coreApi) => new GeoZarrRasterSource(data, options, coreApi)
|
|
13815
13882
|
};
|
|
13816
13883
|
var GeoZarrRasterSource = class _GeoZarrRasterSource extends ZarrSource {
|
|
13817
13884
|
/** Shared source initialization request. */
|
|
@@ -13834,9 +13901,7 @@ var GeoZarrRasterSource = class _GeoZarrRasterSource extends ZarrSource {
|
|
|
13834
13901
|
}
|
|
13835
13902
|
/** Opens sibling array metadata without selecting or decoding their samples. */
|
|
13836
13903
|
async loadGridMetadata() {
|
|
13837
|
-
const { metadata, group: group2 } = await this.getInitializationPromise();
|
|
13838
|
-
const groupAttributes = metadata.metadata?.groupAttributes;
|
|
13839
|
-
const layout = getSpatialMultiscaleLevels(groupAttributes, metadata.array);
|
|
13904
|
+
const { metadata, group: group2, layout } = await this.getInitializationPromise();
|
|
13840
13905
|
const levels = [];
|
|
13841
13906
|
for (const level of layout) {
|
|
13842
13907
|
if (level.array === metadata.array) {
|
|
@@ -13859,6 +13924,15 @@ var GeoZarrRasterSource = class _GeoZarrRasterSource extends ZarrSource {
|
|
|
13859
13924
|
levels.push({ id: level.id, array: level.array });
|
|
13860
13925
|
}
|
|
13861
13926
|
}
|
|
13927
|
+
const selectedScale = layout.find((level) => level.array === metadata.array)?.scale;
|
|
13928
|
+
if (selectedScale) {
|
|
13929
|
+
for (const [index, level] of levels.entries()) {
|
|
13930
|
+
const scale = layout[index].scale;
|
|
13931
|
+
if (level.metadata && !isConsistentOMELevel(scale, selectedScale, level.metadata, metadata)) {
|
|
13932
|
+
delete level.metadata;
|
|
13933
|
+
}
|
|
13934
|
+
}
|
|
13935
|
+
}
|
|
13862
13936
|
const normalizedLevels = levels.length ? levels : [{ id: metadata.array, array: metadata.array, metadata }];
|
|
13863
13937
|
const matrices = normalizedLevels.map((level) => getSpatialChunkMatrix(level.id, level.metadata));
|
|
13864
13938
|
const commonCoordinateReferenceSystem = typeof metadata.crs === "string" && normalizedLevels.every((level) => level.metadata?.crs === metadata.crs) ? metadata.crs : void 0;
|
|
@@ -13983,11 +14057,25 @@ var GeoZarrRasterSource = class _GeoZarrRasterSource extends ZarrSource {
|
|
|
13983
14057
|
const array2 = await open(group2.resolve(arrayPath), { kind: "array", signal });
|
|
13984
14058
|
const groupAttributes = normalizeAttributes(group2.attrs);
|
|
13985
14059
|
const arrayAttributes = normalizeAttributes(array2.attrs);
|
|
13986
|
-
const
|
|
13987
|
-
|
|
13988
|
-
|
|
13989
|
-
|
|
13990
|
-
)
|
|
14060
|
+
const openGroupAttributes = async (path) => normalizeAttributes((await open(group2.resolve(path), { kind: "group", signal })).attrs);
|
|
14061
|
+
let layout = getSpatialMultiscaleLevels(groupAttributes, arrayPath, {
|
|
14062
|
+
spatialOME: declaresCoordinateReferenceSystem({ ...groupAttributes, ...arrayAttributes })
|
|
14063
|
+
});
|
|
14064
|
+
let level = layout.find((candidate) => candidate.array === arrayPath);
|
|
14065
|
+
let levelGroupAttributes = level?.group ? await openGroupAttributes(level.group) : {};
|
|
14066
|
+
if (!layout.length) {
|
|
14067
|
+
const omeLayout = getOMELevelsOrEmpty(groupAttributes, arrayPath);
|
|
14068
|
+
const omeLevel = omeLayout.find((candidate) => candidate.array === arrayPath);
|
|
14069
|
+
const omeLevelGroupAttributes = omeLevel?.group ? await openGroupAttributes(omeLevel.group).catch((error) => {
|
|
14070
|
+
rethrowUnlessAbsent(error);
|
|
14071
|
+
return {};
|
|
14072
|
+
}) : {};
|
|
14073
|
+
if (declaresCoordinateReferenceSystem(omeLevelGroupAttributes)) {
|
|
14074
|
+
layout = omeLayout;
|
|
14075
|
+
level = omeLevel;
|
|
14076
|
+
levelGroupAttributes = omeLevelGroupAttributes;
|
|
14077
|
+
}
|
|
14078
|
+
}
|
|
13991
14079
|
const attributes = {
|
|
13992
14080
|
...groupAttributes,
|
|
13993
14081
|
...levelGroupAttributes,
|
|
@@ -14021,17 +14109,25 @@ var GeoZarrRasterSource = class _GeoZarrRasterSource extends ZarrSource {
|
|
|
14021
14109
|
const xDimensionIndex = dimensions.indexOf(spatialDimensions[1]);
|
|
14022
14110
|
const width = array2.shape[xDimensionIndex];
|
|
14023
14111
|
const height = array2.shape[yDimensionIndex];
|
|
14024
|
-
|
|
14112
|
+
let gridMappingPromise;
|
|
14113
|
+
const getGridMapping = () => gridMappingPromise ||= loadCFGridMapping(group2, arrayPath, attributes, signal);
|
|
14114
|
+
const coordinateTransform = options?.transform || normalizeAffineTransform(attributes["spatial:transform"]) || // An ancestor grid mapping can be shared by several multiscale levels: it gives the CRS only.
|
|
14115
|
+
normalizeGDALGeoTransform(
|
|
14116
|
+
await getGridMapping().then((mapping) => mapping?.local ? mapping.attributes.GeoTransform : null)
|
|
14117
|
+
) || (!metadataOnly ? await loadCFCoordinateTransform(group2, arrayPath, spatialDimensions, signal) : null);
|
|
14025
14118
|
if (!coordinateTransform) {
|
|
14026
14119
|
throw new Error(
|
|
14027
|
-
"GeoZarrRasterSource requires spatial:transform metadata, explicit geozarr.transform, or regular 1D CF coordinate arrays."
|
|
14120
|
+
"GeoZarrRasterSource requires spatial:transform metadata, explicit geozarr.transform, a CF grid-mapping GeoTransform, or regular 1D CF coordinate arrays."
|
|
14028
14121
|
);
|
|
14029
14122
|
}
|
|
14030
14123
|
const declaredRegistration = normalizeRegistration(attributes["spatial:registration"]);
|
|
14031
14124
|
const transform = declaredRegistration === "node" ? convertNodeTransformToPixelTransform(coordinateTransform) : coordinateTransform;
|
|
14032
14125
|
const declaredBoundingBox = normalizeBoundingBox(attributes["spatial:bbox"]);
|
|
14033
14126
|
const boundingBox = declaredRegistration === "pixel" && declaredBoundingBox ? toRasterBoundingBox(declaredBoundingBox) : getTransformBoundingBox(transform, width, height);
|
|
14034
|
-
const coordinateReferenceSystem = options?.coordinateReferenceSystem || normalizeDeclaredCoordinateReferenceSystem(attributes) ||
|
|
14127
|
+
const coordinateReferenceSystem = options?.coordinateReferenceSystem || normalizeDeclaredCoordinateReferenceSystem(attributes) || getCFCoordinateReferenceSystem(
|
|
14128
|
+
(await getGridMapping())?.attributes || null,
|
|
14129
|
+
spatialDimensions
|
|
14130
|
+
);
|
|
14035
14131
|
const defaultSelection = options?.defaultSelection || {};
|
|
14036
14132
|
const selectionDimensions = dimensions.map((dimensionName, dimensionIndex) => ({
|
|
14037
14133
|
name: dimensionName,
|
|
@@ -14071,7 +14167,7 @@ var GeoZarrRasterSource = class _GeoZarrRasterSource extends ZarrSource {
|
|
|
14071
14167
|
transform,
|
|
14072
14168
|
registration: declaredRegistration
|
|
14073
14169
|
};
|
|
14074
|
-
return { group: group2, array: array2, metadata, xDimensionIndex, yDimensionIndex };
|
|
14170
|
+
return { group: group2, array: array2, metadata, xDimensionIndex, yDimensionIndex, layout };
|
|
14075
14171
|
}
|
|
14076
14172
|
};
|
|
14077
14173
|
function normalizeAttributes(attributes) {
|
|
@@ -14131,12 +14227,19 @@ function convertNodeTransformToPixelTransform(transform) {
|
|
|
14131
14227
|
translateY - (rotationY + scaleY) / 2
|
|
14132
14228
|
];
|
|
14133
14229
|
}
|
|
14134
|
-
async function loadCFCoordinateTransform(group2, spatialDimensions, signal) {
|
|
14230
|
+
async function loadCFCoordinateTransform(group2, arrayPath, spatialDimensions, signal) {
|
|
14231
|
+
let coordinates;
|
|
14135
14232
|
try {
|
|
14136
|
-
|
|
14137
|
-
loadCoordinateValues(group2, spatialDimensions[0], signal),
|
|
14138
|
-
loadCoordinateValues(group2, spatialDimensions[1], signal)
|
|
14233
|
+
coordinates = await Promise.all([
|
|
14234
|
+
loadCoordinateValues(group2, arrayPath, spatialDimensions[0], signal),
|
|
14235
|
+
loadCoordinateValues(group2, arrayPath, spatialDimensions[1], signal)
|
|
14139
14236
|
]);
|
|
14237
|
+
} catch (error) {
|
|
14238
|
+
rethrowUnlessAbsent(error);
|
|
14239
|
+
return null;
|
|
14240
|
+
}
|
|
14241
|
+
const [yCoordinates, xCoordinates] = coordinates;
|
|
14242
|
+
try {
|
|
14140
14243
|
const scaleX = getRegularCoordinateSpacing(xCoordinates, spatialDimensions[1]);
|
|
14141
14244
|
const scaleY = getRegularCoordinateSpacing(yCoordinates, spatialDimensions[0]);
|
|
14142
14245
|
return [scaleX, 0, xCoordinates[0] - scaleX / 2, 0, scaleY, yCoordinates[0] - scaleY / 2];
|
|
@@ -14144,11 +14247,8 @@ async function loadCFCoordinateTransform(group2, spatialDimensions, signal) {
|
|
|
14144
14247
|
return null;
|
|
14145
14248
|
}
|
|
14146
14249
|
}
|
|
14147
|
-
async function loadCoordinateValues(group2, coordinateName, signal) {
|
|
14148
|
-
const coordinateArray = await
|
|
14149
|
-
kind: "array",
|
|
14150
|
-
signal
|
|
14151
|
-
});
|
|
14250
|
+
async function loadCoordinateValues(group2, arrayPath, coordinateName, signal) {
|
|
14251
|
+
const { array: coordinateArray } = await openNearestArray(group2, arrayPath, coordinateName, signal);
|
|
14152
14252
|
if (coordinateArray.shape.length !== 1 || coordinateArray.shape[0] < 2) {
|
|
14153
14253
|
throw new Error(
|
|
14154
14254
|
`Coordinate ${coordinateName} must be a one-dimensional array with at least two values.`
|
|
@@ -14160,6 +14260,23 @@ async function loadCoordinateValues(group2, coordinateName, signal) {
|
|
|
14160
14260
|
}
|
|
14161
14261
|
return Array.from(coordinateChunk.data);
|
|
14162
14262
|
}
|
|
14263
|
+
async function openNearestArray(group2, arrayPath, name, signal) {
|
|
14264
|
+
const segments = arrayPath.split("/").slice(0, -1);
|
|
14265
|
+
let lastError;
|
|
14266
|
+
for (let depth = segments.length; depth >= 0; depth--) {
|
|
14267
|
+
const path = [...segments.slice(0, depth), name].join("/");
|
|
14268
|
+
try {
|
|
14269
|
+
const array2 = await open(group2.resolve(path), { kind: "array", signal });
|
|
14270
|
+
return { array: array2, local: depth === segments.length };
|
|
14271
|
+
} catch (error) {
|
|
14272
|
+
if (!isZarritaError(error, "NotFoundError")) {
|
|
14273
|
+
throw error;
|
|
14274
|
+
}
|
|
14275
|
+
lastError = error;
|
|
14276
|
+
}
|
|
14277
|
+
}
|
|
14278
|
+
throw lastError;
|
|
14279
|
+
}
|
|
14163
14280
|
function getRegularCoordinateSpacing(coordinates, coordinateName) {
|
|
14164
14281
|
const spacing = (coordinates.at(-1) - coordinates[0]) / (coordinates.length - 1);
|
|
14165
14282
|
if (!Number.isFinite(spacing) || spacing === 0) {
|
|
@@ -14174,22 +14291,27 @@ function getRegularCoordinateSpacing(coordinates, coordinateName) {
|
|
|
14174
14291
|
}
|
|
14175
14292
|
return spacing;
|
|
14176
14293
|
}
|
|
14177
|
-
async function
|
|
14294
|
+
async function loadCFGridMapping(group2, arrayPath, attributes, signal) {
|
|
14178
14295
|
const gridMapping = normalizeString(attributes.grid_mapping);
|
|
14179
|
-
if (gridMapping)
|
|
14180
|
-
|
|
14181
|
-
|
|
14182
|
-
|
|
14183
|
-
|
|
14184
|
-
|
|
14185
|
-
|
|
14186
|
-
|
|
14187
|
-
|
|
14188
|
-
|
|
14189
|
-
|
|
14190
|
-
|
|
14191
|
-
|
|
14192
|
-
|
|
14296
|
+
if (!gridMapping) return null;
|
|
14297
|
+
const gridMappingName = gridMapping.trim().split(/[\s:]/, 1)[0];
|
|
14298
|
+
try {
|
|
14299
|
+
const { array: array2, local } = await openNearestArray(group2, arrayPath, gridMappingName, signal);
|
|
14300
|
+
return { attributes: normalizeAttributes(array2.attrs), local };
|
|
14301
|
+
} catch (error) {
|
|
14302
|
+
rethrowUnlessAbsent(error);
|
|
14303
|
+
return null;
|
|
14304
|
+
}
|
|
14305
|
+
}
|
|
14306
|
+
function rethrowUnlessAbsent(error) {
|
|
14307
|
+
if (!isZarritaError(error, "NotFoundError")) {
|
|
14308
|
+
throw error;
|
|
14309
|
+
}
|
|
14310
|
+
}
|
|
14311
|
+
function getCFCoordinateReferenceSystem(gridMappingAttributes, spatialDimensions) {
|
|
14312
|
+
const coordinateReferenceSystem = gridMappingAttributes && (normalizeString(gridMappingAttributes.crs_wkt) || normalizeString(gridMappingAttributes.spatial_ref) || normalizeString(gridMappingAttributes["proj:wkt2"]) || normalizeString(gridMappingAttributes["proj:code"]));
|
|
14313
|
+
if (coordinateReferenceSystem) {
|
|
14314
|
+
return coordinateReferenceSystem;
|
|
14193
14315
|
}
|
|
14194
14316
|
const normalizedDimensions = spatialDimensions.map((dimension) => dimension.toLowerCase());
|
|
14195
14317
|
if (["lat", "latitude"].includes(normalizedDimensions[0]) && ["lon", "longitude"].includes(normalizedDimensions[1])) {
|
|
@@ -14197,6 +14319,35 @@ async function loadCFCoordinateReferenceSystem(group2, attributes, spatialDimens
|
|
|
14197
14319
|
}
|
|
14198
14320
|
return void 0;
|
|
14199
14321
|
}
|
|
14322
|
+
function normalizeGDALGeoTransform(value) {
|
|
14323
|
+
const coefficients = typeof value === "string" ? value.trim().split(/\s+/).map(Number) : value;
|
|
14324
|
+
if (!Array.isArray(coefficients) || coefficients.length !== 6 || coefficients.some((coefficient) => typeof coefficient !== "number" || !Number.isFinite(coefficient))) {
|
|
14325
|
+
return null;
|
|
14326
|
+
}
|
|
14327
|
+
const [originX, pixelWidth, rotationX, originY, rotationY, pixelHeight] = coefficients;
|
|
14328
|
+
if (pixelWidth === 0 || pixelHeight === 0) return null;
|
|
14329
|
+
return [pixelWidth, rotationX, originX, rotationY, pixelHeight, originY];
|
|
14330
|
+
}
|
|
14331
|
+
function getOMELevelsOrEmpty(attributes, arrayPath) {
|
|
14332
|
+
try {
|
|
14333
|
+
return getSpatialMultiscaleLevels(attributes, arrayPath, { spatialOME: true });
|
|
14334
|
+
} catch {
|
|
14335
|
+
return [];
|
|
14336
|
+
}
|
|
14337
|
+
}
|
|
14338
|
+
function declaresCoordinateReferenceSystem(attributes) {
|
|
14339
|
+
return Boolean(
|
|
14340
|
+
normalizeDeclaredCoordinateReferenceSystem(attributes) || normalizeString(attributes.grid_mapping)
|
|
14341
|
+
);
|
|
14342
|
+
}
|
|
14343
|
+
function isConsistentOMELevel(scale, selectedScale, level, selected) {
|
|
14344
|
+
return selected.spatialDimensions.every((dimension, index) => {
|
|
14345
|
+
const coefficient = index === 0 ? 4 : 0;
|
|
14346
|
+
const expected = Math.abs(scale[dimension] / selectedScale[dimension]);
|
|
14347
|
+
const actual = Math.abs(level.transform[coefficient] / selected.transform[coefficient]);
|
|
14348
|
+
return Number.isFinite(expected) && Math.abs(actual - expected) <= expected * 1e-6;
|
|
14349
|
+
});
|
|
14350
|
+
}
|
|
14200
14351
|
function getTransformBoundingBox(transform, width, height) {
|
|
14201
14352
|
const corners = [
|
|
14202
14353
|
transformPosition(transform, 0, 0),
|
|
@@ -14386,12 +14537,12 @@ function normalizeDeclaredCoordinateReferenceSystem(attributes) {
|
|
|
14386
14537
|
return projection && typeof projection === "object" && !Array.isArray(projection) ? projection : void 0;
|
|
14387
14538
|
}
|
|
14388
14539
|
|
|
14389
|
-
// src/zarr/zarr-array-
|
|
14390
|
-
var
|
|
14540
|
+
// src/zarr/zarr-array-loader.ts
|
|
14541
|
+
var ZarrArrayLoaderWithParser = {
|
|
14391
14542
|
dataType: null,
|
|
14392
14543
|
dataSource: null,
|
|
14393
14544
|
batchType: null,
|
|
14394
|
-
name: "
|
|
14545
|
+
name: "ZarrArrayLoader",
|
|
14395
14546
|
id: "zarr-array",
|
|
14396
14547
|
module: "scientific",
|
|
14397
14548
|
version: "latest",
|
|
@@ -14419,7 +14570,7 @@ var ZarrArraySourceLoaderWithParser = {
|
|
|
14419
14570
|
zarrArray: { path: void 0, dimensions: void 0 }
|
|
14420
14571
|
},
|
|
14421
14572
|
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
14422
|
-
|
|
14573
|
+
createDataSourceSync: (data, options, coreApi) => new ZarrArraySource(data, options, coreApi)
|
|
14423
14574
|
};
|
|
14424
14575
|
var ZarrArraySource = class extends ZarrSource {
|
|
14425
14576
|
/** Cached array initialization. */
|
|
@@ -14511,15 +14662,15 @@ function isZarrArraySlice(selector) {
|
|
|
14511
14662
|
return typeof selector === "object" && selector !== null;
|
|
14512
14663
|
}
|
|
14513
14664
|
|
|
14514
|
-
// src/zarr/spatial-data-
|
|
14515
|
-
var
|
|
14665
|
+
// src/zarr/spatial-data-loader.ts
|
|
14666
|
+
var SpatialDataLoaderWithParser = {
|
|
14516
14667
|
dataType: null,
|
|
14517
14668
|
dataSource: null,
|
|
14518
14669
|
batchType: null,
|
|
14519
|
-
name: "
|
|
14670
|
+
name: "SpatialDataLoader",
|
|
14520
14671
|
id: "spatial-data",
|
|
14521
14672
|
module: "scientific",
|
|
14522
|
-
version:
|
|
14673
|
+
version: OMEZarrLoaderWithParser.version,
|
|
14523
14674
|
extensions: ["zarr"],
|
|
14524
14675
|
mimeTypes: [],
|
|
14525
14676
|
type: "spatial-data",
|
|
@@ -14542,7 +14693,7 @@ var SpatialDataSourceLoaderWithParser = {
|
|
|
14542
14693
|
}
|
|
14543
14694
|
},
|
|
14544
14695
|
testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
|
|
14545
|
-
|
|
14696
|
+
createDataSourceSync: (data, options, coreApi) => new SpatialDataSource(data, options, coreApi)
|
|
14546
14697
|
};
|
|
14547
14698
|
var SpatialDataSource = class extends ZarrSource {
|
|
14548
14699
|
/** Shared normalized metadata discovery request. */
|
|
@@ -14728,14 +14879,14 @@ function getString(value) {
|
|
|
14728
14879
|
}
|
|
14729
14880
|
// Annotate the CommonJS export names for ESM import in node:
|
|
14730
14881
|
0 && (module.exports = {
|
|
14882
|
+
GeoZarrLoader,
|
|
14731
14883
|
GeoZarrRasterSource,
|
|
14732
|
-
GeoZarrSourceLoader,
|
|
14733
14884
|
OMEZarrImageSource,
|
|
14734
|
-
|
|
14885
|
+
OMEZarrLoader,
|
|
14886
|
+
SpatialDataLoader,
|
|
14735
14887
|
SpatialDataSource,
|
|
14736
|
-
|
|
14888
|
+
ZarrArrayLoader,
|
|
14737
14889
|
ZarrArraySource,
|
|
14738
|
-
ZarrArraySourceLoader,
|
|
14739
14890
|
ZarrPixelSource,
|
|
14740
14891
|
loadZarr,
|
|
14741
14892
|
loadZarrConsolidatedMetadata
|