Skip to content
Permalink
Browse files

Move method to string to QgsGcpTransformerInterface class

  • Loading branch information
nyalldawson committed Feb 21, 2021
1 parent fe8c768 commit 6628d5d27a99316733e3b0961df00992e7120a37
@@ -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 );
@@ -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
//
@@ -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

/**
@@ -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 );
@@ -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 );
}
}
@@ -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 );

@@ -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 );
@@ -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;
@@ -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;
}
@@ -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 )
@@ -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 );

0 comments on commit 6628d5d

Please sign in to comment.