Skip to content

Commit ce5c6ba

Browse files
committed
Merge pull request #41 from pnorman/3_cartographers
Add a new post on changes for cartographers in 3.0.0
2 parents 3131e35 + adca8ea commit ce5c6ba

2 files changed

Lines changed: 77 additions & 2 deletions

File tree

_data/author.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,9 @@ Jean-François Doyon:
6363
twitterurl:
6464
twitter:
6565

66-
67-
66+
Paul Norman:
67+
- name: Paul Norman
68+
image: /images/authors/blank.jpg
69+
github: https://github.com/pnorman
70+
twitterurl: https://twitter.com/penorman
71+
twitter: penorman
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
layout: 01_post
3+
title: "Mapnik 3.0.0 notes for cartographers"
4+
author: Paul Norman
5+
category: Mapnik
6+
---
7+
8+
With the [Mapnik 3.0.0 release](/news/release-3.0.0/) there have been important changes that impact cartographers. It is possible to write a stylesheet that works with both 2.2 and 3.0, but it some attention to the changes.
9+
10+
## Major changes
11+
12+
### Clipping
13+
14+
The clip property now defaults to false. This fixes many problems with cut-off labels when rendering map tiles, but can require special considerations of performance in some cases.
15+
16+
When features are likely to be
17+
18+
* complex;
19+
* often mostly or entirely off-screen, while still bounding box overlapping the rendered area; and
20+
* using slow rendering rules
21+
22+
Don't assume that turning clip on will result in performance gains. In [some cases](https://github.com/gravitystorm/openstreetmap-carto/pull/51) it is faster to not clip.
23+
24+
Clip should not generally be turned off for features being labeled or lines with a dasharray.
25+
26+
Lines labeled with infrequent labels may need `text-spacing` adjusted.
27+
28+
### Line offset from polygons
29+
30+
`line-offset` on polygons no longer depends on winding order of the polygon. For polygons following the right-hand rule, the behavior has not changed. For polygons following the left-hand rule, the stylesheet will need to have line-offset properties multiplied by -1.
31+
32+
Most polygons follow the right-hand rule, including those produced by [https://github.com/openstreetmap/osm2pgsql](osm2pgsql). If using a different data source and `line-offset`, this should be checked.
33+
34+
For PostGIS datasources with polygons that follow the left-hand rule instead, if compatibility is needed between 2.2 and 3.0, this can be achieved with SQL like
35+
36+
{% highlight sql %}
37+
(SELECT
38+
ST_ForceRHR(the_geom) AS the_geom
39+
FROM foo
40+
WHERE the_geom && !bbox!) AS p
41+
{% endhighlight %}
42+
43+
The existing `line-offset` in the stylesheet will need to be inverted.
44+
45+
### Text offsetting from lines
46+
47+
Handling of text offset from lines has changed. To get consistent behavior between 2.2 and 3.0, use `vertical-alignment: middle`. This may require adjustments to the `text-dy` value.
48+
49+
### Harfbuzz support
50+
51+
Mapnik now uses harfbuzz for text layout. This offers far superior support for complex scripts, particularly some southeast Asian languages. Generally this requires no changes on the part of the cartographer, but should be tested as part of any 3.0 upgrade plan.
52+
53+
Where maps have only Latin text and do not need shaping, kerning, or ligatures, harfbuzz can be disabled by setting `export HB_SHAPER_LIST=fallback`, resulting in up to 15% performance gains in text rendering.
54+
55+
### Character placement
56+
57+
Character placement has been improved, resulting in overall superior kerning. The need for [workarounds to get placement right on SVGs](https://github.com/zverik/nik4#generate-a-vector-drawing-from-a-map) has been eliminated.
58+
59+
### Rotated point and polygon text
60+
61+
Label collision bounding boxes for point and polygon labels are now per label, not per character. This means when a label is rotated, the bounding box can become substantially larger.
62+
63+
This can substantially reduce label density for point placements when `orientation` other than a multiple of 90 is used. It does not impact line placements, which is the common case of rotated labels.
64+
65+
## New features
66+
67+
Besides these changes, there are lots of other new features which can be found in the [changelog](https://github.com/mapnik/mapnik/blob/master/CHANGELOG.md#300)
68+
69+
Paul Norman
70+
71+
Consultant and OpenStreetMap Developer

0 commit comments

Comments
 (0)