Bug report #14985

Rule-based labels are not shown

Added by dr - over 4 years ago. Updated over 4 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Labelling
Affected QGIS version:master Regression?:No
Operating System:Ubuntu, Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:22933

Description

1. Open attached layer
2. Properties โ†’ Labels โ†’ Rule-based labeling โ†’ Add rule (Filter: rstr('Special Speed Situation'), Label with: RSTR2)
3. Click on Test button: "Filter returned 3 feature(s)"

rstr - is my custom function added through Expression string builder:

import re

from qgis.core import *
from qgis.gui import *

@qgsfunction(args='auto', group='Custom')
def func(value1, feature, parent):
    return value1

def fvals(feature):
    return ((field.name(), feature.attribute(field.name())) for
        field in feature.fields())

@qgsfunction(args='auto', group='KartaBY')
def rstr(value1, feature, parent):
    pattern = r'^RSTR([1-9]|1[0-9]|2[0-9]|3[0-2])(_([1-9]|1[0-9]|2[0-9]|3[0-2]))?$'
    for name, value in fvals(feature):
        if (re.match(pattern, name) and
            value1.lower() in value.lower()):
            return True

As result - no labels on map.

test-layer.zip (1.36 KB) dr -, 2016-06-08 12:06 PM

Associated revisions

Revision 1bc17e6c
Added by Nyall Dawson over 4 years ago

Default to requesting all attributes for python expression functions

Fix #14985

Revision 248ba385
Added by Nyall Dawson over 4 years ago

Default to requesting all attributes for python expression functions

Fix #14985

(cherry-picked from 1bc17e6c4f40ab64a7d3443886e13f926dab23b7)

History

#1 Updated by Maxim Dubinin over 4 years ago

  • Operating System changed from Ubuntu to Ubuntu, Windows

tested on Win 7 32bit, same result - no labels

#2 Updated by Nyall Dawson over 4 years ago

  • Status changed from Open to Closed

Also available in: Atom PDF