From: Thomas Petazzoni <thomas.petazz...@free-electrons.com>

Mapnik is current using context.set_matrix() to modify the Cairo
transformation matrix to render markers at the right location and with
the right angle on the map. This is typically used to render one-way
arrows with the MapQuest stylesheet.

Unfortunately, context.set_matrix() completely _overrides_ the
existing Cairo transformation matrix instead of making an _additional_
transformation to it. However, in MapOSMatic
(http://www.maposmatic.org), for our map-rendering needs, we pass to
Mapnik a Cairo surface on which we have already applied a
translation+scaling transformation. The usage of .set_matrix() by
Mapnik completely overrides this transformation, with the result of
having completely misplaced one-way arrows.

By using context.transform(), then the transformation matrix is
applied on _top_ of the current one, which fixes the rendering. Now,
the one-way arrows are at the right locations on our translated+scaled
Cairo surface.

Thanks to Gaƫl Utard <gael.ut...@kisis.fr> for his help in debugging
this problem.

Signed-off-by: Thomas Petazzoni <thomas.petazz...@free-electrons.com>
---
 src/cairo_renderer.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp
index 589247e..12f6277 100644
--- a/src/cairo_renderer.cpp
+++ b/src/cairo_renderer.cpp
@@ -1269,7 +1269,7 @@ void cairo_renderer_base::start_map_processing(Map const& 
map)
                 double x, y, angle;
                 while (placement.get_point(&x, &y, &angle)) {
                     Cairo::Matrix matrix = Cairo::rotation_matrix(angle) * 
Cairo::translation_matrix(x,y) ;
-                    context.set_matrix(matrix);
+                    context.transform(matrix);
                     context.add_path(arrow_);
                 }
             }
-- 
1.7.4.1


Reply via email to