1

I'm using priority option for labels in my geoserver SLD stylesheet because I have multiple overlapping points.

<Priority>
  <ogc:PropertyName>language</ogc:PropertyName>
</Priority>

The problem is, geoserver renders both labels if there are two overlapping points. The priority one is above, and the another one is below.

enter image description here

I need only one of those labels (top priority one) to be rendered.

EDIT:

Whole TextSymbolizer looks like this:

<TextSymbolizer>
        <Label>
          <ogc:PropertyName>pisanjeimena</ogc:PropertyName>
        </Label>
        <Priority>
          <ogc:PropertyName>language</ogc:PropertyName>
        </Priority>
        <VendorOption name="group">false</VendorOption>
        <VendorOption name="labelAllGroup">true</VendorOption>
        <VendorOption name="spaceAround">10</VendorOption> <!--allow labels to overlap-->
        <!--<VendorOption name="followLine">true</VendorOption>--> <!--option forces a label to follow the curve of the line-->
        <VendorOption name="maxDisplacement">30</VendorOption> <!--option controls the displacement of the label along a line-->
        <VendorOption name="repeat">100</VendorOption> <!--option determines how often GeoServer displays labels along a line-->
        <VendorOption name="autoWrap">150</VendorOption> <!--option wraps labels when they exceed the given width (in pixels)-->
        <!--<VendorOption name="conflictResolution">false</VendorOption>--> <!--conflictResolution option to false causes this label to bypass conflict resolution-->
        <VendorOption name="goodnessOfFit">0.3</VendorOption>      
        <Halo>
          <Radius>2</Radius>
          <Fill>
            <CssParameter name="fill">#FFFFFF</CssParameter>
            <CssParameter name="fill-opacity">0.6</CssParameter>
          </Fill>
        </Halo>
        <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>
          <CssParameter name="fill-opacity">0.6</CssParameter>
        </Font>
        <LabelPlacement>
          <PointPlacement>
            <AnchorPoint>
              <AnchorPointX>0.5</AnchorPointX>
              <AnchorPointY>0.0</AnchorPointY>
            </AnchorPoint>
            <Displacement>
              <DisplacementX>0</DisplacementX>
              <DisplacementY>5</DisplacementY>
            </Displacement>
          </PointPlacement>
        </LabelPlacement>
        <Fill>
          <CssParameter name="fill"><ogc:PropertyName>boja</ogc:PropertyName></CssParameter>
        </Fill>             
      </TextSymbolizer>

Language property that is used in <Priority> is numerical value (language ID). Language with higher ID should be a priority one.

1
  • please show the whole of your TextSymboliser as other options will affect the display of the text. Also what are the values of the language attribute for the two points shown.
    – Ian Turton
    Commented Mar 20, 2019 at 10:00

1 Answer 1

1

You have confused the label placement algorithm by giving it too many instructions and choices.

    <VendorOption name="group">false</VendorOption>
    <VendorOption name="labelAllGroup">true</VendorOption>

You can leave these two out as they are the defaults.

    <VendorOption name="spaceAround">10</VendorOption> <!--allow labels to overlap-->

This doesn't do what your comment suggests you think it does. If you want labels to overlap (and you probably don't) then set a negative value.

    <VendorOption name="maxDisplacement">30</VendorOption> <!--option controls the displacement of the label along a line-->

Again, this is unlikely to be what you want, as it allows the renderer to jiggle labels around (up to 30px) to get more labels in. It is almost certainly where your problem occurs. Thus, you can get two (or more) labels for a set of stacked points.

    <VendorOption name="repeat">100</VendorOption> <!--option determines how often GeoServer displays labels along a line-->

This only applies to lines, so leave it out.

    <VendorOption name="autoWrap">150</VendorOption> <!--option wraps labels when they exceed the given width (in pixels)-->

This is fine (assuming your labels have spaces in them.

    <!--<VendorOption name="conflictResolution">false</VendorOption>--> <!--conflictResolution option to false causes this label to bypass conflict resolution-->

Turning conflictResolution off like this allows the renderer to draw as many labels as it likes as it can ignore all the other settings - thus, all your points will be labelled. Don't turn it off unless you are very sure you know what you are doing.

    <VendorOption name="goodnessOfFit">0.3</VendorOption>    

This is to allow the renderer to exceed the bounds of the polygon it is labeling inside, it has no effect on points such as you are using so leave it out.

1
  • Got it. Thanks for pointing out the wrong things. This SLD is legacy, so I wrongly assumed it was correct. Commented Mar 20, 2019 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.