Changed the way equality tests are done in qgscoordinatereference system. 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.

This commit is contained in:
Tim Sutton 2012-04-07 09:18:37 +02:00
parent 1f43afd9ef
commit 4524023fe1

View File

@ -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;
}