0

We are using GeoServer 2.10.0. While displaying the labels in the maps, the labels which are there on the border of the tiles(4*4) are not getting displayed properly. the labels can be seen after further zooming in or out(when they fall in the center of the tile and not in the border). in this image you can see the labels are being cut

On zooming further, the labels come properly, as expected

In the first image, the labels are cut.

1.png

But in the second image, we see on zooming further, the labels are shown as expected.

2.png

Please see the SLD.

SLD:

<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0" 
                       xsi:schemaLocation="http://www.opengis.net/sld 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>pxs_gna_mobile_site</Name>
    <UserStyle>
      <Name>Geo_Style_pxs_gna_mobile_site</Name>
      <FeatureTypeStyle>
        <Rule>
          <Name>Geo_Rule_pxs_gna_mobile_site</Name>
          <MaxScaleDenominator>350000.0</MaxScaleDenominator>
          <PointSymbolizer>
            <Graphic>
              <ExternalGraphic>
                <OnlineResource xlink:type="simple" xlink:href="http://server:port/geoserver/styles/MobileTower_green.png"/>
                <Format>image/png</Format>
              </ExternalGraphic>
              <Size>40</Size>
            </Graphic>
          </PointSymbolizer>

          <TextSymbolizer>
                   <Geometry>
  <ogc:Function name="centroid">
    <ogc:PropertyName>geom</ogc:PropertyName>
  </ogc:Function>
</Geometry>
            <Label>
              <ogc:PropertyName>candidate_code</ogc:PropertyName>
            </Label>
            <Font>
              <CssParameter name="font-family">Arial</CssParameter>
              <CssParameter name="font-size">12</CssParameter>
              <CssParameter name="font-style">normal</CssParameter>
              <CssParameter name="font-weight">bold</CssParameter>
            </Font>
            <LabelPlacement>
              <PointPlacement>
                <AnchorPoint>
                  <AnchorPointX>0.5</AnchorPointX>
                  <AnchorPointY>0.5</AnchorPointY>
                </AnchorPoint>
                <Displacement>
                  <DisplacementX>5</DisplacementX>
                  <DisplacementY>5</DisplacementY>
                </Displacement>
              </PointPlacement>
            </LabelPlacement>
            <Halo>
                <Radius>2</Radius>
                <Fill>
                    <CssParameter name="fill">#FFFFFF</CssParameter>
                </Fill>
            </Halo>         
            <Fill>
              <CssParameter name="fill">#000000</CssParameter>
            </Fill>
             <VendorOption name="spaceAround">-1</VendorOption>
            <VendorOption name="partials">true</VendorOption>
            <VendorOption name="group">yes</VendorOption>
            <VendorOption name="labelAllGroup">true</VendorOption>
            <VendorOption name="conflictResolution">false</VendorOption>
          </TextSymbolizer>
        </Rule>
        <Rule>
        <Name>Geo_Rule_pxs_gna_mobile_site</Name>
          <MinScaleDenominator>350000.0</MinScaleDenominator>
          <PointSymbolizer>
            <Graphic>
              <ExternalGraphic>
                <OnlineResource xlink:type="simple" xlink:href="http://server:port/geoserver/styles/MobileTower_green.png"/>
                <Format>image/png</Format>
              </ExternalGraphic>
              <Size>40</Size>
            </Graphic>
          </PointSymbolizer>
        </Rule>
      </FeatureTypeStyle>
    </UserStyle>
  </NamedLayer>
</StyledLayerDescriptor>
pkpanda
  • 33
  • 6

2 Answers2

3

You are not using a fixed location for your labels therefore the partials strategy is unable to work correctly as it needs to know exactly where the label is going to be drawn on each tile.

Add the following at the top of your TextSymbolizer to force where the label should appear:

<Geometry>
  <ogc:Function name="centroid">
    <ogc:PropertyName>the_geom</ogc:PropertyName>
  </ogc:Function>
</Geometry>

This, of course, assumes your geometry attribute is called the_geom change it if necessary to match your features. Also make sure that you have turned off your browser caching while you are testing this. I would also remove the following as there is no telling what the interactions between all of those options is:

        <VendorOption name="spaceAround">-1</VendorOption>
        <VendorOption name="group">yes</VendorOption>
        <VendorOption name="labelAllGroup">true</VendorOption>
        <VendorOption name="conflictResolution">false</VendorOption>
Ian Turton
  • 81,417
  • 6
  • 84
  • 185
2

Here is a fully worked example using the states layer in GeoServer,

First with the default label placement and tiles:

enter image description here

Note how Wisconsin (WI) is labelled 4 times where it appears on 4 different tiles.

Now with a fixed position for the geometry in the TextSymbbolizer:

<Geometry>
  <ogc:Function name="centroid">
    <ogc:PropertyName>the_geom</ogc:PropertyName>
  </ogc:Function>
</Geometry>

enter image description here

Note how each state is labelled at most once but several of them are not labelled (e.g. Wisconsin) as the label will not fit on the tile so it is not drawn. Normally this would be the correct solution but since we know there is a tile next to this one which could display the rest of the label it would be OK to draw some of the label. GeoServer has no way of knowing this (as each map request is independent to GeoServer) but we can let it know by adding the <VendorOption name="partials">true</VendorOption>. This tells GeoServer it can draw as much label as fits on the tile.

enter image description here

Ian Turton
  • 81,417
  • 6
  • 84
  • 185