Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CssParameter for stroke-opacity ignored in PolygonSymbolizer #4132

Closed
mapserver-bot opened this issue Apr 4, 2012 · 5 comments
Closed

CssParameter for stroke-opacity ignored in PolygonSymbolizer #4132

mapserver-bot opened this issue Apr 4, 2012 · 5 comments
Assignees
Milestone

Comments

@mapserver-bot
Copy link

Reporter: myOpenLayersUName
Date: 2011/12/21 - 18:59
Trac URL: http://trac.osgeo.org/mapserver/ticket/4132
The following value is ignored in an SLD 's Stroke tag:[[BR]]
stroke-opacity

As far as I can tell, the reason is because mapogcsld.c's msSLDParseStroke method uses the following line to set this value in the style:

psStyle->color.alpha = (int)(atof(psCssParam->psChild->psNext->pszValue)*255);

While that line works for LineSymbolizer's it should be as follows for PolygonSymbolizer's:

psStyle->outlinecolor.alpha = (int)(atof(psCssParam->psChild->psNext->pszValue)*255);

Unfortunately, I don't know how I would know which Symbolizer I'm dealing with at that point in the code so I can't suggest a fix but I'm sure someone who knows this code would be able to come up with something fairly quickly.

@mapserver-bot
Copy link
Author

Author: myOpenLayersUName
Date: 2011/12/22 - 19:02
Well, this probably isn't the proper way to do this, but I've simply put both lines of code into the block that sets the stroke-opacity in msSLDParseStroke and it works for both LineSymbolizer and PolygonSymbolizer now:

    :

    else if (strcasecmp(psStrkName, "stroke-opacity") == 0)
    {
        if(psCssParam->psChild &&  psCssParam->psChild->psNext &&
           psCssParam->psChild->psNext->pszValue)
        {
            psStyle->color.alpha =
                (int)(atof(psCssParam->psChild->psNext->pszValue)*255);
            psStyle->outlinecolor.alpha =
                (int)(atof(psCssParam->psChild->psNext->pszValue)*255);
        }
     }

     :

It's what we're going with unless I learn it's a bad idea through this venue at some point.

@mapserver-bot
Copy link
Author

Author: dmorissette
Date: 2011/12/23 - 20:58
The title says 'stroke-opacity' is ignored, but then the rest of the comments relate to the alpha only.

Perhaps if you could include an example (SLD) that would help understand the issue?

@mapserver-bot
Copy link
Author

Author: myOpenLayersUName
Date: 2011/12/24 - 04:47

<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" version="1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd">
    <NamedLayer>
        <Name>Polygon</Name>
        <UserStyle>
            <FeatureTypeStyle>
                <Rule>
                    <Name>Polygon</Name>
                    <Title>Drawing layer</Title>
                    <PolygonSymbolizer>
                        <Fill>
                            <CssParameter name="fill">#FF0000</CssParameter>
                            <CssParameter name="fill-opacity">0.4</CssParameter>
                        </Fill>
                        <Stroke>
                            <CssParameter name="stroke">#000000</CssParameter>
                            <CssParameter name="stroke-opacity">0.6</CssParameter>
                            <CssParameter name="stroke-width">10.0</CssParameter>
                            <CssParameter name="stroke-dasharray" />
                        </Stroke>
                    </PolygonSymbolizer>
                </Rule>
            </FeatureTypeStyle>
        </UserStyle>
    </NamedLayer>
</StyledLayerDescriptor>

This was the PolygonSymbolizer I was trying to use. Everything was rendered appropriately except the stroke-opacity. When I changed the lines as indicated above, it worked but I really have little idea whether it's correct or appropriate.

Additional background info can be found at: http://osgeo-org.1803224.n2.nabble.com/Some-PointSymbolizer-values-are-being-ignored-SLD-Syntax-problem-td7028772.html. The original message discusses stoke-opacity with PointSymbolizers (among other things), but the second and latter messages talk about stoke-opacity in the PolygonSymbolizer.

@ghost ghost assigned sdlime, tbonfort and dmorissette Jun 8, 2012
@myGitHubUName
Copy link

In direct response to dmorrisette's comment: "The title says 'stroke-opacity' is ignored, but then the rest of the comments relate to the alpha only.", the existing code seemed to look at the alpha to determine opacity elsewhere so I merely continued the practice in my code to be consistent. I thought it odd as well, but it seems to be the case throughout this particular class definition (mapogcsld).

Cheers,
jtm

@tbonfort
Copy link
Member

msSLDParseStroke has a parameter to tell if we should use the style's color or outlinecolor. Untested fix committed, keeping fingers crossed :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants