Catch inverse transform failures in raster reprojector. Fix for #5895

This commit is contained in:
Magnus Homann 2012-09-12 15:11:19 +02:00
parent b890e1f11e
commit 87b9b5dd8a

View File

@ -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;