Skip to content

Conversation

alexbruy
Copy link
Contributor

@alexbruy alexbruy commented Sep 23, 2025

Description

Various fixes for Processing check/fix geometry algorithms:

  • raise an exception in geometry checker algorithms if selected unique ID field contains duplicated values to prevent failures at the geometry repair step (fixes Check geometry (angle) does not check whether feature ID is unique #61398)
  • avoid use of QgsProject::instance() in algorithms
  • correctly mark algorithms which require project with the corresponding flag
  • added cancellation support in geometry checks

@alexbruy alexbruy added the Processing Relating to QGIS Processing framework or individual Processing algorithms label Sep 23, 2025
@github-actions github-actions bot added this to the 4.0.0 milestone Sep 23, 2025
@alexbruy
Copy link
Contributor Author

@Djedouas what do you think?

@alexbruy alexbruy changed the title Processing geom check check ID for uniqueness in geometry checker algorithms Sep 23, 2025
Copy link
Contributor

github-actions bot commented Sep 23, 2025

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 4256f9d)

🍎 MacOS Qt6 builds

Download MacOS Qt6 builds of this PR for testing.
This installer is not signed, control+click > open the app to avoid the warning
(Built from commit 4256f9d)

Copy link
Member

@Djedouas Djedouas left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@alexbruy alexbruy force-pushed the processing-geom-check-id branch from 6bdb560 to 068098a Compare October 1, 2025 07:19
@alexbruy
Copy link
Contributor Author

alexbruy commented Oct 1, 2025

@nyalldawson, @Djedouas I have updated PR with another approach. Now check for duplicated IDs is performed in the geometry checker when unique ID field index is set in the geometry checker context.

I also added support for cancellation as most of the checks do not have it.

@Djedouas may I ask why are you using QgsProject::instance() in the algorithms and not project from the context? Also I noticed that all algorithms are marked with NoThreading flag. According to you

And big layers are what we expect to have with these check algorithms.

But with checks/fixes running in the main thread they seem not very usable with large datasets.

@Djedouas
Copy link
Member

Djedouas commented Oct 1, 2025

Thank you for the support of the algorithm cancellation :)

I think that you are right to throw an exception if the processing is cancelled. But we need to homogenize with the cancellation check that is in most check algorithms during the for loop on check errors (i.e. https://github.com/qgis/QGIS/blob/master/src/analysis/processing/qgsalgorithmcheckgeometryarea.cpp#L195), and throw an exception as well.

Going through a rapid verification of check algorithms, there are some that are missing this cancellation check (i.e. https://github.com/qgis/QGIS/blob/master/src/analysis/processing/qgsalgorithmcheckgeometryselfintersection.cpp#L186 maybe it's the only one?).

Thank you as well for the unique field ID verification inside the geometry checker 👍🏼 looks good to me. That's a huge improvement.

@Djedouas may I ask why are you using QgsProject::instance() in the algorithms and not project from the context? Also I noticed that all algorithms are marked with NoThreading flag.

Good question :) At the beginning of this work to implement these algorithms, I surely chose the multithreaded option. But then there were a lot of segmentation faults that I was unsure where they were coming from. So to be sure they were not coming from the processing themselves, I put the NoThreading flag.

Your question makes me think that it could be because the processings are using QgsProject::instance() instead of the context project.

We have to end up with multithreaded algorithms to handle large datasets. If you manage to achieve this, It would be great!! (and I suggest adapting the PR title then 😉 )

checks

If the uniqueIdFieldIndex in QgsGeometryCheckerContext is a valid field
index, check that there are no duplicated values in that field and fail
if this is the case.
checker algorithms

The small gaps check still rely on QgsProject::instance() as well
as corresponding fixer.
@alexbruy alexbruy force-pushed the processing-geom-check-id branch from 068098a to db45b37 Compare October 1, 2025 13:51
@alexbruy alexbruy changed the title check ID for uniqueness in geometry checker algorithms fixes for Processing geometry checker algorithms Oct 1, 2025
@alexbruy alexbruy force-pushed the processing-geom-check-id branch from ba3b3ec to 109f584 Compare October 2, 2025 07:33
@alexbruy alexbruy requested a review from nyalldawson October 2, 2025 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Geometry checker Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Check geometry (angle) does not check whether feature ID is unique
3 participants