Skip to content

Commit 39851f4

Browse files
committedNov 13, 2017
Invalidate crs cache after adding a new user CRS
Refs #17257
1 parent e0b2c27 commit 39851f4

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed
 

‎src/core/qgscoordinatereferencesystem.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1714,6 +1714,8 @@ long QgsCoordinateReferenceSystem::saveAsUserCrs( const QString &name )
17141714
}
17151715
else
17161716
returnId = -1;
1717+
1718+
invalidateCache();
17171719
return returnId;
17181720
}
17191721

‎tests/src/core/testqgscoordinatereferencesystem.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ void TestQgsCoordinateReferenceSystem::initTestCase()
106106
//
107107
// init QGIS's paths - true means that all path will be inited from prefix
108108
QgsApplication::init( mTempFolder );
109+
QgsApplication::createDatabase();
109110
QgsApplication::initQgis();
110111
QgsApplication::showSettings();
111112

@@ -820,6 +821,13 @@ void TestQgsCoordinateReferenceSystem::saveAsUserCrs()
820821

821822
long newId = userCrs.saveAsUserCrs( QStringLiteral( "babies first projection" ) );
822823
QCOMPARE( newId, static_cast< long >( USER_CRS_START_ID ) );
824+
QCOMPARE( userCrs.srsid(), newId );
825+
826+
// new CRS with same definition, check that it's matched to user crs
827+
QgsCoordinateReferenceSystem userCrs2 = QgsCoordinateReferenceSystem::fromProj4( madeUpProjection );
828+
QVERIFY( userCrs2.isValid() );
829+
QCOMPARE( userCrs2.toProj4(), madeUpProjection );
830+
QCOMPARE( userCrs2.srsid(), userCrs.srsid() );
823831
}
824832

825833
QGSTEST_MAIN( TestQgsCoordinateReferenceSystem )

0 commit comments

Comments
 (0)
Please sign in to comment.