diff --git a/_data/author.yml b/_data/author.yml index 430e5eb..08a77b6 100644 --- a/_data/author.yml +++ b/_data/author.yml @@ -63,5 +63,9 @@ Jean-François Doyon: twitterurl: twitter: - - +Paul Norman: +- name: Paul Norman + image: /images/authors/blank.jpg + github: https://github.com/pnorman + twitterurl: https://twitter.com/penorman + twitter: penorman diff --git a/_posts/blog/2015-07-11-3.0-cartographer.md b/_posts/blog/2015-07-11-3.0-cartographer.md new file mode 100644 index 0000000..467f40e --- /dev/null +++ b/_posts/blog/2015-07-11-3.0-cartographer.md @@ -0,0 +1,71 @@ +--- +layout: 01_post +title: "Mapnik 3.0.0 notes for cartographers" +author: Paul Norman +category: Mapnik +--- + +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. + +## Major changes + +### Clipping + +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. + +When features are likely to be + +* complex; +* often mostly or entirely off-screen, while still bounding box overlapping the rendered area; and +* using slow rendering rules + +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. + +Clip should not generally be turned off for features being labeled or lines with a dasharray. + +Lines labeled with infrequent labels may need `text-spacing` adjusted. + +### Line offset from polygons + +`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. + +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. + +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 + +{% highlight sql %} +(SELECT + ST_ForceRHR(the_geom) AS the_geom + FROM foo + WHERE the_geom && !bbox!) AS p +{% endhighlight %} + +The existing `line-offset` in the stylesheet will need to be inverted. + +### Text offsetting from lines + +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. + +### Harfbuzz support + +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. + +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. + +### Character placement + +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. + +### Rotated point and polygon text + +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. + +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. + +## New features + +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) + +Paul Norman + +Consultant and OpenStreetMap Developer