Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Expose processFeature to public API
  • Loading branch information
elpaso authored and nyalldawson committed Sep 14, 2018
1 parent 123905a commit f35e376
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 48 deletions.
49 changes: 25 additions & 24 deletions python/core/auto_generated/processing/qgsprocessingalgorithm.sip.in
Expand Up @@ -857,6 +857,31 @@ Constructor for QgsProcessingFeatureBasedAlgorithm.
virtual QgsProcessingAlgorithm::Flags flags() const;


virtual QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException ) = 0 /VirtualErrorHandler=processing_exception_handler/;
%Docstring
Processes an individual input ``feature`` from the source. Algorithms should implement their
logic in this method for performing the algorithm's operation (e.g. replacing the feature's
geometry with the centroid of the original feature geometry for a 'centroid' type
algorithm).

Implementations should return a list containing the modified feature. Returning an empty an list
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.

Additionally, multiple features can be returned for a single input feature. Each returned feature
will be added to the algorithm's output. This allows for "explode" type algorithms where a single
input feature results in multiple output features.

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
the base class and subclasses do not need to reimplement this logic.

Algorithms can throw a QgsProcessingException if a fatal error occurred which should
prevent the algorithm execution from continuing. This can be annoying for users though as it
can break valid model execution - so use with extreme caution, and consider using
``feedback`` to instead report non-fatal processing failures for features instead.
%End

protected:

virtual void initAlgorithm( const QVariantMap &configuration = QVariantMap() );
Expand Down Expand Up @@ -931,30 +956,6 @@ Returns the source's coordinate reference system. This will only return a valid
called from a subclasses' processFeature() implementation.
%End

virtual QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException ) = 0 /VirtualErrorHandler=processing_exception_handler/;
%Docstring
Processes an individual input ``feature`` from the source. Algorithms should implement their
logic in this method for performing the algorithm's operation (e.g. replacing the feature's
geometry with the centroid of the original feature geometry for a 'centroid' type
algorithm).

Implementations should return a list containing the modified feature. Returning an empty an list
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.

Additionally, multiple features can be returned for a single input feature. Each returned feature
will be added to the algorithm's output. This allows for "explode" type algorithms where a single
input feature results in multiple output features.

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
the base class and subclasses do not need to reimplement this logic.

Algorithms can throw a QgsProcessingException if a fatal error occurred which should
prevent the algorithm execution from continuing. This can be annoying for users though as it
can break valid model execution - so use with extreme caution, and consider using
``feedback`` to instead report non-fatal processing failures for features instead.
%End

virtual QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException );

Expand Down
49 changes: 25 additions & 24 deletions src/core/processing/qgsprocessingalgorithm.h
Expand Up @@ -864,6 +864,31 @@ class CORE_EXPORT QgsProcessingFeatureBasedAlgorithm : public QgsProcessingAlgor

QgsProcessingAlgorithm::Flags flags() const override;

/**
* Processes an individual input \a feature from the source. Algorithms should implement their
* logic in this method for performing the algorithm's operation (e.g. replacing the feature's
* geometry with the centroid of the original feature geometry for a 'centroid' type
* algorithm).
*
* Implementations should return a list containing the modified feature. Returning an empty an list
* 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.
*
* Additionally, multiple features can be returned for a single input feature. Each returned feature
* will be added to the algorithm's output. This allows for "explode" type algorithms where a single
* input feature results in multiple output features.
*
* 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
* the base class and subclasses do not need to reimplement this logic.
*
* Algorithms can throw a QgsProcessingException if a fatal error occurred which should
* prevent the algorithm execution from continuing. This can be annoying for users though as it
* can break valid model execution - so use with extreme caution, and consider using
* \a feedback to instead report non-fatal processing failures for features instead.
*/
virtual QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) SIP_THROW( QgsProcessingException ) = 0 SIP_VIRTUALERRORHANDLER( processing_exception_handler );

protected:

void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override;
Expand Down Expand Up @@ -937,30 +962,6 @@ class CORE_EXPORT QgsProcessingFeatureBasedAlgorithm : public QgsProcessingAlgor
*/
QgsCoordinateReferenceSystem sourceCrs() const;

/**
* Processes an individual input \a feature from the source. Algorithms should implement their
* logic in this method for performing the algorithm's operation (e.g. replacing the feature's
* geometry with the centroid of the original feature geometry for a 'centroid' type
* algorithm).
*
* Implementations should return a list containing the modified feature. Returning an empty an list
* 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.
*
* Additionally, multiple features can be returned for a single input feature. Each returned feature
* will be added to the algorithm's output. This allows for "explode" type algorithms where a single
* input feature results in multiple output features.
*
* 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
* the base class and subclasses do not need to reimplement this logic.
*
* Algorithms can throw a QgsProcessingException if a fatal error occurred which should
* prevent the algorithm execution from continuing. This can be annoying for users though as it
* can break valid model execution - so use with extreme caution, and consider using
* \a feedback to instead report non-fatal processing failures for features instead.
*/
virtual QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) SIP_THROW( QgsProcessingException ) = 0 SIP_VIRTUALERRORHANDLER( processing_exception_handler );

QVariantMap processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override SIP_THROW( QgsProcessingException );

Expand Down

0 comments on commit f35e376

Please sign in to comment.