geoserversld

Geoserver style increase size when user zooms


I have a style with some rules

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
  xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.0.0/StyledLayerDescriptor.xsd"
  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">
  <NamedLayer>
    <Name>centros_transformacion</Name>
    <UserStyle>
      <Title>Estado normal</Title>
      <FeatureTypeStyle>                             
       <!-- REGLAS -->      
        <Rule>
          <!-- Centro transformación OK-->
          <Title>punto verde</Title>      
           <PointSymbolizer>
            <Graphic>
              <ExternalGraphic>
                <OnlineResource xlink:type="simple" xlink:href="simb_ok.png" />
                <Format>image/png</Format>
              </ExternalGraphic>
                <Size>
                  25
                 </Size>
            </Graphic>
          </PointSymbolizer>         
        </Rule>
        <Rule>
          <!-- Centro transformación DESCONECTADO -->
          <Title>punto gris</Title>
          <ogc:Filter>
            <ogc:PropertyIsEqualTo>
              <ogc:PropertyName>status</ogc:PropertyName>
              <ogc:Literal>-1</ogc:Literal>
            </ogc:PropertyIsEqualTo>
          </ogc:Filter>
          <PointSymbolizer>
            <Graphic>
              <ExternalGraphic>
                <OnlineResource xlink:type="simple" xlink:href="simb_desconectado.png" />
                <Format>image/png</Format>
              </ExternalGraphic>
              <Size>25</Size>
            </Graphic>
          </PointSymbolizer>       
        </Rule>

This displays points in a a map and the image changes depending of one value from database, and this works perfectly.

The problem is the size of the item, I set a size of 25 pixels and when I zoom this value is recalculated and looks good. But when the user zooms to much the image is very very small.

I would like to control this but seems impossible.

I try with this inside the size tag but the result is the same.

<Size>
   <ogc:Function name="Interpolate">
       <ogc:Function name="env">
         <ogc:Literal>wms_scale_denominator</ogc:Literal>
         </ogc:Function>
            <ogc:Literal>100</ogc:Literal>
            <ogc:Literal>25</ogc:Literal>
        </ogc:Function>
 </Size>

¿Could you tell me how to do this please?


Solution

  • You're close, an interpolation needs control points on the scale to work, something like this, setting 100 at 1:10k, and making it 25 at 1:100k, with linear interpolation.

    <Size>
       <ogc:Function name="Interpolate">
           <ogc:Function name="env">
             <ogc:Literal>wms_scale_denominator</ogc:Literal>
           </ogc:Function>
           <ogc:Literal>10000</Literal>
           <ogc:Literal>100</ogc:Literal>
           <ogc:Literal>100000</Literal>
           <ogc:Literal>25</ogc:Literal>            
       </ogc:Function>
     </Size>