From afca6449540ceeeeb3d935999a6290a3b04fbc56 Mon Sep 17 00:00:00 2001 From: Martin Dobias Date: Wed, 7 Nov 2018 15:07:46 +0100 Subject: [PATCH] [gdal] Fix raster block output when block extent is outside of valid area This was causing problems in 3D view when raster was used as DEM... terrain tiles were generated also where they should not appear and contained random heights that caused failures of camera center adjustment to terrain. In the areas completely outside of raster's extent the block was being returned with some values uninitialized (instead of having correctly set no-data values) --- src/providers/gdal/qgsgdalprovider.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/providers/gdal/qgsgdalprovider.cpp b/src/providers/gdal/qgsgdalprovider.cpp index 868a09b158f..6ed4b986216 100644 --- a/src/providers/gdal/qgsgdalprovider.cpp +++ b/src/providers/gdal/qgsgdalprovider.cpp @@ -640,6 +640,13 @@ QgsRasterBlock *QgsGdalProvider::block( int bandNo, const QgsRectangle &extent, return block; } + if ( !mExtent.intersects( extent ) ) + { + // the requested extent is completely outside of the raster's extent - nothing to do + block->setIsNoData(); + return block; + } + if ( !mExtent.contains( extent ) ) { QRect subRect = QgsRasterBlock::subRect( extent, width, height, mExtent );