[Qgis-developer] symbol levels with rule based rendering

Tim Sutton lists at linfiniti.com
Fri Dec 24 15:13:56 EST 2010


Hi

On Thu, Dec 23, 2010 at 3:31 AM, Mayeul Kauffmann
<mayeul.kauffmann at free.fr> wrote:
> Dear list members,
> I would highly value some advice with some coding problem I facewith
> rule-based rendering.
>
> I am preparing a patch and I have made extensive additions to many parts
> of the code to support some useful features to render map with complex
> symbology grammar (see http://trac.osgeo.org/qgis/ticket/3222 for a
> discussion). Still, I have problems with the symbol levels. I would like
> to enable symbol levels when several rules are matched. It would be
> useful when a feature (specially highways) should be represented with a
> combination of symbols. For instance, a road can be on a bridge, under a
> tunnel [with transparent tunnel symbol], in construction, bordered with
> trees, have restricted access, be a one-way road, etc. In many cases, it
> is possible to simply combine the symbols, e.g. one symbol for the road
> itself and another one for the bridge "around" it, and an arrow for
> one-ways. It would be possible to use only one rule for all highways
> (except motorways if shown with wider symbol). If we have 30 types of
> ways and 5 types of additional symbols (bridge, etc), we could then show
> many tags combinations with only 30+5=35 rules instead of 30*5=150.
> (Imagine if you add 10 scale-based rules: you got 1500 combinations!!).
>
> For the implementation, I modified the symbolForFeature function in
> src/core/symbology-ng/qgsrulebasedrendererv2.cpp
>
>
> Here is what I'm trying to do: For the first matched rule for a given
> feature, the code makes a copy of the rule's symbol. If other rules are
> matched, it merges the layers of the additional matched rule with the
> symbol(s) of previously matched rule(s). It also merges the information
> on symbol levels.
>
> Tests on rendering on small areas (with features matched by 2 rules)
> works partially:
>
>    * the symbols are correctly merged. A new symbol is created and
> displayed, based on the symbology and levels of the matching rules 8-)
>    * However, it modifies the symbol associated with the first matched
> rule and shown in the style sheet (if you open the layer properties, you
> see that the symbol has been permanently modified): the 1st matched rule
> is now represented by a combination of the 2 original symbols. This
> change is saved permanently in the Layer Properties. Similarly for
> symbol levels. 8-(
>    * it crashes very often 8-(
>
> I've pasted my draft code here:
> http://trac.osgeo.org/qgis/ticket/3222#comment:7
>

I'm very curious to try out your patch. If I can summarise what you
are trying to do in a nutshell, its to make a rule based renderer
where each rule that is matched ads one or more symbol layers to the
item symbol and adds an accompanying layer level entry. More or less
correct?

Martin Dobias (who is I think enjoying some time away from the
computer over xmas) will be the best one to help you with your
questions, but I can say that if my description above is correct, it
will be most welcom as it will allow us to create  very nice
cartography at the end of the day.

Regards

Tim

>
> I'm sure there are several incorrect thinks here. Anyone could help?
> Thanks and Merry Christmas!
> Mayeul
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
Tim Sutton - QGIS Project Steering Committee Member (Release  Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
 * QGIS programming and support services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================


More information about the Qgis-developer mailing list