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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Apr 28 16:57:01 EDT 2011


Author: rblazek
Date: 2011-04-28 13:57:01 -0700 (Thu, 28 Apr 2011)
New Revision: 15845

Modified:
   trunk/qgis/src/core/qgsrasterprojector.cpp
Log:
keep row col in limits to avoid crash with 32661; decrease max cp matrix size

Modified: trunk/qgis/src/core/qgsrasterprojector.cpp
===================================================================
--- trunk/qgis/src/core/qgsrasterprojector.cpp	2011-04-28 20:54:43 UTC (rev 15844)
+++ trunk/qgis/src/core/qgsrasterprojector.cpp	2011-04-28 20:57:01 UTC (rev 15845)
@@ -85,7 +85,7 @@
     }
     // What is the maximum reasonable size of transformatio matrix?
     // TODO: consider better when to break - ratio
-    if ( mCPRows * mCPCols > 0.25 * mDestRows * mDestCols )
+    if ( mCPRows * mCPCols > 0.0625 * mDestRows * mDestCols )
     {
       QgsDebugMsg( "Too large CP matrix" );
       mApproximate = false;
@@ -312,6 +312,14 @@
   *theSrcRow = ( int ) floor(( mSrcExtent.yMaximum() - y ) / mSrcXRes );
   *theSrcCol = ( int ) floor(( x - mSrcExtent.xMinimum() ) / mSrcYRes );
 
+  // With epsg 32661 (Polar Stereographic) it was happening that *theSrcCol == mSrcCols
+  // For now silently correct limits to avoid crashes
+  // TODO: review
+  if ( *theSrcRow >= mSrcRows ) *theSrcRow = mSrcRows - 1;
+  if ( *theSrcRow < 0 ) *theSrcRow = 0;
+  if ( *theSrcCol >= mSrcCols ) *theSrcCol = mSrcCols - 1;
+  if ( *theSrcCol < 0 ) *theSrcCol = 0;
+
   assert( *theSrcRow < mSrcRows );
   assert( *theSrcCol < mSrcCols );
 }
@@ -357,6 +365,12 @@
   *theSrcRow = ( int ) floor(( mSrcExtent.yMaximum() - mySrcY ) / mSrcXRes );
   *theSrcCol = ( int ) floor(( mySrcX - mSrcExtent.xMinimum() ) / mSrcYRes );
 
+  // For now silently correct limits to avoid crashes
+  // TODO: review
+  if ( *theSrcRow >= mSrcRows ) *theSrcRow = mSrcRows - 1;
+  if ( *theSrcRow < 0 ) *theSrcRow = 0;
+  if ( *theSrcCol >= mSrcCols ) *theSrcCol = mSrcCols - 1;
+  if ( *theSrcCol < 0 ) *theSrcCol = 0;
   assert( *theSrcRow < mSrcRows );
   assert( *theSrcCol < mSrcCols );
 }



More information about the QGIS-commit mailing list