Bug report #16706

Rule based symbology matching "lack of value" is not properly encoded in SLD

Added by Andrea Aime over 7 years ago. Updated over 6 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Symbology
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

Description

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>

Related issues

Related to QGIS Application - Bug report #17056: exporting categorized symbology to sld then importing res... Closed 2017-08-24

Associated revisions

Revision c923d5b6
Added by Andrea Aime over 6 years ago

Fixes #16706, categorized symbology matching lack of value is not properly encoded in SLD

History

#2 Updated by Paul van Genuchten about 7 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 7 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?

#4 Updated by Paul van Genuchten about 7 years ago

sorry andrea, i think my issue is a bit different, i created a new issue at #17056

#5 Updated by Jürgen Fischer about 7 years ago

  • Related to Bug report #17056: exporting categorized symbology to sld then importing results in all features having the no-filter value added

#6 Updated by Andrea Aime over 6 years ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Also available in: Atom PDF