Skip to content

Commit

Permalink
Catch inverse transform failures in raster reprojector. Fix for #5895
Browse files Browse the repository at this point in the history
  • Loading branch information
homann committed Sep 12, 2012
1 parent b890e1f commit 87b9b5d
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions src/core/qgsrasterprojector.cpp
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit 87b9b5d

Please sign in to comment.