From 8ef8cbf4e23f632a8759b0d4682928cf6c2e1607 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Wed, 4 May 2022 19:54:07 +0100 Subject: [PATCH 1/2] output tile load errors to console --- src/ol/source/GeoTIFF.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ol/source/GeoTIFF.js b/src/ol/source/GeoTIFF.js index c9f8f4d3ff..085100466a 100644 --- a/src/ol/source/GeoTIFF.js +++ b/src/ol/source/GeoTIFF.js @@ -770,6 +770,11 @@ class GeoTIFFSource extends DataTile { } return data; + }) + .catch(function (error) { + // output then rethrow + console.error(error); // eslint-disable-line no-console + throw error; }); } } From cf95f6313b6ab3c50422076e4f0c35ae927e40a9 Mon Sep 17 00:00:00 2001 From: mike-000 <49240900+mike-000@users.noreply.github.com> Date: Wed, 4 May 2022 20:18:17 +0100 Subject: [PATCH 2/2] fix lint --- src/ol/source/GeoTIFF.js | 155 ++++++++++++++++++++------------------- 1 file changed, 78 insertions(+), 77 deletions(-) diff --git a/src/ol/source/GeoTIFF.js b/src/ol/source/GeoTIFF.js index 085100466a..65d960d8a8 100644 --- a/src/ol/source/GeoTIFF.js +++ b/src/ol/source/GeoTIFF.js @@ -685,97 +685,98 @@ class GeoTIFFSource extends DataTile { const normalize = this.normalize_; const metadata = this.metadata_; - return Promise.all(requests).then(function (sourceSamples) { - /** @type {Uint8Array|Float32Array} */ - let data; - if (normalize) { - data = new Uint8Array(dataLength); - } else { - data = new Float32Array(dataLength); - } + return Promise.all(requests) + .then(function (sourceSamples) { + /** @type {Uint8Array|Float32Array} */ + let data; + if (normalize) { + data = new Uint8Array(dataLength); + } else { + data = new Float32Array(dataLength); + } - let dataIndex = 0; - for (let pixelIndex = 0; pixelIndex < pixelCount; ++pixelIndex) { - let transparent = addAlpha; - for (let sourceIndex = 0; sourceIndex < sourceCount; ++sourceIndex) { - const source = sourceInfo[sourceIndex]; + let dataIndex = 0; + for (let pixelIndex = 0; pixelIndex < pixelCount; ++pixelIndex) { + let transparent = addAlpha; + for (let sourceIndex = 0; sourceIndex < sourceCount; ++sourceIndex) { + const source = sourceInfo[sourceIndex]; - let min = source.min; - let max = source.max; - let gain, bias; - if (normalize) { - const stats = metadata[sourceIndex][0]; - if (min === undefined) { - if (stats && STATISTICS_MINIMUM in stats) { - min = parseFloat(stats[STATISTICS_MINIMUM]); - } else { - min = getMinForDataType(sourceSamples[sourceIndex][0]); - } - } - if (max === undefined) { - if (stats && STATISTICS_MAXIMUM in stats) { - max = parseFloat(stats[STATISTICS_MAXIMUM]); - } else { - max = getMaxForDataType(sourceSamples[sourceIndex][0]); - } - } - - gain = 255 / (max - min); - bias = -min * gain; - } - - for ( - let sampleIndex = 0; - sampleIndex < samplesPerPixel[sourceIndex]; - ++sampleIndex - ) { - const sourceValue = - sourceSamples[sourceIndex][sampleIndex][pixelIndex]; - - let value; + let min = source.min; + let max = source.max; + let gain, bias; if (normalize) { - value = clamp(gain * sourceValue + bias, 0, 255); - } else { - value = sourceValue; + const stats = metadata[sourceIndex][0]; + if (min === undefined) { + if (stats && STATISTICS_MINIMUM in stats) { + min = parseFloat(stats[STATISTICS_MINIMUM]); + } else { + min = getMinForDataType(sourceSamples[sourceIndex][0]); + } + } + if (max === undefined) { + if (stats && STATISTICS_MAXIMUM in stats) { + max = parseFloat(stats[STATISTICS_MAXIMUM]); + } else { + max = getMaxForDataType(sourceSamples[sourceIndex][0]); + } + } + + gain = 255 / (max - min); + bias = -min * gain; } - if (!addAlpha) { - data[dataIndex] = value; - } else { - let nodata = source.nodata; - if (nodata === undefined) { - let bandIndex; - if (source.bands) { - bandIndex = source.bands[sampleIndex] - 1; - } else { - bandIndex = sampleIndex; - } - nodata = nodataValues[sourceIndex][bandIndex]; + for ( + let sampleIndex = 0; + sampleIndex < samplesPerPixel[sourceIndex]; + ++sampleIndex + ) { + const sourceValue = + sourceSamples[sourceIndex][sampleIndex][pixelIndex]; + + let value; + if (normalize) { + value = clamp(gain * sourceValue + bias, 0, 255); + } else { + value = sourceValue; } - if (sourceValue !== nodata) { - transparent = false; + if (!addAlpha) { data[dataIndex] = value; + } else { + let nodata = source.nodata; + if (nodata === undefined) { + let bandIndex; + if (source.bands) { + bandIndex = source.bands[sampleIndex] - 1; + } else { + bandIndex = sampleIndex; + } + nodata = nodataValues[sourceIndex][bandIndex]; + } + + if (sourceValue !== nodata) { + transparent = false; + data[dataIndex] = value; + } } + dataIndex++; + } + } + if (addAlpha) { + if (!transparent) { + data[dataIndex] = 255; } dataIndex++; } } - if (addAlpha) { - if (!transparent) { - data[dataIndex] = 255; - } - dataIndex++; - } - } - return data; - }) - .catch(function (error) { - // output then rethrow - console.error(error); // eslint-disable-line no-console - throw error; - }); + return data; + }) + .catch(function (error) { + // output then rethrow + console.error(error); // eslint-disable-line no-console + throw error; + }); } }