Bug report #11863

invalid sld for graduated style on field with negative values

Added by Maarten Pronk about 9 years ago. Updated almost 9 years ago.

Affected QGIS version:2.6.1 Regression?:No
Operating System:Linux, Windows Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:20078


When creating a graduated style on a field with negative values, the resulting sld file has the following xml:


The sld has a Literal within a Literal. Loading the same sld back into QGIS produces rules with || like:

value > '-' || 4.45316 AND value <= '-' || 0.786648

Which results in the same visualization for all negative fields.

Affects 2.4 to 2.6.1, probably also older versions. Tested on different layers, with different fields on Windows & Linux.

issue.zip - exampe project, shape plus invalid sld (11.1 KB) Richard Duivenvoorde, 2015-03-30 02:42 AM

Associated revisions

Revision f800ac63
Added by Martin Dobias almost 9 years ago

Merge pull request #1975 from rduivenvoorde/sldfix_11863

Fixes #11863 (invalid SLD with negative values)


#1 Updated by Richard Duivenvoorde almost 9 years ago

  • Target version set to Version 2.8.2
  • Category changed from Symbology to Expressions
  • File issue.zip added

I've been trying to debug this, and it appears that for the creation of the sld qgsexpression is used.

And after the parsing of an expression string like:

foo > -0.01 AND foo <= -0.001

the minus signs are seen/parsed as unary operators instead of a minus+doube

adding an example project so hopefully somebody more into this part of the code is able to debug/fix it better

#2 Updated by Richard Duivenvoorde almost 9 years ago

According to others it is not the parsing that is the problem,
it is the xml/sld generation which does not take the unary-minus into account.


is my try to fix this...

#3 Updated by Martin Dobias almost 9 years ago

  • Status changed from Open to Closed

#4 Updated by Richard Duivenvoorde almost 9 years ago

  • Target version changed from Version 2.8.2 to Version 2.10

Also available in: Atom PDF