From 87b9b5dd8a2769e52722d378df88e865f01306b3 Mon Sep 17 00:00:00 2001 From: Magnus Homann Date: Wed, 12 Sep 2012 15:11:19 +0200 Subject: [PATCH] Catch inverse transform failures in raster reprojector. Fix for #5895 --- src/core/qgsrasterprojector.cpp | 38 ++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/core/qgsrasterprojector.cpp b/src/core/qgsrasterprojector.cpp index 07e14ec9eb8..e19c64cda5f 100644 --- a/src/core/qgsrasterprojector.cpp +++ b/src/core/qgsrasterprojector.cpp @@ -594,10 +594,21 @@ bool QgsRasterProjector::checkCols() QgsPoint mySrcPoint3 = mCPMatrix[r+1][c]; QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 ); - QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform ); - double mySqrDist = myDestApprox.sqrDist( myDestPoint ); - if ( mySqrDist > mSqrTolerance ) - return false; + try + { + QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform ); + double mySqrDist = myDestApprox.sqrDist( myDestPoint ); + if ( mySqrDist > mSqrTolerance ) + { + return false; + } + } + catch ( QgsCsException &e ) + { + Q_UNUSED( e ); + // Caught an error in transform + return false; + } } } return true; @@ -618,10 +629,21 @@ bool QgsRasterProjector::checkRows() QgsPoint mySrcPoint3 = mCPMatrix[r][c+1]; QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 ); - QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform ); - double mySqrDist = myDestApprox.sqrDist( myDestPoint ); - if ( mySqrDist > mSqrTolerance ) - return false; + try + { + QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform ); + double mySqrDist = myDestApprox.sqrDist( myDestPoint ); + if ( mySqrDist > mSqrTolerance ) + { + return false; + } + } + catch ( QgsCsException &e ) + { + Q_UNUSED( e ); + // Caught an error in transform + return false; + } } } return true;