Use worker for GeoTIFF decoding
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
import DataTile from './DataTile.js';
|
||||
import State from './State.js';
|
||||
import TileGrid from '../tilegrid/TileGrid.js';
|
||||
import {Pool, fromUrl as tiffFromUrl, fromUrls as tiffFromUrls} from 'geotiff';
|
||||
import {create as createDecoderWorker} from '../worker/geotiff-decoder.js';
|
||||
import {get as getProjection} from '../proj.js';
|
||||
import {fromUrl as tiffFromUrl, fromUrls as tiffFromUrls} from 'geotiff';
|
||||
import {toSize} from '../size.js';
|
||||
|
||||
/**
|
||||
@@ -19,6 +20,14 @@ import {toSize} from '../size.js';
|
||||
* @property {number} [nodata] Values to discard.
|
||||
*/
|
||||
|
||||
let workerPool;
|
||||
function getWorkerPool() {
|
||||
if (!workerPool) {
|
||||
workerPool = new Pool(undefined, createDecoderWorker());
|
||||
}
|
||||
return workerPool;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {import("geotiff/src/geotiff.js").GeoTIFF|import("geotiff/src/geotiff.js").MultiGeoTIFF} tiff A GeoTIFF.
|
||||
* @return {Promise<Array<import("geotiff/src/geotiffimage.js").GeoTIFFImage>>} Resolves to a list of images.
|
||||
@@ -317,7 +326,10 @@ class GeoTIFFSource extends DataTile {
|
||||
const sourceInfo = this.sourceInfo_;
|
||||
for (let sourceIndex = 0; sourceIndex < sourceCount; ++sourceIndex) {
|
||||
const image = this.sourceImagery_[sourceIndex][z];
|
||||
requests[sourceIndex] = image.readRasters({window: pixelBounds});
|
||||
requests[sourceIndex] = image.readRasters({
|
||||
window: pixelBounds,
|
||||
pool: getWorkerPool(),
|
||||
});
|
||||
if (sourceInfo[sourceIndex].nodata !== undefined) {
|
||||
addAlpha = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user