Allowing to pass additional options to the
geotiff.js source
This commit is contained in:
@@ -207,14 +207,15 @@ function getImagesForTIFF(tiff) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {SourceInfo} source The GeoTIFF source.
|
* @param {SourceInfo} source The GeoTIFF source.
|
||||||
|
* @param {object} options Options for the GeoTIFF source.
|
||||||
* @return {Promise<Array<GeoTIFFImage>>} Resolves to a list of images.
|
* @return {Promise<Array<GeoTIFFImage>>} Resolves to a list of images.
|
||||||
*/
|
*/
|
||||||
function getImagesForSource(source) {
|
function getImagesForSource(source, options) {
|
||||||
let request;
|
let request;
|
||||||
if (source.overviews) {
|
if (source.overviews) {
|
||||||
request = tiffFromUrls(source.url, source.overviews);
|
request = tiffFromUrls(source.url, source.overviews, options);
|
||||||
} else {
|
} else {
|
||||||
request = tiffFromUrl(source.url);
|
request = tiffFromUrl(source.url, options);
|
||||||
}
|
}
|
||||||
return request.then(getImagesForTIFF);
|
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
|
* 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
|
* 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.
|
* 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
|
* @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
|
* reading GeoTIFFs with the purpose of displaying them as RGB images, setting this to `true` will
|
||||||
* convert other color spaces (YCbCr, CMYK) to RGB.
|
* convert other color spaces (YCbCr, CMYK) to RGB.
|
||||||
@@ -351,6 +353,12 @@ class GeoTIFFSource extends DataTile {
|
|||||||
|
|
||||||
const numSources = this.sourceInfo_.length;
|
const numSources = this.sourceInfo_.length;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {object}
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.sourceOptions_ = options.sourceOptions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @type {Array<Array<GeoTIFFImage>>}
|
* @type {Array<Array<GeoTIFFImage>>}
|
||||||
* @private
|
* @private
|
||||||
@@ -409,7 +417,10 @@ class GeoTIFFSource extends DataTile {
|
|||||||
const self = this;
|
const self = this;
|
||||||
const requests = new Array(numSources);
|
const requests = new Array(numSources);
|
||||||
for (let i = 0; i < numSources; ++i) {
|
for (let i = 0; i < numSources; ++i) {
|
||||||
requests[i] = getImagesForSource(this.sourceInfo_[i]);
|
requests[i] = getImagesForSource(
|
||||||
|
this.sourceInfo_[i],
|
||||||
|
this.sourceOptions_
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Promise.all(requests)
|
Promise.all(requests)
|
||||||
.then(function (sources) {
|
.then(function (sources) {
|
||||||
|
|||||||
Reference in New Issue
Block a user