Skip to content
Browse files

[processing] Fix "Centroids" alg with multipart geometries

when the "Create centroid for each part" option is enabled discard incoming fid field and regenerate it

See 1b2ca79 #42363

(cherry picked from commit c2451a9)
  • Loading branch information
agiudiceandrea authored and nyalldawson committed Apr 17, 2021
1 parent d9a1ca3 commit ab5e990024de8319ad3a368535cbb0db0f2ad59f
@@ -50,6 +50,14 @@ QString QgsCentroidAlgorithm::outputName() const
return QObject::tr( "Centroids" );

QgsFeatureSink::SinkFlags QgsCentroidAlgorithm::sinkFlags() const
if ( mAllParts )
return QgsProcessingFeatureBasedAlgorithm::sinkFlags() | QgsFeatureSink::RegeneratePrimaryKey;
return QgsProcessingFeatureBasedAlgorithm::sinkFlags();

QString QgsCentroidAlgorithm::shortHelpString() const
return QObject::tr( "This algorithm creates a new point layer, with points representing the centroid of the geometries in an input layer.\n\n"
@@ -51,6 +51,7 @@ class QgsCentroidAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QString outputName() const override;
QgsProcessing::SourceType outputLayerType() const override { return QgsProcessing::TypeVectorPoint; }
QgsWkbTypes::Type outputWkbType( QgsWkbTypes::Type inputWkbType ) const override { Q_UNUSED( inputWkbType ) return QgsWkbTypes::Point; }
QgsFeatureSink::SinkFlags sinkFlags() const override;

bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;

0 comments on commit ab5e990

Please sign in to comment.