Skip to content

Commit

Permalink
Invalid CRS instances should be equal
Browse files Browse the repository at this point in the history
  • Loading branch information
wonder-sk committed Mar 25, 2014
1 parent c69f2e1 commit af9da1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/core/qgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1130,7 +1130,8 @@ long QgsCoordinateReferenceSystem::findMatchingProj()

bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSystem &theSrs ) const
{
return mIsValidFlag && theSrs.mIsValidFlag && theSrs.authid() == authid();
return ( !mIsValidFlag && !theSrs.mIsValidFlag ) ||
( mIsValidFlag && theSrs.mIsValidFlag && theSrs.authid() == authid() );
}

bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &theSrs ) const
Expand Down
7 changes: 7 additions & 0 deletions tests/src/core/testqgscoordinatereferencesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class TestQgsCoordinateReferenceSystem: public QObject
void validate();
void equality();
void noEquality();
void equalityInvalid();
void readXML();
void writeXML();
void setCustomSrsValidation();
Expand Down Expand Up @@ -312,6 +313,12 @@ void TestQgsCoordinateReferenceSystem::noEquality()
debugPrint( myCrs );
QVERIFY( myCrs != myCrs2 );
}
void TestQgsCoordinateReferenceSystem::equalityInvalid()
{
QgsCoordinateReferenceSystem invalidCrs1;
QgsCoordinateReferenceSystem invalidCrs2;
QVERIFY( invalidCrs1 == invalidCrs2 );
}
void TestQgsCoordinateReferenceSystem::readXML()
{
//QgsCoordinateReferenceSystem myCrs;
Expand Down

0 comments on commit af9da1d

Please sign in to comment.