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

[server] Add project's context before rendering #6787

Merged
merged 5 commits into from
Apr 16, 2018

Conversation

pblottiere
Copy link
Member

@pblottiere pblottiere commented Apr 12, 2018

Description

This PR:

  • Fixes a segmentation fault in core
  • Add the project context in map settings before rendering
  • Add a unit test with a symbol's rotation defined as a project variable

Checklist

  • Commit messages are descriptive and explain the rationale for changes
  • Commits which fix bugs include fixes #11111 in the commit message next to the description
  • Commits which add new features are tagged with [FEATURE] in the commit message
  • Commits which change the UI or existing user workflows are tagged with [needs-docs] in the commit message and containt sufficient information in the commit message to be documented
  • I have read the QGIS Coding Standards and this PR complies with them
  • This PR passes all existing unit tests (test results will be reported by travis-ci after opening this PR)
  • New unit tests have been added for core changes
  • I have run the scripts/prepare-commit.sh script before each commit

@@ -1125,6 +1125,9 @@ namespace QgsWms
{
mapSettings.setBackgroundColor( backgroundColor );
}

// add context from project (global variables, ...)
mapSettings.setExpressionContext( mProject->createExpressionContext() );
Copy link
Collaborator

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

Copy link
Member Author

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!

Copy link
Collaborator

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)

Copy link
Member Author

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... :)

Copy link
Collaborator

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).

Copy link
Member Author

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 :).

Copy link
Collaborator

Choose a reason for hiding this comment

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

Perfect!

@pblottiere pblottiere merged commit 5e33d7d into qgis:master Apr 16, 2018
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.

3 participants