Bug in GetLegendGraphic countMatched-feature when using MaxScaleDenominator in SLD

Description

There is a bug in the new „return feature count“-feature in the GetLegendGraphic-request (parameter: "LEGEND_OPTIONS=countMatched:true").

If you specify the „MaxScaleDenominator“ in your SLD-rule, the returned feature count in the generated legend is always „0“. The map-view for this SLD-rule (GetMap-request) works fine and displays the features correctly according to the scale.

The returned feature count works also correctly if you use the „minScaleDenominator“.

To reproduce, use the "archsites"-demo layer and create a new SLD called "Count_Test" (SLD-content is below). Assign it to the "archsites"-layer.

Here are the requests to reproduce the bug:

Using scale: 4261

GetMap-Request:

http://localhost:8080/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=sf%3Aarchsites&SRS=EPSG%3A26713&WIDTH=768&HEIGHT=498&BBOX=593148.2540677547%2C4914310.483436286%2C594064.4715987869%2C4914904.593241565&STYLES=Count_Test

--> correct

GetLegendGraphic-request:
http://localhost:8080/geoserver/wms?SERVICE=WMS&REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=sf:archsites&SCALE=4261&EXCEPTIONS=application/json&BBOX=593148.2540677547%2C4914310.483436286%2C594064.4715987869%2C4914904.593241565&SRS=EPSG%3A26713&FORMAT_OPTIONS=layout:legend&LEGEND_OPTIONS=countMatched:true;fontAntiAliasing:true;forceLabels:on&STYLE=Count_Test

returns in GetLegendGraphics-image: „maxScale5000 (0)“ --> wrong

Using scale: 8521:

GetMap-Request:

http://localhost:8080/geoserver/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&LAYERS=sf%3Aarchsites&SRS=EPSG%3A26713&WIDTH=769&HEIGHT=498&BBOX=592690.1453022385%2C4914013.428533647%2C594522.5803643031%2C4915201.648144204&STYLES=Count_Test

-->correct

GetLegendGraphic-request:
http://localhost:8080/geoserver/wms?SERVICE=WMS&REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=20&HEIGHT=20&LAYER=sf:archsites&SCALE=8521&EXCEPTIONS=application/json&BBOX=592690.1453022385%2C4914013.428533647%2C594522.5803643031%2C4915201.648144204&SRS=EPSG%3A26713&FORMAT_OPTIONS=layout:legend&LEGEND_OPTIONS=countMatched:true;fontAntiAliasing:true;forceLabels:on&STYLE=Count_Test

returns in GetLegendGraphics-image: „minScale5000 (2)“ --> correct

SLD:
<?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</Name>
<UserStyle>
<Name>Count_Test</Name>
<Title>Count_Test</Title>
<FeatureTypeStyle>
<Rule>
<Name>maxScale5000</Name>
<Title>maxScale5000</Title>
<MaxScaleDenominator>5000</MaxScaleDenominator>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#00FFFF</CssParameter>
</Fill>
</Mark>
<Opacity>1</Opacity>
<Size>10</Size>
</Graphic>
</PointSymbolizer>
</Rule>
<Rule>
<Name>minScale5000</Name>
<Title>minScale5000</Title>
<MinScaleDenominator>5000</MinScaleDenominator>
<PointSymbolizer>
<Graphic>
<Mark>
<WellKnownName>circle</WellKnownName>
<Fill>
<CssParameter name="fill">#734C00</CssParameter>
</Fill>
</Mark>
<Opacity>1</Opacity>
<Size>9</Size>
</Graphic>
</PointSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

Environment

None

Status

Assignee

Andrea Aime

Reporter

Paul Biskup

Triage

Fix versions

Affects versions

Priority

Medium
Configure