@loaders.gl/scientific 5.0.0-alpha.14 → 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.
Files changed (176) hide show
  1. package/LICENSE +2 -30
  2. package/README.md +15 -3
  3. package/THIRD-PARTY-NOTICES.md +21 -0
  4. package/dist/hdf5/http-range-reader.d.ts.map +1 -1
  5. package/dist/hdf5/http-range-reader.js +2 -12
  6. package/dist/hdf5/http-range-reader.js.map +1 -1
  7. package/dist/hdf5/index.cjs +2 -11
  8. package/dist/hdf5/index.cjs.map +2 -2
  9. package/dist/index.cjs +136 -4148
  10. package/dist/index.cjs.map +4 -3
  11. package/dist/index.d.ts +14 -7
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +7 -4
  14. package/dist/index.js.map +1 -1
  15. package/dist/lib/parsers/parse-npy.d.ts +15 -0
  16. package/dist/lib/parsers/parse-npy.d.ts.map +1 -0
  17. package/dist/lib/parsers/parse-npy.js +81 -0
  18. package/dist/lib/parsers/parse-npy.js.map +1 -0
  19. package/dist/netcdf/bundled.cjs +47 -46
  20. package/dist/netcdf/index.cjs +47 -46
  21. package/dist/netcdf/index.cjs.map +3 -3
  22. package/dist/netcdf/index.d.ts +2 -1
  23. package/dist/netcdf/index.d.ts.map +1 -1
  24. package/dist/netcdf/index.js +2 -1
  25. package/dist/netcdf/index.js.map +1 -1
  26. package/dist/netcdf/netcdf-loader-with-parser.cjs +396 -2
  27. package/dist/netcdf/netcdf-loader-with-parser.d.ts +10 -0
  28. package/dist/netcdf/netcdf-loader-with-parser.d.ts.map +1 -1
  29. package/dist/netcdf/netcdf-loader-with-parser.js +3 -1
  30. package/dist/netcdf/netcdf-loader-with-parser.js.map +1 -1
  31. package/dist/netcdf/netcdf-loader.cjs +12 -9
  32. package/dist/netcdf/netcdf-loader.cjs.map +7 -0
  33. package/dist/netcdf/netcdf-loader.d.ts +10 -21
  34. package/dist/netcdf/netcdf-loader.d.ts.map +1 -1
  35. package/dist/netcdf/netcdf-loader.js +6 -3
  36. package/dist/netcdf/netcdf-loader.js.map +1 -1
  37. package/dist/netcdf/netcdf-source-loader.cjs +17 -31
  38. package/dist/netcdf/netcdf-source-loader.d.ts +2 -20
  39. package/dist/netcdf/netcdf-source-loader.d.ts.map +1 -1
  40. package/dist/netcdf/netcdf-source-loader.js +22 -20
  41. package/dist/netcdf/netcdf-source-loader.js.map +1 -1
  42. package/dist/netcdf/unbundled.cjs +47 -46
  43. package/dist/netcdf.dev.js +3095 -2654
  44. package/dist/netcdf.min.js +4 -4
  45. package/dist/npy-format.d.ts +12 -0
  46. package/dist/npy-format.d.ts.map +1 -0
  47. package/dist/npy-format.js +15 -0
  48. package/dist/npy-format.js.map +1 -0
  49. package/dist/{netcdf/netcdf-source-loader-types.cjs → npy-loader-types.cjs} +34 -35
  50. package/dist/npy-loader-types.cjs.map +7 -0
  51. package/dist/npy-loader-types.d.ts +53 -0
  52. package/dist/npy-loader-types.d.ts.map +1 -0
  53. package/dist/npy-loader-types.js +32 -0
  54. package/dist/npy-loader-types.js.map +1 -0
  55. package/dist/npy-loader.cjs +273 -0
  56. package/dist/npy-loader.cjs.map +6 -0
  57. package/dist/npy-loader.d.ts +27 -0
  58. package/dist/npy-loader.d.ts.map +1 -0
  59. package/dist/npy-loader.js +15 -0
  60. package/dist/npy-loader.js.map +1 -0
  61. package/dist/npy-worker.d.ts +2 -0
  62. package/dist/npy-worker.d.ts.map +1 -0
  63. package/dist/npy-worker.js +1285 -0
  64. package/dist/npy-worker.js.map +1 -0
  65. package/dist/nrrd/parse-nrrd.d.ts +22 -0
  66. package/dist/nrrd/parse-nrrd.d.ts.map +1 -0
  67. package/dist/nrrd/parse-nrrd.js +228 -0
  68. package/dist/nrrd/parse-nrrd.js.map +1 -0
  69. package/dist/nrrd-loader-types.cjs +58 -0
  70. package/dist/nrrd-loader-types.cjs.map +7 -0
  71. package/dist/nrrd-loader-types.d.ts +31 -0
  72. package/dist/nrrd-loader-types.d.ts.map +1 -0
  73. package/dist/nrrd-loader-types.js +25 -0
  74. package/dist/nrrd-loader-types.js.map +1 -0
  75. package/dist/nrrd-loader.cjs +252 -0
  76. package/dist/nrrd-loader.cjs.map +6 -0
  77. package/dist/nrrd-loader.d.ts +16 -0
  78. package/dist/nrrd-loader.d.ts.map +1 -0
  79. package/dist/nrrd-loader.js +8 -0
  80. package/dist/nrrd-loader.js.map +1 -0
  81. package/dist/vtk/index.cjs +26 -4117
  82. package/dist/vtk/index.cjs.map +3 -3
  83. package/dist/vtk/vtk-xml.js +4 -4
  84. package/dist/vtk/vtk-xml.js.map +1 -1
  85. package/dist/vtk/vtk.d.ts.map +1 -1
  86. package/dist/vtk/vtk.js +19 -1
  87. package/dist/vtk/vtk.js.map +1 -1
  88. package/dist/vtk-loader-types.cjs +58 -0
  89. package/dist/vtk-loader-types.cjs.map +7 -0
  90. package/dist/vtk-loader-types.d.ts +34 -0
  91. package/dist/vtk-loader-types.d.ts.map +1 -0
  92. package/dist/vtk-loader-types.js +25 -0
  93. package/dist/vtk-loader-types.js.map +1 -0
  94. package/dist/vtk-loader.cjs +384 -0
  95. package/dist/vtk-loader.cjs.map +6 -0
  96. package/dist/vtk-loader.d.ts +21 -0
  97. package/dist/vtk-loader.d.ts.map +1 -0
  98. package/dist/vtk-loader.js +21 -0
  99. package/dist/vtk-loader.js.map +1 -0
  100. package/dist/workers/npy-worker.d.ts +2 -0
  101. package/dist/workers/npy-worker.d.ts.map +1 -0
  102. package/dist/workers/npy-worker.js +7 -0
  103. package/dist/workers/npy-worker.js.map +1 -0
  104. package/dist/zarr/{geo-zarr-source-loader.d.ts → geo-zarr-loader.d.ts} +9 -9
  105. package/dist/zarr/geo-zarr-loader.d.ts.map +1 -0
  106. package/dist/zarr/{geo-zarr-source-loader.js → geo-zarr-loader.js} +167 -48
  107. package/dist/zarr/geo-zarr-loader.js.map +1 -0
  108. package/dist/zarr/index.cjs +221 -70
  109. package/dist/zarr/index.cjs.map +3 -3
  110. package/dist/zarr/index.d.ts +8 -8
  111. package/dist/zarr/index.d.ts.map +1 -1
  112. package/dist/zarr/index.js +4 -4
  113. package/dist/zarr/index.js.map +1 -1
  114. package/dist/zarr/lib/spatial-multiscales.d.ts +13 -2
  115. package/dist/zarr/lib/spatial-multiscales.d.ts.map +1 -1
  116. package/dist/zarr/lib/spatial-multiscales.js +94 -8
  117. package/dist/zarr/lib/spatial-multiscales.js.map +1 -1
  118. package/dist/zarr/{ome-zarr-source-loader.d.ts → ome-zarr-loader.d.ts} +9 -9
  119. package/dist/zarr/ome-zarr-loader.d.ts.map +1 -0
  120. package/dist/zarr/{ome-zarr-source-loader.js → ome-zarr-loader.js} +5 -5
  121. package/dist/zarr/ome-zarr-loader.js.map +1 -0
  122. package/dist/zarr/{spatial-data-source.d.ts → spatial-data-loader.d.ts} +11 -11
  123. package/dist/zarr/spatial-data-loader.d.ts.map +1 -0
  124. package/dist/zarr/{spatial-data-source.js → spatial-data-loader.js} +7 -7
  125. package/dist/zarr/spatial-data-loader.js.map +1 -0
  126. package/dist/zarr/{zarr-array-source.d.ts → zarr-array-loader.d.ts} +9 -9
  127. package/dist/zarr/{zarr-array-source.d.ts.map → zarr-array-loader.d.ts.map} +1 -1
  128. package/dist/zarr/{zarr-array-source.js → zarr-array-loader.js} +5 -5
  129. package/dist/zarr/{zarr-array-source.js.map → zarr-array-loader.js.map} +1 -1
  130. package/dist/zarr/zarr-loader-types.cjs +161 -0
  131. package/dist/zarr/zarr-loader-types.cjs.map +7 -0
  132. package/dist/zarr/zarr-loader-types.d.ts +32 -32
  133. package/dist/zarr/zarr-loader-types.d.ts.map +1 -1
  134. package/dist/zarr/zarr-loader-types.js +24 -24
  135. package/dist/zarr/zarr-loader-types.js.map +1 -1
  136. package/dist/zarr.dev.js +305 -84
  137. package/dist/zarr.min.js +50 -50
  138. package/package.json +58 -8
  139. package/src/hdf5/http-range-reader.ts +3 -11
  140. package/src/index.ts +27 -16
  141. package/src/lib/parsers/parse-npy.ts +123 -0
  142. package/src/netcdf/index.ts +2 -5
  143. package/src/netcdf/netcdf-loader-with-parser.ts +3 -1
  144. package/src/netcdf/netcdf-loader.ts +5 -3
  145. package/src/netcdf/netcdf-source-loader.ts +32 -24
  146. package/src/npy-format.ts +17 -0
  147. package/src/npy-loader-types.ts +47 -0
  148. package/src/npy-loader.ts +21 -0
  149. package/src/npy-worker.ts +6 -0
  150. package/src/nrrd/parse-nrrd.ts +267 -0
  151. package/src/nrrd-loader-types.ts +25 -0
  152. package/src/nrrd-loader.ts +7 -0
  153. package/src/vtk/vtk-xml.ts +4 -4
  154. package/src/vtk/vtk.ts +28 -1
  155. package/src/vtk-loader-types.ts +25 -0
  156. package/src/vtk-loader.ts +19 -0
  157. package/src/workers/npy-worker.ts +8 -0
  158. package/src/zarr/{geo-zarr-source-loader.ts → geo-zarr-loader.ts} +206 -55
  159. package/src/zarr/index.ts +17 -17
  160. package/src/zarr/lib/spatial-multiscales.ts +104 -8
  161. package/src/zarr/{ome-zarr-source-loader.ts → ome-zarr-loader.ts} +11 -11
  162. package/src/zarr/{spatial-data-source.ts → spatial-data-loader.ts} +16 -16
  163. package/src/zarr/{zarr-array-source.ts → zarr-array-loader.ts} +10 -10
  164. package/src/zarr/zarr-loader-types.ts +35 -35
  165. package/third-party-licenses/iobuffer-LICENSE +21 -0
  166. package/dist/netcdf/netcdf-source-loader-types.d.ts +0 -28
  167. package/dist/netcdf/netcdf-source-loader-types.d.ts.map +0 -1
  168. package/dist/netcdf/netcdf-source-loader-types.js +0 -32
  169. package/dist/netcdf/netcdf-source-loader-types.js.map +0 -1
  170. package/dist/zarr/geo-zarr-source-loader.d.ts.map +0 -1
  171. package/dist/zarr/geo-zarr-source-loader.js.map +0 -1
  172. package/dist/zarr/ome-zarr-source-loader.d.ts.map +0 -1
  173. package/dist/zarr/ome-zarr-source-loader.js.map +0 -1
  174. package/dist/zarr/spatial-data-source.d.ts.map +0 -1
  175. package/dist/zarr/spatial-data-source.js.map +0 -1
  176. package/src/netcdf/netcdf-source-loader-types.ts +0 -45
package/dist/zarr.dev.js CHANGED
@@ -2563,18 +2563,17 @@ var __exports__ = (() => {
2563
2563
  var zarr_bundle_exports = {};
2564
2564
  __export(zarr_bundle_exports, {
2565
2565
  FetchError: () => import_core3.FetchError,
2566
+ GeoZarrLoader: () => GeoZarrLoaderWithParser,
2566
2567
  GeoZarrRasterSource: () => GeoZarrRasterSource,
2567
- GeoZarrSourceLoader: () => GeoZarrSourceLoaderWithParser,
2568
2568
  JSONLoader: () => JSONLoader,
2569
2569
  NullLoader: () => import_core3.NullLoader,
2570
- NullWorkerLoader: () => import_core3.NullWorkerLoader,
2571
2570
  OMEZarrImageSource: () => OMEZarrImageSource,
2572
- OMEZarrSourceLoader: () => OMEZarrSourceLoaderWithParser,
2571
+ OMEZarrLoader: () => OMEZarrLoaderWithParser,
2573
2572
  RequestScheduler: () => RequestScheduler,
2573
+ SpatialDataLoader: () => SpatialDataLoaderWithParser,
2574
2574
  SpatialDataSource: () => SpatialDataSource,
2575
- SpatialDataSourceLoader: () => SpatialDataSourceLoaderWithParser,
2575
+ ZarrArrayLoader: () => ZarrArrayLoaderWithParser,
2576
2576
  ZarrArraySource: () => ZarrArraySource,
2577
- ZarrArraySourceLoader: () => ZarrArraySourceLoaderWithParser,
2578
2577
  ZarrPixelSource: () => zarr_pixel_source_default,
2579
2578
  _BrowserFileSystem: () => import_core3._BrowserFileSystem,
2580
2579
  _fetchProgress: () => import_core3._fetchProgress,
@@ -2584,6 +2583,7 @@ var __exports__ = (() => {
2584
2583
  concatenateArrayBuffersAsync: () => concatenateArrayBuffersAsync,
2585
2584
  coreApi: () => import_core3.coreApi,
2586
2585
  createDataSource: () => import_core3.createDataSource,
2586
+ createDataSourceSync: () => import_core3.createDataSourceSync,
2587
2587
  document: () => document_,
2588
2588
  encode: () => import_core3.encode,
2589
2589
  encodeInBatches: () => import_core3.encodeInBatches,
@@ -3221,6 +3221,35 @@ var __exports__ = (() => {
3221
3221
  return log3;
3222
3222
  }
3223
3223
  var log2 = createLog();
3224
+ var NullLog = class {
3225
+ /** Discards debug messages. */
3226
+ log() {
3227
+ return ignoreMessage;
3228
+ }
3229
+ /** Discards informational messages. */
3230
+ info() {
3231
+ return ignoreMessage;
3232
+ }
3233
+ /** Discards messages marked to be emitted once. */
3234
+ once() {
3235
+ return ignoreMessage;
3236
+ }
3237
+ /** Discards warnings. */
3238
+ warn() {
3239
+ return ignoreMessage;
3240
+ }
3241
+ /** Discards errors. */
3242
+ error() {
3243
+ return ignoreMessage;
3244
+ }
3245
+ };
3246
+ function ignoreMessage() {
3247
+ }
3248
+ var nullLog = new NullLog();
3249
+ function getLoaderLog(options) {
3250
+ const logger = options?.core?.log;
3251
+ return logger === null ? nullLog : logger || log2;
3252
+ }
3224
3253
 
3225
3254
  // ../core/src/loader-utils/lib/javascript-utils/is-type.ts
3226
3255
  var isBoolean = (value) => typeof value === "boolean";
@@ -3859,7 +3888,7 @@ var __exports__ = (() => {
3859
3888
  return authenticatedFetch;
3860
3889
  }
3861
3890
  function getAuthenticatedFetch(options = {}) {
3862
- const fetchOption = options.fetch ?? options.core?.fetch;
3891
+ const fetchOption = options.core?.fetch;
3863
3892
  let fetchFunction;
3864
3893
  if (typeof fetchOption === "function") {
3865
3894
  fetchFunction = fetchOption;
@@ -4064,6 +4093,8 @@ var __exports__ = (() => {
4064
4093
  options;
4065
4094
  data;
4066
4095
  url;
4096
+ /** Stable query-visible name, resolved without fetching source data. */
4097
+ name;
4067
4098
  /** Shared parser options derived from the source options, excluding source-only core controls. */
4068
4099
  loadOptions;
4069
4100
  /** A resolved fetch function extracted from the shared core options. */
@@ -4080,6 +4111,7 @@ var __exports__ = (() => {
4080
4111
  );
4081
4112
  this.data = data;
4082
4113
  this.url = typeof data === "string" ? resolvePath(data) : "";
4114
+ this.name = getDataSourceName(data, this.options);
4083
4115
  const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(this.options));
4084
4116
  this.loadOptions = loadOptions;
4085
4117
  const fetch2 = getFetchFunction(loadOptions);
@@ -4088,6 +4120,8 @@ var __exports__ = (() => {
4088
4120
  this.fetch = fetch2;
4089
4121
  }
4090
4122
  setProps(options) {
4123
+ if (options.core?.name !== void 0 && options.core.name !== this.name)
4124
+ throw new Error("Data source names are fixed at creation.");
4091
4125
  const mergedOptions = mergeOptions(this.options, options);
4092
4126
  const loadOptions = resolveAuthenticationOptions(getSourceLoaderOptions(mergedOptions));
4093
4127
  this.options = mergedOptions;
@@ -4117,7 +4151,7 @@ var __exports__ = (() => {
4117
4151
  if (callback) {
4118
4152
  callback(normalizedError, this);
4119
4153
  } else {
4120
- log2.warn(`${this.constructor.name}: ${normalizedError.message}`)();
4154
+ getLoaderLog(this.options).warn(`${this.constructor.name}: ${normalizedError.message}`)();
4121
4155
  }
4122
4156
  return normalizedError;
4123
4157
  }
@@ -4135,23 +4169,13 @@ var __exports__ = (() => {
4135
4169
  if (options?.core) {
4136
4170
  loadOptions.core = { ...options.core };
4137
4171
  const parserCore = loadOptions.core;
4138
- for (const key of ["type", "attributions", "loaders", "onError", "loadOptions"]) {
4172
+ for (const key of ["type", "name", "attributions", "loaders", "onError", "loadOptions"]) {
4139
4173
  delete parserCore[key];
4140
4174
  }
4141
4175
  if (Object.keys(parserCore).length === 0) {
4142
4176
  delete loadOptions.core;
4143
4177
  }
4144
4178
  }
4145
- const topLevelBaseUri = typeof loadOptions.baseUri === "string" ? loadOptions.baseUri : void 0;
4146
- const topLevelBaseUrl = typeof loadOptions.baseUrl === "string" ? loadOptions.baseUrl : void 0;
4147
- if (topLevelBaseUri !== void 0 || topLevelBaseUrl !== void 0) {
4148
- loadOptions.core ||= {};
4149
- if (loadOptions.core.baseUrl === void 0) {
4150
- loadOptions.core.baseUrl = topLevelBaseUrl ?? topLevelBaseUri;
4151
- }
4152
- delete loadOptions.baseUri;
4153
- delete loadOptions.baseUrl;
4154
- }
4155
4179
  return loadOptions;
4156
4180
  }
4157
4181
  function normalizeError(error, message) {
@@ -4166,10 +4190,47 @@ var __exports__ = (() => {
4166
4190
  function unavailableCoreApiMethod(methodName) {
4167
4191
  return () => {
4168
4192
  throw new Error(
4169
- `CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.createDataSource().`
4193
+ `CoreAPI.${methodName} is unavailable. Use @loaders.gl/core.createDataSourceSync().`
4170
4194
  );
4171
4195
  };
4172
4196
  }
4197
+ function getDataSourceName(data, options) {
4198
+ const explicitName = options.core?.name;
4199
+ if (explicitName !== void 0) {
4200
+ if (typeof explicitName !== "string" || !explicitName.trim())
4201
+ throw new Error("Data source name must be a non-empty string.");
4202
+ return explicitName;
4203
+ }
4204
+ if (data && typeof data === "object") {
4205
+ const named = data;
4206
+ if (typeof named.name === "string" && named.name.trim())
4207
+ return data instanceof Blob ? removeFileExtension(named.name) : named.name;
4208
+ const metadata = named.schema?.metadata;
4209
+ const embeddedName = metadata instanceof Map ? metadata.get("name") : metadata?.name;
4210
+ if (typeof embeddedName === "string" && embeddedName.trim()) return embeddedName;
4211
+ }
4212
+ if (typeof data === "string") {
4213
+ try {
4214
+ const url = new URL(data.replace(/\\/g, "/"), "https://source.invalid/");
4215
+ if (!["data:", "blob:"].includes(url.protocol)) {
4216
+ let basename = url.pathname.split("/").filter(Boolean).pop();
4217
+ if (basename) {
4218
+ try {
4219
+ basename = decodeURIComponent(basename);
4220
+ } catch {
4221
+ }
4222
+ return removeFileExtension(basename);
4223
+ }
4224
+ }
4225
+ } catch {
4226
+ }
4227
+ }
4228
+ return options.core?.type && options.core.type !== "auto" ? options.core.type : "source";
4229
+ }
4230
+ function removeFileExtension(name) {
4231
+ const extension = name.lastIndexOf(".");
4232
+ return extension > 0 ? name.slice(0, extension) : name;
4233
+ }
4173
4234
 
4174
4235
  // ../../node_modules/@math.gl/geospatial/dist/crs/spatial-reference.js
4175
4236
  function createSpatialReference(options = {}) {
@@ -4233,6 +4294,7 @@ var __exports__ = (() => {
4233
4294
  metadata: field.metadata || Object.freeze({})
4234
4295
  })
4235
4296
  );
4297
+ const queryCapabilities = Object.freeze({ ...options.capabilities });
4236
4298
  return Object.freeze({
4237
4299
  sourceType: options.sourceType,
4238
4300
  queryType: options.queryType,
@@ -4241,7 +4303,8 @@ var __exports__ = (() => {
4241
4303
  description: options.description,
4242
4304
  schema,
4243
4305
  columns: Object.freeze(columns),
4244
- capabilities: Object.freeze({ ...options.capabilities }),
4306
+ capabilities: queryCapabilities,
4307
+ queryCapabilities,
4245
4308
  spatial: options.spatial ? Object.freeze({
4246
4309
  ...options.spatial,
4247
4310
  bounds: options.spatial.bounds ? Object.freeze({
@@ -4290,10 +4353,13 @@ var __exports__ = (() => {
4290
4353
  validateTileMatrixGeometry(matrix);
4291
4354
  }
4292
4355
  function validateTileMatrixGeometry(matrix) {
4293
- if (typeof matrix.id !== "string" || !matrix.id || matrix.origin.length !== 2 || matrix.tileSize.length !== 2 || matrix.matrixSize.length !== 2 || !Number.isFinite(matrix.resolution) || matrix.resolution <= 0 || matrix.resolutionY !== void 0 && (!Number.isFinite(matrix.resolutionY) || matrix.resolutionY <= 0) || !matrix.origin.every(Number.isFinite) || ![...matrix.tileSize, ...matrix.matrixSize].every((value) => Number.isSafeInteger(value) && value > 0) || !["topLeft", "bottomLeft"].includes(matrix.cornerOfOrigin)) {
4356
+ if (!matrix || typeof matrix.id !== "string" || !Array.isArray(matrix.origin) || !Array.isArray(matrix.tileSize) || !Array.isArray(matrix.matrixSize) || matrix.variableMatrixWidths !== void 0 && !Array.isArray(matrix.variableMatrixWidths) || !matrix.id || matrix.origin.length !== 2 || matrix.tileSize.length !== 2 || matrix.matrixSize.length !== 2 || !Number.isFinite(matrix.resolution) || matrix.resolution <= 0 || matrix.resolutionY !== void 0 && (!Number.isFinite(matrix.resolutionY) || matrix.resolutionY <= 0) || !matrix.origin.every(Number.isFinite) || ![...matrix.tileSize, ...matrix.matrixSize].every((value) => Number.isSafeInteger(value) && value > 0) || !["topLeft", "bottomLeft"].includes(matrix.cornerOfOrigin)) {
4294
4357
  throw new RangeError("Invalid tile matrix geometry");
4295
4358
  }
4296
- const bands = [...matrix.variableMatrixWidths ?? []].sort((first, second) => first.minTileRow - second.minTileRow);
4359
+ const bands = [...matrix.variableMatrixWidths ?? []];
4360
+ if (bands.some((band) => !band))
4361
+ throw new RangeError("Invalid variable matrix width");
4362
+ bands.sort((first, second) => first.minTileRow - second.minTileRow);
4297
4363
  let previousRow = -1;
4298
4364
  for (const band of bands) {
4299
4365
  if (!Number.isSafeInteger(band.coalesce) || band.coalesce <= 1 || matrix.matrixSize[0] % band.coalesce !== 0 || !Number.isSafeInteger(band.minTileRow) || !Number.isSafeInteger(band.maxTileRow) || band.minTileRow <= previousRow || band.maxTileRow < band.minTileRow || band.maxTileRow >= matrix.matrixSize[1])
@@ -4343,6 +4409,7 @@ var __exports__ = (() => {
4343
4409
  }
4344
4410
  function getTileMatrixSet(crs, matrices) {
4345
4411
  if (!crs || !matrices.length) return void 0;
4412
+ if (new Set(matrices.map((matrix) => matrix.id)).size !== matrices.length) return void 0;
4346
4413
  const tileMatrices = [];
4347
4414
  for (const matrix of matrices) {
4348
4415
  const tileMatrix = toTileMatrix(matrix);
@@ -4353,15 +4420,18 @@ var __exports__ = (() => {
4353
4420
  }
4354
4421
  function toTileMatrix(matrix) {
4355
4422
  const { id, resolution, resolutionY, origin, tileSize, matrixSize } = matrix;
4423
+ if (matrix.variableMatrixWidths !== void 0 && !Array.isArray(matrix.variableMatrixWidths))
4424
+ return null;
4356
4425
  if (resolution === void 0 || !origin || !tileSize || !matrixSize) return null;
4357
4426
  const tileMatrix = {
4358
4427
  id,
4359
4428
  resolution,
4360
4429
  ...resolutionY !== void 0 ? { resolutionY } : {},
4361
4430
  origin: [origin[0], origin[1]],
4362
- cornerOfOrigin: matrix.cornerOfOrigin ?? "topLeft",
4431
+ cornerOfOrigin: matrix.cornerOfOrigin === void 0 ? "topLeft" : matrix.cornerOfOrigin,
4363
4432
  tileSize: [tileSize[0], tileSize[1]],
4364
- matrixSize: [matrixSize[0], matrixSize[1]]
4433
+ matrixSize: [matrixSize[0], matrixSize[1]],
4434
+ ...matrix.variableMatrixWidths !== void 0 ? { variableMatrixWidths: matrix.variableMatrixWidths } : {}
4365
4435
  };
4366
4436
  try {
4367
4437
  validateTileMatrix(tileMatrix);
@@ -12678,6 +12748,11 @@ var __exports__ = (() => {
12678
12748
  this.feature = feature;
12679
12749
  }
12680
12750
  };
12751
+ function isZarritaError(err2, ...tags) {
12752
+ if (!(err2 instanceof ZarritaError))
12753
+ return false;
12754
+ return tags.length === 0 || tags.includes(err2._tag);
12755
+ }
12681
12756
 
12682
12757
  // ../../node_modules/zarrita/dist/src/codecs/_shared.js
12683
12758
  function unimplementedEncode(codecName) {
@@ -15089,7 +15164,7 @@ var __exports__ = (() => {
15089
15164
  return [...directChildren].sort();
15090
15165
  }
15091
15166
 
15092
- // src/zarr/ome-zarr-source-loader.ts
15167
+ // src/zarr/ome-zarr-loader.ts
15093
15168
  var VERSION4 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
15094
15169
  async function loadZarrConsolidatedMetadata(url, options = {}) {
15095
15170
  const fetcher = options.fetch || fetch;
@@ -15186,12 +15261,12 @@ var __exports__ = (() => {
15186
15261
  return await open(location, { kind: "group", signal });
15187
15262
  }
15188
15263
  };
15189
- var OMEZarrSourceLoaderWithParser = {
15264
+ var OMEZarrLoaderWithParser = {
15190
15265
  dataType: null,
15191
15266
  /** Runtime source type marker used by `createDataSource()` type inference. */
15192
15267
  dataSource: null,
15193
15268
  batchType: null,
15194
- name: "OMEZarrSourceLoader",
15269
+ name: "OMEZarrLoader",
15195
15270
  id: "omezarr",
15196
15271
  module: "scientific",
15197
15272
  version: VERSION4,
@@ -15225,7 +15300,7 @@ var __exports__ = (() => {
15225
15300
  }
15226
15301
  },
15227
15302
  testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
15228
- createDataSource: (data, options, coreApi2) => new OMEZarrImageSource(data, options, coreApi2)
15303
+ createDataSourceSync: (data, options, coreApi2) => new OMEZarrImageSource(data, options, coreApi2)
15229
15304
  };
15230
15305
  var OMEZarrImageSource = class extends ZarrSource {
15231
15306
  /** Shared source initialization request. */
@@ -15575,7 +15650,9 @@ var __exports__ = (() => {
15575
15650
  }
15576
15651
 
15577
15652
  // src/zarr/lib/spatial-multiscales.ts
15578
- function getSpatialMultiscaleLevels(attributes, array2) {
15653
+ function getSpatialMultiscaleLevels(attributes, array2, { spatialOME = false } = {}) {
15654
+ const omeMultiscales = spatialOME ? getOMEMultiscales(attributes) : null;
15655
+ if (omeMultiscales) return getOMEMultiscaleLevels(omeMultiscales, array2);
15579
15656
  const multiscales = attributes?.multiscales;
15580
15657
  const layout = multiscales?.layout;
15581
15658
  if (!Array.isArray(layout) || !layout.length) return [];
@@ -15585,28 +15662,88 @@ var __exports__ = (() => {
15585
15662
  }
15586
15663
  const assets = entries.map((entry) => entry.asset);
15587
15664
  if (new Set(assets).size !== assets.length) throw new Error("Duplicate spatial multiscales asset.");
15665
+ return resolveLevels(assets, array2, entries);
15666
+ }
15667
+ function getOMEMultiscales(attributes) {
15668
+ if (Array.isArray(attributes?.multiscales)) return attributes.multiscales;
15669
+ const ome = attributes?.ome;
15670
+ return Array.isArray(ome?.multiscales) ? ome.multiscales : null;
15671
+ }
15672
+ function getOMEMultiscaleLevels(multiscales, array2) {
15673
+ const candidates = multiscales.filter((multiscale2) => {
15674
+ const datasets2 = multiscale2?.datasets;
15675
+ return Array.isArray(datasets2) && datasets2.some((dataset) => isChildPath(dataset?.path) && (array2 === dataset.path || array2.startsWith(`${dataset.path}/`)));
15676
+ });
15677
+ if (!candidates.length) return [];
15678
+ if (candidates.length > 1) throw new Error("Array belongs to more than one OME-NGFF multiscale.");
15679
+ const multiscale = candidates[0];
15680
+ const datasets = multiscale.datasets;
15681
+ if (datasets.some((dataset) => !dataset || !isChildPath(dataset.path))) {
15682
+ throw new Error("OME-NGFF dataset paths must be relative child paths.");
15683
+ }
15684
+ const paths = datasets.map((dataset) => dataset.path);
15685
+ if (new Set(paths).size !== paths.length) throw new Error("Duplicate OME-NGFF dataset path.");
15686
+ const axes = getOMEAxisNames(multiscale.axes);
15687
+ return resolveLevels(paths, array2, datasets.map(() => ({}))).map((level, index) => ({
15688
+ ...level,
15689
+ scale: getOMEScale(axes, [
15690
+ datasets[index].coordinateTransformations,
15691
+ multiscale.coordinateTransformations
15692
+ ])
15693
+ }));
15694
+ }
15695
+ function resolveLevels(assets, array2, attributes) {
15588
15696
  const matches2 = assets.filter((asset) => array2 === asset || array2.startsWith(`${asset}/`));
15589
15697
  if (matches2.length !== 1) return [];
15590
15698
  const suffix = array2.slice(matches2[0].length);
15591
- return entries.map((entry, index) => ({
15592
- id: assets[index],
15593
- array: `${assets[index]}${suffix}`,
15594
- ...suffix ? { group: assets[index] } : {},
15595
- attributes: entry
15699
+ return assets.map((asset, index) => ({
15700
+ id: asset,
15701
+ array: `${asset}${suffix}`,
15702
+ ...suffix ? { group: asset } : {},
15703
+ attributes: attributes[index]
15596
15704
  }));
15597
15705
  }
15706
+ function getOMEAxisNames(axes) {
15707
+ const names = Array.isArray(axes) ? axes.map((axis) => typeof axis === "string" ? axis : axis?.name) : [];
15708
+ if (!names.length || names.some((name) => typeof name !== "string" || !name)) {
15709
+ throw new Error("OME-NGFF multiscales require named axes.");
15710
+ }
15711
+ if (new Set(names).size !== names.length) throw new Error("Duplicate OME-NGFF axis name.");
15712
+ return names;
15713
+ }
15714
+ function getOMEScale(axes, transformLists) {
15715
+ const scale = axes.map(() => 1);
15716
+ for (const transforms of transformLists) {
15717
+ if (transforms === void 0) continue;
15718
+ if (!Array.isArray(transforms)) {
15719
+ throw new Error("OME-NGFF coordinateTransformations must be a list.");
15720
+ }
15721
+ for (const transform of transforms) {
15722
+ if (transform?.type === "identity" || transform?.type === "translation") continue;
15723
+ if (transform?.type !== "scale") {
15724
+ throw new Error(`Unsupported OME-NGFF coordinate transformation ${String(transform?.type)}.`);
15725
+ }
15726
+ const values = transform.scale;
15727
+ if (!Array.isArray(values) || values.length !== axes.length || values.some((value) => typeof value !== "number" || !Number.isFinite(value) || value === 0)) {
15728
+ throw new Error("OME-NGFF scale must give one finite non-zero value per axis.");
15729
+ }
15730
+ values.forEach((value, index) => scale[index] *= value);
15731
+ }
15732
+ }
15733
+ return Object.fromEntries(axes.map((axis, index) => [axis, scale[index]]));
15734
+ }
15598
15735
  function isChildPath(value) {
15599
- return typeof value === "string" && value.length > 0 && !/[\\%:?#\u0000-\u0020]/.test(value) && value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
15736
+ return typeof value === "string" && value.length > 0 && !/[\\%:?#\u0000- ]/.test(value) && value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
15600
15737
  }
15601
15738
 
15602
- // src/zarr/geo-zarr-source-loader.ts
15739
+ // src/zarr/geo-zarr-loader.ts
15603
15740
  var VERSION5 = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
15604
- var GeoZarrSourceLoaderWithParser = {
15741
+ var GeoZarrLoaderWithParser = {
15605
15742
  dataType: null,
15606
15743
  /** Runtime source type marker used by `createDataSource()` type inference. */
15607
15744
  dataSource: null,
15608
15745
  batchType: null,
15609
- name: "GeoZarrSourceLoader",
15746
+ name: "GeoZarrLoader",
15610
15747
  id: "geozarr",
15611
15748
  module: "scientific",
15612
15749
  version: VERSION5,
@@ -15646,7 +15783,7 @@ var __exports__ = (() => {
15646
15783
  }
15647
15784
  },
15648
15785
  testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
15649
- createDataSource: (data, options, coreApi2) => new GeoZarrRasterSource(data, options, coreApi2)
15786
+ createDataSourceSync: (data, options, coreApi2) => new GeoZarrRasterSource(data, options, coreApi2)
15650
15787
  };
15651
15788
  var GeoZarrRasterSource = class _GeoZarrRasterSource extends ZarrSource {
15652
15789
  /** Shared source initialization request. */
@@ -15669,9 +15806,7 @@ var __exports__ = (() => {
15669
15806
  }
15670
15807
  /** Opens sibling array metadata without selecting or decoding their samples. */
15671
15808
  async loadGridMetadata() {
15672
- const { metadata, group: group2 } = await this.getInitializationPromise();
15673
- const groupAttributes = metadata.metadata?.groupAttributes;
15674
- const layout = getSpatialMultiscaleLevels(groupAttributes, metadata.array);
15809
+ const { metadata, group: group2, layout } = await this.getInitializationPromise();
15675
15810
  const levels = [];
15676
15811
  for (const level of layout) {
15677
15812
  if (level.array === metadata.array) {
@@ -15694,6 +15829,15 @@ var __exports__ = (() => {
15694
15829
  levels.push({ id: level.id, array: level.array });
15695
15830
  }
15696
15831
  }
15832
+ const selectedScale = layout.find((level) => level.array === metadata.array)?.scale;
15833
+ if (selectedScale) {
15834
+ for (const [index, level] of levels.entries()) {
15835
+ const scale = layout[index].scale;
15836
+ if (level.metadata && !isConsistentOMELevel(scale, selectedScale, level.metadata, metadata)) {
15837
+ delete level.metadata;
15838
+ }
15839
+ }
15840
+ }
15697
15841
  const normalizedLevels = levels.length ? levels : [{ id: metadata.array, array: metadata.array, metadata }];
15698
15842
  const matrices = normalizedLevels.map((level) => getSpatialChunkMatrix(level.id, level.metadata));
15699
15843
  const commonCoordinateReferenceSystem = typeof metadata.crs === "string" && normalizedLevels.every((level) => level.metadata?.crs === metadata.crs) ? metadata.crs : void 0;
@@ -15818,11 +15962,25 @@ var __exports__ = (() => {
15818
15962
  const array2 = await open(group2.resolve(arrayPath), { kind: "array", signal });
15819
15963
  const groupAttributes = normalizeAttributes(group2.attrs);
15820
15964
  const arrayAttributes = normalizeAttributes(array2.attrs);
15821
- const layout = getSpatialMultiscaleLevels(groupAttributes, arrayPath);
15822
- const level = layout.find((candidate) => candidate.array === arrayPath);
15823
- const levelGroupAttributes = level?.group ? normalizeAttributes(
15824
- (await open(group2.resolve(level.group), { kind: "group", signal })).attrs
15825
- ) : {};
15965
+ const openGroupAttributes = async (path) => normalizeAttributes((await open(group2.resolve(path), { kind: "group", signal })).attrs);
15966
+ let layout = getSpatialMultiscaleLevels(groupAttributes, arrayPath, {
15967
+ spatialOME: declaresCoordinateReferenceSystem({ ...groupAttributes, ...arrayAttributes })
15968
+ });
15969
+ let level = layout.find((candidate) => candidate.array === arrayPath);
15970
+ let levelGroupAttributes = level?.group ? await openGroupAttributes(level.group) : {};
15971
+ if (!layout.length) {
15972
+ const omeLayout = getOMELevelsOrEmpty(groupAttributes, arrayPath);
15973
+ const omeLevel = omeLayout.find((candidate) => candidate.array === arrayPath);
15974
+ const omeLevelGroupAttributes = omeLevel?.group ? await openGroupAttributes(omeLevel.group).catch((error) => {
15975
+ rethrowUnlessAbsent(error);
15976
+ return {};
15977
+ }) : {};
15978
+ if (declaresCoordinateReferenceSystem(omeLevelGroupAttributes)) {
15979
+ layout = omeLayout;
15980
+ level = omeLevel;
15981
+ levelGroupAttributes = omeLevelGroupAttributes;
15982
+ }
15983
+ }
15826
15984
  const attributes = {
15827
15985
  ...groupAttributes,
15828
15986
  ...levelGroupAttributes,
@@ -15856,17 +16014,25 @@ var __exports__ = (() => {
15856
16014
  const xDimensionIndex = dimensions.indexOf(spatialDimensions[1]);
15857
16015
  const width = array2.shape[xDimensionIndex];
15858
16016
  const height = array2.shape[yDimensionIndex];
15859
- const coordinateTransform = options?.transform || normalizeAffineTransform(attributes["spatial:transform"]) || (!metadataOnly ? await loadCFCoordinateTransform(group2, spatialDimensions, signal) : null);
16017
+ let gridMappingPromise;
16018
+ const getGridMapping = () => gridMappingPromise ||= loadCFGridMapping(group2, arrayPath, attributes, signal);
16019
+ const coordinateTransform = options?.transform || normalizeAffineTransform(attributes["spatial:transform"]) || // An ancestor grid mapping can be shared by several multiscale levels: it gives the CRS only.
16020
+ normalizeGDALGeoTransform(
16021
+ await getGridMapping().then((mapping) => mapping?.local ? mapping.attributes.GeoTransform : null)
16022
+ ) || (!metadataOnly ? await loadCFCoordinateTransform(group2, arrayPath, spatialDimensions, signal) : null);
15860
16023
  if (!coordinateTransform) {
15861
16024
  throw new Error(
15862
- "GeoZarrRasterSource requires spatial:transform metadata, explicit geozarr.transform, or regular 1D CF coordinate arrays."
16025
+ "GeoZarrRasterSource requires spatial:transform metadata, explicit geozarr.transform, a CF grid-mapping GeoTransform, or regular 1D CF coordinate arrays."
15863
16026
  );
15864
16027
  }
15865
16028
  const declaredRegistration = normalizeRegistration(attributes["spatial:registration"]);
15866
16029
  const transform = declaredRegistration === "node" ? convertNodeTransformToPixelTransform(coordinateTransform) : coordinateTransform;
15867
16030
  const declaredBoundingBox = normalizeBoundingBox(attributes["spatial:bbox"]);
15868
16031
  const boundingBox = declaredRegistration === "pixel" && declaredBoundingBox ? toRasterBoundingBox(declaredBoundingBox) : getTransformBoundingBox(transform, width, height);
15869
- const coordinateReferenceSystem = options?.coordinateReferenceSystem || normalizeDeclaredCoordinateReferenceSystem(attributes) || await loadCFCoordinateReferenceSystem(group2, attributes, spatialDimensions, signal);
16032
+ const coordinateReferenceSystem = options?.coordinateReferenceSystem || normalizeDeclaredCoordinateReferenceSystem(attributes) || getCFCoordinateReferenceSystem(
16033
+ (await getGridMapping())?.attributes || null,
16034
+ spatialDimensions
16035
+ );
15870
16036
  const defaultSelection = options?.defaultSelection || {};
15871
16037
  const selectionDimensions = dimensions.map((dimensionName, dimensionIndex) => ({
15872
16038
  name: dimensionName,
@@ -15906,7 +16072,7 @@ var __exports__ = (() => {
15906
16072
  transform,
15907
16073
  registration: declaredRegistration
15908
16074
  };
15909
- return { group: group2, array: array2, metadata, xDimensionIndex, yDimensionIndex };
16075
+ return { group: group2, array: array2, metadata, xDimensionIndex, yDimensionIndex, layout };
15910
16076
  }
15911
16077
  };
15912
16078
  function normalizeAttributes(attributes) {
@@ -15966,12 +16132,19 @@ var __exports__ = (() => {
15966
16132
  translateY - (rotationY + scaleY) / 2
15967
16133
  ];
15968
16134
  }
15969
- async function loadCFCoordinateTransform(group2, spatialDimensions, signal) {
16135
+ async function loadCFCoordinateTransform(group2, arrayPath, spatialDimensions, signal) {
16136
+ let coordinates;
15970
16137
  try {
15971
- const [yCoordinates, xCoordinates] = await Promise.all([
15972
- loadCoordinateValues(group2, spatialDimensions[0], signal),
15973
- loadCoordinateValues(group2, spatialDimensions[1], signal)
16138
+ coordinates = await Promise.all([
16139
+ loadCoordinateValues(group2, arrayPath, spatialDimensions[0], signal),
16140
+ loadCoordinateValues(group2, arrayPath, spatialDimensions[1], signal)
15974
16141
  ]);
16142
+ } catch (error) {
16143
+ rethrowUnlessAbsent(error);
16144
+ return null;
16145
+ }
16146
+ const [yCoordinates, xCoordinates] = coordinates;
16147
+ try {
15975
16148
  const scaleX = getRegularCoordinateSpacing(xCoordinates, spatialDimensions[1]);
15976
16149
  const scaleY = getRegularCoordinateSpacing(yCoordinates, spatialDimensions[0]);
15977
16150
  return [scaleX, 0, xCoordinates[0] - scaleX / 2, 0, scaleY, yCoordinates[0] - scaleY / 2];
@@ -15979,11 +16152,8 @@ var __exports__ = (() => {
15979
16152
  return null;
15980
16153
  }
15981
16154
  }
15982
- async function loadCoordinateValues(group2, coordinateName, signal) {
15983
- const coordinateArray = await open(group2.resolve(coordinateName), {
15984
- kind: "array",
15985
- signal
15986
- });
16155
+ async function loadCoordinateValues(group2, arrayPath, coordinateName, signal) {
16156
+ const { array: coordinateArray } = await openNearestArray(group2, arrayPath, coordinateName, signal);
15987
16157
  if (coordinateArray.shape.length !== 1 || coordinateArray.shape[0] < 2) {
15988
16158
  throw new Error(
15989
16159
  `Coordinate ${coordinateName} must be a one-dimensional array with at least two values.`
@@ -15995,6 +16165,23 @@ var __exports__ = (() => {
15995
16165
  }
15996
16166
  return Array.from(coordinateChunk.data);
15997
16167
  }
16168
+ async function openNearestArray(group2, arrayPath, name, signal) {
16169
+ const segments = arrayPath.split("/").slice(0, -1);
16170
+ let lastError;
16171
+ for (let depth = segments.length; depth >= 0; depth--) {
16172
+ const path = [...segments.slice(0, depth), name].join("/");
16173
+ try {
16174
+ const array2 = await open(group2.resolve(path), { kind: "array", signal });
16175
+ return { array: array2, local: depth === segments.length };
16176
+ } catch (error) {
16177
+ if (!isZarritaError(error, "NotFoundError")) {
16178
+ throw error;
16179
+ }
16180
+ lastError = error;
16181
+ }
16182
+ }
16183
+ throw lastError;
16184
+ }
15998
16185
  function getRegularCoordinateSpacing(coordinates, coordinateName) {
15999
16186
  const spacing = (coordinates.at(-1) - coordinates[0]) / (coordinates.length - 1);
16000
16187
  if (!Number.isFinite(spacing) || spacing === 0) {
@@ -16009,22 +16196,27 @@ var __exports__ = (() => {
16009
16196
  }
16010
16197
  return spacing;
16011
16198
  }
16012
- async function loadCFCoordinateReferenceSystem(group2, attributes, spatialDimensions, signal) {
16199
+ async function loadCFGridMapping(group2, arrayPath, attributes, signal) {
16013
16200
  const gridMapping = normalizeString(attributes.grid_mapping);
16014
- if (gridMapping) {
16015
- const gridMappingName = gridMapping.trim().split(/[\s:]/, 1)[0];
16016
- try {
16017
- const gridMappingArray = await open(group2.resolve(gridMappingName), {
16018
- kind: "array",
16019
- signal
16020
- });
16021
- const gridMappingAttributes = normalizeAttributes(gridMappingArray.attrs);
16022
- const coordinateReferenceSystem = normalizeString(gridMappingAttributes.crs_wkt) || normalizeString(gridMappingAttributes.spatial_ref) || normalizeString(gridMappingAttributes["proj:wkt2"]) || normalizeString(gridMappingAttributes["proj:code"]);
16023
- if (coordinateReferenceSystem) {
16024
- return coordinateReferenceSystem;
16025
- }
16026
- } catch {
16027
- }
16201
+ if (!gridMapping) return null;
16202
+ const gridMappingName = gridMapping.trim().split(/[\s:]/, 1)[0];
16203
+ try {
16204
+ const { array: array2, local } = await openNearestArray(group2, arrayPath, gridMappingName, signal);
16205
+ return { attributes: normalizeAttributes(array2.attrs), local };
16206
+ } catch (error) {
16207
+ rethrowUnlessAbsent(error);
16208
+ return null;
16209
+ }
16210
+ }
16211
+ function rethrowUnlessAbsent(error) {
16212
+ if (!isZarritaError(error, "NotFoundError")) {
16213
+ throw error;
16214
+ }
16215
+ }
16216
+ function getCFCoordinateReferenceSystem(gridMappingAttributes, spatialDimensions) {
16217
+ const coordinateReferenceSystem = gridMappingAttributes && (normalizeString(gridMappingAttributes.crs_wkt) || normalizeString(gridMappingAttributes.spatial_ref) || normalizeString(gridMappingAttributes["proj:wkt2"]) || normalizeString(gridMappingAttributes["proj:code"]));
16218
+ if (coordinateReferenceSystem) {
16219
+ return coordinateReferenceSystem;
16028
16220
  }
16029
16221
  const normalizedDimensions = spatialDimensions.map((dimension) => dimension.toLowerCase());
16030
16222
  if (["lat", "latitude"].includes(normalizedDimensions[0]) && ["lon", "longitude"].includes(normalizedDimensions[1])) {
@@ -16032,6 +16224,35 @@ var __exports__ = (() => {
16032
16224
  }
16033
16225
  return void 0;
16034
16226
  }
16227
+ function normalizeGDALGeoTransform(value) {
16228
+ const coefficients = typeof value === "string" ? value.trim().split(/\s+/).map(Number) : value;
16229
+ if (!Array.isArray(coefficients) || coefficients.length !== 6 || coefficients.some((coefficient) => typeof coefficient !== "number" || !Number.isFinite(coefficient))) {
16230
+ return null;
16231
+ }
16232
+ const [originX, pixelWidth, rotationX, originY, rotationY, pixelHeight] = coefficients;
16233
+ if (pixelWidth === 0 || pixelHeight === 0) return null;
16234
+ return [pixelWidth, rotationX, originX, rotationY, pixelHeight, originY];
16235
+ }
16236
+ function getOMELevelsOrEmpty(attributes, arrayPath) {
16237
+ try {
16238
+ return getSpatialMultiscaleLevels(attributes, arrayPath, { spatialOME: true });
16239
+ } catch {
16240
+ return [];
16241
+ }
16242
+ }
16243
+ function declaresCoordinateReferenceSystem(attributes) {
16244
+ return Boolean(
16245
+ normalizeDeclaredCoordinateReferenceSystem(attributes) || normalizeString(attributes.grid_mapping)
16246
+ );
16247
+ }
16248
+ function isConsistentOMELevel(scale, selectedScale, level, selected) {
16249
+ return selected.spatialDimensions.every((dimension, index) => {
16250
+ const coefficient = index === 0 ? 4 : 0;
16251
+ const expected = Math.abs(scale[dimension] / selectedScale[dimension]);
16252
+ const actual = Math.abs(level.transform[coefficient] / selected.transform[coefficient]);
16253
+ return Number.isFinite(expected) && Math.abs(actual - expected) <= expected * 1e-6;
16254
+ });
16255
+ }
16035
16256
  function getTransformBoundingBox(transform, width, height) {
16036
16257
  const corners = [
16037
16258
  transformPosition(transform, 0, 0),
@@ -16221,12 +16442,12 @@ var __exports__ = (() => {
16221
16442
  return projection && typeof projection === "object" && !Array.isArray(projection) ? projection : void 0;
16222
16443
  }
16223
16444
 
16224
- // src/zarr/zarr-array-source.ts
16225
- var ZarrArraySourceLoaderWithParser = {
16445
+ // src/zarr/zarr-array-loader.ts
16446
+ var ZarrArrayLoaderWithParser = {
16226
16447
  dataType: null,
16227
16448
  dataSource: null,
16228
16449
  batchType: null,
16229
- name: "ZarrArraySourceLoader",
16450
+ name: "ZarrArrayLoader",
16230
16451
  id: "zarr-array",
16231
16452
  module: "scientific",
16232
16453
  version: "latest",
@@ -16254,7 +16475,7 @@ var __exports__ = (() => {
16254
16475
  zarrArray: { path: void 0, dimensions: void 0 }
16255
16476
  },
16256
16477
  testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
16257
- createDataSource: (data, options, coreApi2) => new ZarrArraySource(data, options, coreApi2)
16478
+ createDataSourceSync: (data, options, coreApi2) => new ZarrArraySource(data, options, coreApi2)
16258
16479
  };
16259
16480
  var ZarrArraySource = class extends ZarrSource {
16260
16481
  /** Cached array initialization. */
@@ -16346,15 +16567,15 @@ var __exports__ = (() => {
16346
16567
  return typeof selector === "object" && selector !== null;
16347
16568
  }
16348
16569
 
16349
- // src/zarr/spatial-data-source.ts
16350
- var SpatialDataSourceLoaderWithParser = {
16570
+ // src/zarr/spatial-data-loader.ts
16571
+ var SpatialDataLoaderWithParser = {
16351
16572
  dataType: null,
16352
16573
  dataSource: null,
16353
16574
  batchType: null,
16354
- name: "SpatialDataSourceLoader",
16575
+ name: "SpatialDataLoader",
16355
16576
  id: "spatial-data",
16356
16577
  module: "scientific",
16357
- version: OMEZarrSourceLoaderWithParser.version,
16578
+ version: OMEZarrLoaderWithParser.version,
16358
16579
  extensions: ["zarr"],
16359
16580
  mimeTypes: [],
16360
16581
  type: "spatial-data",
@@ -16377,7 +16598,7 @@ var __exports__ = (() => {
16377
16598
  }
16378
16599
  },
16379
16600
  testURL: (url) => /\.zarr(?:$|[/?#])/i.test(url),
16380
- createDataSource: (data, options, coreApi2) => new SpatialDataSource(data, options, coreApi2)
16601
+ createDataSourceSync: (data, options, coreApi2) => new SpatialDataSource(data, options, coreApi2)
16381
16602
  };
16382
16603
  var SpatialDataSource = class extends ZarrSource {
16383
16604
  /** Shared normalized metadata discovery request. */