File tree Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Expand file tree Collapse file tree 3 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -827,7 +827,10 @@ class QgsProcessingFeatureBasedAlgorithm : QgsProcessingAlgorithm
827827 geometry with the centroid of the original feature geometry for a 'centroid' type
828828 algorithm).
829829
830- Implementations should return the modified feature.
830+ Implementations should return the modified feature. Returning an invalid feature (e.g.
831+ a default constructed QgsFeature) will indicate that this feature should be 'skipped',
832+ and will not be added to the algorithm's output. Subclasses can use this approach to
833+ filter the incoming features as desired.
831834
832835 The provided ``feedback`` object can be used to push messages to the log and for giving feedback
833836 to users. Note that handling of progress reports and algorithm cancelation is handled by
Original file line number Diff line number Diff line change @@ -656,7 +656,8 @@ QVariantMap QgsProcessingFeatureBasedAlgorithm::processAlgorithm( const QVariant
656656 }
657657
658658 QgsFeature transformed = processFeature ( f, feedback );
659- sink->addFeature ( transformed, QgsFeatureSink::FastInsert );
659+ if ( transformed.isValid () )
660+ sink->addFeature ( transformed, QgsFeatureSink::FastInsert );
660661
661662 feedback->setProgress ( current * step );
662663 current++;
Original file line number Diff line number Diff line change @@ -798,7 +798,10 @@ class CORE_EXPORT QgsProcessingFeatureBasedAlgorithm : public QgsProcessingAlgor
798798 * geometry with the centroid of the original feature geometry for a 'centroid' type
799799 * algorithm).
800800 *
801- * Implementations should return the modified feature.
801+ * Implementations should return the modified feature. Returning an invalid feature (e.g.
802+ * a default constructed QgsFeature) will indicate that this feature should be 'skipped',
803+ * and will not be added to the algorithm's output. Subclasses can use this approach to
804+ * filter the incoming features as desired.
802805 *
803806 * The provided \a feedback object can be used to push messages to the log and for giving feedback
804807 * to users. Note that handling of progress reports and algorithm cancelation is handled by
You can’t perform that action at this time.
0 commit comments