I wrote some SLD code to style my map layer, which is stored on GeoServer. The GeoServer input window for SLD does not show any error message, but when I open my map in OpenLayers it does not show the map as i wish. In this case, my intend is to color the country polygons similar to the safety level, which is a decimal in my postgres database, so that finally dangerous regions should be like red and safe regions like green.
My code:
<!-- Template taken from: http://docs.geoserver.org/stable/en/user/styling/sld/cookbook/polygons.html#attribute-based-polygon -->
<?xml version="1.0" encoding="UTF-8"?>
<sld:UserStyle xmlns="http://www.opengis.net/sld" xmlns:sld="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:gml="http://www.opengis.net/gml">
<sld:Title/>
<FeatureTypeStyle>
<Rule>
<Name>HighRisk</Name>
<Title>WGI < -0.5</Title>
<ogc:Filter>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>wgi</ogc:PropertyName>
<ogc:Literal>-0.5</ogc:Literal>
</ogc:PropertyIsLessThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#fc8d59</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>MediumRisk</Name>
<Title>WGI > -0.5 und < 0.5</Title>
<ogc:Filter>
<ogc:And>
<ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyName>wgi</ogc:PropertyName>
<ogc:Literal>-0.5</ogc:Literal>
</ogc:PropertyIsGreaterThanOrEqualTo>
<ogc:PropertyIsLessThan>
<ogc:PropertyName>wgi</ogc:PropertyName>
<ogc:Literal>0.5</ogc:Literal>
</ogc:PropertyIsLessThan>
</ogc:And>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#ffffbf</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Name>LowRisk</Name>
<Title>WGI > 0.5</Title>
<ogc:Filter>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>WGI</ogc:PropertyName>
<ogc:Literal>0.5</ogc:Literal>
</ogc:PropertyIsGreaterThan>
</ogc:Filter>
<PolygonSymbolizer>
<Fill>
<CssParameter name="fill">#91cf60</CssParameter>
</Fill>
</PolygonSymbolizer>
</Rule>
<Rule>
<Title>Boundary</Title>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke-width">0.2</CssParameter>
<CssParameter name="stroke">#e2e2e2</CssParameter>
</Stroke>
</LineSymbolizer>
<TextSymbolizer>
<Label>
<ogc:PropertyName>STATE_ABBR</ogc:PropertyName>
</Label>
<Font>
<CssParameter name="font-family">Times New Roman</CssParameter>
<CssParameter name="font-style">Normal</CssParameter>
<CssParameter name="font-size">14</CssParameter>
</Font>
<LabelPlacement>
<PointPlacement>
<AnchorPoint>
<AnchorPointX>-0.5</AnchorPointX>
<AnchorPointY>0.5</AnchorPointY>
</AnchorPoint>
</PointPlacement>
</LabelPlacement>
</TextSymbolizer>
</Rule>
</FeatureTypeStyle>
</sld:UserStyle>
Unfortunately my map looks like this so far:
Any help and tips are appreciated!