Looks like a great patch. However it would be great to have some tests to accompany this. There are a number of places transforms are uses so it will be important to test them all.
Anyway, I am traveling this week and mostly offline. I will take a look at applying next week when back. In the meantime it would be great if you could create an issue and attach this patch. Thanks! Dane On Mar 26, 2012, at 10:49 AM, Thomas Petazzoni <[email protected]> wrote: > From: Thomas Petazzoni <[email protected]> > > 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 <[email protected]> for his help in debugging > this problem. > > Signed-off-by: Thomas Petazzoni <[email protected]> > --- > 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 >
