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

[FEATURE] item_variables expression function inside compositions #3968

Merged
merged 3 commits into from Jan 11, 2017

Conversation

nyalldawson
Copy link
Collaborator

This adds a new item_variables expression function when expressions are used inside a composition context.

The function takes a single argument, the id for an item inside the composition, and returns a map of variable name to value for that item.

This allows you to do things like insert text in a label fetching properties of another item in the composition, eg

Insert scale of map into a label:

map_get( item_variables( 'map'),'map_scale')

Insert x coordinate of map center into a label:

x(map_get( item_variables( 'map'),'map_extent_center'))

Previously this has been impossible to do without resorting to custom python expression functions, yet it's a common requirement

@nyalldawson
Copy link
Collaborator Author

Bonus commit:

I've added some new expression variables for map settings (these also work with composer maps, using the item_variables function)

  • map_crs, map_crs_definition: retrieves crs details for map
  • map_units: retrieves units for map (eg 'meters','degrees')

This adds a new item_variables expression function when expressions
are used inside a composition context.

The function takes a single argument, the id for an item inside
the composition, and returns a map of variable name to value
for that item.

This allows you to do things like insert text in a label fetching
properties of another item in the composition, eg

Insert scale of map into a label:

map_get( item_variables( 'map'),'map_scale')

Insert x coordinate of map center into a label:

x(map_get( item_variables( 'map'),'map_extent_center'))
- map_crs, map_crs_definition: retrieves crs details for map
- map_units: retrieves units for map (eg 'meters','degrees')
@rldhont
Copy link
Contributor

rldhont commented Nov 12, 2018

Hi @nyalldawson
Do you think map_crs, map_crs_definition and map_units could be backported ?

@nyalldawson
Copy link
Collaborator Author

@rldhont I'd be -0 for that. It'd be backporting a feature, but I won't stand in the way if you want to take responsibility.

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.

None yet

2 participants