geostyler / geostyler-sld-parser

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

Sld parser potential issue with OpenLayers parser #605

Open Eullar opened 2 years ago

Eullar commented 2 years ago

Question

Hey. I think I found an issue when working with Sld and OpenLayers parsers. Sld parses fill-opacity to fillOpacity field:

case 'fill-opacity':
          fillSymbolizer.fillOpacity = parseFloat(value);
          break;

However later on opacity field is also set:

if (!fillSymbolizer.color) {
      fillSymbolizer.opacity = 0;
    }

I also found out that in OpenLayers parser, when creating Polygon symbolizer from Fill symbolizer, opacity field is used, which won't work because the opacity will be null because the color is set, therefor the color will always be solid:

 getOlPolygonSymbolizerFromFillSymbolizer(symbolizer: FillSymbolizer): OlStyleFill {
    let fill = symbolizer.color ? new this.OlStyleFillConstructor({
      color: (symbolizer.opacity !== null && symbolizer.opacity !== undefined) ?
        OlStyleUtil.getRgbaColor(symbolizer.color, symbolizer.opacity) : symbolizer.color
    }) : null;

Am I correct in thinking that this is not right? If this is an issue, is it an issue of Sld or OpenLayers parser?

KaiVolland commented 2 years ago

Hey @Eullar,

thanks for the report.

  1. Actually you could arguee, that an opacity without a fillcolor does not make sence, but I think you're right and we should not modify this. Maybe you could open a PR with a (failing) test that contains the input and expected output?

  2. I think you're also right about the OLParser. Would be nice if you could open an issue here. And same as for the bug here. An PR with a failing test for the input and expected output would be very helpful.