<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
 
 <title>mapnik.org</title>
 <link href="http://mapnik.org/"/>
 <link href="http://mapnik.org/atom.xml" rel="self" type="application/atom+xml"/>
 <updated>2013-04-19T15:11:56-07:00</updated>
 <id>http://mapnik.org/</id>
 <author>
   <name>Artem Pavlenko</name>
   <email>artem.mapnik@gmail.com</email>
 </author>
 
 
 <entry>
   <title>WKT geometry parsing benchmark</title>
   <link type="text/html" rel="alternate" href="http://mapnik.org/news/2013/04/19/wkt-parsing-benchmark"/>
   <updated>2013-04-19T00:00:00-07:00</updated>
   <id>http://mapnik.org/news/2013/04/19/wkt-parsing-benchmark</id>
   <content type="html">
     &lt;p&gt;In addition to beautiful rendering capabilities Mapnik also offers a fast C++ and Python API for working with raw geo features. You can create them on the fly from a variety of formats including wkt, wkb, and geojson. This feature allows creative programers to use Mapnik like you would OGR to read or create data and output it to other formats.&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/springmeyer/5423500.js&quot;&gt;&lt;/script&gt;


&lt;h2&gt;Geometry parsing for datasources and tests&lt;/h2&gt;

&lt;p&gt;The WKT and GeoJSON geometry parsing support in Mapnik core makes it easy to support for these formats in datasource plugins like the Mapnik &lt;a href=&quot;https://github.com/mapnik/mapnik/wiki/CSV-Plugin&quot;&gt;CSV plugin&lt;/a&gt;. And because the CSV plugin supports inline WKT strings you can write simple, standalone test cases for Mapnik bugs as easily as &lt;a href=&quot;https://github.com/mapnik/mapnik/issues/1484&quot;&gt;ticket #1484 demonstrates&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Geometry parsing performance&lt;/h2&gt;

&lt;p&gt;As more people find the Mapnik CSV plugin they start throwing more and more data at it. We need to ensure that our parsing is as fast as possible. So today I started on some benchmarks to figure out baselines for performance. The questions I&amp;rsquo;m interested in are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;If parsing WKT across many threads does performance decline or improve? (We&amp;rsquo;ve found in the past that &lt;a href=&quot;http://mapnik.org/news/2012/04/06/faster-map-loading&quot;&gt;std::locale locking can kill threaded performance&lt;/a&gt; when parsing XML strings)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Does performance differ depending on the C++ library used? (the emergence of &lt;code&gt;clang++&lt;/code&gt; and &lt;code&gt;libc++&lt;/code&gt; on OS X make this an easy and relevant test)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How does Mapnik WKT parsing compare to other common libraries that people use for parsing WKT geometries?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;First look at benchmarking results&lt;/h2&gt;

&lt;p&gt;Today I created a first pass at a C++ benchmark. The code is on &lt;a href=&quot;https://github.com/springmeyer/wkt-parsing-benchmark&quot;&gt;github&lt;/a&gt;. Please see the &lt;a href=&quot;https://github.com/springmeyer/wkt-parsing-benchmark/blob/master/README.md&quot;&gt;README&lt;/a&gt; for details on how to set it up and run the tests.&lt;/p&gt;

&lt;p&gt;There are two tests of Mapnik and &lt;a href=&quot;http://trac.osgeo.org/geos/&quot;&gt;GEOS&lt;/a&gt; that parse a set of very simple WKT geometries 100 thousand times, one serially and the other broken into 10 threads of work that each parse 10 thousand times.&lt;/p&gt;

&lt;p&gt;The results on my system (OS X 10.8 / &lt;code&gt;clang++&lt;/code&gt;) were:&lt;/p&gt;

&lt;h3&gt;mapnik compiled against libc++, using -std=c++11&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;$ ./run
1) threaded -&amp;gt; mapnik: 640 milliseconds
2) threaded -&amp;gt; geos: 2470 milliseconds
3) mapnik: 2800 milliseconds
4) geos: 9150 milliseconds
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;CAVEAT: Geos is not linked against libc++ in this test&lt;/p&gt;

&lt;h3&gt;mapnik compiled against libstdc++, using -ansi&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;$ ./run
1) threaded -&amp;gt; mapnik: 880 milliseconds
2) threaded -&amp;gt; geos: 2520 milliseconds
3) mapnik: 3440 milliseconds
4) geos: 9200 milliseconds
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;NOTE: smaller numbers are better and indicate that the tests finished faster.&lt;/p&gt;

&lt;p&gt;The results seem to indicate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;High concurrency, as you would hope and expect, does not hurt performance but rather helps. This is great, but not always the case in C++ when parsing strings. If your parsing code triggers mutex locks then concurrency like this can hurt.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mapnik is more than 2x faster than GEOS for these simple &lt;a href=&quot;https://github.com/springmeyer/wkt-parsing-benchmark/blob/master/cases/wkt.csv&quot;&gt;test cases&lt;/a&gt;. So, the next step here is to 1) figure out if Mapnik continues to perform well on larger WKT strings and 2) make sure we are using the GEOS API correctly.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Mapnik is slightly faster when compiled against &lt;a href=&quot;http://libcxx.llvm.org/&quot;&gt;libc++&lt;/a&gt; and built in C++11 mode (than if compiled against &lt;code&gt;libstdc++&lt;/code&gt; in &lt;code&gt;-ansi&lt;/code&gt; mode. This is great &amp;ndash; will be interesting to learn why. My guess is that &lt;code&gt;boost::spirit&lt;/code&gt;, which mapnik uses internally to parse WKT is benefiting from c++11 features. Or &lt;code&gt;libc++&lt;/code&gt; is providing faster implementations of key functionality than the standard gnu &lt;code&gt;libstdc++&lt;/code&gt;. Or both :)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;Please feel free to check out the benchmarks, run them yourself, and suggest other caveats or improvements. File issues &lt;a href=&quot;https://github.com/springmeyer/wkt-parsing-benchmark/issues&quot;&gt;here&lt;/a&gt; to provide comments.&lt;/p&gt;

   </content>
 </entry>
 
 <entry>
   <title>Summer of Code 2012 - Summary</title>
   <link type="text/html" rel="alternate" href="http://mapnik.org/news/2012/10/06/gsoc2012-status9"/>
   <updated>2012-10-06T00:00:00-07:00</updated>
   <id>http://mapnik.org/news/2012/10/06/gsoc2012-status9</id>
   <content type="html">
     &lt;p&gt;Google Summer of Code 2012 is over now. All the previous posts where rather
technical so I would like to talk about applications and show some beautiful
images in this post.&lt;/p&gt;

&lt;p&gt;First of all: If you live in a region where names are spelled using only
characters from the ASCII set you will not notice this work very much.
It was one design goal not to change the behavior for texts that are already
correctly rendered. There are some minor differences but nothing big. However
it is still worth to read on as I added many more cool features.&lt;/p&gt;

&lt;h1&gt;Rendering complex scripts&lt;/h1&gt;

&lt;p&gt;Mapnik can render &lt;em&gt;any&lt;/em&gt; script supported by HarfBuzz now. If something is
rendered incorrectly check if the font supports the characters you want
to use, as this is the most likely cause of any problems. Especially do &lt;em&gt;not&lt;/em&gt; use
Unifont! It doesn&amp;rsquo;t support any of the features required for correct rendering
of most complex scripts.&lt;/p&gt;

&lt;p&gt;I don&amp;rsquo;t publish example images here because I can&amp;rsquo;t judge which images would
show the most improvement. If a native speaker wants to add samples where
text that was broken before is really good now please open an
&lt;a href=&quot;https://github.com/mapnik/mapnik.github.com/issues&quot;&gt;issue on Github.com&lt;/a&gt; and
I will publish it here.&lt;/p&gt;

&lt;p&gt;There are some new features and bug fixes not related to complex scripts
as well:&lt;/p&gt;

&lt;h1&gt;Improved line placements&lt;/h1&gt;

&lt;h2&gt;Line breaks&lt;/h2&gt;

&lt;p&gt;Since a long time Mapnik is able to handle line breaks in the text (either
automatically created or supplied in the input data) but this feature never
worked for line placements. You could render a long town name very well, but
long street names were a problem so far. This situation is improved by
enabling this for line placements as well.&lt;/p&gt;

&lt;p&gt;However there is one important
limitation: You have to set wrap-width to a certain value or provide input text
with line break characters (&amp;lsquo;\n&amp;rsquo;). There is no function to automatically select
the right wrap-width value depending on the line length yet. Automatic hyphenation
of long text is also not available yet. This will be implemented at some later
time.&lt;/p&gt;

&lt;h3&gt;Example image&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/images/harfbuzz/multiline-streets.png&quot; alt=&quot;Multiline street labels&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Syntax&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;TextSymbolizer wrap-width=&quot;100&quot; ...&amp;gt;[name]&amp;lt;/TextSymbolizer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;Correct offsets&lt;/h2&gt;

&lt;p&gt;Mapnik already supported offsetting text on lines, but the algorithm was very
simple and only worked well for almost straight lines.
The new code uses the offset converter class to produce real offsets which
works for every line shape.&lt;/p&gt;

&lt;p&gt;This feature can be used to produce labels for e.g. borders.&lt;/p&gt;

&lt;h3&gt;Example image&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/images/harfbuzz/countries.png&quot; alt=&quot;Country labels&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Syntax&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;TextSymbolizer dy=&quot;10&quot; ...&amp;gt;[name]&amp;lt;/TextSymbolizer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;Upright&lt;/h2&gt;

&lt;p&gt;For certain applications it is desirable to have a fixed orientation of the
text with respect to the line direction. In the &amp;ldquo;offsets&amp;rdquo; example above you
might have noticed that &amp;ldquo;Country 2&amp;rdquo; changes the text direction at one point
in order to keep it upright.&lt;/p&gt;

&lt;p&gt;This is useful behavior in most cases, but there are applications (like contour
lines) where you don&amp;rsquo;t want to switch the direction. Therefore a new
parameter &amp;ldquo;upright&amp;rdquo; was added to TextSymbolizer to choose the desired function.&lt;/p&gt;

&lt;h3&gt;Example image&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/images/harfbuzz/contour.png&quot; alt=&quot;contour lines&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Syntax&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;TextSymbolizer upright=&quot;auto&quot; ...&amp;gt;[name]&amp;lt;/TextSymbolizer&amp;gt;
&amp;lt;TextSymbolizer upright=&quot;left&quot; ...&amp;gt;[name]&amp;lt;/TextSymbolizer&amp;gt;
&amp;lt;TextSymbolizer upright=&quot;right&quot; ...&amp;gt;[name]&amp;lt;/TextSymbolizer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;Rotate displacement&lt;/h1&gt;

&lt;p&gt;Mapnik supports rotating text via the &lt;code&gt;orientation&lt;/code&gt; parameter to TextSymbolizer.
As long as the text is centered on the point being labeled the question which
center to use for rotation is trivial. But once the text is moved from this
position there are different possible points.&lt;/p&gt;

&lt;p&gt;Up to now Mapnik always rotated around the label&amp;rsquo;s center but now one can also
select to include the displacement when rotating text. This feature is best
described by the following two images:&lt;/p&gt;

&lt;h3&gt;Example images&lt;/h3&gt;

&lt;p&gt;Rotate displacement: Off (default)
&lt;img src=&quot;/images/harfbuzz/rotate_displacement_off.png&quot; alt=&quot;rotate displacement off&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Rotate displacement: On
&lt;img src=&quot;/images/harfbuzz/rotate_displacement_on.png&quot; alt=&quot;rotate displacement on&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Syntax&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;TextSymbolizer dx=&quot;5&quot; rotate-displacement=&quot;true&quot; ...&amp;gt;[name]&amp;lt;/TextSymbolizer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;Kerning &amp;amp; Ligatures&lt;/h1&gt;

&lt;p&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Kerning&quot;&gt;Kerning&lt;/a&gt; and
&lt;a href=&quot;http://en.wikipedia.org/wiki/Typographic_ligature&quot;&gt;ligatures&lt;/a&gt; are
two features you probably won&amp;rsquo;t notice if you don&amp;rsquo;t
know about them. But they improve the text rending in subtle ways:&lt;/p&gt;

&lt;p&gt;Kerning reduces the spacing between characters when one of them is top-heavy and
the other one is bottom-heavy.&lt;/p&gt;

&lt;p&gt;A ligature is the combination of two or more characters into a single glyph for
improved visual appearance.&lt;/p&gt;

&lt;h3&gt;Example images&lt;/h3&gt;

&lt;p&gt;Kerning:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/harfbuzz/kerning.gif&quot; alt=&quot;kerning&quot; /&gt;&lt;/p&gt;

&lt;p&gt;With ligatures:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/harfbuzz/ligatures-hb.png&quot; alt=&quot;ligatures&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Without ligatures:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/harfbuzz/ligatures-master.png&quot; alt=&quot;ligatures&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Syntax&lt;/h3&gt;

&lt;p&gt;This feature is always enabled.&lt;/p&gt;

&lt;h1&gt;Shield Symbolizer&lt;/h1&gt;

&lt;h2&gt;New syntax&lt;/h2&gt;

&lt;p&gt;ShieldSymbolizer syntax was
&lt;a href=&quot;https://github.com/mapnik/mapnik/wiki/ShieldSymbolizer&quot;&gt;documented&lt;/a&gt;
and updated to reflect actual behavior. However it was noticed that the current
syntax is rather counter-intuitive so a new, better one was defined.
Previously &amp;ldquo;shield-dx&amp;rdquo; moved shield &lt;em&gt;and&lt;/em&gt; text and &amp;ldquo;dx&amp;rdquo; moved text only. This was
reversed so that &amp;ldquo;shield-dx&amp;rdquo; moves the shield only.&lt;/p&gt;

&lt;p&gt;For &amp;ldquo;dx&amp;rdquo; (and &amp;ldquo;dy&amp;rdquo;) the behavior depends on the value of &amp;ldquo;unlock-image&amp;rdquo; (which had
an undefined function before).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;unlock-image=&amp;ldquo;false&amp;rdquo;: dx moves text &lt;em&gt;and&lt;/em&gt; image&lt;/li&gt;
&lt;li&gt;unlock-image=&amp;ldquo;true&amp;rdquo;: dx moves text &lt;em&gt;only&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;This parameter is especially useful with the alternate positions functions
described below.&lt;/p&gt;

&lt;h2&gt;Label position tolerance&lt;/h2&gt;

&lt;p&gt;Mapnik moves labels a bit when there is a collision at the designated place,
however this feature only worked for TextSymbolizer but not for ShieldSymbolizer.
This is fixed now.&lt;/p&gt;

&lt;p&gt;This feature can be used for better labeling of highways with multiple names.&lt;/p&gt;

&lt;h3&gt;Example image&lt;/h3&gt;

&lt;p&gt;&lt;img src=&quot;/images/harfbuzz/multiple-shields.png&quot; alt=&quot;multiple shields&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Syntax&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;ShieldSymbolizer label-position-tolerance=&quot;100&quot;&amp;gt;[ref]&amp;lt;/ShieldSymbolizer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;or automatically enabled for Symbolizers with non-zero &lt;code&gt;spacing&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;ShieldSymbolizer spacing=&quot;200&quot;&amp;gt;[ref]&amp;lt;/ShieldSymbolizer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;Alternate positions&lt;/h2&gt;

&lt;p&gt;ShieldSymbolizer was extended to support the alternate placements mechanism already
implemented in TextSymbolizer. This feature is similar to the one above, but has
different uses. It doesn&amp;rsquo;t simply move the shield along the way, but allows
to set completely different parameters. You can change the font, offset,
position, etc. (Selecting a different shield image or shield-offset is not supported, yet but will
be in the future. You can use dx and dy in combination with unlock-image to
get the desired effect in most cases.)&lt;/p&gt;

&lt;h3&gt;Example image&lt;/h3&gt;

&lt;p&gt;Labeling multiple bus routes at the same bus stop:
&lt;img src=&quot;/images/harfbuzz/busstop.png&quot; alt=&quot;bus routes&quot; /&gt;&lt;/p&gt;

&lt;h3&gt;Syntax&lt;/h3&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;ShieldSymbolizer [...] placement-type=&quot;list&quot; horizontal-alignment=&quot;middle&quot; vertical-alignment=&quot;middle&quot;&amp;gt;[ref]
&amp;lt;Placement dx=&quot;50&quot;/&amp;gt;
&amp;lt;Placement dx=&quot;100&quot;/&amp;gt;
&amp;lt;Placement dx=&quot;0&quot; dy=&quot;35&quot;/&amp;gt;
&amp;lt;Placement dx=&quot;50&quot; /&amp;gt;
&amp;lt;Placement dx=&quot;100&quot;/&amp;gt;
&amp;lt;/ShieldSymbolizer&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This syntax is not optimal but an placement algorithm supporting grid placements
will be added some time.&lt;/p&gt;

&lt;h1&gt;Installation&lt;/h1&gt;

&lt;p&gt;Download and install harfbuzz:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-0.9.4.tar.bz2
tar -xjf harfbuzz-0.9.4.tar.bz2
cd harfbuzz-0.9.4/
./configure &quot;ICU_CFLAGS=`icu-config --cflags`&quot; &quot;ICU_LIBS=`icu-config --ldflags`&quot;
make
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and as root&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;make install
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Download and install mapnik&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;git clone -b harfbuzz --depth 1 git://github.com/mapnik/mapnik.git mapnik-harfbuzz
cd mapnik-harfbuzz
./configure
make
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and as root&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;make install # Warning this overwrites previous mapnik installations!
&lt;/code&gt;&lt;/pre&gt;

   </content>
 </entry>
 
 <entry>
   <title>Stamen, Compositing, and Mapnik 2.1</title>
   <link type="text/html" rel="alternate" href="http://mapnik.org/news/2012/08/27/stamen-compositing-mapnik-v2.1"/>
   <updated>2012-08-27T00:00:00-07:00</updated>
   <id>http://mapnik.org/news/2012/08/27/stamen-compositing-mapnik-v2.1</id>
   <content type="html">
     &lt;p&gt;What if software existed that combined the power of Photoshop-like image effects with Illustrator-like vector transformations that was fully open source, spatially capable, and could handle big data like OpenStreetMap? Well, hopefully this future will feel near as you start using Mapnik 2.1.&lt;/p&gt;

&lt;h3&gt;A compositing framework in core&lt;/h3&gt;

&lt;p&gt;In time, Mapnik 0.7.x added support for blending modes in rasters thanks to the work of &lt;a href=&quot;http://mapa.ump.waw.pl/ump-www/&quot;&gt;Marcin Rudowski&lt;/a&gt;. And as of last week, with the &lt;a href=&quot;news/2012/08/24/release-2.1.0/&quot;&gt;release of Mapnik 2.1&lt;/a&gt; and a ton of work from Artem, we now support the &lt;code&gt;comp-op&lt;/code&gt; property on all symbolizers (and Styles) making compositing possible for both vectors and rasters, together. This new support is a solid framework to build on, and more modes can now easily be added with few code changes.&lt;/p&gt;

&lt;h3&gt;Thanks Stamen&lt;/h3&gt;

&lt;p&gt;Our friends at &lt;a href=&quot;http://stamen.com&quot;&gt;Stamen Design&lt;/a&gt; have been advocating for the value of Photoshop-like alpha blending in mapping for many years. As far back as 2008 Mike was already beautifully &lt;a href=&quot;http://mike.teczno.com/notes/hillshading.html&quot;&gt;working around&lt;/a&gt; limitations in Mapnik for terrain hillshading and proactively advocating for better support by writing new software like &lt;a href=&quot;http://permalink.gmane.org/gmane.comp.gis.mapnik.devel/518&quot;&gt;TileStache&lt;/a&gt;. Shawn was instrumental in helping me see the viability of compositing in Mapnik by helping sketching out ideas &lt;a href=&quot;https://github.com/mapnik/mapnik/wiki/Ideas_Compositing&quot;&gt;on the Mapnik wiki&lt;/a&gt;. Last week I saw &lt;a href=&quot;http://twitter.com/shawnbot/status/239186880762085377&quot;&gt;Shawn advocating&lt;/a&gt; for the full suite of advanced photoshop blend modes in the upcoming CSS Spec, which is awesome and something we can &lt;a href=&quot;https://github.com/mapnik/mapnik/issues/1448&quot;&gt;also do in Mapnik&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Revisting innovations&lt;/h3&gt;

&lt;p&gt;After reflecting on how far we&amp;rsquo;ve come in Mapnik and thinking of Shawn&amp;rsquo;s work I was reminded of his sweet little project called &lt;a href=&quot;http://content.stamen.com/trees-cabs-crime_in_venice&quot;&gt;Trees, Cabs &amp;amp; Crime&lt;/a&gt; where he experimented with rendering three themes of point data and compositing them together using subtractive blending to bring out patterns of correlation.&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://content.stamen.com/trees-cabs-crime_in_venice&quot; &gt;&lt;img alt=&quot;Trees, Cabs &amp; Crime in San Francisco from Shawn Allen&quot; src=&quot;http://farm8.staticflickr.com/7104/7190127927_09965a1701_n.jpg&quot;/&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that Mapnik 2.1 is out I figured it should be doable to render Shawn&amp;rsquo;s exact map with just a single Mapnik stylesheet.&lt;/p&gt;

&lt;h3&gt;Trees, Cabs &amp;amp; Crime re-rendered in Mapnik 2.1&lt;/h3&gt;

&lt;p&gt;After finding &lt;a href=&quot;https://github.com/shawnbot/concoct/blob/master/Makefile&quot;&gt;Shawn&amp;rsquo;s makefiles&lt;/a&gt; I saw the process should be as simple as reading data from three csv files and using a darkening blend mode as the canvas of each layer is rendered. Mapnik 2.1 newly supports reading direct from CSV files and one of the supported &lt;code&gt;comp-op&lt;/code&gt; modes is &lt;code&gt;darken&lt;/code&gt;, so matching Shawn&amp;rsquo;s exact output was pretty straightforward. You can find the full Mapnik XML below:&lt;/p&gt;

&lt;script src=&quot;https://gist.github.com/3491644.js?file=re-concoct.xml&quot;&gt;&lt;/script&gt;


&lt;h3&gt;Folloups&lt;/h3&gt;

&lt;p&gt;And soon after this post &lt;a href=&quot;https://twitter.com/shawnbot/status/244241515549974529&quot;&gt;Shawn got things working in TileMill 0.10.0&lt;/a&gt; (which uses Mapnik 2.1).&lt;/p&gt;

   </content>
 </entry>
 
 <entry>
   <title>Release 2.1.0</title>
   <link type="text/html" rel="alternate" href="http://mapnik.org/news/2012/08/24/release-2.1.0"/>
   <updated>2012-08-24T00:00:00-07:00</updated>
   <id>http://mapnik.org/news/2012/08/24/release-2.1.0</id>
   <content type="html">
     &lt;p&gt;&lt;img alt=&quot;release 2.1&quot; src=&quot;/images/release-2.1.png&quot; width=&quot;480&quot;/&gt;&lt;/p&gt;

&lt;p&gt;The Mapnik team is pleased to announce the Mapnik 2.1 release! It was almost a year in the making and we have tons of new features including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A new framework for Style level image manipulation called &lt;a href=&quot;http://mapnik.org/news/2012/04/26/image-filters/&quot;&gt;Image filters&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;A new pipeline for chained coordinate transformations like clipping or smoothing called &lt;a href=&quot;http://mapbox.com/blog/expanding-mapnik-carto/&quot;&gt;Vertex Converters&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Compositing modes at Symbolizer and (experimental) Style level. Infinite possibilities from this, see a few examples &lt;a href=&quot;http://mapbox.com/blog/tilemill-compositing-operations-preview/&quot;&gt;from AJ&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Support for &lt;a href=&quot;https://github.com/mapnik/mapnik/issues/314&quot;&gt;Style level opacity&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;WKT, WKB, GeoJSON, SVG parsers and generators that can be used outside of rendering&lt;/li&gt;
&lt;li&gt;Data-driven SVG style transforms on svg markers and images thanks to &lt;a href=&quot;https://github.com/lightmare&quot;&gt;@lightmare&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Data-driven &lt;code&gt;orientation&lt;/code&gt; for Text, &lt;code&gt;height&lt;/code&gt; for Buildings, and &lt;code&gt;width/height&lt;/code&gt; for Markers.&lt;/li&gt;
&lt;li&gt;A new &lt;a href=&quot;https://github.com/mapnik/mapnik/wiki/CSV-Plugin&quot;&gt;CSV input plugin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A new &lt;a href=&quot;https://github.com/mapnik/mapnik/wiki/GeoJSON-Plugin&quot;&gt;GeoJSON input plugin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;A new &lt;a href=&quot;https://github.com/mapnik/mapnik/wiki/Python-Plugin&quot;&gt;Python input plugin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Better text labeling through support for &lt;code&gt;placement-type=&quot;list&quot;&lt;/code&gt;. See the docs at the bottom of &lt;a href=&quot;https://github.com/mapnik/mapnik/wiki/TextSymbolizer&quot;&gt;this page&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Improved Map loading &lt;a href=&quot;/news/2012/04/06/faster-map-loading/&quot;&gt;speeds&lt;/a&gt; as well as &lt;a href=&quot;https://github.com/mapnik/mapnik/issues/1441&quot;&gt;warnings and errors&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Summary and Changelog&lt;/h2&gt;

&lt;p&gt;For more details on 2.1 features and fixes see the &lt;a href=&quot;https://github.com/mapnik/mapnik/wiki/MapnikReleases&quot;&gt;Summary&lt;/a&gt; and the &lt;a href=&quot;https://github.com/mapnik/mapnik/wiki/Release2.1.0&quot;&gt;Changelog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Everyone is recommended to upgrade!&lt;/p&gt;

&lt;h2&gt;Installing&lt;/h2&gt;

&lt;p&gt;With this release installing Mapnik has never been easier. For Mac users the popular Homebrew package system already includes &lt;a href=&quot;https://github.com/mxcl/homebrew/commit/0d115ce857e8990c25dcb15d0cf647500faa8b2c&quot;&gt;Mapnik 2.1&lt;/a&gt;. Or, if you don&amp;rsquo;t want to wait for the compile just grab the one-click &lt;a href=&quot;https://github.com/downloads/mapnik/mapnik/mapnik-v2.1.0.dmg&quot;&gt;64bit Framework Installer&lt;/a&gt; for OS X 10.6 &amp;ndash;&gt; 10.8.&lt;/p&gt;

&lt;p&gt;For Ubuntu users, we have a PPA ready for you. Simply install Mapnik 2.1 like:&lt;/p&gt;

&lt;pre&gt;
sudo apt-get install -y python-software-properties
echo 'yes' | sudo add-apt-repository ppa:mapnik/v2.1.0
sudo apt-get update
# install core mapnik
sudo apt-get install -y libmapnik mapnik-utils python-mapnik
# install the python binding
sudo apt-get install -y python-mapnik
# confirm mapnik-config returns 2.1.0
mapnik-config -v
&lt;/pre&gt;


&lt;p&gt;And everyone can get the source from the &lt;a href=&quot;http://mapnik.org/download/&quot;&gt;downloads page&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Coming soon&lt;/h3&gt;

&lt;p&gt;We plan Windows binaries in the next month. We will work to provide two flavors:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Mapnik built with Visual Studio 2008 that will provide python bindings for python.org provided Python 2.6 and 2.7&lt;/li&gt;
&lt;li&gt;Mapnik built with Visual Studio 2009 that will provide node.js bindings for nodejs.org provided Node v0.8.x&lt;/li&gt;
&lt;/ol&gt;


&lt;p&gt;We also plan an OS X SDK installer (sometime in the next 3-4 months) that will include all headers and dependencies Mapnik uses in order to provide a drop-in development ease for XCode. Note: this SDK may instead target Mapnik 2.2.x development, we&amp;rsquo;ll see.&lt;/p&gt;

&lt;h3&gt;Try Tilemill&lt;/h3&gt;

&lt;p&gt;If you are a TileMill user, or interested in trying it out, the upcoming TileMill 0.10.0 release will use and expose Mapnik 2.1 features. Intrepid OS X and Windows are encouraged to try out the latest TileMill 0.10.x development builds available at the &lt;a href=&quot;https://github.com/mapbox/tilemill/downloads&quot;&gt;TileMill development snapshots download page&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;Thanks!&lt;/h2&gt;

&lt;p&gt;Thanks to all the &lt;a href=&quot;https://github.com/mapnik/mapnik/graphs/contributors&quot;&gt;contributors&lt;/a&gt; and the many companies that have supported and encouraged Mapnik 2.1 development over the past year, notably:
&lt;a href=&quot;http://kosmosnimki.ru/&quot;&gt;kosmosnimki&lt;/a&gt;, &lt;a href=&quot;http://mapy.cz/&quot;&gt;mapy.cz&lt;/a&gt;, &lt;a href=&quot;http://mapquest.com/&quot;&gt;mapquest&lt;/a&gt;, &lt;a href=&quot;http://stamen.com/&quot;&gt;stamen&lt;/a&gt;, &lt;a href=&quot;http://cartodb.com/&quot;&gt;cartodb&lt;/a&gt;, &lt;a href=&quot;http://mapbox.com&quot;&gt;MapBox&lt;/a&gt;, and many more.&lt;/p&gt;

   </content>
 </entry>
 
 <entry>
   <title>Summer of Code 2012 - Collision detection, offsetting, and performance</title>
   <link type="text/html" rel="alternate" href="http://mapnik.org/news/2012/08/13/gsoc2012-status8"/>
   <updated>2012-08-13T00:00:00-07:00</updated>
   <id>http://mapnik.org/news/2012/08/13/gsoc2012-status8</id>
   <content type="html">
     &lt;p&gt;Building on my work from &lt;a href=&quot;http://mapnik.org/news/2012/08/04/gsoc2012-status7&quot;&gt;last week&lt;/a&gt;
I completed several smaller tasks this week. While each task on its own was not
very big, together they have lead to a state where almost all tests pass!&lt;/p&gt;

&lt;h1&gt;Collision detection&lt;/h1&gt;

&lt;p&gt;The most important part was implementing collision detection for line placements.&lt;/p&gt;

&lt;p&gt;First a short description of the old code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calculate position of glyph&lt;/li&gt;
&lt;li&gt;Store position&lt;/li&gt;
&lt;li&gt;Repeat until all characters are processed&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Calculate bounding box (requires a lot of the same calculations already done for the position again)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Check for collision&lt;/li&gt;
&lt;li&gt;Store bounding box&lt;/li&gt;
&lt;li&gt;Repeat for all characters&lt;/li&gt;
&lt;li&gt;Updated detector with stored bounding boxes&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;As one can see this is not very efficient because processing time is wasted
when there is a collision on one of the first characters.&lt;/p&gt;

&lt;p&gt;The new code therefore does this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Calculate position of glyph&lt;/li&gt;
&lt;li&gt;Store position&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Calculate bounding box (using the already computed values)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Check for collision&lt;/li&gt;
&lt;li&gt;Store bounding box&lt;/li&gt;
&lt;li&gt;Repeat for all characters&lt;/li&gt;
&lt;li&gt;Updated detector with stored bounding boxes&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;This has two advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Position calculations don&amp;rsquo;t have to be done a second time&lt;/li&gt;
&lt;li&gt;If there a collision occurs processing is aborted immediately instead of wasting time processing all
following characters&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;The new detector therefore should be a bit faster in the average case
and much faster when there are lots of collisions.&lt;/p&gt;

&lt;h1&gt;Label position tolerance&lt;/h1&gt;

&lt;p&gt;This property was very easy to implement, but I think the current approach is
not very efficient. When a placement can&amp;rsquo;t be made at the intended place up to
200(!) slightly different places are tried. This usually means moving the text
one pixel and trying again. I think the displacement should grow exponentially.
So instead of trying +-1, +-2, +-3, +-4, +-5,&amp;hellip; try +-1, +-2, +-4, +-8, +-16, &amp;hellip;
This would bring a huge increase in performance.
I implemented the old behavior because I don&amp;rsquo;t know if there are any applications
which require it.&lt;/p&gt;

&lt;h1&gt;Offset lines&lt;/h1&gt;

&lt;p&gt;First I implemented support for dis-placement along the line. This allows you to
render text offset from the center of the line.
Then I also implemented displacement perpendicular to the line. However I did
not use the algorithm from the old code (which estimated the direction an then
shifted all characters in the same direction) but instead I produce true offsets using the
new parallel line &lt;a href=&quot;https://github.com/mapnik/mapnik/pull/1269&quot;&gt;support in master&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The difference can be seen in this picture:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/harfbuzz/line-offset.png&quot; alt=&quot;text offset&quot; /&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Code for this image: &amp;lt;TextSymbolizer spacing=&quot;1&quot; placement=&quot;line&quot; dy=&quot;-10&quot; vertical-alignment=&quot;middle&quot; ...&amp;gt;'Some Text'&amp;lt;/TextSymbolizer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;With the old code text touches the line but it keeps the distance perfectly
with the new code. Stylesheets using offsets probably need a modification to
produce the same results: Up to now Mapnik ignored vertical-alignment for line
placements, but the new code uses it. To get the old behavior one has to include
&lt;code&gt;vertical-alignment=&quot;middle&quot;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Here is an example showing that it also works well with complex scripts:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/images/harfbuzz/offseted.png&quot; alt=&quot;Khmer text offset&quot; /&gt;
&lt;code&gt;Code for this image: &amp;lt;TextSymbolizer placement=&quot;line&quot; spacing=&quot;20&quot; max-char-angle-delta=&quot;0&quot; dy=&quot;6&quot; ...&amp;gt;&quot;ផ្លូវ​១២៣&quot;&amp;lt;/TextSymbolizer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;h1&gt;Multi line labels&lt;/h1&gt;

&lt;p&gt;The offset functionality allowed me to implement multi line labels very
efficiently. One can
use the same functions for point and line placements now
(&lt;code&gt;jalign&lt;/code&gt;, &lt;code&gt;wrap-width&lt;/code&gt;, &lt;code&gt;wrap-before&lt;/code&gt;, embedded newline characters).&lt;/p&gt;

&lt;p&gt;Example:
&lt;img src=&quot;/images/harfbuzz/multiline.png&quot; alt=&quot;multi line text&quot; /&gt;
&lt;code&gt;Code for this image: &amp;lt;TextSymbolizer placement=&quot;line&quot; spacing=&quot;20&quot; max-char-angle-delta=&quot;0&quot; dy=&quot;6&quot; ...&amp;gt;&quot;Hello&amp;amp;#10;World!&quot;&amp;lt;/TextSymbolizer&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;As one can see sometimes the placement is not perfect, but this only happens
for very rare cases (zig-zag-pattern). More common cases (straight lines, circles)
are handled correctly. The problem is that there is currently no function to
map a point on the original line to the offset line in offset_converter.&lt;/p&gt;

&lt;h1&gt;Performance tweaks&lt;/h1&gt;

&lt;p&gt;Profiler output for old versions of Mapnik has shown that during text rendering a lot
of time spent is spent in trigonometric functions like &lt;code&gt;sin&lt;/code&gt;, &lt;code&gt;cos&lt;/code&gt;, and &lt;code&gt;atan2&lt;/code&gt;. So instead
of calculating theses values several times (IIRC the old code calculated them
at least 5 times per character), I store them after the first time. I think
even this one calculation could be removed but it would complicate some other
things (determining which characters are upside down) so I&amp;rsquo;m waiting for data
saying it is really necessary before doing it.&lt;/p&gt;

&lt;h1&gt;Grid renderer&lt;/h1&gt;

&lt;p&gt;As the API is stable now I also reenabled support for grid renderer.&lt;/p&gt;

&lt;h1&gt;Next steps&lt;/h1&gt;

&lt;p&gt;Only one big thing is left:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add support for ShieldSymbolizer&lt;/li&gt;
&lt;/ul&gt;


   </content>
 </entry>
 
 <entry>
   <title>Summer of Code 2012 - Line placements and font sets</title>
   <link type="text/html" rel="alternate" href="http://mapnik.org/news/2012/08/04/gsoc2012-status7"/>
   <updated>2012-08-04T00:00:00-07:00</updated>
   <id>http://mapnik.org/news/2012/08/04/gsoc2012-status7</id>
   <content type="html">
     &lt;p&gt;&lt;a href=&quot;http://mapnik.org/news/2012/07/31/gsoc2012-status6&quot;&gt;Last week&lt;/a&gt; I implemented
point placements for the new HarfBuzz text shaping/rendering code. This week
my goal was to implement line placements, but I started with something different:&lt;/p&gt;

&lt;h1&gt;Font sets&lt;/h1&gt;

&lt;p&gt;I implemented fonts sets as this was on my TODO list for a long time. Also it
was not very hard, but the &lt;a href=&quot;https://github.com/mapnik/mapnik/commit/c529bf7b0681ac95499894f010ae34af8c1af5f4&quot;&gt;implementation&lt;/a&gt;
is different from what the old code did.&lt;/p&gt;

&lt;p&gt;Currently Mapnik tries to look up a glyph for each character and if it finds one
in the active font is uses this glyph. Otherwise it tries the next font.
With HarfBuzz one can&amp;rsquo;t use this method, as there is no 1:1 character to glyph
mapping. One character can produce multiple glyphs and several characters together
can result in a single glyph. So the new code instead processes each text run
as one unit. (For font selection a run usually is text with a certain script,
but there are other parameters, too.)&lt;/p&gt;

&lt;p&gt;If no font containing all glyphs for a certain run is found the whole run
is suppressed. It could be discussed if it would be better to suppress rendering
the whole text, but this behavior is similar to the old one.&lt;/p&gt;

&lt;h1&gt;Vertex cache&lt;/h1&gt;

&lt;p&gt;As a next step I looked at the old placement finder code and I was horrified.
The main function for line placements was about 200 lines long and you have to
spend a very long time to understand what exactly is happening there. One of the
biggest problems is that it does all the path processing in the same function
as finding the actual placement.&lt;/p&gt;

&lt;h2&gt;Some background on paths in Mapnik&lt;/h2&gt;

&lt;p&gt;In Mapnik a path is an object that implements two functions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;void rewind(): Go back to the first point in this path.&lt;/li&gt;
&lt;li&gt;unsigned vertex(double &amp;amp;x, double &amp;amp;y): Returns a path command (move to,
line to, end) and the coordinates of the associated point.&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;As one can clearly see it is a nightmare to use this for placement finding. For
example you can&amp;rsquo;t go back a step if you need to. You only can start from the
beginning again. While placing glyphs one needs to go forward a certain amount
but with these functions one can only go forward one point at a time.
One point might be
enough but sometimes it is not. So you have to check each time you move forward
how many points you have to skip. At the same time you have to make sure not to
fall of the end of the path (which might crash the program) and not to process
a &amp;ldquo;move to&amp;rdquo; command (as no text should be placed across discontinuities in the
path).&lt;/p&gt;

&lt;p&gt;In order not to get insane while writing the placement finder code I decided
to write a &lt;code&gt;class vertex_cache&lt;/code&gt; first. This class caches the vertices and
adds functions to advance or go back an exactly defined length.&lt;/p&gt;

&lt;h1&gt;Placement finder&lt;/h1&gt;

&lt;p&gt;After having created this class writing the placement finder code wasn&amp;rsquo;t hard
anymore. The code for line placements is very similar to the code for point
placements. There are some small differences which make it a little bit more
difficult:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rotation angle is dependent on the width of the character at corners (begin
and end have to match the line)&lt;/li&gt;
&lt;li&gt;Multi-glyph sequences where only the first glyph can be placed normally all
other glyphs expect to be placed on a straight line (see &lt;a href=&quot;https://github.com/mapnik/mapnik/issues/1208#issuecomment-7513988&quot;&gt;this discussion&lt;/a&gt; for
details)&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;While working on line placements I decided to add the function requested
in bug &lt;a href=&quot;https://github.com/mapnik/mapnik/issues/614&quot;&gt;#614&lt;/a&gt; (Optional disabling
auto-upright and selecting which direction is upright). This change shows the
advantage of the new clean design: Only a single line in placement finder had
to be changed! (Some more lines where needed for loading and saving this
attribute from/to XML.)&lt;/p&gt;

&lt;p&gt;The current placement finder code doesn&amp;rsquo;t handle offsets, yet. I don&amp;rsquo;t want
to use fake offsets as in Mapnik master as this can lead to ugly renderings:
&lt;a href=&quot;https://github.com/mapnik/mapnik/diff_blob/620f3f943e2a6e165d008fa3f84aa97a0abdecda/tests/visual_tests/images/line-offset-900-reference.png?raw=true&quot;&gt;&lt;img width=&quot;500&quot; src=&quot;https://github.com/mapnik/mapnik/diff_blob/620f3f943e2a6e165d008fa3f84aa97a0abdecda/tests/visual_tests/images/line-offset-900-reference.png?raw=true&quot; /&gt;&lt;/a&gt;
Instead I will try to render on a line parallel to the path.&lt;/p&gt;

&lt;h1&gt;Next steps&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Add collision detection to line placements&lt;/li&gt;
&lt;li&gt;Add support for ShieldSymbolizer&lt;/li&gt;
&lt;/ul&gt;


   </content>
 </entry>
 
 <entry>
   <title>Release 2.0.2</title>
   <link type="text/html" rel="alternate" href="http://mapnik.org/news/2012/08/03/release-2.0.2"/>
   <updated>2012-08-03T00:00:00-07:00</updated>
   <id>http://mapnik.org/news/2012/08/03/release-2.0.2</id>
   <content type="html">
     &lt;p&gt;The Mapnik team is pleased to announce Mapnik 2.0.2, the second stable bugfix release in the 2.0.x series, and also the last as development is now focused exclusively on the upcoming 2.1.x series (the one that supports compositing).&lt;/p&gt;

&lt;p&gt;For details on 2.0.2 fixes see the &lt;a href=&quot;https://github.com/mapnik/mapnik/wiki/Release2.0.2&quot;&gt;Changelog&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Get the source from the &lt;a href=&quot;http://mapnik.org/download/&quot;&gt;downloads page&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Note for TileMill users: TileMill currently requires Mapnik &gt;= 2.1.x and will not work with 2.0.2. So, if you are looking for a release for TileMill stay tuned and watch for 2.1 to be released &lt;a href=&quot;https://github.com/mapnik/mapnik/issues?milestone=8&amp;amp;state=open&quot;&gt;very soon&lt;/a&gt;.&lt;/p&gt;

   </content>
 </entry>
 
 <entry>
   <title>Summer of Code 2012 - Point placements</title>
   <link type="text/html" rel="alternate" href="http://mapnik.org/news/2012/07/31/gsoc2012-status6"/>
   <updated>2012-07-31T00:00:00-07:00</updated>
   <id>http://mapnik.org/news/2012/07/31/gsoc2012-status6</id>
   <content type="html">
     &lt;p&gt;This week my code finally has reached a state where everybody interested can
try it. After having implemented line breaking and fixing a few bugs
&lt;a href=&quot;http://mapnik.org/news/2012/07/22/gsoc2012-status5&quot;&gt;last week&lt;/a&gt; I implemented
the placement finder algorithm for point placements this week.&lt;/p&gt;

&lt;h1&gt;Placement finder&lt;/h1&gt;

&lt;p&gt;The placement finder is the component in Mapnik&amp;rsquo;s rendering stack which takes
a list of glyphs and their relative positions and calculates the positions these
glyphs should go to.
For point placements this isn&amp;rsquo;t terribly hard. You just place them next to each
other and make sure you get character spacing and rotation right. However the
old code to do this job was more than 150 lines long. The new code is only about
60 lines of code and it should be much faster.&lt;/p&gt;

&lt;h2&gt;Collision detection&lt;/h2&gt;

&lt;p&gt;The old code calculated the bounding box for each char and checked for collision
with other text. Now only the bounding box of all text together is used. For point
placements the difference between the sum of all individual bounding boxes
and the complete bounding box is usually very small.&lt;/p&gt;

&lt;p&gt;Let&amp;rsquo;s have a look at some numbers: Assuming that there are already 20 text placements with
an average of 10 characters each and we are trying to place another one
we get this:&lt;/p&gt;

&lt;h3&gt;Old code&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Number of items in collision detector: 200&lt;/li&gt;
&lt;li&gt;Time (in arbitrary units) for a collision detector check: ln2(200) = 7.6&lt;/li&gt;
&lt;li&gt;Number of checks per placement: 10&lt;/li&gt;
&lt;li&gt;Total time: 76&lt;/li&gt;
&lt;/ul&gt;


&lt;h3&gt;New code&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Number of items in collision detector: 20&lt;/li&gt;
&lt;li&gt;Time (in arbitrary units) for a collision detector check: ln2(20) = 4.3&lt;/li&gt;
&lt;li&gt;Number of checks per placement: 1&lt;/li&gt;
&lt;li&gt;Total time: 4.3&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;So the checking takes only 5% of the time it previously did.&lt;/p&gt;

&lt;h2&gt;Mixed directions&lt;/h2&gt;

&lt;p&gt;One other advantage of the new code is that it doesn&amp;rsquo;t explicitly handle
RTL text. This is done in earlier stages of the processing. The old code
assumed text was either completely LTR or RTL. Rendering text
with both directions could work, but didn&amp;rsquo;t always work.&lt;/p&gt;

&lt;h1&gt;Line breaking&lt;/h1&gt;

&lt;p&gt;I also worked on line breaking again, fixing a few bugs &amp;ndash; some of which were
interesting. For example, I noticed that when the first glyph of a string
is longer than the line length my code crashed. The problem here is that it asked
ICU&amp;rsquo;s break iterator for a break position before the first char and it returned
if there is none. As it turns out, the return value for a non-existent break is
INT_MAX-1 leading to an out-of-memory error.&lt;/p&gt;

&lt;p&gt;I also implemented forced line breaks (via &amp;ldquo;\n&amp;rdquo; chars).&lt;/p&gt;

&lt;h1&gt;Test results&lt;/h1&gt;

&lt;p&gt;Most visual tests return similar results to the reference images, however
automatic testing fails because the images aren&amp;rsquo;t identical. HarfBuzz chooses
different (better) character positions than our simple approach in the old code
did. The rendering quality for small font sizes has drastically improved (see
also &lt;a href=&quot;https://github.com/mapnik/mapnik/issues/1290&quot;&gt;bug #1290&lt;/a&gt;):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Old
&lt;img src=&quot;http://mapnik.org/images/harfbuzz/fontsizes-old.png&quot; alt=&quot;font sizes old&quot; /&gt;&lt;/li&gt;
&lt;li&gt;New
&lt;img src=&quot;http://mapnik.org/images/harfbuzz/fontsizes-new.png&quot; alt=&quot;font sizes new&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;p&gt;If you look closely you will also notice that the character spacing is
distributed much better now.&lt;/p&gt;

&lt;p&gt;I also discovered a bug in Mapnik master: RTL text is placed a the wrong position:&lt;/p&gt;

&lt;p&gt;Distance should be at least 16 pixels&lt;/p&gt;

&lt;p&gt;Left: old (wrong), right: new (correct)&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://mapnik.org/images/harfbuzz/rtl-old.png&quot; alt=&quot;RTL old&quot; /&gt;
&lt;img src=&quot;http://mapnik.org/images/harfbuzz/rtl-new.png&quot; alt=&quot;RTL new&quot; /&gt;&lt;/p&gt;

&lt;h1&gt;Next steps&lt;/h1&gt;

&lt;h2&gt;Debug symbolizer&lt;/h2&gt;

&lt;p&gt;Currently I&amp;rsquo;m working on adding a new symbolizer type which simply draws all
the collision detection bounding boxes. This should help verifying that the
calculations are actually correct and no annoying bugs turn up later.&lt;/p&gt;

&lt;h2&gt;Line placement&lt;/h2&gt;

&lt;p&gt;After that I will work on adding line placements to placement finder. This is
not trivial but I will try to split the job into smaller parts so the code
is easy to understand and bugs are less likely.&lt;/p&gt;

   </content>
 </entry>
 
 <entry>
   <title>Summer of Code 2012 - Line breaking</title>
   <link type="text/html" rel="alternate" href="http://mapnik.org/news/2012/07/22/gsoc2012-status5"/>
   <updated>2012-07-22T00:00:00-07:00</updated>
   <id>http://mapnik.org/news/2012/07/22/gsoc2012-status5</id>
   <content type="html">
     &lt;p&gt;Yet an other week has passed and a lot of things have happened since my
&lt;a href=&quot;http://mapnik.org/news/2012/07/13/gsoc2012-status4&quot;&gt;Summer of Code half-time post&lt;/a&gt;:&lt;/p&gt;

&lt;h2&gt;Itemizer&lt;/h2&gt;

&lt;p&gt;I noticed that the rendering I got from the text in bug
&lt;a href=&quot;https://github.com/mapnik/mapnik/issues/519&quot;&gt;#519&lt;/a&gt;
was totally wrong. I tracked it down to ICU&amp;rsquo;s bidi algorithm which returns
text runs in visual order but I assumed they would be in logical order. Therefore
all my offsets were wrong. Returning the runs in visual order makes much more
sense as no further reordering is necessary. While working on the itemizer
I also updated it to operate on parts of the input text for processing lines
after line breaking.&lt;/p&gt;

&lt;p&gt;This brings me to the next topic:&lt;/p&gt;

&lt;h2&gt;Line breaking&lt;/h2&gt;

&lt;p&gt;I finally got line breaking done. It was easier than I originally thought because
I had the idea that I don&amp;rsquo;t need a 1:1 character to glyph width mapping.
It is enough when I know how wide the sum of all characters forming a glyph cluster
is. Now I build a map which assigns the sum of the width of all glyphs forming
a cluster to the first character of this cluster. All other characters get a
width of zero.&lt;/p&gt;

&lt;p&gt;After this map is built line breaking is pretty straight forward. Sum all
widths till the length is longer than the maximum length, then find the last or
next break position and break the line.&lt;/p&gt;

&lt;p&gt;Afterwards reshape each line to get a correct rendering.&lt;/p&gt;

&lt;h2&gt;Kerning&lt;/h2&gt;

&lt;p&gt;I noticed small differences in glyph spacing between texts rendered with Mapnik
trunk and this branch. I found the cause of this behavior:&lt;/p&gt;

&lt;p&gt;HarfBuzz uses the kerning tables in the fonts and produces better spacing.&lt;/p&gt;

&lt;p&gt;Before and after example:
&lt;img src=&quot;http://mapnik.org/images/harfbuzz/kerning.gif&quot; alt=&quot;kerning&quot; /&gt;&lt;/p&gt;

&lt;h2&gt;Infrastructure work&lt;/h2&gt;

&lt;p&gt;I removed almost all code from the old text rendering system. It had grown from
a simple solution to a complex, hard to maintain one. The new system should
be much easier to understand.&lt;/p&gt;

&lt;h2&gt;HarfBuzz&lt;/h2&gt;

&lt;p&gt;HarfBuzz also has made large steps last week. There was a
&lt;a href=&quot;http://lists.freedesktop.org/archives/harfbuzz/2012-July/002154.html&quot;&gt;hackfest in Toronto&lt;/a&gt;
and problems with Indic languages were addressed. After the hackfest was over
the &lt;a href=&quot;http://lists.freedesktop.org/archives/harfbuzz/2012-July/002199.html&quot;&gt;failure rates&lt;/a&gt;
for the following languages were down to less than 0.19%.
Before they were as high as 87.7% (Khmer).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Amil&lt;/li&gt;
&lt;li&gt;Telugu&lt;/li&gt;
&lt;li&gt;Gujarati&lt;/li&gt;
&lt;li&gt;Oriya&lt;/li&gt;
&lt;li&gt;Devanagari&lt;/li&gt;
&lt;li&gt;Gurmukhi&lt;/li&gt;
&lt;li&gt;Bengali&lt;/li&gt;
&lt;li&gt;Kannada&lt;/li&gt;
&lt;li&gt;Malayalam&lt;/li&gt;
&lt;li&gt;Khmer&lt;/li&gt;
&lt;li&gt;Sinhala&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Next steps&lt;/h2&gt;

&lt;p&gt;Next week I will reimplement as much as possible of the placement finder functionality.&lt;/p&gt;

   </content>
 </entry>
 
 <entry>
   <title>Summer of Code 2012 - Half time</title>
   <link type="text/html" rel="alternate" href="http://mapnik.org/news/2012/07/13/gsoc2012-status4"/>
   <updated>2012-07-13T00:00:00-07:00</updated>
   <id>http://mapnik.org/news/2012/07/13/gsoc2012-status4</id>
   <content type="html">
     &lt;p&gt;After half of this year&amp;rsquo;s Summer of Code is over I have the first real results to present you:&lt;/p&gt;

&lt;p&gt;Text rendering works now and serveral bugs seem to be gone.
First of all here are some sample images:&lt;/p&gt;

&lt;table border=&quot;0&quot; width=&quot;100%&quot;&gt;
&lt;tr&gt;&lt;th&gt;Name&lt;th colspan=&quot;2&quot;&gt;Branch
&lt;tr&gt;&lt;th width=&quot;20%&quot;&gt;&lt;th width=&quot;40%&quot;&gt;master&lt;th width=&quot;40%&quot;&gt;harfbuzz
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/mapnik/mapnik/issues/1146&quot;&gt;Bug 1146&lt;/a&gt;
&lt;td&gt;&lt;img src=&quot;http://mapnik.org/images/harfbuzz/bug-1146-master.png&quot;&gt;
&lt;td&gt;&lt;img src=&quot;http://mapnik.org/images/harfbuzz/bug-1146-hb.png&quot;&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/mapnik/mapnik/issues/1154&quot;&gt;Bug 1154&lt;/a&gt;
&lt;td&gt;&lt;img src=&quot;http://mapnik.org/images/harfbuzz/bug-1154-master.png&quot;&gt;
&lt;td&gt;&lt;img src=&quot;http://mapnik.org/images/harfbuzz/bug-1154-hb.png&quot;&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;https://github.com/mapnik/mapnik/issues/1208&quot;&gt;Bug 1208&lt;/a&gt;
&lt;td&gt;&lt;img src=&quot;http://mapnik.org/images/harfbuzz/bug-1208-master.png&quot;&gt;
&lt;td&gt;&lt;img src=&quot;http://mapnik.org/images/harfbuzz/bug-1208-hb.png&quot;&gt;
&lt;tr&gt;
&lt;td&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Typographic_ligature&quot;&gt;Ligatures&lt;/a&gt;
&lt;td&gt;&lt;img src=&quot;http://mapnik.org/images/harfbuzz/ligatures-master.png&quot;&gt;
&lt;td&gt;&lt;img src=&quot;http://mapnik.org/images/harfbuzz/ligatures-hb.png&quot;&gt;
&lt;/table&gt;


&lt;p&gt;As you can see the first two bugs are solved and we got ligatures for free.
However Khmer rendering (third bug) is still broken, but this is not a problem
in Mapnik. HarfBuzz simply doesn&amp;rsquo;t support Khmer well enough yet. But this
should change &lt;a href=&quot;http://lists.freedesktop.org/archives/harfbuzz/2012-July/002154.html&quot;&gt;next week&lt;/a&gt;.
The nice thing about using HarfBuzz is that we don&amp;rsquo;t have to care about each
script but instead can rely on it to do the job and simply take the glyphs.&lt;/p&gt;

&lt;p&gt;The next major bug (&lt;a href=&quot;https://github.com/mapnik/mapnik/issues/519&quot;&gt;#519&lt;/a&gt;) isn&amp;rsquo;t
solved yet and is actually worse than what we have in master now because text
runs with mixed directions are processed in the wrong order by current code.
This will be fixed together with &lt;a href=&quot;http://mapnik.org/news/2012/07/02/gsoc2012-status3&quot;&gt;line breaking&lt;/a&gt;
as the problem is in the same area (wrong ordering of text runs).&lt;/p&gt;

&lt;h2&gt;Next steps&lt;/h2&gt;

&lt;p&gt;I will try to solve line breaking this week. Probably this will be all I do as
line breaking is hard (see last post for details).&lt;/p&gt;

&lt;h2&gt;Other things that need to be done&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Automatic font selection (aka fontsets)&lt;/li&gt;
&lt;li&gt;Reimplement placement finder to work with new code (currently it&amp;rsquo;s only a stub)&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;Update&lt;/h2&gt;

&lt;p&gt;All &lt;a href=&quot;http://licadho-cambodia.org/mapnik/khmer.html&quot;&gt;Khmer tests&lt;/a&gt; provided by
Github user &lt;a href=&quot;https://github.com/nirvn&quot;&gt;nirvn&lt;/a&gt; render
correctly with current HarfBuzz and a small fix in Mapnik. I don&amp;rsquo;t upload
example images here because the rendering looks exactly like the reference
renderings.&lt;/p&gt;

   </content>
 </entry>
 
 
</feed>
