Skip to content

Commit

Permalink
Changed the way equality tests are done in qgscoordinatereference sys…
Browse files Browse the repository at this point in the history
…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 4524023
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -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
Expand All @@ -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;
}

Expand Down

0 comments on commit 4524023

Please sign in to comment.