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 Processing algorithms to deal with metadata #59411

Merged
merged 6 commits into from
Nov 12, 2024

Conversation

alexbruy
Copy link
Contributor

Description

Add a few native algorithms to deal with layer metadata:

  • Copy layer metadata to copy metadata from an input layer to a target layer
  • Apply layer metadata to set layer metadata from a QMD file
  • Export layer metadata to export layer metadata in a QMD file

When copying and applying metadata it is possible to set metadata as a default metadata for a layer.

Supersedes #59375.

@alexbruy alexbruy added Feature Processing Relating to QGIS Processing framework or individual Processing algorithms Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. labels Nov 11, 2024
@qgis-bot
Copy link
Collaborator

@alexbruy
This pull request has been tagged as requiring documentation.

A documentation ticket will be opened at https://github.com/qgis/QGIS-Documentation when this PR is merged.

Please update the description (not the comments) with helpful description and screenshot to help the work from documentors.
Also, any commit having [needs-doc] or [Needs Documentation] in will see its message pushed to the issue, so please be as verbose as you can.

Thank you!

@github-actions github-actions bot added this to the 3.42.0 milestone Nov 11, 2024
@alexbruy alexbruy changed the title Processing copy metadata Add Processing algorithms to deal with metadata Nov 11, 2024
@DelazJ DelazJ added the Changelog Items that are queued to appear in the visual changelog - remove after harvesting label Nov 11, 2024
@qgis-bot
Copy link
Collaborator

@alexbruy

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!

Copy link

github-actions bot commented Nov 11, 2024

🪟 Windows builds

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

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 289efe2)

@nyalldawson
Copy link
Collaborator

@alexbruy This is great! Thank you!

(thinking aloud) Some other ideas I've had for metadata related algorithms are:

  • "Update layer metadata" -- copies all NON-EMPTY metadata fields from the source layer to the target layer, and leaves empty source fields unchanged in the target. (QgsAbstractMetadataBase::combine does this logic already)
  • "Set metadata fields" -- exposes the simple metadata fields like title, type, language, abstract, identifier, ... (basically the ones which map across nicely to simple string, enum or datetime parameter types) so that the algorithm specifically sets the corresponding metadata value from the parameter value. This could have a choice for "Ignore empty fields", which would control whether a blank value in the parameter would be used to overwrite an existing value in the layer or not.
  • "Add history metadata" -- exposes a string parameter for "history entry", and ADDS this to any existing history entries in the target layer

That'd address most of the metadata related processing needs. The missing remaining bit then would be some mechanism for auto-copying input layer metadata to generated layers, eg when running tools directly from the toolbox. I think to handle this we'd need API to control "input parameter to copy output layer metadata from" for each individual output that an algorithm generates, so that we can correctly copy the metadata from the correct source when an algorithm has multiple layer input parameters.

And then finally some mechanism to auto-append a history entry for generated layers summarising the processing tool and parameters used to generate that layer... 🥳

@alexbruy
Copy link
Contributor Author

@nyalldawson I already was thinking about algorithm to combine metadata, your other suggestions are also valuable. I will add these new tools in the followup pull-request.

As for the API to add history entries to the metadata and copy metadata from input to output this would be really nice to have and if I recall correctly we even have a ticket about it.

@nyalldawson nyalldawson merged commit 4c3e0e1 into qgis:master Nov 12, 2024
29 checks passed
@qgis-bot
Copy link
Collaborator

@alexbruy
A documentation ticket has been opened at qgis/QGIS-Documentation#9381
It is your responsibility to visit this ticket and add as much detail as possible for the documentation team to correctly document this change.
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 Needs Documentation When merging a labeled PR, an issue will be created in the Doc repo. Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants