Skip to content

Commit

Permalink
Merge pull request #58098 from qgis/backport-58096-to-release-3_34
Browse files Browse the repository at this point in the history
[Backport release-3_34] [processing] Fix buffer algorithm's primary key collision
  • Loading branch information
alexbruy authored Jul 15, 2024
2 parents 50a8119 + 16022e6 commit 0f159ca
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/analysis/processing/qgsalgorithmbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ QVariantMap QgsBufferAlgorithm::processAlgorithm( const QVariantMap &parameters,
if ( !source )
throw QgsProcessingException( invalidSourceError( parameters, QStringLiteral( "INPUT" ) ) );

QString dest;
std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, source->fields(), Qgis::WkbType::MultiPolygon, source->sourceCrs() ) );
if ( !sink )
throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) );

// fixed parameters
const bool dissolve = parameterAsBoolean( parameters, QStringLiteral( "DISSOLVE" ), context );
const bool keepDisjointSeparate = parameterAsBoolean( parameters, QStringLiteral( "SEPARATE_DISJOINT" ), context );
Expand All @@ -105,6 +100,12 @@ QVariantMap QgsBufferAlgorithm::processAlgorithm( const QVariantMap &parameters,
const double miterLimit = parameterAsDouble( parameters, QStringLiteral( "MITER_LIMIT" ), context );
const double bufferDistance = parameterAsDouble( parameters, QStringLiteral( "DISTANCE" ), context );
const bool dynamicBuffer = QgsProcessingParameters::isDynamic( parameters, QStringLiteral( "DISTANCE" ) );

QString dest;
std::unique_ptr< QgsFeatureSink > sink( parameterAsSink( parameters, QStringLiteral( "OUTPUT" ), context, dest, source->fields(), Qgis::WkbType::MultiPolygon, source->sourceCrs(), keepDisjointSeparate ? QgsFeatureSink::RegeneratePrimaryKey : QgsFeatureSink::SinkFlags() ) );
if ( !sink )
throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) );

QgsExpressionContext expressionContext = createExpressionContext( parameters, context, source.get() );
QgsProperty bufferProperty;
if ( dynamicBuffer )
Expand Down

0 comments on commit 0f159ca

Please sign in to comment.