artemp/trac2github — Issue #548: Text/ShieldSymbolizer + line placement often results in clipped/cut off shields/labels
Author: artemp
Created: 2011-10-09 20:39:57+00:00
State: open
Labels: Core_Library

This question comes up frequently on mailing lists and IRC: "How can I get mapnik not to cutoff my highway shields?"

The problem is that the placement_finder algorithm only takes into account the envelope of the shield text when considering if the placement is valid if avoid edges is turned on. Thus you may have a chopped off symbol at the edge of a tile.

When metatiles are used with Map.buffer_size > 0, and particularly with line placement, things go goofy: part of a shield is rendered in the buffer, but on the next metatile over, that shield isn't often rendered in that same location.

In the attached patch works. I've addressed this by adding a '''minimum_padding''' property to the TextSymbolizer, which prevents a label (or shield) from being placed too near the edge of the map. If the placement under consideration would put the text envelope + padding are not contained by the map extent, the label will not be placed at that location.

Margin might be a better term than padding for consistency with CSS. This could also be min-padding-x and min-padding-y, but as buffer_size is consistent on all sides and shields are usually squarish in size, I didn't go crazy with expanding all the options.