@@ -829,10 +829,8 @@ void QgsCoordinateTransform::transformCoords( int numPoints, double *x, double *
829
829
}
830
830
}
831
831
832
- // something which won't clash with Proj's real error codes!
833
- constexpr int PROJ_RESULT_FALLBACK_OPERATION_FAILED = -481516 ;
834
-
835
832
mFallbackOperationOccurred = false ;
833
+ bool errorOccurredDuringFallbackOperation = false ;
836
834
if ( actualRes != 0
837
835
&& ( d->mAvailableOpCount > 1 || d->mAvailableOpCount == -1 ) // only use fallbacks if more than one operation is possible -- otherwise we've already tried it and it failed
838
836
&& ( d->mAllowFallbackTransforms || mBallparkTransformsAreAppropriate ) )
@@ -857,13 +855,14 @@ void QgsCoordinateTransform::transformCoords( int numPoints, double *x, double *
857
855
// So here just check proj_errno() for single point transform
858
856
if ( numPoints == 1 )
859
857
{
858
+ projResult = proj_errno ( transform );
860
859
// hmm - something very odd here. We can't trust proj_errno( transform ), as that's giving us incorrect error numbers
861
860
// (such as "failed to load datum shift file", which is definitely incorrect for a default proj created operation!)
862
861
// so we resort to testing values ourselves...
863
- projResult = std::isinf ( xprev[0 ] ) || std::isinf ( yprev[0 ] ) || std::isinf ( zprev[0 ] ) ? PROJ_RESULT_FALLBACK_OPERATION_FAILED : 0 ;
862
+ errorOccurredDuringFallbackOperation = std::isinf ( xprev[0 ] ) || std::isinf ( yprev[0 ] ) || std::isinf ( zprev[0 ] );
864
863
}
865
864
866
- if ( projResult == 0 )
865
+ if ( !errorOccurredDuringFallbackOperation )
867
866
{
868
867
memcpy ( x, xprev.data (), sizeof ( double ) * numPoints );
869
868
memcpy ( y, yprev.data (), sizeof ( double ) * numPoints );
@@ -888,7 +887,7 @@ void QgsCoordinateTransform::transformCoords( int numPoints, double *x, double *
888
887
z[pos] = std::numeric_limits<double >::quiet_NaN ();
889
888
}
890
889
891
- if ( projResult != 0 )
890
+ if ( projResult != 0 || errorOccurredDuringFallbackOperation )
892
891
{
893
892
// something bad happened....
894
893
QString points;
@@ -903,9 +902,9 @@ void QgsCoordinateTransform::transformCoords( int numPoints, double *x, double *
903
902
904
903
#if PROJ_VERSION_MAJOR>=8
905
904
PJ_CONTEXT *projContext = QgsProjContext::get ();
906
- const QString projError = projResult != PROJ_RESULT_FALLBACK_OPERATION_FAILED ? QString::fromUtf8 ( proj_context_errno_string ( projContext, projResult ) ) : QObject::tr ( " Fallback transform failed" );
905
+ const QString projError = !errorOccurredDuringFallbackOperation ? QString::fromUtf8 ( proj_context_errno_string ( projContext, projResult ) ) : QObject::tr ( " Fallback transform failed" );
907
906
#else
908
- const QString projError = projResult != PROJ_RESULT_FALLBACK_OPERATION_FAILED ? QString::fromUtf8 ( proj_errno_string ( projResult ) ) : QObject::tr ( " Fallback transform failed" );
907
+ const QString projError = !errorOccurredDuringFallbackOperation ? QString::fromUtf8 ( proj_errno_string ( projResult ) ) : QObject::tr ( " Fallback transform failed" );
909
908
#endif
910
909
911
910
const QString msg = QObject::tr ( " %1 (%2 to %3) of%4%5Error: %6" )
0 commit comments