Skip to content

Commit

Permalink
Move method to string to QgsGcpTransformerInterface class
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 21, 2021
1 parent fe8c768 commit 6628d5d
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 30 deletions.
Expand Up @@ -59,6 +59,11 @@ Returns the minimum number of Ground Control Points (GCPs) required for paramete
Returns the transformation method.
%End

static QString methodToString( TransformMethod method );
%Docstring
Returns a translated string representing the specified transform ``method``.
%End


private:
QgsGcpTransformerInterface( const QgsGcpTransformerInterface &other );
Expand Down
25 changes: 25 additions & 0 deletions src/analysis/georeferencing/qgsgcptransformer.cpp
Expand Up @@ -25,6 +25,31 @@
#include <cassert>
#include <limits>


QString QgsGcpTransformerInterface::methodToString( QgsGcpTransformerInterface::TransformMethod method )
{
switch ( method )
{
case QgsGcpTransformerInterface::TransformMethod::Linear:
return QObject::tr( "Linear" );
case QgsGcpTransformerInterface::TransformMethod::Helmert:
return QObject::tr( "Helmert" );
case QgsGcpTransformerInterface::TransformMethod::PolynomialOrder1:
return QObject::tr( "Polynomial 1" );
case QgsGcpTransformerInterface::TransformMethod::PolynomialOrder2:
return QObject::tr( "Polynomial 2" );
case QgsGcpTransformerInterface::TransformMethod::PolynomialOrder3:
return QObject::tr( "Polynomial 3" );
case QgsGcpTransformerInterface::TransformMethod::ThinPlateSpline:
return QObject::tr( "Thin Plate Spline (TPS)" );
case QgsGcpTransformerInterface::TransformMethod::Projective:
return QObject::tr( "Projective" );
default:
return QObject::tr( "Not set" );
}
}


//
// QgsLinearGeorefTransform
//
Expand Down
5 changes: 5 additions & 0 deletions src/analysis/georeferencing/qgsgcptransformer.h
Expand Up @@ -76,6 +76,11 @@ class ANALYSIS_EXPORT QgsGcpTransformerInterface SIP_ABSTRACT
*/
virtual TransformMethod method() const = 0;

/**
* Returns a translated string representing the specified transform \a method.
*/
static QString methodToString( TransformMethod method );

#ifndef SIP_RUN

/**
Expand Down
35 changes: 6 additions & 29 deletions src/app/georeferencer/qgsgeorefmainwindow.cpp
Expand Up @@ -377,7 +377,7 @@ bool QgsGeoreferencerMainWindow::getTransformSettings()

d.getTransformSettings( mTransformParam, mResamplingMethod, mCompressionMethod,
mModifiedRasterFileName, mProjection, mPdfOutputMapFile, mPdfOutputFile, mSaveGcp, mUseZeroForTrans, mLoadInQgis, mUserResX, mUserResY );
mTransformParamLabel->setText( tr( "Transform: " ) + convertTransformEnumToString( mTransformParam ) );
mTransformParamLabel->setText( tr( "Transform: " ) + QgsGcpTransformerInterface::methodToString( mTransformParam ) );
mGeorefTransform.selectTransformParametrisation( mTransformParam );
mGCPListWidget->setGeorefTransform( &mGeorefTransform );
mWorldFileName = guessWorldFileName( mRasterFileName );
Expand Down Expand Up @@ -433,7 +433,7 @@ void QgsGeoreferencerMainWindow::generateGDALScript()
FALLTHROUGH
default:
mMessageBar->pushMessage( tr( "Invalid Transform" ), tr( "GDAL scripting is not supported for %1 transformation." )
.arg( convertTransformEnumToString( mTransformParam ) )
.arg( QgsGcpTransformerInterface::methodToString( mTransformParam ) )
, Qgis::Critical );
}
}
Expand Down Expand Up @@ -1136,7 +1136,7 @@ void QgsGeoreferencerMainWindow::createStatusBar()
statusBar()->addPermanentWidget( mRotationEdit, 0 );

mTransformParamLabel = createBaseLabelStatus();
mTransformParamLabel->setText( tr( "Transform: " ) + convertTransformEnumToString( mTransformParam ) );
mTransformParamLabel->setText( tr( "Transform: " ) + QgsGcpTransformerInterface::methodToString( mTransformParam ) );
mTransformParamLabel->setToolTip( tr( "Current transform parametrisation" ) );
statusBar()->addPermanentWidget( mTransformParamLabel, 0 );

Expand Down Expand Up @@ -1695,7 +1695,7 @@ bool QgsGeoreferencerMainWindow::writePDFReportFile( const QString &fileName, co
QGraphicsRectItem *previousItem = layoutMap;
if ( wldTransform )
{
QString parameterTitle = tr( "Transformation parameters" ) + QStringLiteral( " (" ) + convertTransformEnumToString( transform.transformParametrisation() ) + QStringLiteral( ")" );
QString parameterTitle = tr( "Transformation parameters" ) + QStringLiteral( " (" ) + QgsGcpTransformerInterface::methodToString( transform.transformParametrisation() ) + QStringLiteral( ")" );
parameterLabel = new QgsLayoutItemLabel( &layout );
parameterLabel->setFont( titleFont );
parameterLabel->setText( parameterTitle );
Expand Down Expand Up @@ -1822,7 +1822,7 @@ void QgsGeoreferencerMainWindow::updateTransformParamLabel()
return;
}

QString transformName = convertTransformEnumToString( mGeorefTransform.transformParametrisation() );
QString transformName = QgsGcpTransformerInterface::methodToString( mGeorefTransform.transformParametrisation() );
QString labelString = tr( "Transform: " ) + transformName;

QgsPointXY origin;
Expand Down Expand Up @@ -1979,7 +1979,7 @@ bool QgsGeoreferencerMainWindow::checkReadyGeoref()
if ( mPoints.count() < static_cast<int>( mGeorefTransform.minimumGcpCount() ) )
{
mMessageBar->pushMessage( tr( "Not Enough GCPs" ), tr( "%1 transformation requires at least %2 GCPs. Please define more." )
.arg( convertTransformEnumToString( mTransformParam ) ).arg( mGeorefTransform.minimumGcpCount() )
.arg( QgsGcpTransformerInterface::methodToString( mTransformParam ) ).arg( mGeorefTransform.minimumGcpCount() )
, Qgis::Critical );
return false;
}
Expand Down Expand Up @@ -2061,29 +2061,6 @@ QgsRectangle QgsGeoreferencerMainWindow::transformViewportBoundingBox( const Qgs
return QgsRectangle( minX, minY, maxX, maxY );
}

QString QgsGeoreferencerMainWindow::convertTransformEnumToString( QgsGeorefTransform::TransformMethod transform )
{
switch ( transform )
{
case QgsGcpTransformerInterface::TransformMethod::Linear:
return tr( "Linear" );
case QgsGcpTransformerInterface::TransformMethod::Helmert:
return tr( "Helmert" );
case QgsGcpTransformerInterface::TransformMethod::PolynomialOrder1:
return tr( "Polynomial 1" );
case QgsGcpTransformerInterface::TransformMethod::PolynomialOrder2:
return tr( "Polynomial 2" );
case QgsGcpTransformerInterface::TransformMethod::PolynomialOrder3:
return tr( "Polynomial 3" );
case QgsGcpTransformerInterface::TransformMethod::ThinPlateSpline:
return tr( "Thin plate spline (TPS)" );
case QgsGcpTransformerInterface::TransformMethod::Projective:
return tr( "Projective" );
default:
return tr( "Not set" );
}
}

QString QgsGeoreferencerMainWindow::convertResamplingEnumToString( QgsImageWarper::ResamplingMethod resampling )
{
switch ( resampling )
Expand Down
1 change: 0 additions & 1 deletion src/app/georeferencer/qgsgeorefmainwindow.h
Expand Up @@ -179,7 +179,6 @@ class QgsGeoreferencerMainWindow : public QMainWindow, private Ui::QgsGeorefPlug
bool checkReadyGeoref();
QgsRectangle transformViewportBoundingBox( const QgsRectangle &canvasExtent, QgsGeorefTransform &t,
bool rasterToWorld = true, uint numSamples = 4 );
QString convertTransformEnumToString( QgsGeorefTransform::TransformMethod transform );
QString convertResamplingEnumToString( QgsImageWarper::ResamplingMethod resampling );
int polynomialOrder( QgsGeorefTransform::TransformMethod transform );
QString guessWorldFileName( const QString &rasterFileName );
Expand Down

0 comments on commit 6628d5d

Please sign in to comment.