1

The Title kind of says it all. Trying to Center Justify a label of a polygon using a sld style file on Geoserver 2.10.1. Here is the code snippet followed by a screenshot of the label now.

          <sld:Rule>
        <ogc:Filter>
          <ogc:PropertyIsLike wildCard="*" singleChar="#" escapeChar="!">
            <ogc:PropertyName>building</ogc:PropertyName>
            <ogc:Literal>*</ogc:Literal>
          </ogc:PropertyIsLike>
        </ogc:Filter>
        <sld:MinScaleDenominator>0</sld:MinScaleDenominator>
        <sld:MaxScaleDenominator>3600</sld:MaxScaleDenominator>
        <sld:Name>Yes</sld:Name>
        <sld:Title>Building</sld:Title>
        <sld:PolygonSymbolizer>
          <sld:Fill>
            <sld:CssParameter name="fill">#d4d6e4</sld:CssParameter>
          </sld:Fill>
          <sld:Stroke>
            <sld:CssParameter name="stroke">#d4d6e4</sld:CssParameter>
            <sld:CssParameter name="stroke-width">0.5</sld:CssParameter>
            <sld:CssParameter name="stroke-linejoin">round</sld:CssParameter>
          </sld:Stroke>
        </sld:PolygonSymbolizer>
        <sld:TextSymbolizer>
          <sld:Label>
            <ogc:PropertyName>name</ogc:PropertyName>
          </sld:Label>
          <sld:Font>
            <sld:CssParameter name="font-size">12</sld:CssParameter>
            <sld:CssParameter name="font-family">Nimbus Sans L Regular Condensed</sld:CssParameter>
          </sld:Font>
          <sld:LabelPlacement>
            <sld:LinePlacement>
              <sld:PerpendicularOffset>0</sld:PerpendicularOffset>
            </sld:LinePlacement>
          </sld:LabelPlacement>
          <sld:Fill>
            <sld:CssParameter name="fill">#749dae</sld:CssParameter>
          </sld:Fill>
          <sld:VendorOption name="maxDisplacement">50</sld:VendorOption>
          <sld:VendorOption name="labelAllGroup">TRUE</sld:VendorOption>
          <sld:VendorOption name="removeOverlaps">TRUE</sld:VendorOption>
          <sld:VendorOption name="autoWrap">40</sld:VendorOption>
          <sld:VendorOption name="group">TRUE</sld:VendorOption>
          <sld:Halo>
            <sld:Radius>
              <ogc:Literal>0.26</ogc:Literal>
            </sld:Radius>
            <sld:Fill>
              <sld:CssParameter name="fill">#bce6f4</sld:CssParameter>
            </sld:Fill>
          </sld:Halo>
        </sld:TextSymbolizer>
      </sld:Rule>

Screen shot

1

I don't beleive this is currently possible. You (or someone else) could write a function that centred some text by padding with spaces but there is little chance it would ever get backported as far back as 2.10 which is several years obselete.

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.