From fce42dc80f0815b454773ff591e61b9e342bacd7 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Mon, 6 Sep 2021 15:26:19 -0600 Subject: [PATCH] Check for crs starting with last image --- src/ol/source/GeoTIFF.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/ol/source/GeoTIFF.js b/src/ol/source/GeoTIFF.js index 6570e9e91a..515978ea42 100644 --- a/src/ol/source/GeoTIFF.js +++ b/src/ol/source/GeoTIFF.js @@ -357,13 +357,17 @@ class GeoTIFFSource extends DataTile { } if (!this.getProjection()) { - const firstImage = sources[0][0]; - if (firstImage.geoKeys) { - const code = - firstImage.geoKeys.ProjectedCSTypeGeoKey || - firstImage.geoKeys.GeographicTypeGeoKey; - if (code) { - this.projection = getProjection(`EPSG:${code}`); + const firstSource = sources[0]; + for (let i = firstSource.length - 1; i >= 0; --i) { + const image = firstSource[i]; + if (image.geoKeys) { + const code = + image.geoKeys.ProjectedCSTypeGeoKey || + image.geoKeys.GeographicTypeGeoKey; + if (code) { + this.projection = getProjection(`EPSG:${code}`); + break; + } } } }