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

Add merge policies #60710

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open

Conversation

JuhoErvasti
Copy link
Contributor

@JuhoErvasti JuhoErvasti commented Feb 21, 2025

Fixes #59494.

Similarly to already existing Split and Duplicate "policies" this PR implements Merge Policies, which determine the initial values in the Merge Features dialog. The PR includes the following merge policies:

From the existing Qgis::FieldDomainMergePolicy enum:

  • Sum: numeric fields only
  • Geometry Weighted: numeric fields only, uses weighted average by geometry
  • Default Value: uses the default value set in QGIS

New policies:

  • Unset Field: similarly to Split & Duplicate policies clears the field and lets the data provider populate any default value if one exists. If it doesn't the first feature is used (this is the behavior which is currently implemented)
  • Largest Geometry: use the value from the feature with the biggest geometry (length/area/number of parts for multipoints)
  • Minimum Value: numeric fields only
  • Maximum Value: numeric fields only
  • Skip Attribute: sets the initial state to "Skip", if not modified manually value will be NULL

Initial merge dialog before PR:
MERGEPOLICY_BEFORE

Initial merge dialog after PR:
MERGEPOLICY_AFTER

Configuring the policies:
image

Funded by the National Land Survey of Finland.

@github-actions github-actions bot added this to the 3.44.0 milestone Feb 21, 2025
Copy link

github-actions bot commented Feb 21, 2025

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 7b51a6b)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 7b51a6b)

src/core/qgis.h Outdated
LargestGeometry, //!< Use value from the feature with the largest geometry \since QGIS 3.44
MinimumValue, //!< Use the minimum value from the features-to-be-merged \since QGIS 3.44
MaximumValue, //!< Use the maximum value from the features-to-be-merged \since QGIS 3.44
SkipAttribute, //!< Use a null value \since QGIS 3.44
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd use an explicit name for this one:

Suggested change
SkipAttribute, //!< Use a null value \since QGIS 3.44
SetToNull, //!< Use a null value \since QGIS 3.44

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nyalldawson Changed. Should the change be reflected in the GUI as well (combobox etc.)? I initially went with SkipAttribute since that terminology is already used in the merge dialog itself.

And thank you for the review!

@nyalldawson nyalldawson added Feature Changelog Items that are queued to appear in the visual changelog - remove after harvesting labels Feb 24, 2025
@qgis-bot
Copy link
Collaborator

@JuhoErvasti

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog Items that are queued to appear in the visual changelog - remove after harvesting Feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DB default values override actual values in merge selected features tool
3 participants