Skip to content
Permalink
Browse files

raster no data speed up

  • Loading branch information
blazek committed Apr 13, 2013
1 parent 7d425bf commit 5280e212ecd9a6967c7b9621702ef003b62dd550
@@ -269,6 +269,11 @@ QGis::DataType QgsRasterBlock::typeWithNoDataValue( QGis::DataType dataType, dou
return newDataType;
}

bool QgsRasterBlock::hasNoData() const
{
return mHasNoDataValue || mNoDataBitmap != 0;
}

bool QgsRasterBlock::isNoDataValue( double value, double noDataValue )
{
// More precise would be qIsNaN(value) && qIsNaN(noDataValue(bandNo)), but probably
@@ -302,6 +307,7 @@ QRgb QgsRasterBlock::color( int row, int column ) const

bool QgsRasterBlock::isNoData( size_t index )
{
if ( !mHasNoDataValue && !mNoDataBitmap ) return false;
if ( index >= ( size_t )mWidth*mHeight )
{
QgsDebugMsg( QString( "Index %1 out of range (%2 x %3)" ).arg( index ).arg( mWidth ).arg( mHeight ) );
@@ -662,7 +668,7 @@ bool QgsRasterBlock::convert( QGis::DataType destDataType )
return true;
}

void QgsRasterBlock::applyNodataValues( const QgsRasterRangeList & rangeList )
void QgsRasterBlock::applyNoDataValues( const QgsRasterRangeList & rangeList )
{
if ( rangeList.isEmpty() )
{
@@ -144,6 +144,12 @@ class CORE_EXPORT QgsRasterBlock
* @return true if the block has no data value */
bool hasNoDataValue() const { return mHasNoDataValue; }

/** Returns true if thee block may contain no data. It does not guarantee
* that it really contains any no data. It can be used to speed up processing.
* Not the difference between this method and hasNoDataValue().
* @return true if the block may contain no data */
bool hasNoData() const;

/** Return no data value.
* @return No data value */
double noDataValue() const { return mNoDataValue; }
@@ -292,7 +298,7 @@ class CORE_EXPORT QgsRasterBlock

inline static void writeValue( void *data, QGis::DataType type, size_t index, double value );

void applyNodataValues( const QgsRasterRangeList & rangeList );
void applyNoDataValues( const QgsRasterRangeList & rangeList );

/** \brief Get error */
QgsError error() const { return mError; }
@@ -233,7 +233,7 @@ QgsRasterBlock * QgsRasterDataProvider::block( int theBandNo, QgsRectangle cons

// apply user no data values
// TODO: there are other readBlock methods where no data are not applied
block->applyNodataValues( userNoDataValue( theBandNo ) );
block->applyNoDataValues( userNoDataValue( theBandNo ) );
return block;
}

@@ -386,7 +386,7 @@ QgsRasterBlock* QgsGdalProvider::block( int theBandNo, const QgsRectangle &theEx
block->setIsNoDataExcept( subRect );
}
readBlock( theBandNo, theExtent, theWidth, theHeight, block->data() );
block->applyNodataValues( userNoDataValue( theBandNo ) );
block->applyNoDataValues( userNoDataValue( theBandNo ) );
return block;
}

0 comments on commit 5280e21

Please sign in to comment.
You can’t perform that action at this time.