Skip to content

Commit

Permalink
A fix for comparing two CRS:es that only differs by their +towgs84 pa…
Browse files Browse the repository at this point in the history
…rams. Fixes partly #1815.

git-svn-id: http://svn.osgeo.org/qgis/trunk@11380 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann committed Aug 14, 2009
1 parent aae80cb commit 97ac21e
Showing 1 changed file with 22 additions and 12 deletions.
34 changes: 22 additions & 12 deletions src/core/qgscoordinatereferencesystem.cpp
Expand Up @@ -876,20 +876,29 @@ bool QgsCoordinateReferenceSystem::operator==( const QgsCoordinateReferenceSyste
{
return false;
}
else if ( OSRIsGeographic( mCRS ) && OSRIsGeographic( theSrs.mCRS ) )
{
// qWarning("QgsCoordinateReferenceSystem::operator== srs1 and srs2 are geographic ");
return OSRIsSameGeogCS( mCRS, theSrs.mCRS );
}
else if ( OSRIsProjected( mCRS ) && OSRIsProjected( theSrs.mCRS ) )
{
// qWarning("QgsCoordinateReferenceSystem::operator== srs1 and srs2 are projected ");
return OSRIsSame( mCRS, theSrs.mCRS );
}
else
char *thisStr;
char *otherStr;

// OSRIsSame is not relaibel when it comes to comparing +towgs84 parameters
// Use string compare on WKT instead.
if ( ( OSRExportToWkt( mCRS, &thisStr ) == OGRERR_NONE ) )
{
return false;
if ( OSRExportToWkt( theSrs.mCRS, &otherStr ) == OGRERR_NONE )
{
QgsDebugMsg( QString( "Comparing " ) + thisStr );
QgsDebugMsg( QString( " with " ) + otherStr );
if ( !strcmp( thisStr, otherStr ) )
{
QgsDebugMsg( QString( "MATCHED!" ) + otherStr );
OGRFree( *thisStr );
OGRFree( *otherStr );
return true;
}
OGRFree( *otherStr );
}
OGRFree( *thisStr );
}
return false;
}

bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &theSrs )
Expand Down Expand Up @@ -1135,6 +1144,7 @@ void QgsCoordinateReferenceSystem::debugPrint()
QgsDebugMsg( "* Valid : " + ( mIsValidFlag ? QString( "true" ) : QString( "false" ) ) );
QgsDebugMsg( "* SrsId : " + QString::number( mSrsId ) );
QgsDebugMsg( "* Proj4 : " + toProj4() );
QgsDebugMsg( "* WKT : " + toWkt() );
QgsDebugMsg( "* Desc. : " + mDescription );
if ( mapUnits() == QGis::Meters )
{
Expand Down

0 comments on commit 97ac21e

Please sign in to comment.