mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-26 00:02:08 -05:00
Move invalid geometry callback from Python to c++
This commit is contained in:
parent
98617c90bd
commit
57f2c623ce
@ -137,6 +137,8 @@ Destination project
|
||||
void setInvalidGeometryCheck( const QgsFeatureRequest::InvalidGeometryCheck &check );
|
||||
%Docstring
|
||||
Sets the behavior used for checking invalid geometries in input layers.
|
||||
Settings this to anything but QgsFeatureRequest.GeometryNoCheck will also
|
||||
reset the invalidGeometryCallback() to a default implementation.
|
||||
.. seealso:: invalidGeometryCheck()
|
||||
%End
|
||||
|
||||
|
@ -77,12 +77,6 @@ def createContext():
|
||||
invalid_features_method = QgsFeatureRequest.GeometryAbortOnInvalid
|
||||
context.setInvalidGeometryCheck(invalid_features_method)
|
||||
|
||||
def raise_error(f):
|
||||
raise GeoAlgorithmExecutionException(QCoreApplication.translate("FeatureIterator",
|
||||
'Features with invalid geometries found. Please fix these geometries or specify the "Ignore invalid input features" flag'))
|
||||
|
||||
context.setInvalidGeometryCallback(raise_error)
|
||||
|
||||
def raise_transform_error(f):
|
||||
raise GeoAlgorithmExecutionException(QCoreApplication.translate("FeatureIterator",
|
||||
'Encountered a transform error when reprojecting feature with id {}.'.format(f.id())))
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "qgsexpressioncontext.h"
|
||||
#include "qgsfeaturerequest.h"
|
||||
#include "qgsmaplayerlistutils.h"
|
||||
#include "qgsprocessingexception.h"
|
||||
|
||||
/**
|
||||
* \class QgsProcessingContext
|
||||
@ -167,9 +168,23 @@ class CORE_EXPORT QgsProcessingContext
|
||||
|
||||
/**
|
||||
* Sets the behavior used for checking invalid geometries in input layers.
|
||||
* Settings this to anything but QgsFeatureRequest::GeometryNoCheck will also
|
||||
* reset the invalidGeometryCallback() to a default implementation.
|
||||
* \see invalidGeometryCheck()
|
||||
*/
|
||||
void setInvalidGeometryCheck( const QgsFeatureRequest::InvalidGeometryCheck &check ) { mInvalidGeometryCheck = check; }
|
||||
void setInvalidGeometryCheck( const QgsFeatureRequest::InvalidGeometryCheck &check )
|
||||
{
|
||||
mInvalidGeometryCheck = check;
|
||||
|
||||
if ( mInvalidGeometryCheck == QgsFeatureRequest::GeometryAbortOnInvalid )
|
||||
{
|
||||
auto callback = []( const QgsFeature & feature )
|
||||
{
|
||||
throw QgsProcessingException( QObject::tr( "Feature (%1) has invalid geometry. Please fix the geometry or change the Processing setting to the \"Ignore invalid input features\" option." ).arg( feature.id() ) );
|
||||
};
|
||||
mInvalidGeometryCallback = callback;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -475,12 +475,3 @@ long QgsProcessingFeatureSource::featureCount() const
|
||||
{
|
||||
return mSource->featureCount();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user