diff --git a/src/app/georeferencer/qgsgeorefmainwindow.cpp b/src/app/georeferencer/qgsgeorefmainwindow.cpp index a897b8d0f8a9..db5a0c58e659 100644 --- a/src/app/georeferencer/qgsgeorefmainwindow.cpp +++ b/src/app/georeferencer/qgsgeorefmainwindow.cpp @@ -189,6 +189,7 @@ void QgsGeoreferencerMainWindow::reset() { mRasterFileName.clear(); mModifiedRasterFileName.clear(); + mCreateWorldFileOnly = false; setWindowTitle( tr( "Georeferencer" ) ); //delete old points @@ -237,6 +238,7 @@ void QgsGeoreferencerMainWindow::openRaster( const QString &fileName ) mRasterFileName = fileName; } mModifiedRasterFileName.clear(); + mCreateWorldFileOnly = false; QString errMsg; if ( !QgsRasterLayer::isValidRasterFileName( mRasterFileName, errMsg ) ) @@ -337,7 +339,7 @@ void QgsGeoreferencerMainWindow::doGeoreference() mMessageBar->pushMessage( tr( "Georeference Successful" ), tr( "Raster was successfully georeferenced." ), Qgis::MessageLevel::Success ); if ( mLoadInQgis ) { - if ( mModifiedRasterFileName.isEmpty() ) + if ( mCreateWorldFileOnly ) { QgisApp::instance()->addRasterLayer( mRasterFileName, QFileInfo( mRasterFileName ).completeBaseName(), QString() ); } @@ -353,6 +355,7 @@ bool QgsGeoreferencerMainWindow::getTransformSettings() { QgsTransformSettingsDialog d( mRasterFileName, mModifiedRasterFileName ); d.setTargetCrs( mTargetCrs ); + d.setCreateWorldFileOnly( mCreateWorldFileOnly ); if ( !d.exec() ) { return false; @@ -360,6 +363,7 @@ bool QgsGeoreferencerMainWindow::getTransformSettings() d.getTransformSettings( mTransformParam, mResamplingMethod, mCompressionMethod, mModifiedRasterFileName, mPdfOutputMapFile, mPdfOutputFile, mSaveGcp, mUseZeroForTrans, mLoadInQgis, mUserResX, mUserResY ); + mCreateWorldFileOnly = d.createWorldFileOnly(); mTargetCrs = d.targetCrs(); mTransformParamLabel->setText( tr( "Transform: " ) + QgsGcpTransformerInterface::methodToString( mTransformParam ) ); @@ -1269,8 +1273,8 @@ bool QgsGeoreferencerMainWindow::georeference() if ( !checkReadyGeoref() ) return false; - if ( mModifiedRasterFileName.isEmpty() && ( QgsGcpTransformerInterface::TransformMethod::Linear == mGeorefTransform.transformParametrisation() || - QgsGcpTransformerInterface::TransformMethod::Helmert == mGeorefTransform.transformParametrisation() ) ) + if ( mCreateWorldFileOnly && ( QgsGcpTransformerInterface::TransformMethod::Linear == mGeorefTransform.transformParametrisation() || + QgsGcpTransformerInterface::TransformMethod::Helmert == mGeorefTransform.transformParametrisation() ) ) { QgsPointXY origin; double pixelXSize, pixelYSize, rotation; @@ -1316,7 +1320,7 @@ bool QgsGeoreferencerMainWindow::georeference() } return true; } - else // Helmert, Polinom 1, Polinom 2, Polinom 3 + else { QgsImageWarper warper( this ); int res = warper.warpFile( mRasterFileName, mModifiedRasterFileName, mGeorefTransform, @@ -1867,8 +1871,8 @@ bool QgsGeoreferencerMainWindow::checkReadyGeoref() return false; } - //MH: helmert transformation without warping disabled until qgis is able to read rotated rasters efficiently - if ( mModifiedRasterFileName.isEmpty() && QgsGcpTransformerInterface::TransformMethod::Linear != mTransformParam /*&& QgsGeorefTransform::Helmert != mTransformParam*/ ) + if ( mCreateWorldFileOnly + && ( QgsGcpTransformerInterface::TransformMethod::Linear != mTransformParam && QgsGcpTransformerInterface::TransformMethod::Helmert != mTransformParam ) ) { QMessageBox::information( this, tr( "Georeferencer" ), tr( "Please set output raster name." ) ); getTransformSettings(); diff --git a/src/app/georeferencer/qgsgeorefmainwindow.h b/src/app/georeferencer/qgsgeorefmainwindow.h index 6c8b1171fb87..83737e7a0273 100644 --- a/src/app/georeferencer/qgsgeorefmainwindow.h +++ b/src/app/georeferencer/qgsgeorefmainwindow.h @@ -244,6 +244,7 @@ class QgsGeoreferencerMainWindow : public QMainWindow, private Ui::QgsGeorefPlug QgsImageWarper::ResamplingMethod mResamplingMethod; QgsGeorefTransform mGeorefTransform; QString mCompressionMethod; + bool mCreateWorldFileOnly = false; QgsGCPList mPoints; QList< QgsGcpPoint > mSavedPoints; diff --git a/src/app/georeferencer/qgstransformsettingsdialog.cpp b/src/app/georeferencer/qgstransformsettingsdialog.cpp index 0412ebfd65b1..9ae8c263ae71 100644 --- a/src/app/georeferencer/qgstransformsettingsdialog.cpp +++ b/src/app/georeferencer/qgstransformsettingsdialog.cpp @@ -104,8 +104,6 @@ QgsTransformSettingsDialog::QgsTransformSettingsDialog( const QString &raster, c cmbResampling->setCurrentIndex( settings.value( QStringLiteral( "/Plugin-GeoReferencer/lastresampling" ), 0 ).toInt() ); cmbCompressionComboBox->setCurrentIndex( settings.value( QStringLiteral( "/Plugin-GeoReferencer/lastcompression" ), 0 ).toInt() ); - mWorldFileCheckBox->setChecked( settings.value( QStringLiteral( "/Plugin-Georeferencer/word_file_checkbox" ), false ).toBool() ); - cbxUserResolution->setChecked( settings.value( QStringLiteral( "/Plugin-Georeferencer/user_specified_resolution" ), false ).toBool() ); bool ok; dsbHorizRes->setValue( settings.value( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resx" ), .0 ).toDouble( &ok ) ); @@ -132,6 +130,17 @@ QgsCoordinateReferenceSystem QgsTransformSettingsDialog::targetCrs() const return mCrsSelector->crs(); } +bool QgsTransformSettingsDialog::createWorldFileOnly() const +{ + return mWorldFileCheckBox->isChecked(); +} + +void QgsTransformSettingsDialog::setCreateWorldFileOnly( bool enabled ) +{ + mWorldFileCheckBox->setChecked( enabled ); + mWorldFileCheckBox_stateChanged( mWorldFileCheckBox->checkState() ); +} + void QgsTransformSettingsDialog::getTransformSettings( QgsGeorefTransform::TransformMethod &tp, QgsImageWarper::ResamplingMethod &rm, QString &comprMethod, QString &raster, QString &pdfMapFile, QString &pdfReportFile, bool &saveGcpPoints, bool &zt, bool &loadInQgis, @@ -144,14 +153,8 @@ void QgsTransformSettingsDialog::getTransformSettings( QgsGeorefTransform::Trans rm = static_cast< QgsImageWarper::ResamplingMethod >( cmbResampling->currentData().toInt() ); comprMethod = cmbCompressionComboBox->currentData().toString(); - if ( mWorldFileCheckBox->isChecked() ) - { - raster.clear(); - } - else - { - raster = mOutputRaster->filePath(); - } + raster = mOutputRaster->filePath(); + pdfMapFile = mPdfMap->filePath(); pdfReportFile = mPdfReport->filePath(); zt = cbxZeroAsTrans->isChecked(); @@ -166,23 +169,6 @@ void QgsTransformSettingsDialog::getTransformSettings( QgsGeorefTransform::Trans saveGcpPoints = saveGcpCheckBox->isChecked(); } -void QgsTransformSettingsDialog::resetSettings() -{ - QgsSettings s; - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/lasttransformation" ), -1 ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/lastresampling" ), 0 ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/lastcompression" ), 0 ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/targetsrs" ), QString() ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/zeroastrans" ), false ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/loadinqgis" ), false ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/save_gcp_points" ), false ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resolution" ), false ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resx" ), 1.0 ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resy" ), -1.0 ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/word_file_checkbox" ), false ); - s.setValue( QStringLiteral( "/Plugin-GeoReferencer/lastPDFReportDir" ), QDir::homePath() ); -} - void QgsTransformSettingsDialog::accept() { if ( !mOutputRaster->filePath().isEmpty() ) @@ -216,10 +202,8 @@ void QgsTransformSettingsDialog::accept() settings.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resolution" ), cbxUserResolution->isChecked() ); settings.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resx" ), dsbHorizRes->value() ); settings.setValue( QStringLiteral( "/Plugin-GeoReferencer/user_specified_resy" ), dsbVerticalRes->value() ); - settings.setValue( QStringLiteral( "/Plugin-GeoReferencer/word_file_checkbox" ), mWorldFileCheckBox->isChecked() ); settings.setValue( QStringLiteral( "/Plugin-GeoReferencer/save_gcp_points" ), saveGcpCheckBox->isChecked() ); - QDialog::accept(); } diff --git a/src/app/georeferencer/qgstransformsettingsdialog.h b/src/app/georeferencer/qgstransformsettingsdialog.h index 4407590d74c2..13e0132006e4 100644 --- a/src/app/georeferencer/qgstransformsettingsdialog.h +++ b/src/app/georeferencer/qgstransformsettingsdialog.h @@ -39,11 +39,20 @@ class QgsTransformSettingsDialog : public QDialog, private Ui::QgsTransformSetti */ QgsCoordinateReferenceSystem targetCrs() const; + /** + * Returns TRUE if the create world file only option is set. + */ + bool createWorldFileOnly() const; + + /** + * Sets whether the create world file only option should be set. + */ + void setCreateWorldFileOnly( bool enabled ); + void getTransformSettings( QgsGeorefTransform::TransformMethod &tp, QgsImageWarper::ResamplingMethod &rm, QString &comprMethod, QString &raster, QString &pdfMapFile, QString &pdfReportFile, bool &saveGcpPoints, bool &zt, bool &loadInQgis, double &resX, double &resY ); - static void resetSettings(); protected: void accept() override;