artemp/mapnik — Issue #732: Offset for TextSymbolizer produces ugly results for ways with narrow curves
Author: artemp
Created: 2011-10-11 16:34:08+00:00
State: open
Labels: Core_Library

The attached image shows an example in which I used a TextSymbolizer with dy=6 and a font size of 9. This produces ugly results on the ways "Lac de la Chambre" and "Campagnol", while "Venturon" and "Côte Brune" look OK.

This seems to happen whenever ways have narrow curves. My suspicion (see second attachment):

When dy=0, the way is taken as the path for the text (1). So far, so good.

When dy<>0, the way is still taken as the path for the text, but test is shifted by a fixed offset (2). I haven't figured out how Mapnik figures out the direction for this (rectangular to the straight line from the first to the last point?) - in any case, while this works well for straight lines and also for curves which are significantly longer than the text, it does not work well for sharp curves. You can see how the distance between text and way varies.

My suggestion for a better algorithm: Create a hull curve around the way at the distance specified by dy. Split it in half at the ends of the way and use the part which is on the "correct" side of the way as the path for the text (3).

The result: a constant distance between the label and the line (4).