Skip to content

Commit

Permalink
Avoid null fill in gdal provider if raster covers the whole requested…
Browse files Browse the repository at this point in the history
… extent. Enable raster provider code block which was outcommented in earlier commit
  • Loading branch information
mhugent committed Dec 12, 2012
1 parent 9ae2f59 commit 98351f2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterdataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
19 changes: 11 additions & 8 deletions src/providers/gdal/qgsgdalprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 98351f2

Please sign in to comment.