2

Is there any way to use the conditional statement in SLD based on scale to set parameter for example:

  • for scale between 25001 and 50 000 set size 15
  • for scale between 5001 and 25 000 set size 28
  • for scale between 400 and 5000 set size 40

I have rule like this

<Name>Test</Name>
<UserStyle>
  <Title>Test</Title>
  <FeatureTypeStyle>

    <Rule>
      <Title>Test</Title>
      <MaxScaleDenominator>50000</MaxScaleDenominator>
      <Filter>
        <PropertyIsEqualTo>
          <PropertyName>value1</PropertyName>
          <Literal>1</Literal>
        </PropertyIsEqualTo>
      </Filter>
      <PolygonSymbolizer>
        <Fill>
          <GraphicFill>
            <Graphic>
              <Mark>
                <WellKnownName>shape://slash</WellKnownName>
                <Stroke>
                  <CssParameter name="stroke">#004d26</CssParameter>
                  <CssParameter name="stroke-width">3</CssParameter>          
                </Stroke>
   
              </Mark>
              <Size>15</Size> <!--  tighter pattern -->
            </Graphic>
          </GraphicFill>
          <CssParameter name="fill-opacity"> 
            <ogc:Function name="env">
              <ogc:Literal>geom_fill_opacity</ogc:Literal>
              <ogc:Literal>0.6</ogc:Literal>
            </ogc:Function>
          </CssParameter>  
        </Fill>
        <Stroke>
          <CssParameter name="stroke">#004d26</CssParameter>
          <CssParameter name="stroke-width">0.2</CssParameter>
          <CssParameter name="stroke-opacity">
            <ogc:Function name="env">
              <ogc:Literal>geom_stroke_opacity</ogc:Literal>
              <ogc:Literal>1</ogc:Literal>
            </ogc:Function>
          </CssParameter>

        </Stroke>
      </PolygonSymbolizer>
    </Rule>
   

2 Answers 2

1

In GeoServer 2.20 you can mark a rule for usage just in the map, or just in the legend:

https://docs.geoserver.org/latest/en/user/styling/sld/extensions/rendering-selection.html

Set the two rules you want to hide as "mapOnly" and they should disappear from the legend.

0

No, each rule with it's scale dependencies is independent of the other rules so you can simply specify the size (or colour or whatever) in that rule.

If having multiple rules causes issue for your legend then pass in the scale to the getLegend request as described in the manual.

3
  • OK, thank you, but in that case in the legend I will have three types of symbology somekind for the same thing, is it possible to avoid it? for example to have only one symbol, hide the other 2 in the legend
    – ncica
    Oct 21, 2021 at 10:54
  • somehow hide a rule from the GetLegendGraphics?
    – ncica
    Oct 21, 2021 at 11:01
  • @ncica, did you find a solution to your question? Apr 4 at 11:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.