[Geoserver-users] How to label cached polygon labels

Hello,

I am changing a non-cached polygon layer to a cached polygon. By default it appears that the polygons are labeled once per tile, which is not desired. I did adjust the metatile size to minimize the extra labels, which helps reduce the number of labels, but does not eliminate the problem. Recently, I came across a snippet of code that changes the label Geometry from a polygon to a point. With this code the polygons are only labeled once, however it comes at a cost that the labels no longer fit inside the polygon . Is there any way to label a polygon once per shape and have the label fit inside the polygon.

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

Thanks

Mark Volz
GIS Specialist