2

I'm using Geoserver 2.6.2.

I need to display land parcels and their references (a number). I have specified a maxscaledenominator for the features (polygons) but I don't want references to appear at such a scale for it will be a nonsense (parcels appear very small and dense so that no additional information is needing on the map). Is it possible to specify a maxscaledenominator for labels as well?

Here is an extract of my code:

<UserStyle>
    <FeatureTypeStyle>
        <Rule>
            <MaxScaleDenominator>20000</MaxScaleDenominator>
            <PolygonSymbolizer>
                <Stroke>
                    <CssParameter name="stroke">#000000</CssParameter>
                    <CssParameter name="stroke-width">1</CssParameter>
                </Stroke>
            </PolygonSymbolizer>
            <TextSymbolizer>
                <Geometry>
                    <ogc:Function name="centroid">
                        <ogc:PropertyName>the_geom</ogc:PropertyName>
                    </ogc:Function>
                </Geometry>
                <Label>
                    <ogc:PropertyName>reference</ogc:PropertyName>
                </Label>
                <Fill>
                    <CssParameter name="fill">#000000</CssParameter>
                </Fill>
            </TextSymbolizer>
        </Rule>
    </FeatureTypeStyle>
</UserStyle>
2

Only a Rule can have a scale denominator, but that's fine as you can have as many Rules as you need. So just split your labels into another rule with its own MaxScaleDenominator, like this:

<UserStyle>
    <FeatureTypeStyle>
        <Rule>
            <MaxScaleDenominator>20000</MaxScaleDenominator>
            <PolygonSymbolizer>
                <Stroke>
                    <CssParameter name="stroke">#000000</CssParameter>
                    <CssParameter name="stroke-width">1</CssParameter>
                </Stroke>
            </PolygonSymbolizer>
         </Rule>
         <Rule>
            <MaxScaleDenominator>5000</MaxScaleDenominator>
            <TextSymbolizer>
                <Geometry>
                    <ogc:Function name="centroid">
                        <ogc:PropertyName>the_geom</ogc:PropertyName>
                    </ogc:Function>
                </Geometry>
                <Label>
                    <ogc:PropertyName>reference</ogc:PropertyName>
                </Label>
                <Fill>
                    <CssParameter name="fill">#000000</CssParameter>
                </Fill>
            </TextSymbolizer>
        </Rule>
    </FeatureTypeStyle>
</UserStyle>
1
  • The issue with your proposal is that the GeoServer style legend gets overloaded as one item is created per rule... Any idea on how to keep only features rules within legend? – wiltomap Sep 15 '17 at 14:01
0

Maybe it's too late, but you can see this https://docs.geoserver.org/latest/en/user/styling/sld/reference/textsymbolizer.html#scalable-font-size When you are in a determinate scale you put font 0 is you dont want to see

       <CssParameter name="font-size">
           <ogc:Function name="Categorize">
             <!-- Value to transform -->
             <ogc:Function name="env">
               <ogc:Literal>wms_scale_denominator</ogc:Literal>
             </ogc:Function>
             <ogc:Literal>12</ogc:Literal>
             <ogc:Literal>999999</ogc:Literal>
             <ogc:Literal>0</ogc:Literal>
             <ogc:Literal>1000000</ogc:Literal>
             <ogc:Literal>0</ogc:Literal>
           </ogc:Function>
         </CssParameter>

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.