Mapnik 3.0.16 Release Nov 16, 2017 | Artem Pavlenko
Mapnik 3.0.12 Release Sep 08, 2016 | Artem Pavlenko
Mapnik 3.0.10 Release Feb 29, 2016 | Artem Pavlenko
Node Mapnik 3.5.0 Release Feb 29, 2016 | Sam Matthews
Mapnik 3.0.9 Release Nov 26, 2015 | Artem Pavlenko
Mapnik 3.0.7 and 3.0.8 Releases Oct 26, 2015 | Artem Pavlenko
Mapnik 3.0.6 Release Oct 08, 2015 | Artem Pavlenko
Mapnik 3.0.5 Release Sep 17, 2015 | Artem Pavlenko
Mapnik 3.0.4 Release Aug 26, 2015 | Artem Pavlenko
Introducing a Color Blind Filter Aug 14, 2015 | Blake Thompson
Mapnik 3.0.3 Release Aug 12, 2015 | Artem Pavlenko
Mapnik 3.0.2 Release Jul 31, 2015 | Blake Thompson

latest news

New text placement system

Jul 13, 2011

BY:   Herman Kraus

The first part of my Google Summer of Code project is completed now.

As a result one can choose arbitrary alternative placements for TextSymbolizers if the default placement fails. However this is no longer limited to placements, but one can also change text, font size, color, etc. Everything is fully configurable now.

When two labels are too close to each other normally one label is placed and the other one is simply ignored. This can lead to undesirable results. Look at the following sample image:

Previously

With the new placement system one can tell Mapnik to try different placement options. In this example I defined the following parameters:

  • First try to place the label below the number with font size 16 (color: blue)
  • Then try to place it above with font size 10 (color: red)
  • Last try to use a shortened label text (color: green)
Now

The syntax to configure this is pretty easy:

<TextSymbolizer name="'Long'+[nr]"  face-name="DejaVu Sans Book" size="16"  placement="point" dy="8" fill="blue" />

becomes

<TextSymbolizer name="'Long'+[nr]"   face-name="DejaVu Sans Book" size="16"   placement="point" dy="8" fill="blue"   placement-type="list">    <Placement size="10" dy="-8" fill="red"/>    <Placement name="'S'+[nr]" fill="green"/></TextSymbolizer>

One can add as many placement options as one wants. Each attribute has the same name as in TextSymbolizer (in fact they share the parser). Each placement inherits all attributes from the previous one. Therefore it is not required to add 'size="10"' in the second Placement tag.

The code is not already included in trunk, but is available in the branch svn.mapnik.org/branches/textplacement.

In the second half of summer of code I will add text formating capabilities to mapnik as described in an older post.

Copyright © 2016 Artem Pavlenko | Downloads | License | Media