Skip to content
Permalink
Browse files
Changed the way equality tests are done in qgscoordinatereference sys…
…tem. Simply comparing WKT's is not effective since the same CRS can be expressed in different ways. Now we compare the authid (which may have some side effects but probably less than the old system. All qgscoordinatereferencesystem tests pass now.
  • Loading branch information
timlinux committed Apr 7, 2012
1 parent 1f43afd commit 4524023fe1724ec83bc0f669c3c3bf2571a04ec6
Showing with 2 additions and 14 deletions.
  1. +2 −14 src/core/qgscoordinatereferencesystem.cpp
@@ -1012,19 +1012,7 @@ long QgsCoordinateReferenceSystem::findMatchingProj()

bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSystem &theSrs ) const
{
QString myWkt = toWkt();
QString theirWkt = theSrs.toWkt();
// if there is a 0,0,0 based Bursa-Wolf conversion, we will test the
// wkt with the TOWGS84 string removed as OSRImportFromProj4
// (which is often used in the class to contruct an SRS)
// does not create the empty TOWGS84 string
// TODO check 3 parameter form too?
// see http://www.gdal.org/ogr/classOGRSpatialReference.html
// TODO this is probably an ugly hack, find a nicer approach TS
QString myToWGSString( ",TOWGS84[0,0,0,0,0,0,0]" );
myWkt.replace( myToWGSString, "" );
theirWkt.replace( myToWGSString, "" );
return mIsValidFlag && theSrs.mIsValidFlag && myWkt == theirWkt;
return mIsValidFlag && theSrs.mIsValidFlag && theSrs.authid() == authid();
}

bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &theSrs ) const
@@ -1035,7 +1023,7 @@ bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSyste
bool QgsCoordinateReferenceSystem::equals( QString theProj4String )
{
QgsCoordinateReferenceSystem r;
r.setProj4String( theProj4String );
r.createFromProj4( theProj4String );
return *this == r;
}

0 comments on commit 4524023

Please sign in to comment.