[QGIS Commit] r11380 - trunk/qgis/src/core

svn_qgis at osgeo.org svn_qgis at osgeo.org
Fri Aug 14 13:57:04 EDT 2009


Author: homann
Date: 2009-08-14 13:57:03 -0400 (Fri, 14 Aug 2009)
New Revision: 11380

Modified:
   trunk/qgis/src/core/qgscoordinatereferencesystem.cpp
Log:
A fix for comparing two CRS:es that only differs by their +towgs84 params. Fixes partly #1815.

Modified: trunk/qgis/src/core/qgscoordinatereferencesystem.cpp
===================================================================
--- trunk/qgis/src/core/qgscoordinatereferencesystem.cpp	2009-08-14 17:11:39 UTC (rev 11379)
+++ trunk/qgis/src/core/qgscoordinatereferencesystem.cpp	2009-08-14 17:57:03 UTC (rev 11380)
@@ -876,20 +876,29 @@
   {
     return false;
   }
-  else if ( OSRIsGeographic( mCRS ) && OSRIsGeographic( theSrs.mCRS ) )
+  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 ) )
   {
-    // qWarning("QgsCoordinateReferenceSystem::operator== srs1 and srs2 are geographic ");
-    return OSRIsSameGeogCS( mCRS, theSrs.mCRS );
+    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 );
   }
-  else if ( OSRIsProjected( mCRS ) && OSRIsProjected( theSrs.mCRS ) )
-  {
-    // qWarning("QgsCoordinateReferenceSystem::operator== srs1 and srs2 are projected ");
-    return OSRIsSame( mCRS, theSrs.mCRS );
-  }
-  else
-  {
-    return false;
-  }
+  return false;
 }
 
 bool QgsCoordinateReferenceSystem::operator!=( const QgsCoordinateReferenceSystem &theSrs )
@@ -1135,6 +1144,7 @@
   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 )
   {



More information about the QGIS-commit mailing list