Skip to content
Permalink
Browse files

Skip invalid returned features

  • Loading branch information
nyalldawson committed Jul 18, 2017
1 parent 29855b3 commit 11cfc78a246e19de67de60000cfbc99f6a2288be
@@ -827,7 +827,10 @@ class QgsProcessingFeatureBasedAlgorithm : QgsProcessingAlgorithm
geometry with the centroid of the original feature geometry for a 'centroid' type
algorithm).

Implementations should return the modified feature.
Implementations should return the modified feature. Returning an invalid feature (e.g.
a default constructed QgsFeature) will indicate that this feature should be 'skipped',
and will not be added to the algorithm's output. Subclasses can use this approach to
filter the incoming features as desired.

The provided ``feedback`` object can be used to push messages to the log and for giving feedback
to users. Note that handling of progress reports and algorithm cancelation is handled by
@@ -656,7 +656,8 @@ QVariantMap QgsProcessingFeatureBasedAlgorithm::processAlgorithm( const QVariant
}

QgsFeature transformed = processFeature( f, feedback );
sink->addFeature( transformed, QgsFeatureSink::FastInsert );
if ( transformed.isValid() )
sink->addFeature( transformed, QgsFeatureSink::FastInsert );

feedback->setProgress( current * step );
current++;
@@ -798,7 +798,10 @@ class CORE_EXPORT QgsProcessingFeatureBasedAlgorithm : public QgsProcessingAlgor
* geometry with the centroid of the original feature geometry for a 'centroid' type
* algorithm).
*
* Implementations should return the modified feature.
* Implementations should return the modified feature. Returning an invalid feature (e.g.
* a default constructed QgsFeature) will indicate that this feature should be 'skipped',
* and will not be added to the algorithm's output. Subclasses can use this approach to
* filter the incoming features as desired.
*
* The provided \a feedback object can be used to push messages to the log and for giving feedback
* to users. Note that handling of progress reports and algorithm cancelation is handled by

0 comments on commit 11cfc78

Please sign in to comment.
You can’t perform that action at this time.