Skip to content
Permalink
Browse files

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.
  • Loading branch information
rouault committed May 27, 2016
1 parent 0ac285d commit a8be64e1f6722426ff9679e6c017efc12839dab7
Showing with 23 additions and 5 deletions.
  1. +18 −1 src/app/qgsrasterlayerproperties.cpp
  2. +5 −4 src/gui/qgsrasterpyramidsoptionswidget.cpp
@@ -183,6 +183,16 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
{
cboResamplingMethod->addItem( method.second, method.first );
}

// keep it in sync with qgsrasterpyramidsoptionwidget.cpp
QString prefix = provider->name() + "/driverOptions/_pyramids/";
QSettings mySettings;
QString defaultMethod = mySettings.value( prefix + "resampling", "AVERAGE" ).toString();
int idx = cboResamplingMethod->findData( defaultMethod );
if ( idx >= 0 )
cboResamplingMethod->setCurrentIndex( idx );


// build pyramid list
QList< QgsRasterPyramid > myPyramidList = provider->buildPyramidList();
QList< QgsRasterPyramid >::iterator myRasterPyramidIterator;
@@ -988,6 +998,13 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
//mark to be pyramided
myPyramidList[myCounterInt].build = myItem->isSelected() || myPyramidList[myCounterInt].exists;
}

// keep it in sync with qgsrasterpyramidsoptionwidget.cpp
QString prefix = provider->name() + "/driverOptions/_pyramids/";
QSettings mySettings;
QString resamplingMethod( cboResamplingMethod->itemData( cboResamplingMethod->currentIndex() ).toString() );
mySettings.setValue( prefix + "resampling", resamplingMethod );

//
// Ask raster layer to build the pyramids
//
@@ -996,7 +1013,7 @@ void QgsRasterLayerProperties::on_buttonBuildPyramids_clicked()
QApplication::setOverrideCursor( Qt::WaitCursor );
QString res = provider->buildPyramids(
myPyramidList,
cboResamplingMethod->itemData( cboResamplingMethod->currentIndex() ).toString(),
resamplingMethod,
( QgsRaster::RasterPyramidsFormat ) cbxPyramidsFormat->currentIndex() );
QApplication::restoreOverrideCursor();
mPyramidProgress->setValue( 0 );
@@ -52,8 +52,8 @@ void QgsRasterPyramidsOptionsWidget::updateUi()
QString prefix = mProvider + "/driverOptions/_pyramids/";
QString tmpStr;

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

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

0 comments on commit a8be64e

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