Skip to content

Commit a8be64e

Browse files
committed
Raster layer properties : use/save default pyramid resampling method
Currently when you build raster pyramids from the Pyramids tab in raster layer properties, the default method proposed is the first one in the combobox, i.e. nearest neighbour. This is generally a poor choice for quality. This changeset uses the settings gdal/driverOptions/_pyramids/resampling already used by the Options dialog to select the resampling method (and AVERAGE if not yet defined), and it saves the user choice when generating them.
1 parent 0ac285d commit a8be64e

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

src/app/qgsrasterlayerproperties.cpp

+18-1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,16 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
183183
{
184184
cboResamplingMethod->addItem( method.second, method.first );
185185
}
186+
187+
// keep it in sync with qgsrasterpyramidsoptionwidget.cpp
188+
QString prefix = provider->name() + "/driverOptions/_pyramids/";
189+
QSettings mySettings;
190+
QString defaultMethod = mySettings.value( prefix + "resampling", "AVERAGE" ).toString();
191+
int idx = cboResamplingMethod->findData( defaultMethod );
192+
if ( idx >= 0 )
193+
cboResamplingMethod->setCurrentIndex( idx );
194+
195+
186196
// build pyramid list
187197
QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList();
188198
QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;
@@ -988,6 +998,13 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
988998
//mark to be pyramided
989999
myPyramidList[myCounterInt].build = myItem->isSelected() || myPyramidList[myCounterInt].exists;
9901000
}
1001+
1002+
// keep it in sync with qgsrasterpyramidsoptionwidget.cpp
1003+
QString prefix = provider->name() + "/driverOptions/_pyramids/";
1004+
QSettings mySettings;
1005+
QString resamplingMethod( cboResamplingMethod->itemData( cboResamplingMethod->currentIndex() ).toString() );
1006+
mySettings.setValue( prefix + "resampling", resamplingMethod );
1007+
9911008
//
9921009
// Ask raster layer to build the pyramids
9931010
//
@@ -996,7 +1013,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
9961013
QApplication::setOverrideCursor( Qt::WaitCursor );
9971014
QString res = provider->buildPyramids(
9981015
myPyramidList,
999-
cboResamplingMethod->itemData( cboResamplingMethod->currentIndex() ).toString(),
1016+
resamplingMethod,
10001017
( QgsRaster::RasterPyramidsFormat ) cbxPyramidsFormat->currentIndex() );
10011018
QApplication::restoreOverrideCursor();
10021019
mPyramidProgress->setValue( 0 );

src/gui/qgsrasterpyramidsoptionswidget.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ void QgsRasterPyramidsOptionsWidget::updateUi()
5252
QString prefix = mProvider + "/driverOptions/_pyramids/";
5353
QString tmpStr;
5454

55-
// cbxPyramidsInternal->setChecked( mySettings.value( prefix + "internal", false ).toBool() );
56-
tmpStr = mySettings.value( prefix + "format", "gtiff" ).toString();
55+
// keep it in sync with qgsrasterlayerproperties.cpp
56+
tmpStr = mySettings.value( prefix + "format", "external" ).toString();
5757
if ( tmpStr == "internal" )
5858
cbxPyramidsFormat->setCurrentIndex( 1 );
5959
else if ( tmpStr == "external_erdas" )
@@ -68,8 +68,9 @@ void QgsRasterPyramidsOptionsWidget::updateUi()
6868
{
6969
cboResamplingMethod->addItem( method.second, method.first );
7070
}
71-
cboResamplingMethod->setCurrentIndex( cboResamplingMethod->findData(
72-
mySettings.value( prefix + "resampling", "AVERAGE" ).toString() ) );
71+
QString defaultMethod = mySettings.value( prefix + "resampling", "AVERAGE" ).toString();
72+
int idx = cboResamplingMethod->findData( defaultMethod );
73+
cboResamplingMethod->setCurrentIndex( idx );
7374

7475
// validate string, only space-separated positive integers are allowed
7576
lePyramidsLevels->setEnabled( cbxPyramidsLevelsCustom->isChecked() );

0 commit comments

Comments
 (0)