This is an automated email from the ASF dual-hosted git repository. desruisseaux pushed a commit to branch geoapi-4.0 in repository https://gitbox.apache.org/repos/asf/sis.git
commit 57164cfbe3618094361614ea09c51bfa2ab14833 Author: Martin Desruisseaux <martin.desruisse...@geomatys.com> AuthorDate: Mon Apr 25 16:32:21 2022 +0200 Avoid an exception when the `gridToCRS` is unspecified in a "cloud optimized GeoTIFF" file. --- .../org/apache/sis/storage/geotiff/MultiResolutionImage.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java index 81c04c6c83..8ca1b4d1ba 100644 --- a/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java +++ b/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/MultiResolutionImage.java @@ -146,14 +146,19 @@ final class MultiResolutionImage extends GridResourceWrapper { final GridGeometry geometry = base.getGridGeometry(); final GridExtent fullExtent = geometry.getExtent(); final GridExtent subExtent = image.getExtent(); - final MatrixSIS gridToCRS = MatrixSIS.castOrCopy(geometry.getGridToCRS(PixelInCell.CELL_CENTER) - .derivative(new DirectPositionView.Double(fullExtent.getPointOfInterest()))); final double[] scales = new double[fullExtent.getDimension()]; for (int i=0; i<scales.length; i++) { scales[i] = fullExtent.getSize(i, false) / subExtent.getSize(i, false); } image.initReducedResolution(base, scales); - resolution = gridToCRS.multiply(scales); + if (geometry.isDefined(GridGeometry.GRID_TO_CRS)) { + final MatrixSIS gridToCRS = MatrixSIS.castOrCopy(geometry.getGridToCRS(PixelInCell.CELL_CENTER) + .derivative(new DirectPositionView.Double(fullExtent.getPointOfInterest()))); + resolution = gridToCRS.multiply(scales); + } else { + // Assume an identity transform for the `gridToCRS` of full resolution image. + resolution = scales; + } for (int i=0; i<resolution.length; i++) { resolution[i] = Math.abs(resolution[i]); }