mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
[processing] implement source flag for feature based algorithms (#5208)
This commit is contained in:
parent
ffbb24481b
commit
09195fb567
@ -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;
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user