MapServer Labels – Handling Labels and Tiles in MapServer

labelingmapservertiles

I'm developing map with Mapserver to be rendered in tiles and testing output with Ka-map. Most of the time labels split on two tiles are matching, but sometimes they're not.
I configured Ka-Map like

$tileWidth = 256;
$tileHeight =256;
$metaWidth = 4;
$metaHeight = 4;
/* $metaBuffer = Buffer size in pixels to add around metatiles to avoid
 * rendering issues along the edge of the map image
 */
$metaBuffer = 256;

but even large buffer of 256 pixels doesn't protect label from occasional splitting.
What good practices do exist to make sure labels are placed deterministically?

Best Answer

You can try the PARTIALS options for MapServer labels. This makes sure that labels are only drawn if they can fit completely on the generated image. It's set to TRUE by default, so try FALSE.

PARTIALS [true|false]

Can text run off the edge of the map? Default is true.

For example:

LABEL
  COLOR  150 150 150
  SIZE 6
  POSITION AUTO
  PARTIALS FALSE
END

There are several other placement options available to experiment with such as REPEATDISTANCE, MAXOVERLAPANGLE, MAXLENGTH and:

POSITION [ul|uc|ur|cl|cc|cr|ll|lc|lr|auto]

Position of the label relative to the labeling point (layers only). “Auto” placement is only available with cached labels.

The auto option for placement is only available for cached labels. To enable this option you the LABELCACHE option must be set to ON for the LAYER object - it is ON by default so you shouldn't have to add this unless yo uwant to be more explicit.

LABELCACHE [on|off]

Specifies whether labels should be drawn as the features for this layer are drawn, or whether they should be cached and drawn after all layers have been drawn. Default is on. Label overlap removal, auto placement etc... are only available when the label cache is active.