[mapserver-dev] GetStyles SLD does not include LAYER's Opacity value

myOpenLayersUName joanne.mcgraw at SYMPATICO.CA
Wed Jun 6 10:29:39 PDT 2012


I originally created a post about this in the Users forum
(http://osgeo-org.1560.n6.nabble.com/GetStyles-SLD-does-not-include-Opacity-value-td4979066.html#a4979520),
but after learning more about it I believe it's more appropriately included
in the Dev forum. If I have erred in doing so, I apologize.

To summarize, in 6.0.1 (and 6.0.3 according to the source), I have a Map
file with a LAYER OPACITY value set to 20. When I perform a GetStyles
request the Rule in the response does not include a "fill-opacity"
CssParameter. Steve Lime suggested that I could deal with this by moving the
OPACITY setting to the LAYER's CLASS' STYLE block and he was correct. Doing
so, in my simple LAYER, returned the fill-opacity in the GetStyles request.

After having thought more about this though, I think there is still a
problem. Whereas my example only has a single CLASS, often there are
multiple and having to introduce the same OPACITY to all those CLASS
definitions just increases the risk of things getting inconsistent along the
way. 

In creating the GetStyles response, the code should look at the CLASS
STYLE`s OPACITY definition but also at the LAYER`s OPACITY definition to
determine whether the fill-opacity should be added to the Rule. Certainly, a
GetMap or GetLegendGraphic request knows to accommodate the definition
occurring in either place (although I had not expected the LAYER's OPACITY
definition to override the CLASS STYLE's definition; I expected the opposite
but it's consistent so not important).

I believe, therefore that the code in mapogcsld.c's msSLDGeneratePolygonSLD
should read something like this (in the section where it's dealing with the
fill-opacity):

        if(psLayer->opacity != 100 && psLayer->opacity != -1) {
            snprintf(szTmp, sizeof(szTmp),
                  "<%s name=\"fill-opacity\">%.2f</%s>\n",
                  sCssParam, (float)psLayer->opacity/100, sCssParam);
            pszSLD = msStringConcatenate(pszSLD, szTmp);
         }
         else if(psStyle->color.alpha != 255 && psStyle->color.alpha!=-1) {
            snprintf(szTmp, sizeof(szTmp),
                  "<%s name=\"fill-opacity\">%.2f</%s>\n",
                  sCssParam, (float)psStyle->color.alpha/255, sCssParam);
            pszSLD = msStringConcatenate(pszSLD, szTmp);
         }

(NOTE: stroke-opacity would be similar but isn't covered in the polygon or
line symbolizers at all at the moment).

Can someone verify if I am correct in my assumptions with this and, if so,
I'll create a ticket to request it be added to the Mapserver code.

Cheers,
jtm

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/GetStyles-SLD-does-not-include-LAYER-s-Opacity-value-tp4979569.html
Sent from the Mapserver - Dev mailing list archive at Nabble.com.


More information about the mapserver-dev mailing list