Bug report #9648

qgis composer map canvas fails to properly render a (complex) rule-based symbology layer

Added by Mathieu Pellerin - nIRV over 10 years ago. Updated over 10 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:Martin Dobias
Category:-
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:18218

Description

Under qgis master (2.3), the qgis composer map canvas fails to properly render a complex rule-based symbology layer. It's affecting both the cache rendering and the export to image.

I've attached a stripped project file that shows the issue. Steps to reproduce:
1. Open the project file
2. Look at the rendering on the qgis map canvas (proper)
3. Open the composer, and set the map item preview to cache
4. At that stage you'll notice the map shows the layer with only a partial rendering of the rule-based symbology.
5. Click on 'Export as Image', the resulting file will have the same rendering issues.

Incidentally, it also shows issues with label rendering upon exporting composer to image, will file a separate issue for that.

mrt-composer-errors.qgs.zip (3.9 MB) Mathieu Pellerin - nIRV, 2014-02-25 04:33 AM

scale_error.png (212 KB) Mathieu Pellerin - nIRV, 2014-02-25 05:12 PM

scale_issue.zip (6.58 KB) Mathieu Pellerin - nIRV, 2014-02-25 05:12 PM

Associated revisions

Revision 1d3ae87c
Added by Martin Dobias over 10 years ago

Fix #9648 (wrong scale in composer)

History

#1 Updated by Mathieu Pellerin - nIRV over 10 years ago

Ok, I realise what's happening. The rule based symbology relies on minimum / maximum scale to activate some styles. The scale value is set to wrong value in composer. This must have to do with scale wrongly factoring in dpi calculation.

That might also be cause of broken labels.

#2 Updated by Mathieu Pellerin - nIRV over 10 years ago

Scale value defined of composer map items is definitively broken, see attached scale_error.png which shows that a map item set to scale 12,192 will have its scale value during rendering set to 1,055,129,875.

Steps to reproduce:
1. Create a project (UTM-based projection is preferred as issue shows more easily using this type of projection)
2. Add a vector layer (with a single feature makes it simpler)
3. Add a data-defined label to the vector layer that shows the scale value (i.e. simply '$scale', or a nicer formatting through 'format_number($scale,0)'
4. Create a composer
5. Add a map item, you'll immediately see the label is way off the scale setting of the map item

Attaching a test project that follows the above steps.

#3 Updated by Martin Dobias over 10 years ago

  • Status changed from Open to Closed

#4 Updated by Mathieu Pellerin - nIRV over 10 years ago

Well, that was easy :)

#5 Updated by Martin Dobias over 10 years ago

Note: the scale in map preview may be a bit different from the scale shown in GUI (but it is correct in print output). This is due to the fact that DPI is a whole number, so the preview (with low DPI) may have real scale a bit different from the expected. That should not be a problem though.

The way how it works now is that scale is always computed from extent width (using canvas width and DPI). For exact scale handling, there could be alternative where extent would be calculated from map center point + scale (using again canvas width and DPI).

#6 Updated by Mathieu Pellerin - nIRV over 10 years ago

Martin, I see, I was about to comment on the slight variation (just compiled a new build with your commit in, testing out).

It might be problematic if a user has min/max scale layer visibility or symbology. The slight variation over here can be +/- 10% with a GUI scale set to 12000. So for e.g., if I set a layer to be visible at scale 12000, and I have a composer map item with scale 12000, the layer would not render in the qgis composer window. That might be confusing for some people. That said, it is somewhat of an edge scenario.

P.S. This commit didn't fix the label size when map is exported to image, will file an issue with steps to reproduce now.

#7 Updated by Martin Dobias over 10 years ago

I am putting this to my "to think about" list :-)

Also available in: Atom PDF