Skip to content

Commit af9da1d

Browse files
committedMar 25, 2014
Invalid CRS instances should be equal
1 parent c69f2e1 commit af9da1d

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
 

‎src/core/qgscoordinatereferencesystem.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,8 @@ long QgsCoordinateReferenceSystem::findMatchingProj()
11301130

11311131
bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSystem &theSrs ) const
11321132
{
1133-
return mIsValidFlag && theSrs.mIsValidFlag && theSrs.authid() == authid();
1133+
return ( !mIsValidFlag && !theSrs.mIsValidFlag ) ||
1134+
( mIsValidFlag && theSrs.mIsValidFlag && theSrs.authid() == authid() );
11341135
}
11351136

11361137
bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &theSrs ) const

‎tests/src/core/testqgscoordinatereferencesystem.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class TestQgsCoordinateReferenceSystem: public QObject
4949
void validate();
5050
void equality();
5151
void noEquality();
52+
void equalityInvalid();
5253
void readXML();
5354
void writeXML();
5455
void setCustomSrsValidation();
@@ -312,6 +313,12 @@ void TestQgsCoordinateReferenceSystem::noEquality()
312313
debugPrint( myCrs );
313314
QVERIFY( myCrs != myCrs2 );
314315
}
316+
void TestQgsCoordinateReferenceSystem::equalityInvalid()
317+
{
318+
QgsCoordinateReferenceSystem invalidCrs1;
319+
QgsCoordinateReferenceSystem invalidCrs2;
320+
QVERIFY( invalidCrs1 == invalidCrs2 );
321+
}
315322
void TestQgsCoordinateReferenceSystem::readXML()
316323
{
317324
//QgsCoordinateReferenceSystem myCrs;

0 commit comments

Comments
 (0)
Please sign in to comment.