Skip to content
Browse files
[processing] When running "point on surface" with "create point for
each part" option enabled, discard incoming fid fields and regenerate

Because we are potentially outputing multiple features per input
feature when this option is enabled, we can't guarantee that the
existing fid values will be unique.

Fixes #42350

(cherry picked from commit 1b2ca79)
  • Loading branch information
nyalldawson committed Apr 17, 2021
1 parent 671c433 commit 5f35dedcb3a4c9cf241f422fc6a800aeeebdfe4b
@@ -50,6 +50,14 @@ QString QgsPointOnSurfaceAlgorithm::outputName() const
return QObject::tr( "Point" );

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

QString QgsPointOnSurfaceAlgorithm::shortHelpString() const
return QObject::tr( "Returns a point guaranteed to lie on the surface of a geometry." );
@@ -51,6 +51,7 @@ class QgsPointOnSurfaceAlgorithm : 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 5f35ded

Please sign in to comment.