Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Processing] Fix Dissolve alg for featureless input layer or containing empty/null geometries, when the output is a memory layer (Fix #53392) #57478

Merged

Conversation

agiudiceandrea
Copy link
Contributor

Description

This PR fixes the "Dissolve" (native:dissolve) processing algorithm which fails to execute when the output layer is a memory layer (particularly when the algorithm is used as part of a model) and the input layer doesn't contain any features or contains features with empty/null geometry as detailed in #53392.

This proposed fix makes sure the Dissolve algorithm:

  • always outputs an empty layer if the input layer doesn't contain any feature
  • handles the empty geometries the same way as the null geometries
  • doesn't try to collect / dissolve null / empty geometries

Fixes #53392.

@github-actions github-actions bot added this to the 3.38.0 milestone May 18, 2024
@agiudiceandrea agiudiceandrea changed the title [Processing] Fix Dissolve alg for featureless input layer or containing empty/null geometries, when the output is a memory layer [Processing] Fix Dissolve alg for featureless input layer or containing empty/null geometries, when the output is a memory layer (Fix #53392) May 18, 2024
@agiudiceandrea agiudiceandrea added Processing Relating to QGIS Processing framework or individual Processing algorithms Bug Either a bug report, or a bug fix. Let's hope for the latter! backport release-3_34 labels May 18, 2024
@@ -36,10 +36,16 @@ QVariantMap QgsCollectorAlgorithm::processCollection( const QVariantMap &paramet
if ( !sink )
throw QgsProcessingException( invalidSinkError( parameters, QStringLiteral( "OUTPUT" ) ) );

QVariantMap outputs;
outputs.insert( QStringLiteral( "OUTPUT" ), dest );

const QStringList fields = parameterAsStrings( parameters, QStringLiteral( "FIELD" ), context );

const long count = source->featureCount();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related to this PR, but... shouldn't this be long long instead of long?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it should be long long everywhere

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it looks like there are many processing algorithms with the same issue, I will subsequently propose a PR to fix them all together.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

Copy link

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit 14c32e7)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport queued_ltr_backports Queued Backports Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dissolve (native) algorithm: "Could not add feature with geometry type GeometryCollection..."
2 participants