3

I'm novice in Geoserver. I use Version 2.15.1.

I would like to display labels. This is my SLD – made and export with QGIS:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:se="http://www.opengis.net/se">
  <NamedLayer>
    <se:Name>Beschriftung</se:Name>
    <UserStyle>
      <se:Name>Beschriftung</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Single symbol</se:Name>
          <se:PointSymbolizer>
            <se:Graphic>
            </se:Graphic>
          </se:PointSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:TextSymbolizer>
            <se:Label>
              <ogc:PropertyName>label_text</ogc:PropertyName>
            </se:Label>
            <se:Font>
              <se:SvgParameter name="font-family">MS Shell Dlg 2</se:SvgParameter>
              <se:SvgParameter name="font-size">6</se:SvgParameter>
            </se:Font>
            <se:LabelPlacement>
              <se:PointPlacement>
                <se:AnchorPoint>
                  <se:AnchorPointX>0</se:AnchorPointX>
                  <se:AnchorPointY>0.5</se:AnchorPointY>
                </se:AnchorPoint>
              </se:PointPlacement>
            </se:LabelPlacement>
            <se:Fill>
              <se:SvgParameter name="fill">#8b0000</se:SvgParameter>
            </se:Fill>
            <se:VendorOption name="maxDisplacement">1</se:VendorOption>
            <se:VendorOption name="conflictResolution">false</se:VendorOption>
          </se:TextSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>

Everything looks nice in QGIS. On the Geoserver the texts are shifted and written in each other.

Am I doing something wrong or is it not possible to insert the SLD from QGis in the geoserver? In addition, I would like the text in different zoom levels are displayed in different sizes. How do I realize that?

The pictures show the text layer together with another layer. First QGIS then Geoserver:

QGis

Geoserver

  • please add a screenshot of the map so we can see what it looks like – Ian Turton Oct 22 at 13:54
  • Thanks. I have added screenshots. – astridx Oct 22 at 14:03
2

The first issue is you have turned conflict resolution off so that GeoServer thinks that it is fine to allow the labels to be stacked on top of each other. So I would remove <se:VendorOption name="conflictResolution">false</se:VendorOption> from the SLD file. In general it is best to allow the labelling engine control conflicts as it works hard to prevent your labels looking bad. The exception to this rule is when you are explicitly placing labels at a fixed X,Y location and controlling the horizontal and vertical alignment of each label individually.

The second issue seems to be that in your QGIS window some of your labels are smaller than others but in the SLD you only have one size of text, it is also possible that you are using a size in map units rather than pixels as GeoServer is doing. I don't believe it is possible to use map unit sizes in SLD, but it may be part of the SE Standard.

To control the size depending on zoom level you will need to look at adding MinScaleDenominator and MaxScaleDenominator as described here or by using a scale dependency.

  • Thank you @Ian Turton You gave me the right tips. – astridx Oct 23 at 18:22

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.