Skip to content

Commit 87b9b5d

Browse files
committed
Catch inverse transform failures in raster reprojector. Fix for #5895
1 parent b890e1f commit 87b9b5d

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

src/core/qgsrasterprojector.cpp

+30-8
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,21 @@ bool QgsRasterProjector::checkCols()
594594
QgsPoint mySrcPoint3 = mCPMatrix[r+1][c];
595595

596596
QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
597-
QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
598-
double mySqrDist = myDestApprox.sqrDist( myDestPoint );
599-
if ( mySqrDist > mSqrTolerance )
600-
return false;
597+
try
598+
{
599+
QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
600+
double mySqrDist = myDestApprox.sqrDist( myDestPoint );
601+
if ( mySqrDist > mSqrTolerance )
602+
{
603+
return false;
604+
}
605+
}
606+
catch ( QgsCsException &e )
607+
{
608+
Q_UNUSED( e );
609+
// Caught an error in transform
610+
return false;
611+
}
601612
}
602613
}
603614
return true;
@@ -618,10 +629,21 @@ bool QgsRasterProjector::checkRows()
618629
QgsPoint mySrcPoint3 = mCPMatrix[r][c+1];
619630

620631
QgsPoint mySrcApprox(( mySrcPoint1.x() + mySrcPoint3.x() ) / 2, ( mySrcPoint1.y() + mySrcPoint3.y() ) / 2 );
621-
QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
622-
double mySqrDist = myDestApprox.sqrDist( myDestPoint );
623-
if ( mySqrDist > mSqrTolerance )
624-
return false;
632+
try
633+
{
634+
QgsPoint myDestApprox = mCoordinateTransform.transform( mySrcApprox, QgsCoordinateTransform::ReverseTransform );
635+
double mySqrDist = myDestApprox.sqrDist( myDestPoint );
636+
if ( mySqrDist > mSqrTolerance )
637+
{
638+
return false;
639+
}
640+
}
641+
catch ( QgsCsException &e )
642+
{
643+
Q_UNUSED( e );
644+
// Caught an error in transform
645+
return false;
646+
}
625647
}
626648
}
627649
return true;

0 commit comments

Comments
 (0)