@@ -85,7 +85,7 @@ QgsRasterProjector::QgsRasterProjector(
85
85
}
86
86
// What is the maximum reasonable size of transformatio matrix?
87
87
// TODO: consider better when to break - ratio
88
- if ( mCPRows * mCPCols > 0.25 * mDestRows * mDestCols )
88
+ if ( mCPRows * mCPCols > 0.0625 * mDestRows * mDestCols )
89
89
{
90
90
QgsDebugMsg ( " Too large CP matrix" );
91
91
mApproximate = false ;
@@ -312,6 +312,14 @@ void QgsRasterProjector::preciseSrcRowCol( int theDestRow, int theDestCol, int *
312
312
*theSrcRow = ( int ) floor (( mSrcExtent .yMaximum () - y ) / mSrcXRes );
313
313
*theSrcCol = ( int ) floor (( x - mSrcExtent .xMinimum () ) / mSrcYRes );
314
314
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
+
315
323
assert ( *theSrcRow < mSrcRows );
316
324
assert ( *theSrcCol < mSrcCols );
317
325
}
@@ -357,6 +365,12 @@ void QgsRasterProjector::approximateSrcRowCol( int theDestRow, int theDestCol, i
357
365
*theSrcRow = ( int ) floor (( mSrcExtent .yMaximum () - mySrcY ) / mSrcXRes );
358
366
*theSrcCol = ( int ) floor (( mySrcX - mSrcExtent .xMinimum () ) / mSrcYRes );
359
367
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 ;
360
374
assert ( *theSrcRow < mSrcRows );
361
375
assert ( *theSrcCol < mSrcCols );
362
376
}
0 commit comments