Bug report #15337
Scale dependent layer visibility and print composer
|Affected QGIS version:||2.16.0||Regression?:||No|
|Operating System:||Windows 7 Professional||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||worksforme|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||23269|
Scale dependent layer visibility set in layer properties -> general or in style -> rule-based is not working properly in print composer. Layers that are visible in the map canvas are not visible in the print composer layout although same scale is used in canvas and composer. In pdf or image export, there is a similar issue as layers appear or do not appear in exported files differing from composer view. The problem seems to be related to bug report #9648 (closed), where problems like this where predicted by Mathieu Pellerin. As I think that scale dependent styling rules and visibility are very important in any complex map styling, it would be great if there is a solution found for the issue.
In the attached files, I described the behaviour concerning scale dependent visibility between canvas and composer in detail. Therefore I created a simple test project with print composer. From that project I created screenshots and pdf exports and documented the used scale thresholds in a word document. Further details are also given in the word document.
In case the test project seems to show some edgy scenarios, I describe a daily-work issue I experience with the bug: Lets say I want to style a topographic base map with buildings displayed depending on scale. From 1:1 to 1:1,000 I want buildings to show in light grey and 50% transparency. From 1:1,001 to 1:10,000 I want to show buildings in solid dark grey. From 1:10,001 buildings shouldn't show at all. Off course, the user expects to get the same view in map composer and in export files. But with the bug, you will have some strange effects when printing maps from composer with close to threshold scale.
It might also help to take a view to the earlier communication on QGIS-user-mailinglist here: http://osgeo-org.1560.x6.nabble.com/Bug-in-Map-Composer-td5277723.html#a5277953.
Unify scale widgets API
Flip all scale based widgets to use scale denominators instead
of actual scales (ie 100.0 instead of 0.01 for 1:100).
This is done for consistency with the rest of the API, which
predominantly uses scale denominators. It also helps
precision loss as a result of multiple 1.0 / scale conversions
throughout the code.
#1 Updated by Steve Lowman over 4 years ago
A brief example involving two raster background layers. Layer A is set to be visible at scales from 1:10000 to 1:24999. Layer B should be visible from 1:24999 to 1:50000. The transition at 1:24999 works correctly in QGIS map canvas, but is quite different in Print Composer and different again in the exported file. The transition scale in Print Composer and the exported file varies depending on the size of the map on the page, for example whether the map fills the page or whether there is a margin at the page edge.
|Context||Scale at which visible layer changes from Layer A to Layer B|
|Exported A3 – map fills the page||25049|
|Exported A3 – map smaller than page||25061|
|Print composer on screen – A3 – map fills the page||25070|
|Print composer on screen – A3 – map smaller than page||25090|
The dynamic zooming capability in map canvas that should be facilitated by scale dependent visibility is made unfeasible in practice by this problem.
The 'affected version' for this bug is set to be 2.16, but clearly it also affects the 2.14 LTR. I have not tested it in 2.18.