[Qgis-user] New Labeling: conditional labels

Nathan Woodrow madmanwoo at gmail.com
Thu Dec 29 02:33:07 PST 2011


It would be handy to add condition statements to QgsExpression so we can
support this kind of thing, Martin would be the guy to talk to about adding
this kind of thing.  He knows the most about QgsExpression.

I am also looking at adding Python support to any sections that also use
QgsExpression; this would allow us to use a QGIS expression for simple-ish
stuff but also Python if need be for doing more powerful stuff.

I started a wiki page[0] before the last Hackfest about some of my ideas
about adding rule based labeling, which would be very cool to have.

[0] http://hub.qgis.org/wiki/quantum-gis/RuleBasedLabelingIdeas

- Nathan

On Thu, Dec 29, 2011 at 8:25 PM, Andreas Neumann <a.neumann at carto.net>wrote:

> Hi Giuseppe,
>
> Thanks for your hint with the syntax - it works in my case.
>
> I think I sort of understand the syntax - at least the > operator and the
> substr. What I do not understand is why I need the *-1 (multiplier).
>
> But I think the syntax is far from being intuitive, without some help.
> Maybe we can come up with a simple solution in the future?
>
> If we could combine the rule-based renderer approach with the current
> labeler (with its new query builder), it would be awesome.
>
> Thanks for your help!
>
> Andreas
>
>
> On Wed, 28 Dec 2011 20:01:43 +0100, Giuseppe Sucameli wrote:
>
>> Hi Andreas,
>>
>> On Thu, Dec 22, 2011 at 2:31 PM, Andreas Neumann <a.neumann at carto.net>
>> wrote:
>>
>>> What I want is that a label is only drawn if a column value is larger
>>> than
>>> 0. I don't want to label features with a value of zero.
>>>
>>> Do you have any hints how the syntax works for such a case? I see ">"
>>> operators but no "if" or "when".
>>>
>>
>> there's no "if" operator, but ">" returns 1 if true and 0 if false,
>> e.g. (field > 5)*10 let's give you 10 or 0 as result.
>>
>> The problem is that you don't want to display anything when
>> the field value is 0, so we can use the substr function.
>>
>> Here's the solution to your problem:
>> substr(id, 0, (id > 0)*-1)
>> that means if id <= 0 then substr(id, 0, 0) else substr(id, 0, -1)
>>
>> In general:
>> substr(output, 0, (condition)*-1)
>>
>> Cheers.
>>
>>  If it is not possible, then I can still do it in Postgis, but it would be
>>> nice being able to do this in QGIS.
>>>
>>> Thanks for any hints,
>>> Andreas
>>>
>>> --
>>> --
>>> Andreas Neumann
>>> Böschacherstrasse 10A
>>> 8624 Grüt (Gossau ZH)
>>> Switzerland
>>> ______________________________**_________________
>>> Qgis-user mailing list
>>> Qgis-user at lists.osgeo.org
>>> http://lists.osgeo.org/**mailman/listinfo/qgis-user<http://lists.osgeo.org/mailman/listinfo/qgis-user>
>>>
>>
> --
> --
> Andreas Neumann
> Böschacherstrasse 10A
> 8624 Grüt (Gossau ZH)
> Switzerland
> ______________________________**_________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/**mailman/listinfo/qgis-user<http://lists.osgeo.org/mailman/listinfo/qgis-user>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20111229/d362fa83/attachment.html>


More information about the Qgis-user mailing list