Skip to content
Permalink
Browse files

[processing] implement source flag for feature based algorithms (#5208)

  • Loading branch information
nirvn committed Sep 18, 2017
1 parent ffbb244 commit 09195fb567e01c0fb1340b6a3ce6e66bf4038f4f
@@ -795,6 +795,12 @@ class QgsProcessingFeatureBasedAlgorithm : QgsProcessingAlgorithm
:rtype: QgsProcessing.SourceType
%End

virtual QgsProcessingFeatureSource::Flag sourceFlags() const;
%Docstring
Returns the processing feature source flags to be used in the algorithm.
:rtype: QgsProcessingFeatureSource.Flag
%End

virtual QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type inputWkbType ) const;
%Docstring
Maps the input WKB geometry type (``inputWkbType``) to the corresponding
@@ -24,6 +24,7 @@
#include "qgis.h"
#include "qgsprocessingalgorithm.h"
#include "qgsprocessingprovider.h"
#include "qgsprocessingutils.h"
#include "qgsmaptopixelgeometrysimplifier.h"

///@cond PRIVATE
@@ -598,6 +599,7 @@ class QgsFixGeometriesAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QgsFixGeometriesAlgorithm *createInstance() const override SIP_FACTORY;

protected:
QgsProcessingFeatureSource::Flag sourceFlags() const override { return QgsProcessingFeatureSource::FlagSkipGeometryValidityChecks; }
QString outputName() const override { return QObject::tr( "Fixed geometries" ); }
QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type type ) const override { return QgsWkbTypes::multiType( type ); }
QgsFeature processFeature( const QgsFeature &feature, QgsProcessingFeedback *feedback ) override;
@@ -654,7 +654,7 @@ QVariantMap QgsProcessingFeatureBasedAlgorithm::processAlgorithm( const QVariant
long count = mSource->featureCount();

QgsFeature f;
QgsFeatureIterator it = mSource->getFeatures();
QgsFeatureIterator it = mSource->getFeatures( QgsFeatureRequest(), sourceFlags() );

double step = count > 0 ? 100.0 / count : 1;
int current = 0;
@@ -23,6 +23,7 @@
#include "qgsprocessingparameters.h"
#include "qgsprocessingoutputs.h"
#include "qgsprocessingcontext.h"
#include "qgsprocessingutils.h"
#include "qgsfeaturesource.h"
#include <QString>
#include <QVariant>
@@ -782,6 +783,11 @@ class CORE_EXPORT QgsProcessingFeatureBasedAlgorithm : public QgsProcessingAlgor
*/
virtual QgsProcessing::SourceType outputLayerType() const { return QgsProcessing::TypeVectorAnyGeometry; }

/**
* Returns the processing feature source flags to be used in the algorithm.
*/
virtual QgsProcessingFeatureSource::Flag sourceFlags() const { return static_cast<QgsProcessingFeatureSource::Flag>( 0 ); }

/**
* Maps the input WKB geometry type (\a inputWkbType) to the corresponding
* output WKB type generated by the algorithm. The default behavior is that the algorithm maintains
@@ -853,7 +859,7 @@ class CORE_EXPORT QgsProcessingFeatureBasedAlgorithm : public QgsProcessingAlgor

private:

std::unique_ptr< QgsFeatureSource > mSource;
std::unique_ptr< QgsProcessingFeatureSource > mSource;

};

0 comments on commit 09195fb

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