Skip to content
Permalink
Browse files

fixed gdal stats approx for large rasters

  • Loading branch information
blazek committed Jul 29, 2012
1 parent eac8bc8 commit 98853419c99baa310f16666772e5db49ce023bf2
Showing with 7 additions and 3 deletions.
  1. +7 −3 src/providers/gdal/qgsgdalprovider.cpp
@@ -1356,12 +1356,16 @@ QgsRasterHistogram QgsGdalProvider::histogram( int theBandNo,
int bApproxOK = false;
if ( theSampleSize > 0 )
{
if (( xSize() * ySize() / theSampleSize ) > 2 ) // not perfect
// cast to double, integer could overflow
if ((( double )xSize() * ( double )ySize() / theSampleSize ) > 2 ) // not perfect
{
QgsDebugMsg( "Approx" );
bApproxOK = true;
}
}

QgsDebugMsg( QString( "xSize() = %1 ySize() = %2 theSampleSize = %3 bApproxOK = %4" ).arg( xSize() ).arg( ySize() ).arg( theSampleSize ).arg( bApproxOK ) );

QgsGdalProgress myProg;
myProg.type = ProgressHistogram;
myProg.provider = this;
@@ -2042,7 +2046,7 @@ bool QgsGdalProvider::hasStatistics( int theBandNo,
int bApproxOK = false;
if ( theSampleSize > 0 )
{
if (( xSize() * ySize() / theSampleSize ) > 2 ) // not perfect
if ((( double )xSize() * ( double )ySize() / theSampleSize ) > 2 ) // not perfect
{
bApproxOK = true;
}
@@ -2119,7 +2123,7 @@ QgsRasterBandStats QgsGdalProvider::bandStatistics( int theBandNo, int theStats,
int bApproxOK = false;
if ( theSampleSize > 0 )
{
if (( xSize() * ySize() / theSampleSize ) > 2 ) // not perfect
if ((( double )xSize() * ( double )ySize() / theSampleSize ) > 2 ) // not perfect
{
bApproxOK = true;
}

0 comments on commit 9885341

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