Skip to content

Commit

Permalink
Show a more helpful message when a custom projection based on WKT
Browse files Browse the repository at this point in the history
is equivalent to a known projection
  • Loading branch information
nyalldawson committed Feb 25, 2020
1 parent 64ececf commit b40d9c4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/app/qgscustomprojectiondialog.cpp
Expand Up @@ -481,12 +481,26 @@ void QgsCustomProjectionDialog::buttonBox_accepted()
if ( def.wkt.isEmpty() )
{
QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ),
tr( "Cannot save '%1' — this Proj string definition is identical to %2.\n\nTry changing the CRS definition to a WKT format instead." ).arg( def.name, crs.authid() ) );
tr( "Cannot save '%1' — this Proj string definition is equivalent to %2.\n\nTry changing the CRS definition to a WKT format instead." ).arg( def.name, crs.authid() ) );
}
else
{
QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ),
tr( "Cannot save '%1' — the definition is identical to %2." ).arg( def.name, crs.authid() ) );
const QStringList authparts = crs.authid().split( ':' );
QString ref;
if ( authparts.size() == 2 )
{
ref = QStringLiteral( "ID[\"%1\",%2]" ).arg( authparts.at( 0 ), authparts.at( 1 ) );
}
if ( !ref.isEmpty() && crs.toWkt( QgsCoordinateReferenceSystem::WKT2_2018 ).contains( ref ) )
{
QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ),
tr( "Cannot save '%1' — the definition is equivalent to %2.\n\n(Try removing \"%3\" from the WKT definition.)" ).arg( def.name, crs.authid(), ref ) );
}
else
{
QMessageBox::warning( this, tr( "Custom Coordinate Reference System" ),
tr( "Cannot save '%1' — the definition is equivalent to %2." ).arg( def.name, crs.authid() ) );
}
}
return;
}
Expand Down

0 comments on commit b40d9c4

Please sign in to comment.