Opened 13 years ago
Last modified 13 years ago
#4132 new defect
CssParameter for stroke-opacity ignored in PolygonSymbolizer
| Reported by: | myOpenLayersUName | Owned by: | mapserverbugs |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | WMS Server | Version: | unspecified |
| Severity: | normal | Keywords: | SLD PolygonSymbolizer stroke-opacity CssParameter |
| Cc: | sdlime |
Description
The following value is ignored in an SLD <PolygonSymbolizer>'s Stroke tag:
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.
Change History (4)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
| Cc: | added |
|---|---|
| Component: | MapServer C Library → WMS Server |
| Owner: | changed from to |
comment:3 by , 13 years ago
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?
comment:4 by , 13 years ago
<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.

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.