Skip to content

Commit f35e376

Browse files
elpasonyalldawson
authored andcommitted
Expose processFeature to public API
1 parent 123905a commit f35e376

File tree

2 files changed

+50
-48
lines changed

2 files changed

+50
-48
lines changed

python/core/auto_generated/processing/qgsprocessingalgorithm.sip.in

+25-24
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,31 @@ Constructor for QgsProcessingFeatureBasedAlgorithm.
857857
virtual QgsProcessingAlgorithm::Flags flags() const;
858858

859859

860+
virtual QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException ) = 0 /VirtualErrorHandler=processing_exception_handler/;
861+
%Docstring
862+
Processes an individual input ``feature`` from the source. Algorithms should implement their
863+
logic in this method for performing the algorithm's operation (e.g. replacing the feature's
864+
geometry with the centroid of the original feature geometry for a 'centroid' type
865+
algorithm).
866+
867+
Implementations should return a list containing the modified feature. Returning an empty an list
868+
will indicate that this feature should be 'skipped', and will not be added to the algorithm's output.
869+
Subclasses can use this approach to filter the incoming features as desired.
870+
871+
Additionally, multiple features can be returned for a single input feature. Each returned feature
872+
will be added to the algorithm's output. This allows for "explode" type algorithms where a single
873+
input feature results in multiple output features.
874+
875+
The provided ``feedback`` object can be used to push messages to the log and for giving feedback
876+
to users. Note that handling of progress reports and algorithm cancelation is handled by
877+
the base class and subclasses do not need to reimplement this logic.
878+
879+
Algorithms can throw a QgsProcessingException if a fatal error occurred which should
880+
prevent the algorithm execution from continuing. This can be annoying for users though as it
881+
can break valid model execution - so use with extreme caution, and consider using
882+
``feedback`` to instead report non-fatal processing failures for features instead.
883+
%End
884+
860885
protected:
861886

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

934-
virtual QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) throw( QgsProcessingException ) = 0 /VirtualErrorHandler=processing_exception_handler/;
935-
%Docstring
936-
Processes an individual input ``feature`` from the source. Algorithms should implement their
937-
logic in this method for performing the algorithm's operation (e.g. replacing the feature's
938-
geometry with the centroid of the original feature geometry for a 'centroid' type
939-
algorithm).
940-
941-
Implementations should return a list containing the modified feature. Returning an empty an list
942-
will indicate that this feature should be 'skipped', and will not be added to the algorithm's output.
943-
Subclasses can use this approach to filter the incoming features as desired.
944-
945-
Additionally, multiple features can be returned for a single input feature. Each returned feature
946-
will be added to the algorithm's output. This allows for "explode" type algorithms where a single
947-
input feature results in multiple output features.
948-
949-
The provided ``feedback`` object can be used to push messages to the log and for giving feedback
950-
to users. Note that handling of progress reports and algorithm cancelation is handled by
951-
the base class and subclasses do not need to reimplement this logic.
952-
953-
Algorithms can throw a QgsProcessingException if a fatal error occurred which should
954-
prevent the algorithm execution from continuing. This can be annoying for users though as it
955-
can break valid model execution - so use with extreme caution, and consider using
956-
``feedback`` to instead report non-fatal processing failures for features instead.
957-
%End
958959

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

src/core/processing/qgsprocessingalgorithm.h

+25-24
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,31 @@ class CORE_EXPORT QgsProcessingFeatureBasedAlgorithm : public QgsProcessingAlgor
864864

865865
QgsProcessingAlgorithm::Flags flags() const override;
866866

867+
/**
868+
* Processes an individual input \a feature from the source. Algorithms should implement their
869+
* logic in this method for performing the algorithm's operation (e.g. replacing the feature's
870+
* geometry with the centroid of the original feature geometry for a 'centroid' type
871+
* algorithm).
872+
*
873+
* Implementations should return a list containing the modified feature. Returning an empty an list
874+
* will indicate that this feature should be 'skipped', and will not be added to the algorithm's output.
875+
* Subclasses can use this approach to filter the incoming features as desired.
876+
*
877+
* Additionally, multiple features can be returned for a single input feature. Each returned feature
878+
* will be added to the algorithm's output. This allows for "explode" type algorithms where a single
879+
* input feature results in multiple output features.
880+
*
881+
* The provided \a feedback object can be used to push messages to the log and for giving feedback
882+
* to users. Note that handling of progress reports and algorithm cancelation is handled by
883+
* the base class and subclasses do not need to reimplement this logic.
884+
*
885+
* Algorithms can throw a QgsProcessingException if a fatal error occurred which should
886+
* prevent the algorithm execution from continuing. This can be annoying for users though as it
887+
* can break valid model execution - so use with extreme caution, and consider using
888+
* \a feedback to instead report non-fatal processing failures for features instead.
889+
*/
890+
virtual QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) SIP_THROW( QgsProcessingException ) = 0 SIP_VIRTUALERRORHANDLER( processing_exception_handler );
891+
867892
protected:
868893

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

940-
/**
941-
* Processes an individual input \a feature from the source. Algorithms should implement their
942-
* logic in this method for performing the algorithm's operation (e.g. replacing the feature's
943-
* geometry with the centroid of the original feature geometry for a 'centroid' type
944-
* algorithm).
945-
*
946-
* Implementations should return a list containing the modified feature. Returning an empty an list
947-
* will indicate that this feature should be 'skipped', and will not be added to the algorithm's output.
948-
* Subclasses can use this approach to filter the incoming features as desired.
949-
*
950-
* Additionally, multiple features can be returned for a single input feature. Each returned feature
951-
* will be added to the algorithm's output. This allows for "explode" type algorithms where a single
952-
* input feature results in multiple output features.
953-
*
954-
* The provided \a feedback object can be used to push messages to the log and for giving feedback
955-
* to users. Note that handling of progress reports and algorithm cancelation is handled by
956-
* the base class and subclasses do not need to reimplement this logic.
957-
*
958-
* Algorithms can throw a QgsProcessingException if a fatal error occurred which should
959-
* prevent the algorithm execution from continuing. This can be annoying for users though as it
960-
* can break valid model execution - so use with extreme caution, and consider using
961-
* \a feedback to instead report non-fatal processing failures for features instead.
962-
*/
963-
virtual QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) SIP_THROW( QgsProcessingException ) = 0 SIP_VIRTUALERRORHANDLER( processing_exception_handler );
964965

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

0 commit comments

Comments
 (0)