Skip to content
Permalink
Browse files

faster grass raster nodata

  • Loading branch information
blazek committed Aug 23, 2012
1 parent 4ae7b52 commit 8015c12acd8a110eeb855bd106d45c26e8b4c5a6
Showing with 32 additions and 30 deletions.
  1. +30 −30 src/providers/grass/qgsgrassrasterprovider.cpp
  2. +2 −0 src/providers/grass/qgsgrassrasterprovider.h
@@ -90,6 +90,35 @@ QgsGrassRasterProvider::QgsGrassRasterProvider( QString const & uri )
mGrassDataType = mInfo["TYPE"].toInt();
QgsDebugMsg( "mGrassDataType = " + QString::number( mGrassDataType ) );

// TODO: avoid showing these strange numbers in GUI
// TODO: don't save no data values in project file, add a flag if value was defined by user
if ( mGrassDataType == CELL_TYPE )
{
//limit: -2147483647;
mNoDataValue = -2000000000;
}
else if ( mGrassDataType == DCELL_TYPE )
{
// Don't use numeric limits, raster layer is using
// qAbs( myValue - mNoDataValue ) <= TINY_VALUE
// if the mNoDataValue would be a limit, the subtraction could overflow.
// No data value is shown in GUI, use some nice number.
// Choose values with small representation error.
// limit: 1.7976931348623157e+308
mNoDataValue = -1e+300;
}
else
{
if ( mGrassDataType != FCELL_TYPE )
{
QgsDebugMsg( "unexpected data type" );
}

// limit: 3.40282347e+38
mNoDataValue = -1e+30;
}
QgsDebugMsg( QString( "mNoDataValue = %1" ).arg( mNoDataValue ) );

// TODO: refresh mRows and mCols if raster was rewritten
// We have to decide some reasonable block size, not to big to occupate too much
// memory, not too small to result in too many calls to readBlock -> qgis.d.rast
@@ -258,36 +287,7 @@ void QgsGrassRasterProvider::readBlock( int bandNo, QgsRectangle const & viewEx

double QgsGrassRasterProvider::noDataValue() const
{
double nul;
// TODO: avoid showing these strange numbers in GUI
// TODO: don't save no data values in project file, add a flag if value was defined by user
if ( mGrassDataType == CELL_TYPE )
{
//limit: -2147483647;
nul = -2000000000;
}
else if ( mGrassDataType == DCELL_TYPE )
{
// Don't use numeric limits, raster layer is using
// qAbs( myValue - mNoDataValue ) <= TINY_VALUE
// if the mNoDataValue would be a limit, the subtraction could overflow.
// No data value is shown in GUI, use some nice number.
// Choose values with small representation error.
// limit: 1.7976931348623157e+308
nul = -1e+300;
}
else
{
if ( mGrassDataType != FCELL_TYPE )
{
QgsDebugMsg( "unexpected data type" );
}

// limit: 3.40282347e+38
nul = -1e+30;
}
QgsDebugMsg( QString( "noDataValue = %1" ).arg( nul ) );
return nul;
return mNoDataValue;
}

double QgsGrassRasterProvider::minimumValue( int bandNo ) const
@@ -256,6 +256,8 @@ class QgsGrassRasterProvider : public QgsRasterDataProvider
QgsCoordinateReferenceSystem mCrs;

QgsGrassRasterValue mRasterValue;

double mNoDataValue;
};

#endif

0 comments on commit 8015c12

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