Skip to content
Permalink
Browse files
keep row col in limits to avoid crash with 32661; decrease max cp mat…
…rix size

git-svn-id: http://svn.osgeo.org/qgis/trunk@15845 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
rblazek committed Apr 28, 2011
1 parent e1c2bbc commit 84ba7c7984b2a0cf2dd845402d6d976ad03c44c3
Showing with 15 additions and 1 deletion.
  1. +15 −1 src/core/qgsrasterprojector.cpp
@@ -85,7 +85,7 @@ QgsRasterProjector::QgsRasterProjector(
}
// 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 @@ void QgsRasterProjector::preciseSrcRowCol( int theDestRow, int theDestCol, int *
*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 @@ void QgsRasterProjector::approximateSrcRowCol( int theDestRow, int theDestCol, i
*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 );
}

0 comments on commit 84ba7c7

Please sign in to comment.