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>
  • Please add the code how you call the Layer from OpenLayers. – bennos Mar 27 '18 at 10:12
  • use partials vendor option – Ian Turton Mar 27 '18 at 11:17
  • I have already used the partials vendor option. But it didn't work. @IanTurton Also I have mentioned in the description that it is not the duplicate of the mentioned question. We do not require any solution involving GeoWebCache. – pkpanda Mar 27 '18 at 14:55
  • @bennos the tiles are getting cut in Geoserver layer preview as well. So it is not a open Layer issue. – pkpanda Mar 27 '18 at 14:56
  • 1
    Do not add images of text, please add the text of sld – Ian Turton Mar 27 '18 at 17:29
2

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>
  • it didn't work. Same problem exists – pkpanda Mar 28 '18 at 10:56
  • please provide the text of your sld and some example data – Ian Turton Mar 28 '18 at 11:09
  • I am unable to attache the code here. Upon attaching the code is not showing. Please suggest some other way – pkpanda Mar 28 '18 at 15:11
  • every one else can add code - please edit your question, paste in the code then select it and press crtl-k to format it. – Ian Turton Mar 28 '18 at 16:04
  • I have added the code as requested. – pkpanda Mar 29 '18 at 6:34
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

  • I have modified my SLD exactly as you mentioned above. But still same issue exists. – pkpanda Apr 6 '18 at 10:48
  • then you will need to provide a link to your complete datafile and SLD – Ian Turton Apr 6 '18 at 12:07

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.