1

I take my first steps in creating SLDs using the documentation.

For TextSymbolizer I found this code snippet to achieve different views in different zoom levels - Zoom-based views.

   <CssParameter name="font-size">
     <ogc:Function name="Categorize">
       <ogc:Function name="env">
         <ogc:Literal>wms_scale_denominator</ogc:Literal>
       </ogc:Function>
       <ogc:Literal>12</ogc:Literal>
       <ogc:Literal>300</ogc:Literal>
       <ogc:Literal>10</ogc:Literal>
       <ogc:Literal>2500</ogc:Literal>
       <ogc:Literal>8</ogc:Literal>
     </ogc:Function>
   </CssParameter>

For PointSymbolizer I found this code snipped to achieve different views in different zoom levels - Zoom-based views.

 <FeatureTypeStyle>
     <Rule>
       <Name>Large</Name>
       <MaxScaleDenominator>160000000</MaxScaleDenominator>
       <PointSymbolizer>
         <Graphic>
           <Mark>
             <WellKnownName>circle</WellKnownName>
             <Fill>
               <CssParameter name="fill">#CC3300</CssParameter>
             </Fill>
           </Mark>
           <Size>12</Size>
         </Graphic>
       </PointSymbolizer>
     </Rule>
     <Rule>
       <Name>Medium</Name>
       <MinScaleDenominator>160000000</MinScaleDenominator>
       <MaxScaleDenominator>320000000</MaxScaleDenominator>
       <PointSymbolizer>
         <Graphic>
           <Mark>
             <WellKnownName>circle</WellKnownName>
             <Fill>
               <CssParameter name="fill">#CC3300</CssParameter>
             </Fill>
           </Mark>
           <Size>8</Size>
         </Graphic>
       </PointSymbolizer>
     </Rule>
     <Rule>
       <Name>Small</Name>
       <MinScaleDenominator>320000000</MinScaleDenominator>
       <PointSymbolizer>
         <Graphic>
           <Mark>
             <WellKnownName>circle</WellKnownName>
             <Fill>
               <CssParameter name="fill">#CC3300</CssParameter>
             </Fill>
           </Mark>
           <Size>4</Size>
         </Graphic>
       </PointSymbolizer>
     </Rule>
   </FeatureTypeStyle>

So I wonder why there is a different syntax and what is the difference between <ogc:Literal>wms_scale_denominator</ogc:Literal> and MaxScaleDenominator/MinScaleDenominator

1

<MinScaleDenominator>160000000</MinScaleDenominator> and <MaxScaleDenominator>320000000</MaxScaleDenominator> specify a start and end scale to display the content of the containing <Rule> at. While <ogc:Literal>wms_scale_denominator</ogc:Literal> is a variable name being passed to the env function, which will return the current scale denominator.

So in:

<CssParameter name="font-size">
     <ogc:Function name="Categorize">
       <ogc:Function name="env">
         <ogc:Literal>wms_scale_denominator</ogc:Literal>
       </ogc:Function>
       <ogc:Literal>12</ogc:Literal>
       <ogc:Literal>300</ogc:Literal>
       <ogc:Literal>10</ogc:Literal>
       <ogc:Literal>2500</ogc:Literal>
       <ogc:Literal>8</ogc:Literal>
     </ogc:Function>
   </CssParameter>

You extract the current scale denominator (env) and use it for a look up in the Categorize function so that below 300 the font size is 12pt, between 300-2499 it is 10pt and above 2500 it is 8pt.

|improve this answer|||||
  • Thank you @Ian Turton – astridx Oct 30 '19 at 16:42

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.