Skip to content
Permalink
Browse files
Compute min/max on demand in gdal provider
  • Loading branch information
mhugent committed Feb 19, 2013
1 parent 2a2465e commit 4d868886d07eefd0aa11f982c13763c472072ed0
Showing with 16 additions and 6 deletions.
  1. +12 −2 src/providers/gdal/qgsgdalprovider.cpp
  2. +4 −4 src/providers/gdal/qgsgdalprovider.h
@@ -787,7 +787,7 @@ double QgsGdalProvider::noDataValue() const
}
#endif

void QgsGdalProvider::computeMinMax( int theBandNo )
void QgsGdalProvider::computeMinMax( int theBandNo ) const
{
QgsDebugMsg( QString( "theBandNo = %1 mMinMaxComputed = %2" ).arg( theBandNo ).arg( mMinMaxComputed[theBandNo-1] ) );
if ( mMinMaxComputed[theBandNo-1] )
@@ -810,11 +810,22 @@ void QgsGdalProvider::computeMinMax( int theBandNo )
double QgsGdalProvider::minimumValue( int theBandNo ) const
{
QgsDebugMsg( QString( "theBandNo = %1" ).arg( theBandNo ) );
if ( !mMinMaxComputed[theBandNo-1] )
{
computeMinMax( theBandNo );
mMinMaxComputed[theBandNo-1] = true;
}
return mMinimum[theBandNo-1];
}
double QgsGdalProvider::maximumValue( int theBandNo ) const
{
QgsDebugMsg( QString( "theBandNo = %1" ).arg( theBandNo ) );
if ( !mMinMaxComputed[theBandNo-1] )
{
computeMinMax( theBandNo );
mMinMaxComputed[theBandNo-1] = true;
}
computeMinMax( theBandNo );
return mMaximum[theBandNo-1];
}

@@ -2341,7 +2352,6 @@ void QgsGdalProvider::initBaseDataset()
//mValidNoDataValue = true;
for ( int i = 1; i <= GDALGetRasterCount( mGdalBaseDataset ); i++ )
{
computeMinMax( i );
GDALRasterBandH myGdalBand = GDALGetRasterBand( mGdalDataset, i );
GDALDataType myGdalDataType = GDALGetRasterDataType( myGdalBand );

@@ -179,7 +179,7 @@ class QgsGdalProvider : public QgsRasterDataProvider, QgsGdalProviderBase

//bool srcHasNoDataValue( int bandNo ) const;
//double noDataValue() const;
void computeMinMax( int bandNo );
void computeMinMax( int bandNo ) const;
double minimumValue( int bandNo ) const;
double maximumValue( int bandNo ) const;

@@ -294,13 +294,13 @@ class QgsGdalProvider : public QgsRasterDataProvider, QgsGdalProviderBase
int mXBlockSize;
int mYBlockSize;

QList<bool> mMinMaxComputed;
mutable QList<bool> mMinMaxComputed;

// List of estimated min values, index 0 for band 1
QList<double> mMinimum;
mutable QList<double> mMinimum;

// List of estimated max values, index 0 for band 1
QList<double> mMaximum;
mutable QList<double> mMaximum;

/** \brief Pointer to the gdaldataset */
GDALDatasetH mGdalBaseDataset;

0 comments on commit 4d86888

Please sign in to comment.