maposmatic-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Maposmatic-dev] [mapnik] [PATCH] cairo_renderer: use transform() in


From: Dane Springmeyer
Subject: Re: [Maposmatic-dev] [mapnik] [PATCH] cairo_renderer: use transform() instead of set_matrix() for markers
Date: Wed, 28 Mar 2012 23:13:10 -0400

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 <address@hidden> wrote:

> From: Thomas Petazzoni <address@hidden>
> 
> 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 <address@hidden> for his help in debugging
> this problem.
> 
> Signed-off-by: Thomas Petazzoni <address@hidden>
> ---
> 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

[Prev in Thread] Current Thread [Next in Thread]