Skip to content

Commit

Permalink
Raster layer properties : use/save default pyramid resampling method
Browse files Browse the repository at this point in the history
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 a8be64e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
19 changes: 18 additions & 1 deletion src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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
//
Expand All @@ -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 );
Expand Down
9 changes: 5 additions & 4 deletions src/gui/qgsrasterpyramidsoptionswidget.cpp
Expand Up @@ -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" )
Expand All @@ -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() );
Expand Down

0 comments on commit a8be64e

Please sign in to comment.