@loaders.gl/geotiff 4.2.0-alpha.3 → 4.2.0-alpha.5

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 (50) hide show
  1. package/dist/dist.dev.js +218 -286
  2. package/dist/dist.min.js +30 -0
  3. package/dist/geotiff-loader.js +71 -52
  4. package/dist/index.cjs +17 -20
  5. package/dist/index.cjs.map +7 -0
  6. package/dist/index.d.ts +3 -3
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +3 -1
  9. package/dist/lib/load-geotiff.d.ts +1 -1
  10. package/dist/lib/load-geotiff.d.ts.map +1 -1
  11. package/dist/lib/load-geotiff.js +57 -21
  12. package/dist/lib/ome/load-ome-tiff.d.ts +1 -1
  13. package/dist/lib/ome/load-ome-tiff.d.ts.map +1 -1
  14. package/dist/lib/ome/load-ome-tiff.js +35 -41
  15. package/dist/lib/ome/ome-indexers.d.ts +1 -1
  16. package/dist/lib/ome/ome-indexers.d.ts.map +1 -1
  17. package/dist/lib/ome/ome-indexers.js +102 -114
  18. package/dist/lib/ome/ome-utils.d.ts +1 -1
  19. package/dist/lib/ome/ome-utils.d.ts.map +1 -1
  20. package/dist/lib/ome/ome-utils.js +56 -60
  21. package/dist/lib/ome/omexml.js +53 -55
  22. package/dist/lib/ome/utils.d.ts +2 -2
  23. package/dist/lib/ome/utils.d.ts.map +1 -1
  24. package/dist/lib/ome/utils.js +23 -12
  25. package/dist/lib/tiff-pixel-source.d.ts +1 -1
  26. package/dist/lib/tiff-pixel-source.d.ts.map +1 -1
  27. package/dist/lib/tiff-pixel-source.js +58 -84
  28. package/dist/lib/utils/tiff-utils.d.ts +1 -1
  29. package/dist/lib/utils/tiff-utils.d.ts.map +1 -1
  30. package/dist/lib/utils/tiff-utils.js +31 -18
  31. package/dist/loaders.js +40 -27
  32. package/dist/types.d.ts +1 -1
  33. package/dist/types.d.ts.map +1 -1
  34. package/dist/types.js +3 -1
  35. package/package.json +8 -4
  36. package/dist/geotiff-loader.js.map +0 -1
  37. package/dist/index.js.map +0 -1
  38. package/dist/lib/load-geotiff.js.map +0 -1
  39. package/dist/lib/ome/load-ome-tiff.js.map +0 -1
  40. package/dist/lib/ome/ome-indexers.js.map +0 -1
  41. package/dist/lib/ome/ome-utils.js.map +0 -1
  42. package/dist/lib/ome/omexml.js.map +0 -1
  43. package/dist/lib/ome/utils.js.map +0 -1
  44. package/dist/lib/tiff-pixel-source.js.map +0 -1
  45. package/dist/lib/utils/Pool.ts.disabled +0 -99
  46. package/dist/lib/utils/decoder.worker.ts.disabled +0 -21
  47. package/dist/lib/utils/proxies.ts.disabled +0 -96
  48. package/dist/lib/utils/tiff-utils.js.map +0 -1
  49. package/dist/loaders.js.map +0 -1
  50. package/dist/types.js.map +0 -1
@@ -1,120 +1,108 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
4
+ /*
5
+ * An "indexer" for a GeoTIFF-based source is a function that takes a
6
+ * "selection" (e.g. { z, t, c }) and returns a Promise for the GeoTIFFImage
7
+ * object corresponding to that selection.
8
+ *
9
+ * For OME-TIFF images, the "selection" object is the same regardless of
10
+ * the format version. However, modern version of Bioformats have a different
11
+ * memory layout for pyramidal resolutions. Thus, we have two different "indexers"
12
+ * depending on which format version is detected.
13
+ *
14
+ * TODO: We currently only support indexing the first image in the OME-TIFF with
15
+ * our indexers. There can be multiple images in an OME-TIFF, so supporting these
16
+ * images will require extending these indexers or creating new methods.
17
+ */
18
+ /*
19
+ * Returns an indexer for legacy Bioformats images. This assumes that
20
+ * downsampled resolutions are stored sequentially in the OME-TIFF.
21
+ */
1
22
  export function getOmeLegacyIndexer(tiff, rootMeta) {
2
- const imgMeta = rootMeta[0];
3
- const {
4
- SizeT,
5
- SizeC,
6
- SizeZ
7
- } = imgMeta.Pixels;
8
- const ifdIndexer = getOmeIFDIndexer(imgMeta);
9
- return (sel, pyramidLevel) => {
10
- const index = ifdIndexer(sel);
11
- const pyramidIndex = pyramidLevel * SizeZ * SizeT * SizeC;
12
- return tiff.getImage(index + pyramidIndex);
13
- };
23
+ const imgMeta = rootMeta[0];
24
+ const { SizeT, SizeC, SizeZ } = imgMeta.Pixels;
25
+ const ifdIndexer = getOmeIFDIndexer(imgMeta);
26
+ return (sel, pyramidLevel) => {
27
+ // Get IFD index at base pyramid level
28
+ const index = ifdIndexer(sel);
29
+ // Get index of first image at pyramidal level
30
+ const pyramidIndex = pyramidLevel * SizeZ * SizeT * SizeC;
31
+ // Return image at IFD index for pyramidal level
32
+ return tiff.getImage(index + pyramidIndex);
33
+ };
14
34
  }
35
+ /*
36
+ * Returns an indexer for modern Bioforamts images that store multiscale
37
+ * resolutions using SubIFDs.
38
+ *
39
+ * The ifdIndexer returns the 'index' to the base resolution for a
40
+ * particular 'selection'. The SubIFDs to the downsampled resolutions
41
+ * of the 'selection' are stored within the `baseImage.fileDirectory`.
42
+ * We use the SubIFDs to get the IFD for the corresponding sub-resolution.
43
+ *
44
+ * NOTE: This function create a custom IFD cache rather than mutating
45
+ * `GeoTIFF.ifdRequests` with a random offset. The IFDs are cached in
46
+ * an ES6 Map that maps a string key that identifies the selection uniquely
47
+ * to the corresponding IFD.
48
+ */
15
49
  export function getOmeSubIFDIndexer(tiff, rootMeta) {
16
- const imgMeta = rootMeta[0];
17
- const ifdIndexer = getOmeIFDIndexer(imgMeta);
18
- const ifdCache = new Map();
19
- return async (sel, pyramidLevel) => {
20
- const index = ifdIndexer(sel);
21
- const baseImage = await tiff.getImage(index);
22
- if (pyramidLevel === 0) {
23
- return baseImage;
24
- }
25
- const {
26
- SubIFDs
27
- } = baseImage.fileDirectory;
28
- if (!SubIFDs) {
29
- throw Error('Indexing Error: OME-TIFF is missing SubIFDs.');
30
- }
31
- const key = `${sel.t}-${sel.c}-${sel.z}-${pyramidLevel}`;
32
- if (!ifdCache.has(key)) {
33
- const subIfdOffset = SubIFDs[pyramidLevel - 1];
34
- ifdCache.set(key, tiff.parseFileDirectoryAt(subIfdOffset));
35
- }
36
- const ifd = await ifdCache.get(key);
37
- return new baseImage.constructor(ifd.fileDirectory, ifd.geoKeyDirectory, tiff.dataView, tiff.littleEndian, tiff.cache, tiff.source);
38
- };
50
+ const imgMeta = rootMeta[0];
51
+ const ifdIndexer = getOmeIFDIndexer(imgMeta);
52
+ const ifdCache = new Map();
53
+ return async (sel, pyramidLevel) => {
54
+ const index = ifdIndexer(sel);
55
+ const baseImage = await tiff.getImage(index);
56
+ // It's the highest resolution, no need to look up SubIFDs.
57
+ if (pyramidLevel === 0) {
58
+ return baseImage;
59
+ }
60
+ const { SubIFDs } = baseImage.fileDirectory;
61
+ if (!SubIFDs) {
62
+ throw Error('Indexing Error: OME-TIFF is missing SubIFDs.');
63
+ }
64
+ // Get IFD for the selection at the pyramidal level
65
+ const key = `${sel.t}-${sel.c}-${sel.z}-${pyramidLevel}`;
66
+ if (!ifdCache.has(key)) {
67
+ // Only create a new request if we don't have the key.
68
+ const subIfdOffset = SubIFDs[pyramidLevel - 1];
69
+ ifdCache.set(key, tiff.parseFileDirectoryAt(subIfdOffset));
70
+ }
71
+ const ifd = await ifdCache.get(key);
72
+ // Create a new image object manually from IFD
73
+ // https://github.com/geotiffjs/geotiff.js/blob/8ef472f41b51d18074aece2300b6a8ad91a21ae1/src/geotiff.js#L447-L453
74
+ return new baseImage.constructor(ifd.fileDirectory, ifd.geoKeyDirectory,
75
+ // @ts-expect-error
76
+ tiff.dataView, tiff.littleEndian, tiff.cache, tiff.source);
77
+ };
39
78
  }
79
+ /*
80
+ * Returns a function that computes the image index based on the dimension
81
+ * order and dimension sizes.
82
+ */
40
83
  function getOmeIFDIndexer(imgMeta) {
41
- const {
42
- SizeC,
43
- SizeZ,
44
- SizeT,
45
- DimensionOrder
46
- } = imgMeta.Pixels;
47
- switch (DimensionOrder) {
48
- case 'XYZCT':
49
- {
50
- return _ref => {
51
- let {
52
- t,
53
- c,
54
- z
55
- } = _ref;
56
- return t * SizeZ * SizeC + c * SizeZ + z;
57
- };
58
- }
59
- case 'XYZTC':
60
- {
61
- return _ref2 => {
62
- let {
63
- t,
64
- c,
65
- z
66
- } = _ref2;
67
- return c * SizeZ * SizeT + t * SizeZ + z;
68
- };
69
- }
70
- case 'XYCTZ':
71
- {
72
- return _ref3 => {
73
- let {
74
- t,
75
- c,
76
- z
77
- } = _ref3;
78
- return z * SizeC * SizeT + t * SizeC + c;
79
- };
80
- }
81
- case 'XYCZT':
82
- {
83
- return _ref4 => {
84
- let {
85
- t,
86
- c,
87
- z
88
- } = _ref4;
89
- return t * SizeC * SizeZ + z * SizeC + c;
90
- };
91
- }
92
- case 'XYTCZ':
93
- {
94
- return _ref5 => {
95
- let {
96
- t,
97
- c,
98
- z
99
- } = _ref5;
100
- return z * SizeT * SizeC + c * SizeT + t;
101
- };
102
- }
103
- case 'XYTZC':
104
- {
105
- return _ref6 => {
106
- let {
107
- t,
108
- c,
109
- z
110
- } = _ref6;
111
- return c * SizeT * SizeZ + z * SizeT + t;
112
- };
113
- }
114
- default:
115
- {
116
- throw new Error(`Invalid OME-XML DimensionOrder, got ${DimensionOrder}.`);
117
- }
118
- }
84
+ const { SizeC, SizeZ, SizeT, DimensionOrder } = imgMeta.Pixels;
85
+ switch (DimensionOrder) {
86
+ case 'XYZCT': {
87
+ return ({ t, c, z }) => t * SizeZ * SizeC + c * SizeZ + z;
88
+ }
89
+ case 'XYZTC': {
90
+ return ({ t, c, z }) => c * SizeZ * SizeT + t * SizeZ + z;
91
+ }
92
+ case 'XYCTZ': {
93
+ return ({ t, c, z }) => z * SizeC * SizeT + t * SizeC + c;
94
+ }
95
+ case 'XYCZT': {
96
+ return ({ t, c, z }) => t * SizeC * SizeZ + z * SizeC + c;
97
+ }
98
+ case 'XYTCZ': {
99
+ return ({ t, c, z }) => z * SizeT * SizeC + c * SizeT + t;
100
+ }
101
+ case 'XYTZC': {
102
+ return ({ t, c, z }) => c * SizeT * SizeZ + z * SizeT + t;
103
+ }
104
+ default: {
105
+ throw new Error(`Invalid OME-XML DimensionOrder, got ${DimensionOrder}.`);
106
+ }
107
+ }
119
108
  }
120
- //# sourceMappingURL=ome-indexers.js.map
@@ -1,4 +1,4 @@
1
- import type { OMEXML, UnitsLength } from './omexml';
1
+ import type { OMEXML, UnitsLength } from "./omexml.js";
2
2
  export declare const DTYPE_LOOKUP: {
3
3
  readonly uint8: "Uint8";
4
4
  readonly uint16: "Uint16";
@@ -1 +1 @@
1
- {"version":3,"file":"ome-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/ome/ome-utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,UAAU,CAAC;AAElD,eAAO,MAAM,YAAY;;;;;;;;;CASf,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,EAAC,MAAM,EAAC,EAAE,MAAM,CAAC,CAAC,CAAC;;sBAoB9B,MAAM;;;kBAcP,MAAM;kBAAQ,WAAW;;;;;;sBAdxB,MAAM;;;EAmChC"}
1
+ {"version":3,"file":"ome-utils.d.ts","sourceRoot":"","sources":["../../../src/lib/ome/ome-utils.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAC,oBAAiB;AAElD,eAAO,MAAM,YAAY;;;;;;;;;CASf,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,EAAC,MAAM,EAAC,EAAE,MAAM,CAAC,CAAC,CAAC;;sBAoB9B,MAAM;;;kBAcP,MAAM;kBAAQ,WAAW;;;;;;sBAdxB,MAAM;;;EAmChC"}
@@ -1,66 +1,62 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { getDims, getLabels } from "./utils.js";
2
5
  export const DTYPE_LOOKUP = {
3
- uint8: 'Uint8',
4
- uint16: 'Uint16',
5
- uint32: 'Uint32',
6
- float: 'Float32',
7
- double: 'Float64',
8
- int8: 'Int8',
9
- int16: 'Int16',
10
- int32: 'Int32'
6
+ uint8: 'Uint8',
7
+ uint16: 'Uint16',
8
+ uint32: 'Uint32',
9
+ float: 'Float32',
10
+ double: 'Float64',
11
+ int8: 'Int8',
12
+ int16: 'Int16',
13
+ int32: 'Int32'
11
14
  };
12
- export function getOmePixelSourceMeta(_ref) {
13
- let {
14
- Pixels
15
- } = _ref;
16
- const labels = getLabels(Pixels.DimensionOrder);
17
- const dims = getDims(labels);
18
- const shape = Array(labels.length).fill(0);
19
- shape[dims('t')] = Pixels.SizeT;
20
- shape[dims('c')] = Pixels.SizeC;
21
- shape[dims('z')] = Pixels.SizeZ;
22
- if (Pixels.Interleaved) {
23
- labels.push('_c');
24
- shape.push(3);
25
- }
26
- const getShape = level => {
27
- const s = [...shape];
28
- s[dims('x')] = Pixels.SizeX >> level;
29
- s[dims('y')] = Pixels.SizeY >> level;
30
- return s;
31
- };
32
- if (!(Pixels.Type in DTYPE_LOOKUP)) {
33
- throw Error(`Pixel type ${Pixels.Type} not supported.`);
34
- }
35
- const dtype = DTYPE_LOOKUP[Pixels.Type];
36
- if (Pixels.PhysicalSizeX && Pixels.PhysicalSizeY) {
37
- const physicalSizes = {
38
- x: {
39
- size: Pixels.PhysicalSizeX,
40
- unit: Pixels.PhysicalSizeXUnit
41
- },
42
- y: {
43
- size: Pixels.PhysicalSizeY,
44
- unit: Pixels.PhysicalSizeYUnit
45
- }
46
- };
47
- if (Pixels.PhysicalSizeZ) {
48
- physicalSizes.z = {
49
- size: Pixels.PhysicalSizeZ,
50
- unit: Pixels.PhysicalSizeZUnit
51
- };
15
+ export function getOmePixelSourceMeta({ Pixels }) {
16
+ // e.g. 'XYZCT' -> ['t', 'c', 'z', 'y', 'x']
17
+ const labels = getLabels(Pixels.DimensionOrder);
18
+ // Compute "shape" of image
19
+ const dims = getDims(labels);
20
+ const shape = Array(labels.length).fill(0);
21
+ shape[dims('t')] = Pixels.SizeT;
22
+ shape[dims('c')] = Pixels.SizeC;
23
+ shape[dims('z')] = Pixels.SizeZ;
24
+ // Push extra dimension if data are interleaved.
25
+ if (Pixels.Interleaved) {
26
+ // @ts-ignore
27
+ labels.push('_c');
28
+ shape.push(3);
52
29
  }
53
- return {
54
- labels,
55
- getShape,
56
- physicalSizes,
57
- dtype
30
+ // Creates a new shape for different level of pyramid.
31
+ // Assumes factor-of-two downsampling.
32
+ const getShape = (level) => {
33
+ const s = [...shape];
34
+ s[dims('x')] = Pixels.SizeX >> level;
35
+ s[dims('y')] = Pixels.SizeY >> level;
36
+ return s;
58
37
  };
59
- }
60
- return {
61
- labels,
62
- getShape,
63
- dtype
64
- };
38
+ if (!(Pixels.Type in DTYPE_LOOKUP)) {
39
+ throw Error(`Pixel type ${Pixels.Type} not supported.`);
40
+ }
41
+ const dtype = DTYPE_LOOKUP[Pixels.Type];
42
+ if (Pixels.PhysicalSizeX && Pixels.PhysicalSizeY) {
43
+ const physicalSizes = {
44
+ x: {
45
+ size: Pixels.PhysicalSizeX,
46
+ unit: Pixels.PhysicalSizeXUnit
47
+ },
48
+ y: {
49
+ size: Pixels.PhysicalSizeY,
50
+ unit: Pixels.PhysicalSizeYUnit
51
+ }
52
+ };
53
+ if (Pixels.PhysicalSizeZ) {
54
+ physicalSizes.z = {
55
+ size: Pixels.PhysicalSizeZ,
56
+ unit: Pixels.PhysicalSizeZUnit
57
+ };
58
+ }
59
+ return { labels, getShape, physicalSizes, dtype };
60
+ }
61
+ return { labels, getShape, dtype };
65
62
  }
66
- //# sourceMappingURL=ome-utils.js.map
@@ -1,64 +1,62 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  import { XMLParser } from 'fast-xml-parser';
2
5
  import { ensureArray, intToRgba } from "../utils/tiff-utils.js";
6
+ // WARNING: Changes to the parser options _will_ effect the types in types/omexml.d.ts.
3
7
  const xmlParser = new XMLParser({
4
- attributeNamePrefix: '',
5
- attributesGroupName: 'attr',
6
- parseTagValue: true,
7
- parseAttributeValue: true,
8
- ignoreAttributes: false
8
+ // Nests attributes withtout prefix under 'attr' key for each node
9
+ attributeNamePrefix: '',
10
+ attributesGroupName: 'attr',
11
+ // Parses numbers for both attributes and nodes
12
+ parseTagValue: true,
13
+ parseAttributeValue: true,
14
+ // Forces attributes to be parsed
15
+ ignoreAttributes: false
9
16
  });
10
- const parse = str => xmlParser.parse(str);
17
+ const parse = (str) => xmlParser.parse(str);
11
18
  export function fromString(str) {
12
- const res = parse(str);
13
- if (!res.OME) {
14
- throw Error('Failed to parse OME-XML metadata.');
15
- }
16
- return ensureArray(res.OME.Image).map(img => {
17
- const Channels = ensureArray(img.Pixels.Channel).map(c => {
18
- if ('Color' in c.attr) {
19
- return {
20
- ...c.attr,
21
- Color: intToRgba(c.attr.Color)
19
+ const res = parse(str);
20
+ if (!res.OME) {
21
+ throw Error('Failed to parse OME-XML metadata.');
22
+ }
23
+ return ensureArray(res.OME.Image).map((img) => {
24
+ const Channels = ensureArray(img.Pixels.Channel).map((c) => {
25
+ if ('Color' in c.attr) {
26
+ return { ...c.attr, Color: intToRgba(c.attr.Color) };
27
+ }
28
+ return { ...c.attr };
29
+ });
30
+ const { AquisitionDate = '', Description = '' } = img;
31
+ const image = {
32
+ ...img.attr,
33
+ AquisitionDate,
34
+ Description,
35
+ Pixels: {
36
+ ...img.Pixels.attr,
37
+ Channels
38
+ }
22
39
  };
23
- }
24
- return {
25
- ...c.attr
26
- };
27
- });
28
- const {
29
- AquisitionDate = '',
30
- Description = ''
31
- } = img;
32
- const image = {
33
- ...img.attr,
34
- AquisitionDate,
35
- Description,
36
- Pixels: {
37
- ...img.Pixels.attr,
38
- Channels
39
- }
40
- };
41
- return {
42
- ...image,
43
- format() {
44
- const {
45
- Pixels
46
- } = image;
47
- const sizes = ['X', 'Y', 'Z'].map(name => {
48
- const size = Pixels[`PhysicalSize${name}`];
49
- const unit = Pixels[`PhysicalSize${name}Unit`];
50
- return size && unit ? `${size} ${unit}` : '-';
51
- }).join(' x ');
52
40
  return {
53
- 'Acquisition Date': image.AquisitionDate,
54
- 'Dimensions (XY)': `${Pixels.SizeX} x ${Pixels.SizeY}`,
55
- 'Pixels Type': Pixels.Type,
56
- 'Pixels Size (XYZ)': sizes,
57
- 'Z-sections/Timepoints': `${Pixels.SizeZ} x ${Pixels.SizeT}`,
58
- Channels: Pixels.SizeC
41
+ ...image,
42
+ format() {
43
+ const { Pixels } = image;
44
+ const sizes = ['X', 'Y', 'Z']
45
+ .map((name) => {
46
+ const size = Pixels[`PhysicalSize${name}`];
47
+ const unit = Pixels[`PhysicalSize${name}Unit`];
48
+ return size && unit ? `${size} ${unit}` : '-';
49
+ })
50
+ .join(' x ');
51
+ return {
52
+ 'Acquisition Date': image.AquisitionDate,
53
+ 'Dimensions (XY)': `${Pixels.SizeX} x ${Pixels.SizeY}`,
54
+ 'Pixels Type': Pixels.Type,
55
+ 'Pixels Size (XYZ)': sizes,
56
+ 'Z-sections/Timepoints': `${Pixels.SizeZ} x ${Pixels.SizeT}`,
57
+ Channels: Pixels.SizeC
58
+ };
59
+ }
59
60
  };
60
- }
61
- };
62
- });
61
+ });
63
62
  }
64
- //# sourceMappingURL=omexml.js.map
@@ -1,5 +1,5 @@
1
- import type { OMEXML } from '../ome/omexml';
2
- import type { Labels } from '../../types';
1
+ import type { OMEXML } from "../ome/omexml.js";
2
+ import type { Labels } from "../../types.js";
3
3
  export declare function getLabels(dimOrder: OMEXML[0]['Pixels']['DimensionOrder']): Labels<["t", "c", "z"] | ["c", "t", "z"] | ["z", "t", "c"] | ["t", "z", "c"] | ["z", "c", "t"] | ["c", "z", "t"]>;
4
4
  export declare function getDims<S extends string>(labels: S[]): (name: S) => number;
5
5
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/ome/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAYxC,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,qHAExE;AAWD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,UAKrC,CAAC,YAOhB"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/lib/ome/utils.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAC,yBAAsB;AAC1C,OAAO,KAAK,EAAC,MAAM,EAAC,uBAAoB;AAYxC,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,qHAExE;AAWD,wBAAgB,OAAO,CAAC,CAAC,SAAS,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,UAKrC,CAAC,YAOhB"}
@@ -1,17 +1,28 @@
1
+ // loaders.gl
2
+ // SPDX-License-Identifier: MIT
3
+ // Copyright (c) vis.gl contributors
1
4
  export function getLabels(dimOrder) {
2
- return dimOrder.toLowerCase().split('').reverse();
5
+ return dimOrder.toLowerCase().split('').reverse();
3
6
  }
7
+ /*
8
+ * Creates an ES6 map of 'label' -> index
9
+ * > const labels = ['a', 'b', 'c', 'd'];
10
+ * > const dims = getDims(labels);
11
+ * > dims('a') === 0;
12
+ * > dims('b') === 1;
13
+ * > dims('c') === 2;
14
+ * > dims('hi!'); // throws
15
+ */
4
16
  export function getDims(labels) {
5
- const lookup = new Map(labels.map((name, i) => [name, i]));
6
- if (lookup.size !== labels.length) {
7
- throw Error('Labels must be unique, found duplicated label.');
8
- }
9
- return name => {
10
- const index = lookup.get(name);
11
- if (index === undefined) {
12
- throw Error('Invalid dimension.');
17
+ const lookup = new Map(labels.map((name, i) => [name, i]));
18
+ if (lookup.size !== labels.length) {
19
+ throw Error('Labels must be unique, found duplicated label.');
13
20
  }
14
- return index;
15
- };
21
+ return (name) => {
22
+ const index = lookup.get(name);
23
+ if (index === undefined) {
24
+ throw Error('Invalid dimension.');
25
+ }
26
+ return index;
27
+ };
16
28
  }
17
- //# sourceMappingURL=utils.js.map
@@ -1,5 +1,5 @@
1
1
  import type { GeoTIFFImage } from 'geotiff';
2
- import type { PixelSource, PixelSourceSelection, PixelSourceMeta, Dtype, Labels, RasterSelection, TileSelection, PixelData } from '../types';
2
+ import type { PixelSource, PixelSourceSelection, PixelSourceMeta, Dtype, Labels, RasterSelection, TileSelection, PixelData } from "../types.js";
3
3
  export declare class TiffPixelSource<S extends string[]> implements PixelSource<S> {
4
4
  dtype: Dtype;
5
5
  tileSize: number;
@@ -1 +1 @@
1
- {"version":3,"file":"tiff-pixel-source.d.ts","sourceRoot":"","sources":["../../src/lib/tiff-pixel-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAG1C,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,KAAK,EACL,MAAM,EACN,eAAe,EACf,aAAa,EACb,SAAS,EAEV,MAAM,UAAU,CAAC;AAIlB,qBAAa,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IACjE,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,EAAE,eAAe,GAAG,SAAS,CAAC;IACzC,OAAO,CAAC,QAAQ,CAA0D;gBAIxE,OAAO,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,EAChE,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,IAAI,CAAC,EAAE,eAAe;IAUlB,SAAS,CAAC,EAAC,SAAS,EAAE,MAAM,EAAC,EAAE,eAAe,CAAC,CAAC,CAAC;IAKjD,OAAO,CAAC,EAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAC,EAAE,aAAa,CAAC,CAAC,CAAC;YAU3C,YAAY;IAuB1B,OAAO,CAAC,cAAc;IAetB,WAAW,CAAC,GAAG,EAAE,KAAK;CAGvB"}
1
+ {"version":3,"file":"tiff-pixel-source.d.ts","sourceRoot":"","sources":["../../src/lib/tiff-pixel-source.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AAG1C,OAAO,KAAK,EACV,WAAW,EACX,oBAAoB,EACpB,eAAe,EACf,KAAK,EACL,MAAM,EACN,eAAe,EACf,aAAa,EACb,SAAS,EAEV,oBAAiB;AAIlB,qBAAa,eAAe,CAAC,CAAC,SAAS,MAAM,EAAE,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC;IACjE,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IAClB,IAAI,EAAE,eAAe,GAAG,SAAS,CAAC;IACzC,OAAO,CAAC,QAAQ,CAA0D;gBAIxE,OAAO,EAAE,CAAC,GAAG,EAAE,oBAAoB,CAAC,CAAC,CAAC,KAAK,OAAO,CAAC,YAAY,CAAC,EAChE,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EAAE,EACf,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,IAAI,CAAC,EAAE,eAAe;IAUlB,SAAS,CAAC,EAAC,SAAS,EAAE,MAAM,EAAC,EAAE,eAAe,CAAC,CAAC,CAAC;IAKjD,OAAO,CAAC,EAAC,CAAC,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAC,EAAE,aAAa,CAAC,CAAC,CAAC;YAU3C,YAAY;IAuB1B,OAAO,CAAC,cAAc;IAetB,WAAW,CAAC,GAAG,EAAE,KAAK;CAGvB"}