@loaders.gl/geotiff 3.1.3 → 4.0.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.
- package/dist/bundle.js +2 -24
- package/dist/bundle.js.map +1 -0
- package/dist/index.js +3 -10
- package/dist/index.js.map +1 -0
- package/dist/lib/load-geotiff.js +31 -56
- package/dist/lib/load-geotiff.js.map +1 -0
- package/dist/lib/ome/load-ome-tiff.js +50 -45
- package/dist/lib/ome/load-ome-tiff.js.map +1 -0
- package/dist/lib/ome/ome-indexers.js +112 -104
- package/dist/lib/ome/ome-indexers.js.map +1 -0
- package/dist/lib/ome/ome-utils.js +69 -59
- package/dist/lib/ome/ome-utils.js.map +1 -0
- package/dist/lib/ome/omexml.js +60 -60
- package/dist/lib/ome/omexml.js.map +1 -0
- package/dist/lib/ome/utils.js +18 -27
- package/dist/lib/ome/utils.js.map +1 -0
- package/dist/lib/tiff-pixel-source.js +106 -59
- package/dist/lib/tiff-pixel-source.js.map +1 -0
- package/dist/lib/utils/Pool.js +72 -78
- package/dist/lib/utils/Pool.js.map +1 -0
- package/dist/{es5/lib → lib}/utils/decoder.worker.ts.disabled +0 -0
- package/dist/lib/utils/proxies.js +56 -79
- package/dist/lib/utils/proxies.js.map +1 -0
- package/dist/lib/utils/tiff-utils.js +24 -40
- package/dist/lib/utils/tiff-utils.js.map +1 -0
- package/dist/types.js +2 -2
- package/dist/{es5/types.js.map → types.js.map} +0 -0
- package/dist/typings/geotiff.js +2 -1
- package/dist/{es5/typings → typings}/geotiff.js.map +0 -0
- package/package.json +4 -4
- package/dist/es5/bundle.js +0 -13
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/index.js +0 -24
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/lib/load-geotiff.js +0 -100
- package/dist/es5/lib/load-geotiff.js.map +0 -1
- package/dist/es5/lib/ome/load-ome-tiff.js +0 -85
- package/dist/es5/lib/ome/load-ome-tiff.js.map +0 -1
- package/dist/es5/lib/ome/ome-indexers.js +0 -167
- package/dist/es5/lib/ome/ome-indexers.js.map +0 -1
- package/dist/es5/lib/ome/ome-utils.js +0 -87
- package/dist/es5/lib/ome/ome-utils.js.map +0 -1
- package/dist/es5/lib/ome/omexml.js +0 -82
- package/dist/es5/lib/ome/omexml.js.map +0 -1
- package/dist/es5/lib/ome/utils.js +0 -32
- package/dist/es5/lib/ome/utils.js.map +0 -1
- package/dist/es5/lib/tiff-pixel-source.js +0 -202
- package/dist/es5/lib/tiff-pixel-source.js.map +0 -1
- package/dist/es5/lib/utils/Pool.js +0 -173
- package/dist/es5/lib/utils/Pool.js.map +0 -1
- package/dist/es5/lib/utils/proxies.js +0 -82
- package/dist/es5/lib/utils/proxies.js.map +0 -1
- package/dist/es5/lib/utils/tiff-utils.js +0 -53
- package/dist/es5/lib/utils/tiff-utils.js.map +0 -1
- package/dist/es5/types.js +0 -2
- package/dist/es5/typings/geotiff.js +0 -2
- package/dist/esm/bundle.js +0 -4
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/index.js +0 -3
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/lib/load-geotiff.js +0 -32
- package/dist/esm/lib/load-geotiff.js.map +0 -1
- package/dist/esm/lib/ome/load-ome-tiff.js +0 -51
- package/dist/esm/lib/ome/load-ome-tiff.js.map +0 -1
- package/dist/esm/lib/ome/ome-indexers.js +0 -116
- package/dist/esm/lib/ome/ome-indexers.js.map +0 -1
- package/dist/esm/lib/ome/ome-utils.js +0 -73
- package/dist/esm/lib/ome/ome-utils.js.map +0 -1
- package/dist/esm/lib/ome/omexml.js +0 -66
- package/dist/esm/lib/ome/omexml.js.map +0 -1
- package/dist/esm/lib/ome/utils.js +0 -21
- package/dist/esm/lib/ome/utils.js.map +0 -1
- package/dist/esm/lib/tiff-pixel-source.js +0 -111
- package/dist/esm/lib/tiff-pixel-source.js.map +0 -1
- package/dist/esm/lib/utils/Pool.js +0 -77
- package/dist/esm/lib/utils/Pool.js.map +0 -1
- package/dist/esm/lib/utils/decoder.worker.ts.disabled +0 -21
- package/dist/esm/lib/utils/proxies.js +0 -63
- package/dist/esm/lib/utils/proxies.js.map +0 -1
- package/dist/esm/lib/utils/tiff-utils.js +0 -28
- package/dist/esm/lib/utils/tiff-utils.js.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/typings/geotiff.js +0 -2
- package/dist/esm/typings/geotiff.js.map +0 -1
|
@@ -1,86 +1,63 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPoolProxy = exports.createOffsetsProxy = exports.checkProxies = void 0;
|
|
4
1
|
const VIV_PROXY_KEY = '__viv';
|
|
5
|
-
const OFFSETS_PROXY_KEY =
|
|
6
|
-
const POOL_PROXY_KEY =
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (!isProxy(tiff, POOL_PROXY_KEY)) {
|
|
16
|
-
console.warn('GeoTIFF source is missing decoder-pool proxy.'); // eslint-disable-line no-console
|
|
17
|
-
}
|
|
2
|
+
const OFFSETS_PROXY_KEY = "".concat(VIV_PROXY_KEY, "-offsets");
|
|
3
|
+
const POOL_PROXY_KEY = "".concat(VIV_PROXY_KEY, "-decoder-pool");
|
|
4
|
+
export function checkProxies(tiff) {
|
|
5
|
+
if (!isProxy(tiff, OFFSETS_PROXY_KEY)) {
|
|
6
|
+
console.warn('GeoTIFF source is missing offsets proxy.');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (!isProxy(tiff, POOL_PROXY_KEY)) {
|
|
10
|
+
console.warn('GeoTIFF source is missing decoder-pool proxy.');
|
|
11
|
+
}
|
|
18
12
|
}
|
|
19
|
-
|
|
20
|
-
/*
|
|
21
|
-
* > isProxy(tiff, POOL_PROXY_KEY) === true; // false
|
|
22
|
-
* > tiff = createPoolProxy(tiff, new Pool());
|
|
23
|
-
* > isProxy(tiff, POOL_PROXY_KEY) === true; // true
|
|
24
|
-
*/
|
|
13
|
+
|
|
25
14
|
function isProxy(tiff, proxyFlag) {
|
|
26
|
-
|
|
15
|
+
return tiff[proxyFlag];
|
|
27
16
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
* rather than traversing the file system remotely.
|
|
37
|
-
*/
|
|
38
|
-
function createOffsetsProxy(tiff, offsets) {
|
|
39
|
-
const get = (target, key) => {
|
|
40
|
-
// Intercept `tiff.getImage`
|
|
41
|
-
if (key === 'getImage') {
|
|
42
|
-
return (index) => {
|
|
43
|
-
// Manually add ifdRequest to tiff if missing and we have an offset.
|
|
44
|
-
if (!(index in target.ifdRequests) && index in offsets) {
|
|
45
|
-
const offset = offsets[index];
|
|
46
|
-
target.ifdRequests[index] = target.parseFileDirectoryAt(offset);
|
|
47
|
-
}
|
|
48
|
-
return target.getImage(index);
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
// tiff['__viv-offsets'] === true
|
|
52
|
-
if (key === OFFSETS_PROXY_KEY) {
|
|
53
|
-
return true;
|
|
17
|
+
|
|
18
|
+
export function createOffsetsProxy(tiff, offsets) {
|
|
19
|
+
const get = (target, key) => {
|
|
20
|
+
if (key === 'getImage') {
|
|
21
|
+
return index => {
|
|
22
|
+
if (!(index in target.ifdRequests) && index in offsets) {
|
|
23
|
+
const offset = offsets[index];
|
|
24
|
+
target.ifdRequests[index] = target.parseFileDirectoryAt(offset);
|
|
54
25
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
26
|
+
|
|
27
|
+
return target.getImage(index);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (key === OFFSETS_PROXY_KEY) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return Reflect.get(target, key);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return new Proxy(tiff, {
|
|
39
|
+
get
|
|
40
|
+
});
|
|
58
41
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
if (key === POOL_PROXY_KEY) {
|
|
80
|
-
return true;
|
|
81
|
-
}
|
|
82
|
-
return Reflect.get(target, key);
|
|
83
|
-
};
|
|
84
|
-
return new Proxy(tiff, { get });
|
|
42
|
+
export function createPoolProxy(tiff, pool) {
|
|
43
|
+
const get = (target, key) => {
|
|
44
|
+
if (key === 'readRasters') {
|
|
45
|
+
return options => {
|
|
46
|
+
return target.readRasters({ ...options,
|
|
47
|
+
pool
|
|
48
|
+
});
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (key === POOL_PROXY_KEY) {
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return Reflect.get(target, key);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return new Proxy(tiff, {
|
|
60
|
+
get
|
|
61
|
+
});
|
|
85
62
|
}
|
|
86
|
-
|
|
63
|
+
//# sourceMappingURL=proxies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/utils/proxies.ts"],"names":["VIV_PROXY_KEY","OFFSETS_PROXY_KEY","POOL_PROXY_KEY","checkProxies","tiff","isProxy","console","warn","proxyFlag","createOffsetsProxy","offsets","get","target","key","index","ifdRequests","offset","parseFileDirectoryAt","getImage","Reflect","Proxy","createPoolProxy","pool","options","readRasters"],"mappings":"AAGA,MAAMA,aAAa,GAAG,OAAtB;AACA,MAAMC,iBAAiB,aAAMD,aAAN,aAAvB;AACA,MAAME,cAAc,aAAMF,aAAN,kBAApB;AAMA,OAAO,SAASG,YAAT,CAAsBC,IAAtB,EAAqC;AAC1C,MAAI,CAACC,OAAO,CAACD,IAAD,EAAOH,iBAAP,CAAZ,EAAuC;AACrCK,IAAAA,OAAO,CAACC,IAAR,CAAa,0CAAb;AACD;;AAED,MAAI,CAACF,OAAO,CAACD,IAAD,EAAOF,cAAP,CAAZ,EAAoC;AAClCI,IAAAA,OAAO,CAACC,IAAR,CAAa,+CAAb;AACD;AACF;;AAOD,SAASF,OAAT,CAAiBD,IAAjB,EAAgCI,SAAhC,EAAmD;AACjD,SAAQJ,IAAD,CAAcI,SAAd,CAAP;AACD;;AAYD,OAAO,SAASC,kBAAT,CAA4BL,IAA5B,EAA2CM,OAA3C,EAA8D;AACnE,QAAMC,GAAG,GAAG,CAACC,MAAD,EAAkBC,GAAlB,KAA+B;AAEzC,QAAIA,GAAG,KAAK,UAAZ,EAAwB;AACtB,aAAQC,KAAD,IAAmB;AAExB,YAAI,EAAEA,KAAK,IAAIF,MAAM,CAACG,WAAlB,KAAkCD,KAAK,IAAIJ,OAA/C,EAAwD;AACtD,gBAAMM,MAAM,GAAGN,OAAO,CAACI,KAAD,CAAtB;AACAF,UAAAA,MAAM,CAACG,WAAP,CAAmBD,KAAnB,IAA4BF,MAAM,CAACK,oBAAP,CAA4BD,MAA5B,CAA5B;AACD;;AACD,eAAOJ,MAAM,CAACM,QAAP,CAAgBJ,KAAhB,CAAP;AACD,OAPD;AAQD;;AAGD,QAAID,GAAG,KAAKZ,iBAAZ,EAA+B;AAC7B,aAAO,IAAP;AACD;;AAED,WAAOkB,OAAO,CAACR,GAAR,CAAYC,MAAZ,EAAoBC,GAApB,CAAP;AACD,GAnBD;;AAoBA,SAAO,IAAIO,KAAJ,CAAUhB,IAAV,EAAgB;AAACO,IAAAA;AAAD,GAAhB,CAAP;AACD;AAUD,OAAO,SAASU,eAAT,CAAyBjB,IAAzB,EAAwCkB,IAAxC,EAAoD;AACzD,QAAMX,GAAG,GAAG,CAACC,MAAD,EAAkBC,GAAlB,KAA+B;AAEzC,QAAIA,GAAG,KAAK,aAAZ,EAA2B;AACzB,aAAQU,OAAD,IAAoD;AAGzD,eAAOX,MAAM,CAACY,WAAP,CAAmB,EAAC,GAAGD,OAAJ;AAAaD,UAAAA;AAAb,SAAnB,CAAP;AACD,OAJD;AAKD;;AAGD,QAAIT,GAAG,KAAKX,cAAZ,EAA4B;AAC1B,aAAO,IAAP;AACD;;AAED,WAAOiB,OAAO,CAACR,GAAR,CAAYC,MAAZ,EAAoBC,GAApB,CAAP;AACD,GAhBD;;AAiBA,SAAO,IAAIO,KAAJ,CAAUhB,IAAV,EAAgB;AAACO,IAAAA;AAAD,GAAhB,CAAP;AACD","sourcesContent":["import type {GeoTIFF} from 'geotiff';\nimport type Pool from './Pool';\n\nconst VIV_PROXY_KEY = '__viv';\nconst OFFSETS_PROXY_KEY = `${VIV_PROXY_KEY}-offsets` as const;\nconst POOL_PROXY_KEY = `${VIV_PROXY_KEY}-decoder-pool` as const;\n\n/*\n * Inspect if the GeoTIFF source is wrapped in our proxies,\n * and warn if missing.\n */\nexport function checkProxies(tiff: GeoTIFF) {\n if (!isProxy(tiff, OFFSETS_PROXY_KEY)) {\n console.warn('GeoTIFF source is missing offsets proxy.'); // eslint-disable-line no-console\n }\n\n if (!isProxy(tiff, POOL_PROXY_KEY)) {\n console.warn('GeoTIFF source is missing decoder-pool proxy.'); // eslint-disable-line no-console\n }\n}\n\n/*\n * > isProxy(tiff, POOL_PROXY_KEY) === true; // false\n * > tiff = createPoolProxy(tiff, new Pool());\n * > isProxy(tiff, POOL_PROXY_KEY) === true; // true\n */\nfunction isProxy(tiff: GeoTIFF, proxyFlag: string) {\n return (tiff as any)[proxyFlag] as boolean;\n}\n\n/*\n * Creates an ES6 Proxy that wraps a GeoTIFF object. The proxy\n * handler intercepts calls to `tiff.getImage` and uses our custom\n * pre-computed offsets to pre-fetch the correct file directory.\n *\n * This is a bit of a hack. Internally GeoTIFF inspects `this.ifdRequests`\n * to see which fileDirectories need to be traversed. By adding the\n * ifdRequest for an 'index' manually, GeoTIFF will await that request\n * rather than traversing the file system remotely.\n */\nexport function createOffsetsProxy(tiff: GeoTIFF, offsets: number[]) {\n const get = (target: GeoTIFF, key: any) => {\n // Intercept `tiff.getImage`\n if (key === 'getImage') {\n return (index: number) => {\n // Manually add ifdRequest to tiff if missing and we have an offset.\n if (!(index in target.ifdRequests) && index in offsets) {\n const offset = offsets[index];\n target.ifdRequests[index] = target.parseFileDirectoryAt(offset);\n }\n return target.getImage(index);\n };\n }\n\n // tiff['__viv-offsets'] === true\n if (key === OFFSETS_PROXY_KEY) {\n return true;\n }\n\n return Reflect.get(target, key);\n };\n return new Proxy(tiff, {get});\n}\n\n/*\n * Creates an ES6 Proxy that wraps a GeoTIFF object. The proxy\n * handler intercepts calls to `tiff.readRasters` and injects\n * a pool argument to every call. This means our TiffPixelSource\n * doesn't need to be aware of whether a decoder pool is in use.\n *\n * > tiff.readRasters({ window }) -> tiff.readRasters({ window, pool });\n */\nexport function createPoolProxy(tiff: GeoTIFF, pool: Pool) {\n const get = (target: GeoTIFF, key: any) => {\n // Intercept calls to `image.readRasters`\n if (key === 'readRasters') {\n return (options: Parameters<typeof target.readRasters>) => {\n // Inject `pool` argument with other raster options.\n // @ts-ignore\n return target.readRasters({...options, pool});\n };\n }\n\n // tiff['__viv-decoder-pool'] === true\n if (key === POOL_PROXY_KEY) {\n return true;\n }\n\n return Reflect.get(target, key);\n };\n return new Proxy(tiff, {get});\n}\n"],"file":"proxies.js"}
|
|
@@ -1,44 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.SIGNAL_ABORTED = exports.getImageSize = exports.isInterleaved = exports.intToRgba = exports.ensureArray = void 0;
|
|
4
|
-
function ensureArray(x) {
|
|
5
|
-
return Array.isArray(x) ? x : [x];
|
|
1
|
+
export function ensureArray(x) {
|
|
2
|
+
return Array.isArray(x) ? x : [x];
|
|
6
3
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
throw Error('Not an integer.');
|
|
18
|
-
}
|
|
19
|
-
// Write number to int32 representation (4 bytes).
|
|
20
|
-
const buffer = new ArrayBuffer(4);
|
|
21
|
-
const view = new DataView(buffer);
|
|
22
|
-
view.setInt32(0, int, false); // offset === 0, littleEndian === false
|
|
23
|
-
// Take u8 view and extract number for each byte (1 byte for R/G/B/A).
|
|
24
|
-
const bytes = new Uint8Array(buffer);
|
|
25
|
-
return Array.from(bytes);
|
|
4
|
+
export function intToRgba(int) {
|
|
5
|
+
if (!Number.isInteger(int)) {
|
|
6
|
+
throw Error('Not an integer.');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const buffer = new ArrayBuffer(4);
|
|
10
|
+
const view = new DataView(buffer);
|
|
11
|
+
view.setInt32(0, int, false);
|
|
12
|
+
const bytes = new Uint8Array(buffer);
|
|
13
|
+
return Array.from(bytes);
|
|
26
14
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* > isInterleaved([1, 24, 24]) === false;
|
|
31
|
-
* > isInterleaved([1, 24, 24, 3]) === true;
|
|
32
|
-
*/
|
|
33
|
-
function isInterleaved(shape) {
|
|
34
|
-
const lastDimSize = shape[shape.length - 1];
|
|
35
|
-
return lastDimSize === 3 || lastDimSize === 4;
|
|
15
|
+
export function isInterleaved(shape) {
|
|
16
|
+
const lastDimSize = shape[shape.length - 1];
|
|
17
|
+
return lastDimSize === 3 || lastDimSize === 4;
|
|
36
18
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
19
|
+
export function getImageSize(source) {
|
|
20
|
+
const interleaved = isInterleaved(source.shape);
|
|
21
|
+
const [height, width] = source.shape.slice(interleaved ? -3 : -2);
|
|
22
|
+
return {
|
|
23
|
+
height,
|
|
24
|
+
width
|
|
25
|
+
};
|
|
42
26
|
}
|
|
43
|
-
|
|
44
|
-
|
|
27
|
+
export const SIGNAL_ABORTED = '__vivSignalAborted';
|
|
28
|
+
//# sourceMappingURL=tiff-utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/utils/tiff-utils.ts"],"names":["ensureArray","x","Array","isArray","intToRgba","int","Number","isInteger","Error","buffer","ArrayBuffer","view","DataView","setInt32","bytes","Uint8Array","from","isInterleaved","shape","lastDimSize","length","getImageSize","source","interleaved","height","width","slice","SIGNAL_ABORTED"],"mappings":"AAEA,OAAO,SAASA,WAAT,CAAwBC,CAAxB,EAAoC;AACzC,SAAOC,KAAK,CAACC,OAAN,CAAcF,CAAd,IAAmBA,CAAnB,GAAuB,CAACA,CAAD,CAA9B;AACD;AASD,OAAO,SAASG,SAAT,CAAmBC,GAAnB,EAAgC;AACrC,MAAI,CAACC,MAAM,CAACC,SAAP,CAAiBF,GAAjB,CAAL,EAA4B;AAC1B,UAAMG,KAAK,CAAC,iBAAD,CAAX;AACD;;AAGD,QAAMC,MAAM,GAAG,IAAIC,WAAJ,CAAgB,CAAhB,CAAf;AACA,QAAMC,IAAI,GAAG,IAAIC,QAAJ,CAAaH,MAAb,CAAb;AACAE,EAAAA,IAAI,CAACE,QAAL,CAAc,CAAd,EAAiBR,GAAjB,EAAsB,KAAtB;AAGA,QAAMS,KAAK,GAAG,IAAIC,UAAJ,CAAeN,MAAf,CAAd;AACA,SAAOP,KAAK,CAACc,IAAN,CAAWF,KAAX,CAAP;AACD;AAOD,OAAO,SAASG,aAAT,CAAuBC,KAAvB,EAAwC;AAC7C,QAAMC,WAAW,GAAGD,KAAK,CAACA,KAAK,CAACE,MAAN,GAAe,CAAhB,CAAzB;AACA,SAAOD,WAAW,KAAK,CAAhB,IAAqBA,WAAW,KAAK,CAA5C;AACD;AAED,OAAO,SAASE,YAAT,CAA0CC,MAA1C,EAAkE;AACvE,QAAMC,WAAW,GAAGN,aAAa,CAACK,MAAM,CAACJ,KAAR,CAAjC;AACA,QAAM,CAACM,MAAD,EAASC,KAAT,IAAkBH,MAAM,CAACJ,KAAP,CAAaQ,KAAb,CAAmBH,WAAW,GAAG,CAAC,CAAJ,GAAQ,CAAC,CAAvC,CAAxB;AACA,SAAO;AAACC,IAAAA,MAAD;AAASC,IAAAA;AAAT,GAAP;AACD;AAED,OAAO,MAAME,cAAc,GAAG,oBAAvB","sourcesContent":["import type {PixelSource} from '../../types';\n\nexport function ensureArray<T>(x: T | T[]) {\n return Array.isArray(x) ? x : [x];\n}\n\n/*\n * Converts 32-bit integer color representation to RGBA tuple.\n * Used to serialize colors from OME-XML metadata.\n *\n * > console.log(intToRgba(100100));\n * > // [0, 1, 135, 4]\n */\nexport function intToRgba(int: number) {\n if (!Number.isInteger(int)) {\n throw Error('Not an integer.');\n }\n\n // Write number to int32 representation (4 bytes).\n const buffer = new ArrayBuffer(4);\n const view = new DataView(buffer);\n view.setInt32(0, int, false); // offset === 0, littleEndian === false\n\n // Take u8 view and extract number for each byte (1 byte for R/G/B/A).\n const bytes = new Uint8Array(buffer);\n return Array.from(bytes) as [number, number, number, number];\n}\n\n/*\n * Helper method to determine whether pixel data is interleaved or not.\n * > isInterleaved([1, 24, 24]) === false;\n * > isInterleaved([1, 24, 24, 3]) === true;\n */\nexport function isInterleaved(shape: number[]) {\n const lastDimSize = shape[shape.length - 1];\n return lastDimSize === 3 || lastDimSize === 4;\n}\n\nexport function getImageSize<T extends string[]>(source: PixelSource<T>) {\n const interleaved = isInterleaved(source.shape);\n const [height, width] = source.shape.slice(interleaved ? -3 : -2);\n return {height, width};\n}\n\nexport const SIGNAL_ABORTED = '__vivSignalAborted';\n"],"file":"tiff-utils.js"}
|
package/dist/types.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export {};
|
|
2
|
+
//# sourceMappingURL=types.js.map
|
|
File without changes
|
package/dist/typings/geotiff.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//# sourceMappingURL=geotiff.js.map
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/geotiff",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.5",
|
|
4
4
|
"description": "Framework-independent loaders for tiff and geotiff",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -19,8 +19,8 @@
|
|
|
19
19
|
"geotiff"
|
|
20
20
|
],
|
|
21
21
|
"types": "dist/index.d.ts",
|
|
22
|
-
"main": "dist/
|
|
23
|
-
"module": "dist/
|
|
22
|
+
"main": "dist/index.js",
|
|
23
|
+
"module": "dist/index.js",
|
|
24
24
|
"sideEffects": false,
|
|
25
25
|
"files": [
|
|
26
26
|
"src",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"fast-xml-parser": "^3.16.0",
|
|
40
40
|
"geotiff": "^1.0.4"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "7a71a54bdf1ddf985cc3af3db90b82e7fa97d025"
|
|
43
43
|
}
|
package/dist/es5/bundle.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
|
-
var moduleExports = _interopRequireWildcard(require("./index"));
|
|
6
|
-
|
|
7
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
8
|
-
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
-
|
|
11
|
-
globalThis.loaders = globalThis.loaders || {};
|
|
12
|
-
module.exports = Object.assign(globalThis.loaders, moduleExports);
|
|
13
|
-
//# sourceMappingURL=bundle.js.map
|
package/dist/es5/bundle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bundle.ts"],"names":["globalThis","loaders","module","exports","Object","assign","moduleExports"],"mappings":";;;;AAAA;;;;;;AAEAA,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AAEAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCK,aAAlC,CAAjB","sourcesContent":["import * as moduleExports from './index';\n// @ts-ignore\nglobalThis.loaders = globalThis.loaders || {};\n// @ts-ignore\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
|
package/dist/es5/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
Object.defineProperty(exports, "loadGeoTiff", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
get: function get() {
|
|
11
|
-
return _loadGeotiff.loadGeoTiff;
|
|
12
|
-
}
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(exports, "TiffPixelSource", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function get() {
|
|
17
|
-
return _tiffPixelSource.default;
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
var _loadGeotiff = require("./lib/load-geotiff");
|
|
22
|
-
|
|
23
|
-
var _tiffPixelSource = _interopRequireDefault(require("./lib/tiff-pixel-source"));
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
package/dist/es5/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;AACA","sourcesContent":["export {loadGeoTiff} from './lib/load-geotiff';\nexport {default as TiffPixelSource} from './lib/tiff-pixel-source';\n"],"file":"index.js"}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.loadGeoTiff = loadGeoTiff;
|
|
9
|
-
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
|
-
var _geotiff = require("geotiff");
|
|
15
|
-
|
|
16
|
-
var _proxies = require("./utils/proxies");
|
|
17
|
-
|
|
18
|
-
var _loadOmeTiff = require("./ome/load-ome-tiff");
|
|
19
|
-
|
|
20
|
-
function loadGeoTiff(_x) {
|
|
21
|
-
return _loadGeoTiff.apply(this, arguments);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function _loadGeoTiff() {
|
|
25
|
-
_loadGeoTiff = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(source) {
|
|
26
|
-
var opts,
|
|
27
|
-
headers,
|
|
28
|
-
offsets,
|
|
29
|
-
tiff,
|
|
30
|
-
firstImage,
|
|
31
|
-
_args = arguments;
|
|
32
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
33
|
-
while (1) {
|
|
34
|
-
switch (_context.prev = _context.next) {
|
|
35
|
-
case 0:
|
|
36
|
-
opts = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
|
|
37
|
-
headers = opts.headers, offsets = opts.offsets;
|
|
38
|
-
|
|
39
|
-
if (!(source instanceof _geotiff.GeoTIFF)) {
|
|
40
|
-
_context.next = 6;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
tiff = source;
|
|
45
|
-
_context.next = 15;
|
|
46
|
-
break;
|
|
47
|
-
|
|
48
|
-
case 6:
|
|
49
|
-
if (!(typeof source === 'string')) {
|
|
50
|
-
_context.next = 12;
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
_context.next = 9;
|
|
55
|
-
return (0, _geotiff.fromUrl)(source, headers);
|
|
56
|
-
|
|
57
|
-
case 9:
|
|
58
|
-
tiff = _context.sent;
|
|
59
|
-
_context.next = 15;
|
|
60
|
-
break;
|
|
61
|
-
|
|
62
|
-
case 12:
|
|
63
|
-
_context.next = 14;
|
|
64
|
-
return (0, _geotiff.fromBlob)(source);
|
|
65
|
-
|
|
66
|
-
case 14:
|
|
67
|
-
tiff = _context.sent;
|
|
68
|
-
|
|
69
|
-
case 15:
|
|
70
|
-
if (offsets) {
|
|
71
|
-
tiff = (0, _proxies.createOffsetsProxy)(tiff, offsets);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
(0, _proxies.checkProxies)(tiff);
|
|
75
|
-
_context.next = 19;
|
|
76
|
-
return tiff.getImage(0);
|
|
77
|
-
|
|
78
|
-
case 19:
|
|
79
|
-
firstImage = _context.sent;
|
|
80
|
-
|
|
81
|
-
if (!(0, _loadOmeTiff.isOmeTiff)(firstImage)) {
|
|
82
|
-
_context.next = 22;
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return _context.abrupt("return", (0, _loadOmeTiff.loadOmeTiff)(tiff, firstImage));
|
|
87
|
-
|
|
88
|
-
case 22:
|
|
89
|
-
throw new Error('GeoTIFF not recognized.');
|
|
90
|
-
|
|
91
|
-
case 23:
|
|
92
|
-
case "end":
|
|
93
|
-
return _context.stop();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}, _callee);
|
|
97
|
-
}));
|
|
98
|
-
return _loadGeoTiff.apply(this, arguments);
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=load-geotiff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/load-geotiff.ts"],"names":["loadGeoTiff","source","opts","headers","offsets","GeoTIFF","tiff","getImage","firstImage","Error"],"mappings":";;;;;;;;;;;;;AAAA;;AAEA;;AAOA;;SA4BsBA,W;;;;;2EAAf,iBACLC,MADK;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAELC,YAAAA,IAFK,2DAEkB,EAFlB;AAIEC,YAAAA,OAJF,GAIsBD,IAJtB,CAIEC,OAJF,EAIWC,OAJX,GAIsBF,IAJtB,CAIWE,OAJX;;AAAA,kBAQDH,MAAM,YAAYI,gBARjB;AAAA;AAAA;AAAA;;AASHC,YAAAA,IAAI,GAAGL,MAAP;AATG;AAAA;;AAAA;AAAA,kBAUM,OAAOA,MAAP,KAAkB,QAVxB;AAAA;AAAA;AAAA;;AAAA;AAAA,mBAWU,sBAAQA,MAAR,EAAgBE,OAAhB,CAXV;;AAAA;AAWHG,YAAAA,IAXG;AAAA;AAAA;;AAAA;AAAA;AAAA,mBAaU,uBAASL,MAAT,CAbV;;AAAA;AAaHK,YAAAA,IAbG;;AAAA;AAwBL,gBAAIF,OAAJ,EAAa;AAMXE,cAAAA,IAAI,GAAG,iCAAmBA,IAAnB,EAAyBF,OAAzB,CAAP;AACD;;AAMD,uCAAaE,IAAb;AArCK;AAAA,mBAuCoBA,IAAI,CAACC,QAAL,CAAc,CAAd,CAvCpB;;AAAA;AAuCCC,YAAAA,UAvCD;;AAAA,iBAyCD,4BAAUA,UAAV,CAzCC;AAAA;AAAA;AAAA;;AAAA,6CA0CI,8BAAYF,IAAZ,EAAkBE,UAAlB,CA1CJ;;AAAA;AAAA,kBA6CC,IAAIC,KAAJ,CAAU,yBAAV,CA7CD;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import {fromUrl, fromBlob, GeoTIFF} from 'geotiff';\n\nimport {\n // createPoolProxy,\n createOffsetsProxy,\n checkProxies\n} from './utils/proxies';\n// import Pool from './lib/Pool';\n\nimport {loadOmeTiff, isOmeTiff} from './ome/load-ome-tiff';\nimport type TiffPixelSource from './tiff-pixel-source';\n\n/** Options for initializing a tiff pixel source. */\ninterface GeoTIFFOptions {\n /** Headers passed to each underlying request. */\n headers?: Record<string, unknown>;\n /** Performance enhancment to index the remote tiff source using pre-computed byte-offsets. Generated via https://github.com/ilan-gold/generate-tiff-offsets */\n offsets?: number[];\n /** Indicates whether a multi-threaded pool of image decoders should be used to decode tiles. */\n pool?: boolean;\n}\n\ninterface GeoTIFFData {\n data: TiffPixelSource<string[]>[];\n metadata: Record<string, unknown>;\n}\n\n/**\n * Opens an OME-TIFF via URL and returns data source and associated metadata for first image.\n *\n * @param source url string, File/Blob object, or GeoTIFF object\n * @param opts options for initializing a tiff pixel source.\n * - `opts.headers` are passed to each underlying fetch request.\n * - `opts.offsets` are a performance enhancment to index the remote tiff source using pre-computed byte-offsets.\n * - `opts.pool` indicates whether a multi-threaded pool of image decoders should be used to decode tiles (default = true).\n * @return data source and associated OME-Zarr metadata.\n */\nexport async function loadGeoTiff(\n source: string | Blob | GeoTIFF,\n opts: GeoTIFFOptions = {}\n): Promise<GeoTIFFData> {\n const {headers, offsets} = opts;\n\n // Create tiff source\n let tiff: GeoTIFF;\n if (source instanceof GeoTIFF) {\n tiff = source;\n } else if (typeof source === 'string') {\n tiff = await fromUrl(source, headers);\n } else {\n tiff = await fromBlob(source);\n }\n\n // if (pool) {\n /*\n * Creates a worker pool to decode tiff tiles. Wraps tiff\n * in a Proxy that injects 'pool' into `tiff.readRasters`.\n */\n // tiff = createPoolProxy(tiff, new Pool());\n // }\n\n if (offsets) {\n /*\n * Performance enhancement. If offsets are provided, we\n * create a proxy that intercepts calls to `tiff.getImage`\n * and injects the pre-computed offsets.\n */\n tiff = createOffsetsProxy(tiff, offsets);\n }\n\n /*\n * Inspect tiff source for our performance enhancing proxies.\n * Prints warnings to console if `offsets` or `pool` are missing.\n */\n checkProxies(tiff);\n\n const firstImage = await tiff.getImage(0);\n\n if (isOmeTiff(firstImage)) {\n return loadOmeTiff(tiff, firstImage);\n }\n\n throw new Error('GeoTIFF not recognized.');\n}\n"],"file":"load-geotiff.js"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.loadOmeTiff = loadOmeTiff;
|
|
9
|
-
exports.isOmeTiff = void 0;
|
|
10
|
-
|
|
11
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
-
|
|
13
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
|
-
|
|
15
|
-
var _tiffPixelSource = _interopRequireDefault(require("../tiff-pixel-source"));
|
|
16
|
-
|
|
17
|
-
var _omeIndexers = require("./ome-indexers");
|
|
18
|
-
|
|
19
|
-
var _omeUtils = require("./ome-utils");
|
|
20
|
-
|
|
21
|
-
var _omexml = require("./omexml");
|
|
22
|
-
|
|
23
|
-
var isOmeTiff = function isOmeTiff(img) {
|
|
24
|
-
return img.fileDirectory.ImageDescription.includes('<OME');
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
exports.isOmeTiff = isOmeTiff;
|
|
28
|
-
|
|
29
|
-
function loadOmeTiff(_x, _x2) {
|
|
30
|
-
return _loadOmeTiff.apply(this, arguments);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function _loadOmeTiff() {
|
|
34
|
-
_loadOmeTiff = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(tiff, firstImage) {
|
|
35
|
-
var _firstImage$fileDirec, ImageDescription, SubIFDs, photometricInterpretation, omexml, levels, pyramidIndexer, imgMeta, _getOmePixelSourceMet, labels, getShape, physicalSizes, dtype, tileSize, meta, data;
|
|
36
|
-
|
|
37
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
38
|
-
while (1) {
|
|
39
|
-
switch (_context.prev = _context.next) {
|
|
40
|
-
case 0:
|
|
41
|
-
_firstImage$fileDirec = firstImage.fileDirectory, ImageDescription = _firstImage$fileDirec.ImageDescription, SubIFDs = _firstImage$fileDirec.SubIFDs, photometricInterpretation = _firstImage$fileDirec.PhotometricInterpretation;
|
|
42
|
-
omexml = (0, _omexml.fromString)(ImageDescription);
|
|
43
|
-
|
|
44
|
-
if (SubIFDs) {
|
|
45
|
-
levels = SubIFDs.length + 1;
|
|
46
|
-
pyramidIndexer = (0, _omeIndexers.getOmeSubIFDIndexer)(tiff, omexml);
|
|
47
|
-
} else {
|
|
48
|
-
levels = omexml.length;
|
|
49
|
-
pyramidIndexer = (0, _omeIndexers.getOmeLegacyIndexer)(tiff, omexml);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
imgMeta = omexml[0];
|
|
53
|
-
_getOmePixelSourceMet = (0, _omeUtils.getOmePixelSourceMeta)(imgMeta), labels = _getOmePixelSourceMet.labels, getShape = _getOmePixelSourceMet.getShape, physicalSizes = _getOmePixelSourceMet.physicalSizes, dtype = _getOmePixelSourceMet.dtype;
|
|
54
|
-
tileSize = firstImage.getTileWidth();
|
|
55
|
-
meta = {
|
|
56
|
-
photometricInterpretation: photometricInterpretation,
|
|
57
|
-
physicalSizes: physicalSizes
|
|
58
|
-
};
|
|
59
|
-
data = Array.from({
|
|
60
|
-
length: levels
|
|
61
|
-
}).map(function (_, resolution) {
|
|
62
|
-
var shape = getShape(resolution);
|
|
63
|
-
|
|
64
|
-
var indexer = function indexer(sel) {
|
|
65
|
-
return pyramidIndexer(sel, resolution);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
var source = new _tiffPixelSource.default(indexer, dtype, tileSize, shape, labels, meta);
|
|
69
|
-
return source;
|
|
70
|
-
});
|
|
71
|
-
return _context.abrupt("return", {
|
|
72
|
-
data: data,
|
|
73
|
-
metadata: imgMeta
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
case 9:
|
|
77
|
-
case "end":
|
|
78
|
-
return _context.stop();
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}, _callee);
|
|
82
|
-
}));
|
|
83
|
-
return _loadOmeTiff.apply(this, arguments);
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=load-ome-tiff.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/ome/load-ome-tiff.ts"],"names":["isOmeTiff","img","fileDirectory","ImageDescription","includes","loadOmeTiff","tiff","firstImage","SubIFDs","photometricInterpretation","PhotometricInterpretation","omexml","levels","length","pyramidIndexer","imgMeta","labels","getShape","physicalSizes","dtype","tileSize","getTileWidth","meta","data","Array","from","map","_","resolution","shape","indexer","sel","source","TiffPixelSource","metadata"],"mappings":";;;;;;;;;;;;;;AAEA;;AACA;;AACA;;AACA;;AAGO,IAAMA,SAAS,GAAG,SAAZA,SAAY,CAACC,GAAD;AAAA,SAAuBA,GAAG,CAACC,aAAJ,CAAkBC,gBAAlB,CAAmCC,QAAnC,CAA4C,MAA5C,CAAvB;AAAA,CAAlB;;;;SAEeC,W;;;;;2EAAf,iBAA2BC,IAA3B,EAA0CC,UAA1C;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA,oCAMDA,UAAU,CAACL,aANV,EAGHC,gBAHG,yBAGHA,gBAHG,EAIHK,OAJG,yBAIHA,OAJG,EAKwBC,yBALxB,yBAKHC,yBALG;AAOCC,YAAAA,MAPD,GAOU,wBAAWR,gBAAX,CAPV;;AAgBL,gBAAIK,OAAJ,EAAa;AAEXI,cAAAA,MAAM,GAAGJ,OAAO,CAACK,MAAR,GAAiB,CAA1B;AACAC,cAAAA,cAAc,GAAG,sCAAoBR,IAApB,EAA0BK,MAA1B,CAAjB;AACD,aAJD,MAIO;AAELC,cAAAA,MAAM,GAAGD,MAAM,CAACE,MAAhB;AACAC,cAAAA,cAAc,GAAG,sCAAoBR,IAApB,EAA0BK,MAA1B,CAAjB;AACD;;AAGKI,YAAAA,OA3BD,GA2BWJ,MAAM,CAAC,CAAD,CA3BjB;AAAA,oCA4B4C,qCAAsBI,OAAtB,CA5B5C,EA4BEC,MA5BF,yBA4BEA,MA5BF,EA4BUC,QA5BV,yBA4BUA,QA5BV,EA4BoBC,aA5BpB,yBA4BoBA,aA5BpB,EA4BmCC,KA5BnC,yBA4BmCA,KA5BnC;AA6BCC,YAAAA,QA7BD,GA6BYb,UAAU,CAACc,YAAX,EA7BZ;AA8BCC,YAAAA,IA9BD,GA8BQ;AAACb,cAAAA,yBAAyB,EAAzBA,yBAAD;AAA4BS,cAAAA,aAAa,EAAbA;AAA5B,aA9BR;AAgCCK,YAAAA,IAhCD,GAgCQC,KAAK,CAACC,IAAN,CAAW;AAACZ,cAAAA,MAAM,EAAED;AAAT,aAAX,EAA6Bc,GAA7B,CAAiC,UAACC,CAAD,EAAIC,UAAJ,EAAmB;AAC/D,kBAAMC,KAAK,GAAGZ,QAAQ,CAACW,UAAD,CAAtB;;AACA,kBAAME,OAAO,GAAG,SAAVA,OAAU,CAACC,GAAD;AAAA,uBAA2BjB,cAAc,CAACiB,GAAD,EAAMH,UAAN,CAAzC;AAAA,eAAhB;;AACA,kBAAMI,MAAM,GAAG,IAAIC,wBAAJ,CAAoBH,OAApB,EAA6BX,KAA7B,EAAoCC,QAApC,EAA8CS,KAA9C,EAAqDb,MAArD,EAA6DM,IAA7D,CAAf;AACA,qBAAOU,MAAP;AACD,aALY,CAhCR;AAAA,6CAuCE;AAACT,cAAAA,IAAI,EAAJA,IAAD;AAAOW,cAAAA,QAAQ,EAAEnB;AAAjB,aAvCF;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import type {GeoTIFF, GeoTIFFImage} from 'geotiff';\n\nimport TiffPixelSource from '../tiff-pixel-source';\nimport {getOmeLegacyIndexer, getOmeSubIFDIndexer, OmeTiffIndexer} from './ome-indexers';\nimport {getOmePixelSourceMeta} from './ome-utils';\nimport {fromString} from './omexml';\nimport type {OmeTiffSelection} from './ome-indexers';\n\nexport const isOmeTiff = (img: GeoTIFFImage) => img.fileDirectory.ImageDescription.includes('<OME');\n\nexport async function loadOmeTiff(tiff: GeoTIFF, firstImage: GeoTIFFImage) {\n // Get first image from tiff and inspect OME-XML metadata\n const {\n ImageDescription,\n SubIFDs,\n PhotometricInterpretation: photometricInterpretation\n } = firstImage.fileDirectory;\n const omexml = fromString(ImageDescription);\n\n /*\n * Image pyramids are stored differently between versions of Bioformats.\n * Thus we need a different indexer depending on which format we have.\n */\n let levels: number;\n let pyramidIndexer: OmeTiffIndexer;\n\n if (SubIFDs) {\n // Image is >= Bioformats 6.0 and resolutions are stored using SubIFDs.\n levels = SubIFDs.length + 1;\n pyramidIndexer = getOmeSubIFDIndexer(tiff, omexml);\n } else {\n // Image is legacy format; resolutions are stored as separate images.\n levels = omexml.length;\n pyramidIndexer = getOmeLegacyIndexer(tiff, omexml);\n }\n\n // TODO: The OmeTIFF loader only works for the _first_ image in the metadata.\n const imgMeta = omexml[0];\n const {labels, getShape, physicalSizes, dtype} = getOmePixelSourceMeta(imgMeta);\n const tileSize = firstImage.getTileWidth();\n const meta = {photometricInterpretation, physicalSizes};\n\n const data = Array.from({length: levels}).map((_, resolution) => {\n const shape = getShape(resolution);\n const indexer = (sel: OmeTiffSelection) => pyramidIndexer(sel, resolution);\n const source = new TiffPixelSource(indexer, dtype, tileSize, shape, labels, meta);\n return source;\n });\n\n return {data, metadata: imgMeta};\n}\n"],"file":"load-ome-tiff.js"}
|