From f062b15bd5a7b712541b1cbf15bbfe880c1e3999 Mon Sep 17 00:00:00 2001 From: Fabian Schindler Date: Tue, 25 Jan 2022 21:52:27 +0100 Subject: [PATCH] Allowing to pass additional options to the geotiff.js source --- src/ol/source/GeoTIFF.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ol/source/GeoTIFF.js b/src/ol/source/GeoTIFF.js index caae328076..87b585d4f8 100644 --- a/src/ol/source/GeoTIFF.js +++ b/src/ol/source/GeoTIFF.js @@ -207,14 +207,15 @@ function getImagesForTIFF(tiff) { /** * @param {SourceInfo} source The GeoTIFF source. + * @param {object} options Options for the GeoTIFF source. * @return {Promise>} Resolves to a list of images. */ -function getImagesForSource(source) { +function getImagesForSource(source, options) { let request; if (source.overviews) { - request = tiffFromUrls(source.url, source.overviews); + request = tiffFromUrls(source.url, source.overviews, options); } else { - request = tiffFromUrl(source.url); + request = tiffFromUrl(source.url, options); } return request.then(getImagesForTIFF); } @@ -308,6 +309,7 @@ function getMaxForDataType(array) { * sources, one with 3 bands and {@link import("./GeoTIFF.js").SourceInfo nodata} configured, and * another with 1 band, the resulting data tiles will have 5 bands: 3 from the first source, 1 alpha * band from the first source, and 1 band from the second source. + * @property {object} [sourceOptions] Additional options to be passed to the underlying geotiff.js source. * @property {boolean} [convertToRGB = false] By default, bands from the sources are read as-is. When * reading GeoTIFFs with the purpose of displaying them as RGB images, setting this to `true` will * convert other color spaces (YCbCr, CMYK) to RGB. @@ -351,6 +353,12 @@ class GeoTIFFSource extends DataTile { const numSources = this.sourceInfo_.length; + /** + * @type {object} + * @private + */ + this.sourceOptions_ = options.sourceOptions; + /** * @type {Array>} * @private @@ -409,7 +417,10 @@ class GeoTIFFSource extends DataTile { const self = this; const requests = new Array(numSources); for (let i = 0; i < numSources; ++i) { - requests[i] = getImagesForSource(this.sourceInfo_[i]); + requests[i] = getImagesForSource( + this.sourceInfo_[i], + this.sourceOptions_ + ); } Promise.all(requests) .then(function (sources) {