Merge pull request #8230 from m-kuhn/gdalDoNotPersistEstimatedMetadata

Do not persist estimated GDAL metadata
This commit is contained in:
Matthias Kuhn 2018-10-25 10:20:54 +02:00 committed by GitHub
commit 8f4f7f11ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -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
{

View File

@ -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