Skip to content

Commit 9b42dc0

Browse files
committedMay 10, 2021
Include coordinate epoch in crs description strings
1 parent 299c81d commit 9b42dc0

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed
 

‎src/core/proj/qgscoordinatereferencesystem.cpp

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,25 +1101,29 @@ QString QgsCoordinateReferenceSystem::description() const
11011101

11021102
QString QgsCoordinateReferenceSystem::userFriendlyIdentifier( IdentifierType type ) const
11031103
{
1104+
QString id;
11041105
if ( !authid().isEmpty() )
11051106
{
11061107
if ( type != ShortString && !description().isEmpty() )
1107-
return QStringLiteral( "%1 - %2" ).arg( authid(), description() );
1108-
return authid();
1108+
id = QStringLiteral( "%1 - %2" ).arg( authid(), description() );
1109+
else
1110+
id = authid();
11091111
}
11101112
else if ( !description().isEmpty() )
1111-
return description();
1113+
id = description();
11121114
else if ( type == ShortString )
1113-
return isValid() ? QObject::tr( "Custom CRS" ) : QObject::tr( "Unknown CRS" );
1115+
id = isValid() ? QObject::tr( "Custom CRS" ) : QObject::tr( "Unknown CRS" );
11141116
else if ( !toWkt( WKT_PREFERRED ).isEmpty() )
1115-
return QObject::tr( "Custom CRS: %1" ).arg(
1116-
type == MediumString ? ( toWkt( WKT_PREFERRED ).left( 50 ) + QString( QChar( 0x2026 ) ) )
1117-
: toWkt( WKT_PREFERRED ) );
1117+
id = QObject::tr( "Custom CRS: %1" ).arg(
1118+
type == MediumString ? ( toWkt( WKT_PREFERRED ).left( 50 ) + QString( QChar( 0x2026 ) ) )
1119+
: toWkt( WKT_PREFERRED ) );
11181120
else if ( !toProj().isEmpty() )
1119-
return QObject::tr( "Custom CRS: %1" ).arg( type == MediumString ? ( toProj().left( 50 ) + QString( QChar( 0x2026 ) ) )
1120-
: toProj() );
1121-
else
1122-
return QString();
1121+
id = QObject::tr( "Custom CRS: %1" ).arg( type == MediumString ? ( toProj().left( 50 ) + QString( QChar( 0x2026 ) ) )
1122+
: toProj() );
1123+
if ( !id.isEmpty() && !std::isnan( d->mCoordinateEpoch ) )
1124+
id += QStringLiteral( " (%1)" ).arg( d->mCoordinateEpoch );
1125+
1126+
return id;
11231127
}
11241128

11251129
QString QgsCoordinateReferenceSystem::projectionAcronym() const

‎tests/src/core/testqgscoordinatereferencesystem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,8 @@ void TestQgsCoordinateReferenceSystem::displayIdentifier()
17071707
QCOMPARE( crs.userFriendlyIdentifier( QgsCoordinateReferenceSystem::ShortString ), QStringLiteral( "Unknown CRS" ) );
17081708
crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) );
17091709
QCOMPARE( crs.userFriendlyIdentifier(), QStringLiteral( "EPSG:4326 - WGS 84" ) );
1710+
crs.setCoordinateEpoch( 2021.3 );
1711+
QCOMPARE( crs.userFriendlyIdentifier(), QStringLiteral( "EPSG:4326 - WGS 84 (2021.3)" ) );
17101712
crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:3111" ) );
17111713
QCOMPARE( crs.userFriendlyIdentifier(), QStringLiteral( "EPSG:3111 - GDA94 / Vicgrid" ) );
17121714
crs = QgsCoordinateReferenceSystem( QStringLiteral( "EPSG:4326" ) );

0 commit comments

Comments
 (0)
Please sign in to comment.