Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix incorrect authid and description after saving a user crs
  • Loading branch information
nyalldawson committed Nov 13, 2017
1 parent 39851f4 commit e967881
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -1698,6 +1698,9 @@ long QgsCoordinateReferenceSystem::saveAsUserCrs( const QString &name )

returnId = sqlite3_last_insert_rowid( myDatabase );
setInternalId( returnId );
if ( authid().isEmpty() )
setAuthId( QStringLiteral( "USER:%1" ).arg( returnId ) );
setDescription( name );

//We add the just created user CRS to the list of recently used CRS
QgsSettings settings;
Expand Down
4 changes: 4 additions & 0 deletions tests/src/core/testqgscoordinatereferencesystem.cpp
Expand Up @@ -822,12 +822,16 @@ void TestQgsCoordinateReferenceSystem::saveAsUserCrs()
long newId = userCrs.saveAsUserCrs( QStringLiteral( "babies first projection" ) );
QCOMPARE( newId, static_cast< long >( USER_CRS_START_ID ) );
QCOMPARE( userCrs.srsid(), newId );
QCOMPARE( userCrs.authid(), QStringLiteral( "USER:100000" ) );
QCOMPARE( userCrs.description(), QStringLiteral( "babies first projection" ) );

// new CRS with same definition, check that it's matched to user crs
QgsCoordinateReferenceSystem userCrs2 = QgsCoordinateReferenceSystem::fromProj4( madeUpProjection );
QVERIFY( userCrs2.isValid() );
QCOMPARE( userCrs2.toProj4(), madeUpProjection );
QCOMPARE( userCrs2.srsid(), userCrs.srsid() );
QCOMPARE( userCrs2.authid(), QStringLiteral( "USER:100000" ) );
QCOMPARE( userCrs2.description(), QStringLiteral( "babies first projection" ) );
}

QGSTEST_MAIN( TestQgsCoordinateReferenceSystem )
Expand Down

0 comments on commit e967881

Please sign in to comment.