Skip to content

Commit

Permalink
Less noisy transform failure errors
Browse files Browse the repository at this point in the history
- Don't spew a whole lot of "rethrowing expection" log messages on the
default log level
- Don't output tons of duplicate transform error messages - instead
only output the message if its different to the last error encountered
(avoids flooding the console when transform failures occur during
raster projection, resulting in quasi-hangs)
  • Loading branch information
nyalldawson committed Feb 17, 2020
1 parent 9e1db2c commit 4f531d2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/core/qgscoordinatetransform.cpp
Expand Up @@ -243,7 +243,7 @@ QgsPointXY QgsCoordinateTransform::transform( const QgsPointXY &point, Transform
catch ( const QgsCsException & )
{
// rethrow the exception
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
QgsDebugMsgLevel( QStringLiteral( "rethrowing exception" ), 2 );
throw;
}

Expand All @@ -260,7 +260,7 @@ QgsPointXY QgsCoordinateTransform::transform( const double theX, const double th
catch ( const QgsCsException & )
{
// rethrow the exception
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
QgsDebugMsgLevel( QStringLiteral( "rethrowing exception" ), 2 );
throw;
}
}
Expand All @@ -287,7 +287,7 @@ QgsRectangle QgsCoordinateTransform::transform( const QgsRectangle &rect, Transf
catch ( const QgsCsException & )
{
// rethrow the exception
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
QgsDebugMsgLevel( QStringLiteral( "rethrowing exception" ), 2 );
throw;
}

Expand Down Expand Up @@ -317,7 +317,7 @@ void QgsCoordinateTransform::transformInPlace( double &x, double &y, double &z,
catch ( const QgsCsException & )
{
// rethrow the exception
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
QgsDebugMsgLevel( QStringLiteral( "rethrowing exception" ), 2 );
throw;
}
}
Expand Down Expand Up @@ -353,7 +353,7 @@ void QgsCoordinateTransform::transformInPlace( float &x, float &y, float &z,
catch ( QgsCsException & )
{
// rethrow the exception
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
QgsDebugMsgLevel( QStringLiteral( "rethrowing exception" ), 2 );
throw;
}
}
Expand Down Expand Up @@ -432,7 +432,7 @@ void QgsCoordinateTransform::transformInPlace(
catch ( const QgsCsException & )
{
// rethrow the exception
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
QgsDebugMsgLevel( QStringLiteral( "rethrowing exception" ), 2 );
throw;
}
}
Expand Down Expand Up @@ -494,7 +494,7 @@ void QgsCoordinateTransform::transformInPlace(
catch ( QgsCsException & )
{
// rethrow the exception
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
QgsDebugMsgLevel( QStringLiteral( "rethrowing exception" ), 2 );
throw;
}
}
Expand Down Expand Up @@ -569,7 +569,7 @@ QgsRectangle QgsCoordinateTransform::transformBoundingBox( const QgsRectangle &r
catch ( const QgsCsException & )
{
// rethrow the exception
QgsDebugMsg( QStringLiteral( "rethrowing exception" ) );
QgsDebugMsgLevel( QStringLiteral( "rethrowing exception" ), 2 );
throw;
}

Expand Down Expand Up @@ -758,8 +758,13 @@ void QgsCoordinateTransform::transformCoords( int numPoints, double *x, double *
pj_dalloc( dstdef );
#endif

QgsDebugMsg( "Projection failed emitting invalid transform signal: " + msg );
QgsDebugMsg( QStringLiteral( "throwing exception" ) );
// don't flood console with thousands of duplicate transform error messages
if ( msg != mLastError )
{
QgsDebugMsg( "Projection failed emitting invalid transform signal: " + msg );
mLastError = msg;
}
QgsDebugMsgLevel( QStringLiteral( "rethrowing exception" ), 2 );

throw QgsCsException( msg );
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgscoordinatetransform.h
Expand Up @@ -577,6 +577,8 @@ class CORE_EXPORT QgsCoordinateTransform
bool mHasContext = false;
#endif

mutable QString mLastError;

#if PROJ_VERSION_MAJOR>=6
bool setFromCache( const QgsCoordinateReferenceSystem &src,
const QgsCoordinateReferenceSystem &dest,
Expand Down

0 comments on commit 4f531d2

Please sign in to comment.