Skip to content

Conversation

@bogind
Copy link
Contributor

@bogind bogind commented Dec 22, 2025

Description

Replacing #63613
As suggested by @nirvn the PR allows access to both Project and User(profile) bookmarks in the expression engine as functions:

  1. project_bookmark - takes 1 parameter, the bookmark name and returns a map object with the properties described below
  2. user_bookmark - similar to project_bookmark but for User Bookmark, so it uses the QgsApplication bookmark manager.

The returned maps\objects are structured to allow access to the following properties of the returned bookmark:

  1. name
  2. id
  3. group
  4. extent - a polygon geometry
  5. extent_rect - an object containing
    5.1. x_min
    5.2. y_min
    5.3. x_max
    5.4. y_max
  6. width
  7. height
  8. crs
  9. rotation

The idea behind the changes are to allow users to use bookmark properties to set specific data driven overrides as well as display them.

The changes are:

  1. In QgsProject added GetNamedUserBookmark and GetNamedProjectBookmark to return a named bookmark and registered both under QgsProject::createExpressionContextScope()
  2. Registered both functions in QgsExpressionContextUtils under QgsExpressionContextUtils::registerContextFunctions
  3. Added JSON help files for both under resources/function_help/json

Built successfully without issues on Windows 11 with QT6 using OSGeo4W qgis-qt6-dev-deps and MS Visual Studio 2022.

@github-actions github-actions bot added this to the 4.0.0 milestone Dec 22, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 22, 2025

🪟 Windows Qt6 builds

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

🍎 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 dfa9d81)

@bogind bogind changed the title User and Project Bookmark expression functions Add expression functions for User and Project Bookmark Dec 23, 2025
@bogind bogind changed the title Add expression functions for User and Project Bookmark Add expression functions for returning User and Project Bookmark Jan 6, 2026
@bogind
Copy link
Contributor Author

bogind commented Jan 8, 2026

Hi @nirvn
could you maybe take a look at the implementation I did here?
I tried to do as you suggested (back in November) and added access to the bookmarks via a function and not variables in as close a way as I could to what is done with project_color_object.

I am just now seeing that you also asked me to name the functions *_bookmark_details but I hope they can still be clear enough as *_bookmark.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant