Bug report #16706
Rule based symbology matching "lack of value" is not properly encoded in SLD
|Affected QGIS version:||2.18.9||Regression?:||No|
|Operating System:||Linux||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||24605|
Having a rule based symbology like:
<renderer-v2 attr="dcpNotAffe" forceraster="0" symbollevels="0" type="categorizedSymbol" enableorderby="0"> <categories> ... <category render="true" symbol="2" value="" label="No information"/>
where value = "" is transformed in the following SLD filter:
<ogc:PropertyIsEqualTo> <ogc:PropertyName>dcpNotAffe</ogc:PropertyName> <ogc:Literal></ogc:Literal> </ogc:PropertyIsEqualTo>
However this is not a 1-1 equivalent, as QGIS matches both empty strings and null values, so the filter should really be:
<ogc:Or> <ogc:PropertyIsNull> <ogc:PropertyName>dcpNotAffe</ogc:PropertyName> </ogc:PropertyIsNull> <ogc:PropertyIsEqualTo> <ogc:PropertyName>dcpNotAffe</ogc:PropertyName> <ogc:Literal></ogc:Literal> </ogc:PropertyIsEqualTo> </ogc:Or>
#2 Updated by Paul van Genuchten about 3 years ago
Hi Andrea, i have this experience, when i import an sld having
if 1 -> red
if 2 -> green
if "" -> yellow
the case if "" is always applied (on top of the previously rendered cases). I guess it is the same issue as you describe here. I'm however surprised you seem to indicate this as an SLD-exporter issue. Isn't this an SLD-importer issue? If QGIS choose to "match both empty strings and null values", it should be the SLD importer that convert the switch-case statement to something which is properly converted to QGIS styling? What do you think?
expected behaviour from sld perspective is that if "" -> yellow is only applied to features having "".
#3 Updated by Andrea Aime about 3 years ago
I have experienced this in export, did not check the import part. See my comment about the different interpretation of null and "", for SLD they are different things, but for QGIS they seem to be treated the same. In export I've solved by having that OR, in import I'm not sure how to handle it, I guess it will degrade to the lax interpretation of QGIS unless the code is modified?