Skip to content

Commit

Permalink
[processing] Log use of ballpark transforms to processing log instead
Browse files Browse the repository at this point in the history
of to the main window message bar

More processing algorithms will require this, but it's a template for
the others to be adapted
  • Loading branch information
nyalldawson committed Feb 17, 2020
1 parent 0b48f0a commit ef06fb7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/analysis/processing/qgsalgorithmtransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ QgsFeatureList QgsTransformAlgorithm::processFeature( const QgsFeature &f, QgsPr
if ( !mCoordOp.isEmpty() )
mTransformContext.addCoordinateOperation( sourceCrs(), mDestCrs, mCoordOp );
mTransform = QgsCoordinateTransform( sourceCrs(), mDestCrs, mTransformContext );

mTransform.disableFallbackOperationHandler( true );
}

if ( feature.hasGeometry() )
Expand All @@ -117,6 +119,14 @@ QgsFeatureList QgsTransformAlgorithm::processFeature( const QgsFeature &f, QgsPr
{
feature.clearGeometry();
}

if ( !mWarnedAboutFallbackTransform && mTransform.fallbackOperationOccurred() )
{
feedback->reportError( QObject::tr( "An alternative, ballpark-only transform was used when transforming coordinates for one or more features. "
"(Possibly an incorrect choice of operation was made for transformations between these reference systems - check "
"that the selected operation is valid for the full extent of the input layer.)" ) );
mWarnedAboutFallbackTransform = true; // only warn once to avoid flooding the log
}
}
catch ( QgsCsException & )
{
Expand Down
1 change: 1 addition & 0 deletions src/analysis/processing/qgsalgorithmtransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class QgsTransformAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QgsCoordinateTransform mTransform;
QgsCoordinateTransformContext mTransformContext;
QString mCoordOp;
bool mWarnedAboutFallbackTransform = false;

};

Expand Down

0 comments on commit ef06fb7

Please sign in to comment.