Skip to content

Commit

Permalink
More server warnings on transformation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso authored and nyalldawson committed May 25, 2021
1 parent 8ac4a73 commit dfaafa6
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/server/qgsserver.cpp
Expand Up @@ -233,10 +233,19 @@ bool QgsServer::init()
const QgsCoordinateReferenceSystem & destinationCrs,
const QgsDatumTransform::TransformDetails & details )
{
QgsServerLogger::instance()->logMessage( QStringLiteral( "Cannot use project transform between %1 and %2 - %3" )
QString gridMessage;
for ( const QgsDatumTransform::GridDetails &grid : details.grids )
{
if ( !grid.isAvailable )
{
gridMessage.append( QStringLiteral( "This transformation requires the grid file '%1', which is not available for use on the system.\n" ).arg( grid.shortName ) );
}
}
QgsServerLogger::instance()->logMessage( QStringLiteral( "Cannot use project transform between %1 and %2 - %3.\n%4" )
.arg( sourceCrs.userFriendlyIdentifier( QgsCoordinateReferenceSystem::ShortString ),
destinationCrs.userFriendlyIdentifier( QgsCoordinateReferenceSystem::ShortString ),
details.name ),
details.name,
gridMessage ),
QStringLiteral( "QGIS Server" ), Qgis::MessageLevel::Warning );
} );

Expand Down Expand Up @@ -272,8 +281,9 @@ bool QgsServer::init()
accuracyMessage = QStringLiteral( "Current transform '%1' has an accuracy of %2 meters, while the preferred transformation '%3' has accuracy %4 meters.\n" ).arg( availableOperation.name )
.arg( availableOperation.accuracy ).arg( preferredOperation.name ).arg( preferredOperation.accuracy );
else if ( preferredOperation.accuracy >= 0 )
accuracyMessage = QStringLiteral( "Current transform '%1' has an unknown accuracy, while the preferred transformation '%2' has accuracy %3 meters.\n" ).arg( availableOperation.name )
.arg( preferredOperation.name ).arg( preferredOperation.accuracy );
accuracyMessage = QStringLiteral( "Current transform '%1' has an unknown accuracy, while the preferred transformation '%2' has accuracy %3 meters.\n" )
.arg( availableOperation.name, preferredOperation.name )
.arg( preferredOperation.accuracy );

const QString longMessage = QStringLiteral( "The preferred transform between '%1' and '%2' is not available for use on the system.\n" ).arg( sourceCrs.userFriendlyIdentifier(),
destinationCrs.userFriendlyIdentifier() )
Expand All @@ -283,6 +293,13 @@ bool QgsServer::init()

} );

QgsCoordinateTransform::setCustomCoordinateOperationCreationErrorHandler( [ = ]( const QgsCoordinateReferenceSystem & sourceCrs, const QgsCoordinateReferenceSystem & destinationCrs, const QString & error )
{
const QString longMessage = QStringLiteral( "No transform is available between %1 and %2: %3" )
.arg( sourceCrs.userFriendlyIdentifier(), destinationCrs.userFriendlyIdentifier(), error );
QgsServerLogger::instance()->logMessage( longMessage, QStringLiteral( "QGIS Server" ), Qgis::MessageLevel::Warning );
} );

// Configure locale
initLocale();

Expand Down

0 comments on commit dfaafa6

Please sign in to comment.