geostyler / geostyler-sld-parser

GeoStyler-Style-Parser implementation for SLD
BSD 2-Clause "Simplified" License
53 stars 34 forks source link

QGIS SLD not processing correctly #911

Closed cwdgservices closed 11 months ago

cwdgservices commented 11 months ago

Is this plugin still compatible with the newest outputs from qgis. We have been trying to get it to export correctly to no avail.

Example: `<?xml version="1.0" encoding="UTF-8"?>

county_boundaries county_boundaries Single symbol #8d5a99 0 #ff0101 1 bevel

`

when running const { output: geostylerStyle } = await sldParser.readStyle(self.SLDFile) it outputs the following:

[ { "name": "Single symbol", "symbolizers": [ { "kind": "Fill" } ] } ]

We did notice that if we manually edited this._sldVersion = '1.1.0'; We were able to get better results but it duplicated the fill twice. Is there something we are doing wrong or a compatibility issue we need to work on.

jansule commented 11 months ago

The unconfigured SLD parser expects a style in version 1.0.0, whereas you are providing a style in version 1.1.0. You can configure the parser to use 1.1.0 by providing the version when instantiating the parser:

const sldParser = new SldStyleParser({
  sldVersion: '1.1.0'
});

You can also try it out in the geostyler demo by selecting the SLD 1.1.0 - Symbology Encoding format in the editor on the right side. Pasting your SLD, it creates following geostyler-style for me:

{
  "name": "county_boundaries",
  "rules": [
    {
      "name": "Single symbol",
      "symbolizers": [
        {
          "kind": "Fill",
          "color": "#8d5a99",
          "fillOpacity": 0,
          "outlineColor": "#ff0101",
          "outlineWidth": 1,
          "outlineJoin": "bevel"
        }
      ]
    }
  ]
}
cwdgservices commented 11 months ago

That is exactly what we needed. I am surprised it was not identifying that we were using 1.1.0. After that declaration everything worked great.