If you have defined an “ElseFilter”, the count for the Else-Filter isn’t correct. It shows always the count of another rule:
To reproduce use the style from below (“Count_Test_2_else”):
GetMap-Request shows 20 brown features (OGC-FIlter “cat>5”) and 5 red features (ElseFilter):
http://localhost:8080/geoserver/sf/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&STYLES=Count_Test_2_else&LAYERS=sf%3Aarchsites&SRS=EPSG%3A26713&WIDTH=769&HEIGHT=499&BBOX=581569.0778227042%2C4910506.0332976645%2C610888.0388157355%2C4929517.547066583
The GetLegendGraphic-Request returns the count of 20 for the first rule (OGC-FIlter “cat>5”) and 20 for the ElseFilter:
http://localhost:8080/geoserver/wms?SERVICE=WMS&REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&LAYER=sf:archsites&EXCEPTIONS=application/json&BBOX=581569.0778227042%2C4910506.0332976645%2C610888.0388157355%2C4929517.547066583&SRS=EPSG%3A26713&FORMAT_OPTIONS=layout:legend&LEGEND_OPTIONS=countMatched:true;fontAntiAliasing:true;forceLabels:on&STYLE=Count_Test_2_else
Style “Count_Test_2_else”:
<?xml version=“1.0” encoding=“ISO-8859-1”?>
<StyledLayerDescriptor xmlns=“http://www.opengis.net/sld” xmlns:ogc=“http://www.opengis.net/ogc” xmlns:xlink=“http://www.w3.org/1999/xlink” 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” version=“1.0.0”>
<NamedLayer>
<Name>Count_Test_2_else</Name>
<UserStyle>
<Name>Count_Test_2_else</Name>
<Title>Count_Test_2_else</Title>
<FeatureTypeStyle>
<Rule>
<Name>catGreater5</Name>
<Title>catGreater5</Title>
<ogc:Filter>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>cat</ogc:PropertyName>
<ogc:Literal>
5
</ogc:Literal>
</ogc:PropertyIsGreaterThan>
</ogc:Filter>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name=“fill”>#734C00</CssParameter>
</Fill>
</Mark>
<Opacity>1</Opacity>
<Size>9</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>elseFilter</Name>
<Title>elseFilter</Title>
<ElseFilter />
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name=“fill”>#FF0000</CssParameter>
</Fill>
</Mark>
<Opacity>1</Opacity>
<Size>9</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
|