Skip to content
Permalink
Browse files
Avoid null fill in gdal provider if raster covers the whole requested…
… extent. Enable raster provider code block which was outcommented in earlier commit
  • Loading branch information
mhugent committed Dec 12, 2012
1 parent 9ae2f59 commit 98351f2b55a3133e0d5136b04616e4984b12b45b
Showing with 12 additions and 9 deletions.
  1. +1 −1 src/core/raster/qgsrasterdataprovider.cpp
  2. +11 −8 src/providers/gdal/qgsgdalprovider.cpp
@@ -90,7 +90,7 @@ QgsRasterBlock * QgsRasterDataProvider::block( int theBandNo, QgsRectangle cons
tmpYRes = yRes;
}

#if 0 //disable for performance reason
#if 1 //disable for performance reason?
if ( tmpExtent != theExtent ||
tmpXRes > xRes || tmpYRes > yRes )
{
@@ -395,14 +395,17 @@ void QgsGdalProvider::readBlock( int theBandNo, QgsRectangle const & theExtent,

int dataSize = dataTypeSize( theBandNo );

// fill with null values
QByteArray ba = QgsRasterBlock::valueBytes( dataType( theBandNo ), noDataValue( theBandNo ) );
char *nodata = ba.data();
char *block = ( char * ) theBlock;
for ( int i = 0; i < thePixelWidth * thePixelHeight; i++ )
{
memcpy( block, nodata, dataSize );
block += dataSize;
if( !mExtent.contains( theExtent ) )
{
// fill with null values
QByteArray ba = QgsRasterBlock::valueBytes( dataType( theBandNo ), noDataValue( theBandNo ) );
char *nodata = ba.data();
char *block = ( char * ) theBlock;
for ( int i = 0; i < thePixelWidth * thePixelHeight; i++ )
{
memcpy( block, nodata, dataSize );
block += dataSize;
}
}

QgsRectangle myRasterExtent = theExtent.intersect( &mExtent );

0 comments on commit 98351f2

Please sign in to comment.