Skip to content
Permalink
Browse files
Add invalid geometry handling method to processing context
  • Loading branch information
nyalldawson committed Apr 26, 2017
1 parent 06a20b9 commit f3cfb8b759daea72df164309fa244957a76f1eb3
Showing with 29 additions and 15 deletions.
  1. +12 −6 python/core/processing/qgsprocessingcontext.sip
  2. +3 −0 python/plugins/processing/tools/general.py
  3. +14 −9 src/core/processing/qgsprocessingcontext.h
@@ -72,14 +72,20 @@ class QgsProcessingContext
Sets the expression ``context``.
%End

};





QgsFeatureRequest::InvalidGeometryCheck invalidGeometryCheck() const;
%Docstring
Returns the behavior used for checking invalid geometries in input layers.
\see setInvalidGeometryCheck()
:rtype: QgsFeatureRequest.InvalidGeometryCheck
%End

void setInvalidGeometryCheck( const QgsFeatureRequest::InvalidGeometryCheck &check );
%Docstring
Sets the behavior used for checking invalid geometries in input layers.
\see invalidGeometryCheck()
%End

};
QFlags<QgsProcessingContext::Flag> operator|(QgsProcessingContext::Flag f1, QFlags<QgsProcessingContext::Flag> f2);


@@ -108,4 +108,7 @@ def createContext():
if use_selection:
context.setFlags(QgsProcessingContext.UseSelection)

invalid_features_method = ProcessingConfig.getSetting(ProcessingConfig.FILTER_INVALID_GEOMETRIES)
context.setInvalidGeometryCheck(invalid_features_method)

return context
@@ -22,6 +22,7 @@
#include "qgis.h"
#include "qgsproject.h"
#include "qgsexpressioncontext.h"
#include "qgsfeaturerequest.h"

/**
* \class QgsProcessingContext
@@ -80,22 +81,26 @@ class CORE_EXPORT QgsProcessingContext
*/
void setExpressionContext( const QgsExpressionContext &context ) { mExpressionContext = context; }

/**
* Returns the behavior used for checking invalid geometries in input layers.
* \see setInvalidGeometryCheck()
*/
QgsFeatureRequest::InvalidGeometryCheck invalidGeometryCheck() const { return mInvalidGeometryCheck; }

/**
* Sets the behavior used for checking invalid geometries in input layers.
* \see invalidGeometryCheck()
*/
void setInvalidGeometryCheck( const QgsFeatureRequest::InvalidGeometryCheck &check ) { mInvalidGeometryCheck = check; }

private:

QgsProcessingContext::Flags mFlags = 0;

QPointer< QgsProject > mProject;

QgsExpressionContext mExpressionContext;
QgsFeatureRequest::InvalidGeometryCheck mInvalidGeometryCheck = QgsFeatureRequest::GeometryNoCheck;

};







Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingContext::Flags )

#endif // QGSPROCESSINGPARAMETERS_H

0 comments on commit f3cfb8b

Please sign in to comment.