0

I have generated SLD's in QGIS that I use in GeoServer. Although the labeling shows fine when previewing the layer in GeoServer, when bringing the WMS in Leaflet then labeling repetition occurs. How do I center labeling in the QGIS generated SLD and avoid repeating labeling?

This is how the leaflet map looks like: enter image description here

Desired outcome: enter image description here

And here is the QGIS generated SLD:

<?xml version="1.0" encoding="UTF-8"?>
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ogc="http://www.opengis.net/ogc" xmlns:se="http://www.opengis.net/se">
  <NamedLayer>
    <se:Name>Uis_Erven</se:Name>
    <UserStyle>
      <se:Name>Uis_Erven</se:Name>
      <se:FeatureTypeStyle>
        <se:Rule>
          <se:Name>Single symbol</se:Name>
          <se:PolygonSymbolizer>
            <se:Fill>
              <se:SvgParameter name="fill">#729b6f</se:SvgParameter>
              <se:SvgParameter name="fill-opacity">0</se:SvgParameter>
            </se:Fill>
            <se:Stroke>
              <se:SvgParameter name="stroke">#232323</se:SvgParameter>
              <se:SvgParameter name="stroke-width">1</se:SvgParameter>
              <se:SvgParameter name="stroke-linejoin">bevel</se:SvgParameter>
            </se:Stroke>
          </se:PolygonSymbolizer>
        </se:Rule>
        <se:Rule>
          <se:TextSymbolizer>
            <se:Label>
              <ogc:PropertyName>erf_num</ogc:PropertyName>
            </se:Label>
            <se:Font>
              <se:SvgParameter name="font-family">Arial</se:SvgParameter>
              <se:SvgParameter name="font-size">8</se:SvgParameter>
              <se:SvgParameter name="font-weight">bold</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">#000000</se:SvgParameter>
            </se:Fill>
            <se:VendorOption name="maxDisplacement">1</se:VendorOption>
          </se:TextSymbolizer>
        </se:Rule>
      </se:FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>
Amelia Nicodemus
  • 667
  • 1
  • 8
  • 21
  • 2
    I believe that your Leaflet is making 256x256 sized tiled requests and your green parcel belongs to 4 tiles and number 613 into two tiles. You can't handle that case with SLD because it works already: each tile has only one label. You should get good result by configuring your Leaflet to send single tile WMS requests. Other options include using a tile cache service, for example TileWebCache that makes bigger requests and splits 256x256 tiles out of them. Read about "metatiles". – user30184 Nov 11 '19 at 11:38
  • @user30184 thank you for the hints, I will do more reading and revert back. – Amelia Nicodemus Nov 11 '19 at 11:42
  • Matatiles seems not to be the best solution as it slows down map rendering. Configuring Leaflet is possibly the best solution in this regard. – Amelia Nicodemus Nov 11 '19 at 14:26
  • This here worked. https://gist.github.com/oliverroick/671408 – Amelia Nicodemus Nov 12 '19 at 09:19
  • Nice, by placing the label into centroid it is guaranteed that the polygon will not get duplicate labels. A side effect is that if you map covers the polygon only partly then it shows without a label. That would apply also to map that has been pre-tiled with metatiles. – user30184 Nov 12 '19 at 14:36
  • Thanks for informing me about the shortcoming of centroid labeling. This means I must know both solutions to see what works best. – Amelia Nicodemus Nov 12 '19 at 14:41

0 Answers0