Skip to content

Commit 7d09e26

Browse files
author
rblazek
committed
keep row col in limits to avoid crash with 32661; decrease max cp matrix size
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15845 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 17f351b commit 7d09e26

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/core/qgsrasterprojector.cpp

+15-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ QgsRasterProjector::QgsRasterProjector(
8585
}
8686
// What is the maximum reasonable size of transformatio matrix?
8787
// TODO: consider better when to break - ratio
88-
if ( mCPRows * mCPCols > 0.25 * mDestRows * mDestCols )
88+
if ( mCPRows * mCPCols > 0.0625 * mDestRows * mDestCols )
8989
{
9090
QgsDebugMsg( "Too large CP matrix" );
9191
mApproximate = false;
@@ -312,6 +312,14 @@ void QgsRasterProjector::preciseSrcRowCol( int theDestRow, int theDestCol, int *
312312
*theSrcRow = ( int ) floor(( mSrcExtent.yMaximum() - y ) / mSrcXRes );
313313
*theSrcCol = ( int ) floor(( x - mSrcExtent.xMinimum() ) / mSrcYRes );
314314

315+
// With epsg 32661 (Polar Stereographic) it was happening that *theSrcCol == mSrcCols
316+
// For now silently correct limits to avoid crashes
317+
// TODO: review
318+
if ( *theSrcRow >= mSrcRows ) *theSrcRow = mSrcRows - 1;
319+
if ( *theSrcRow < 0 ) *theSrcRow = 0;
320+
if ( *theSrcCol >= mSrcCols ) *theSrcCol = mSrcCols - 1;
321+
if ( *theSrcCol < 0 ) *theSrcCol = 0;
322+
315323
assert( *theSrcRow < mSrcRows );
316324
assert( *theSrcCol < mSrcCols );
317325
}
@@ -357,6 +365,12 @@ void QgsRasterProjector::approximateSrcRowCol( int theDestRow, int theDestCol, i
357365
*theSrcRow = ( int ) floor(( mSrcExtent.yMaximum() - mySrcY ) / mSrcXRes );
358366
*theSrcCol = ( int ) floor(( mySrcX - mSrcExtent.xMinimum() ) / mSrcYRes );
359367

368+
// For now silently correct limits to avoid crashes
369+
// TODO: review
370+
if ( *theSrcRow >= mSrcRows ) *theSrcRow = mSrcRows - 1;
371+
if ( *theSrcRow < 0 ) *theSrcRow = 0;
372+
if ( *theSrcCol >= mSrcCols ) *theSrcCol = mSrcCols - 1;
373+
if ( *theSrcCol < 0 ) *theSrcCol = 0;
360374
assert( *theSrcRow < mSrcRows );
361375
assert( *theSrcCol < mSrcCols );
362376
}

0 commit comments

Comments
 (0)