Skip to content
Permalink
Browse files

Merge pull request #8230 from m-kuhn/gdalDoNotPersistEstimatedMetadata

Do not persist estimated GDAL metadata
  • Loading branch information
m-kuhn committed Oct 25, 2018
2 parents d6a2cbf + 70d4a27 commit 8f4f7f11ac715c5a3abc171dbae0c7420b38ca94
Showing with 11 additions and 0 deletions.
  1. +9 −0 src/providers/gdal/qgsgdalprovider.cpp
  2. +2 −0 src/providers/gdal/qgsgdalprovider.h
@@ -470,7 +470,15 @@ QgsGdalProvider::~QgsGdalProvider()
}
if ( mGdalDataset )
{
// Check if already a PAM (persistent auxiliary metadata) file exists
QString pamFile = dataSourceUri( true ) + QLatin1String( ".aux.xml" );
bool pamFileAlreadyExists = QFileInfo( pamFile ).exists();

GDALClose( mGdalDataset );

// If GDAL created a PAM file right now by using estimated metadata, delete it right away
if ( !mStatisticsAreReliable && !pamFileAlreadyExists && QFileInfo( pamFile ).exists() )
QFile( pamFile ).remove();
}

if ( mpParent && *mpParent == this )
@@ -2468,6 +2476,7 @@ QgsRasterBandStats QgsGdalProvider::bandStatistics( int bandNo, int stats, const
myerval = GDALComputeRasterStatistics( myGdalBand, bApproxOK,
&pdfMin, &pdfMax, &pdfMean, &pdfStdDev,
progressCallback, &myProg );
mStatisticsAreReliable = true;
}
else
{
@@ -296,6 +296,8 @@ class QgsGdalProvider : public QgsRasterDataProvider, QgsGdalProviderBase
* Converts a world (\a x, \a y) coordinate to a pixel \a row and \a col.
*/
bool worldToPixel( double x, double y, int &col, int &row ) const;

bool mStatisticsAreReliable = false;
};

#endif

0 comments on commit 8f4f7f1

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