Skip to content

Commit

Permalink
Include coordinate epoch in crs description strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed May 10, 2021
1 parent 299c81d commit 9b42dc0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/core/proj/qgscoordinatereferencesystem.cpp
Expand Up @@ -1101,25 +1101,29 @@ QString QgsCoordinateReferenceSystem::description() const

QString QgsCoordinateReferenceSystem::userFriendlyIdentifier( IdentifierType type ) const
{
QString id;
if ( !authid().isEmpty() )
{
if ( type != ShortString && !description().isEmpty() )
return QStringLiteral( "%1 - %2" ).arg( authid(), description() );
return authid();
id = QStringLiteral( "%1 - %2" ).arg( authid(), description() );
else
id = authid();
}
else if ( !description().isEmpty() )
return description();
id = description();
else if ( type == ShortString )
return isValid() ? QObject::tr( "Custom CRS" ) : QObject::tr( "Unknown CRS" );
id = isValid() ? QObject::tr( "Custom CRS" ) : QObject::tr( "Unknown CRS" );
else if ( !toWkt( WKT_PREFERRED ).isEmpty() )
return QObject::tr( "Custom CRS: %1" ).arg(
type == MediumString ? ( toWkt( WKT_PREFERRED ).left( 50 ) + QString( QChar( 0x2026 ) ) )
: toWkt( WKT_PREFERRED ) );
id = QObject::tr( "Custom CRS: %1" ).arg(
type == MediumString ? ( toWkt( WKT_PREFERRED ).left( 50 ) + QString( QChar( 0x2026 ) ) )
: toWkt( WKT_PREFERRED ) );
else if ( !toProj().isEmpty() )
return QObject::tr( "Custom CRS: %1" ).arg( type == MediumString ? ( toProj().left( 50 ) + QString( QChar( 0x2026 ) ) )
: toProj() );
else
return QString();
id = QObject::tr( "Custom CRS: %1" ).arg( type == MediumString ? ( toProj().left( 50 ) + QString( QChar( 0x2026 ) ) )
: toProj() );
if ( !id.isEmpty() && !std::isnan( d->mCoordinateEpoch ) )
id += QStringLiteral( " (%1)" ).arg( d->mCoordinateEpoch );

return id;
}

QString QgsCoordinateReferenceSystem::projectionAcronym() const
Expand Down
2 changes: 2 additions & 0 deletions tests/src/core/testqgscoordinatereferencesystem.cpp
Expand Up @@ -1707,6 +1707,8 @@ void TestQgsCoordinateReferenceSystem::displayIdentifier()
QCOMPARE( crs.userFriendlyIdentifier( QgsCoordinateReferenceSystem::ShortString ), QStringLiteral( "Unknown CRS" ) );
crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) );
QCOMPARE( crs.userFriendlyIdentifier(), QStringLiteral( "EPSG:4326 - WGS 84" ) );
crs.setCoordinateEpoch( 2021.3 );
QCOMPARE( crs.userFriendlyIdentifier(), QStringLiteral( "EPSG:4326 - WGS 84 (2021.3)" ) );
crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) );
QCOMPARE( crs.userFriendlyIdentifier(), QStringLiteral( "EPSG:3111 - GDA94 / Vicgrid" ) );
crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) );
Expand Down

0 comments on commit 9b42dc0

Please sign in to comment.