Skip to content

Commit

Permalink
Remove very old workaround for a closed GDAL ticket preventing
Browse files Browse the repository at this point in the history
use of existing GDAL raster band statistics
  • Loading branch information
nyalldawson authored and github-actions[bot] committed Dec 15, 2022
1 parent eedf0d7 commit 36e49d4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/core/providers/gdal/qgsgdalprovider.cpp
Expand Up @@ -2844,17 +2844,13 @@ QgsRasterBandStats QgsGdalProvider::bandStatistics( int bandNo, int stats, const
myProg.feedback = feedback;

// try to fetch the cached stats (bForce=FALSE)
// GDALGetRasterStatistics() do not work correctly with bApproxOK=false and bForce=false/true
// see above and https://trac.osgeo.org/gdal/ticket/4857
// -> Cannot used cached GDAL stats for exact

CPLErr myerval =
GDALGetRasterStatistics( myGdalBand, bApproxOK, true, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev );
GDALGetRasterStatistics( myGdalBand, bApproxOK, false, &pdfMin, &pdfMax, &pdfMean, &pdfStdDev );

QgsDebugMsgLevel( QStringLiteral( "myerval = %1" ).arg( myerval ), 2 );

// if cached stats are not found, compute them
if ( !bApproxOK || CE_None != myerval )
if ( CE_None != myerval )
{
QgsDebugMsgLevel( QStringLiteral( "Calculating statistics by GDAL" ), 2 );
myerval = GDALComputeRasterStatistics( myGdalBand, bApproxOK,
Expand Down

0 comments on commit 36e49d4

Please sign in to comment.