-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[server] Add project's context before rendering #6787
Conversation
@@ -1125,6 +1125,9 @@ namespace QgsWms | |||
{ | |||
mapSettings.setBackgroundColor( backgroundColor ); | |||
} | |||
|
|||
// add context from project (global variables, ...) | |||
mapSettings.setExpressionContext( mProject->createExpressionContext() ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be done elsewhere, but I believe you also want a mapSettingsScope added here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @nyalldawson,
This may be done elsewhere, but I believe you also want a mapSettingsScope added here
Could you elaborate a little bit more on that? Because a mapSettingsScope
would contain variables related to QgsMapSettings
(like map rotation), but I don't see where it can be directly useful for the rendering step on the server side?
Thanks for your review!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's got lots of things relating to the map settings - e.g. the extent, which is required by the 25d renderer to work correctly, and scale (which is required by lots of different rules)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But in this case, the mapSettings
variable is already configured with extent, size and so on.
Then it's directly used by QgsMapRendererParallelJob
or QgsMapRendererCustomPainterJob
for the rendering:
QgsMapRendererParallelJob renderJob( mapSettings );
So I don't see how the mapSettingsScope
could be usfeul in this scenario?
Sorry, it's probably obvious... :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you had a rule (or data defined symbology) which relies on any of the variables provided through the map settings scope, then you need this scope added to the expression context or the expressions won't evaluate correctly. (This includes @map_scale, @map_extent, @map_rotation, etc).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then you need this scope added to the expression context or the expressions won't evaluate correctly.
Of course, thank you for your explanation Nyall!
I updated the expression context and unit tests accordingly to check that @map
variables are correctly used :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect!
39d3900
to
2d340a0
Compare
Description
This PR:
Checklist
fixes #11111
in the commit message next to the description[FEATURE]
in the commit message[needs-docs]
in the commit message and containt sufficient information in the commit message to be documentedscripts/prepare-commit.sh
script before each commit