Skip to content

Commit

Permalink
Fix creation of QgsCoordinateReferenceSystem from "user:xxxx" strings
Browse files Browse the repository at this point in the history
Fixes #17254
  • Loading branch information
nyalldawson committed Dec 17, 2017
1 parent b59bd94 commit 8cb4893
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/core/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ bool QgsCoordinateReferenceSystem::createFromString( const QString &definition )
sCrsStringLock.unlock();

bool result = false;
QRegExp reCrsId( "^(epsg|postgis|internal)\\:(\\d+)$", Qt::CaseInsensitive );
QRegExp reCrsId( "^(epsg|postgis|internal|user)\\:(\\d+)$", Qt::CaseInsensitive );
if ( reCrsId.indexIn( definition ) == 0 )
{
QString authName = reCrsId.cap( 1 ).toLower();
Expand Down
8 changes: 8 additions & 0 deletions tests/src/core/testqgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,6 +842,14 @@ void TestQgsCoordinateReferenceSystem::saveAsUserCrs()
QCOMPARE( userCrs2.srsid(), userCrs.srsid() );
QCOMPARE( userCrs2.authid(), QStringLiteral( "USER:100000" ) );
QCOMPARE( userCrs2.description(), QStringLiteral( "babies first projection" ) );

// createFromString with user crs
QgsCoordinateReferenceSystem userCrs3;
userCrs3.createFromString( QStringLiteral( "USER:100000" ) );
QVERIFY( userCrs3.isValid() );
QCOMPARE( userCrs3.authid(), QString( "USER:100000" ) );
QCOMPARE( userCrs3.toProj4(), madeUpProjection );
QCOMPARE( userCrs3.description(), QStringLiteral( "babies first projection" ) );
}

void TestQgsCoordinateReferenceSystem::projectWithCustomCrs()
Expand Down

0 comments on commit 8cb4893

Please sign in to comment.