Skip to content

Commit 8cb4893

Browse files
committed
Fix creation of QgsCoordinateReferenceSystem from "user:xxxx" strings
Fixes #17254
1 parent b59bd94 commit 8cb4893

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/core/qgscoordinatereferencesystem.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString &definition )
220220
sCrsStringLock.unlock();
221221

222222
bool result = false;
223-
QRegExp reCrsId( "^(epsg|postgis|internal)\\:(\\d+)$", Qt::CaseInsensitive );
223+
QRegExp reCrsId( "^(epsg|postgis|internal|user)\\:(\\d+)$", Qt::CaseInsensitive );
224224
if ( reCrsId.indexIn( definition ) == 0 )
225225
{
226226
QString authName = reCrsId.cap( 1 ).toLower();

tests/src/core/testqgscoordinatereferencesystem.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -842,6 +842,14 @@ void TestQgsCoordinateReferenceSystem::saveAsUserCrs()
842842
QCOMPARE( userCrs2.srsid(), userCrs.srsid() );
843843
QCOMPARE( userCrs2.authid(), QStringLiteral( "USER:100000" ) );
844844
QCOMPARE( userCrs2.description(), QStringLiteral( "babies first projection" ) );
845+
846+
// createFromString with user crs
847+
QgsCoordinateReferenceSystem userCrs3;
848+
userCrs3.createFromString( QStringLiteral( "USER:100000" ) );
849+
QVERIFY( userCrs3.isValid() );
850+
QCOMPARE( userCrs3.authid(), QString( "USER:100000" ) );
851+
QCOMPARE( userCrs3.toProj4(), madeUpProjection );
852+
QCOMPARE( userCrs3.description(), QStringLiteral( "babies first projection" ) );
845853
}
846854

847855
void TestQgsCoordinateReferenceSystem::projectWithCustomCrs()

0 commit comments

Comments
 (0)