[Qgis-developer] Labeling layers

Hugo Mercier hugo.mercier at oslandia.com
Mon Mar 24 02:20:03 PDT 2014


Hi all (from Vienna :)),

I've been working on some evolutions of the AEAG "Mask" plugin. This
plugin allows to define a "stencil" layer on top of other layers. The
idea is to be able to highlight a part of the canvas by hiding
(completely or with some transparency) the other parts. And it has to
work when the atlas rendering is turned on, adapting the current
geometry to the atlas geometry.
A first step to integrate this into the core was to add a new "exterior"
filling mode. I've sent a pull request and the merging process is on its
way.
https://github.com/qgis/QGIS/pull/1254

There is still some tricky issues to overcome if we want to have
something properly integrated. One of the remaining issues is related to
labeling, because we want to be able to also hide labels from "masked"
parts, or to display them "below" the mask layer (in case of transparency).

There is some partial solution to that using kinds of hacks. For
instance, labeling expressions may be used for that, something like
"CASE WHEN contains($mask_geometry, $geometry) THEN ... ELSE '' END" or
using the 'show' data defined labeling field.

But this has some limitations : it is not very user-friendly, and the
spatial predicates must be choosen wisely, especially when on-the-fly
simplifications are enabled.

So ... I was thinking of something more integrated. And it might imply
to enhance a little bit the labeling engine.
I was thinking of :
- adding something like a label layer with a 'Z' ordering that the user
could place with drag and drop in the rendering 'stack'. I am not sure
yet of the technical details, and PAL possibilities or limitations here,
but there is apparently ways to define 'obstacles' objects for the
labeling engine. So labels from a layer would be placed with label boxes
from the layers below considered as obstacles.
- exterior fills would also be considered as obstacles (if they are opaques)
- label layer rendering would be mixed with vector layer rendering, so
rendering options avaiable to vector layers could be also used on label
layers (blending modes and so on).

Are there some interests for that ? Can you see other ways to do ?

-- 
Hugo Mercier
Oslandia


More information about the Qgis-developer mailing list