Easier Conditional Labels in QGIS
With Martin’s latest addition of conditional statements it’s now even easier to get conditional labels in QGIS. Following up on the example used in my previous post, we can simplify
substr(osm_name, 0, (clazz = 11 or clazz = 13 or clazz = 15 or clazz = 21)*-1)
to
CASE WHEN (clazz = 11 or clazz = 13 or clazz = 15 or clazz = 21) THEN osm_name END
which is much easier to read and remember.
To avoid roads from being labeled with only their road numbers, I added an additional check that the “osm_name” is longer than six characters. Thanks to Nathan’s syntax highlighting this new and powerful expression based labeling is also comfortable to use.
It’s great ! Now I’m waiting for the same in symbols. Like :
base symbol is symbol1
If label1 = “mercure” so set color to blue else red
add text”label2″ on symbol
Something like this :)
Now I’v to write each rules, for each cases to show each symbols. Instead of writing one conditional symbol rule.
Using QGIS give me so much fun !
Any possibility to avoid writing an endless row of “or or or” but make a comma separated list there? Some way to shorten a larger query?
I didn’t see an IN operator like the one available in SQL but it would definitely be worth a feature request.
Pingback: New Labeling in Quantum GIS « Scratching Surfaces