diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index 3e9f58fd3..17e268b1e 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -50,7 +50,7 @@ typedef transform_list_ptr transform_type; class feature_impl; MAPNIK_DECL void evaluate_transform(agg::trans_affine& tr, feature_impl const& feature, - transform_type const& trans_expr); + transform_type const& trans_expr, double scale_factor=1.0); class MAPNIK_DECL symbolizer_base { diff --git a/include/mapnik/transform_processor.hpp b/include/mapnik/transform_processor.hpp index d720c4350..89f3f7949 100644 --- a/include/mapnik/transform_processor.hpp +++ b/include/mapnik/transform_processor.hpp @@ -107,8 +107,12 @@ struct transform_processor struct node_evaluator : boost::static_visitor { - node_evaluator(transform_type& tr, feature_type const& feat) - : transform_(tr), feature_(feat) {} + node_evaluator(transform_type& tr, + feature_type const& feat, + double scale_factor) + : transform_(tr), + feature_(feat), + scale_factor_(scale_factor) {} void operator() (identity_node const& node) { @@ -117,26 +121,26 @@ struct transform_processor void operator() (matrix_node const& node) { - double a = eval(node.a_); + double a = eval(node.a_) * scale_factor_; // scale x; double b = eval(node.b_); double c = eval(node.c_); - double d = eval(node.d_); - double e = eval(node.e_); - double f = eval(node.f_); + double d = eval(node.d_) * scale_factor_; // scale y; + double e = eval(node.e_) * scale_factor_; // translate x + double f = eval(node.f_) * scale_factor_; // translate y transform_.multiply(agg::trans_affine(a, b, c, d, e, f)); } void operator() (translate_node const& node) { - double tx = eval(node.tx_); - double ty = eval(node.ty_, 0.0); + double tx = eval(node.tx_) * scale_factor_; + double ty = eval(node.ty_, 0.0) * scale_factor_; transform_.translate(tx, ty); } void operator() (scale_node const& node) { - double sx = eval(node.sx_); - double sy = eval(node.sy_, sx); + double sx = eval(node.sx_) * scale_factor_; + double sy = eval(node.sy_, sx) * scale_factor_; transform_.scale(sx, sy); } @@ -172,7 +176,7 @@ struct transform_processor double eval(expr_node const& x) const { mapnik::evaluate e(feature_); - return boost::apply_visitor(e, x).to_double(); + return boost::apply_visitor(e, x).to_double() * scale_factor_; } double eval(expr_node const& x, double def) const @@ -182,6 +186,7 @@ struct transform_processor transform_type& transform_; feature_type const& feature_; + double scale_factor_; }; template @@ -197,9 +202,9 @@ struct transform_processor } static void evaluate(transform_type& tr, feature_type const& feat, - transform_list const& list) + transform_list const& list, double scale_factor) { - node_evaluator eval(tr, feat); + node_evaluator eval(tr, feat, scale_factor); #ifdef MAPNIK_LOG MAPNIK_LOG_DEBUG(transform) << "transform: begin with " << to_string(matrix_node(tr)); diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index c2e466375..7259a3a86 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -125,7 +125,7 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, rasterizer_type ras(ren); agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); box2d clip_box = clipping_extent(); if (sym.clip()) diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index b4290ffce..f35a3405b 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -90,7 +90,7 @@ void agg_renderer::process(line_symbolizer const& sym, renderer_base renb(pixf); agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); box2d clip_box = clipping_extent(); if (sym.clip()) diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index ae82660d0..20c70c806 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -146,7 +146,7 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, renderer_type rp(renb,sa, sg, unsigned(sym.get_opacity()*255)); agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); typedef boost::mpl::vector conv_types; vertex_converter, rasterizer, polygon_pattern_symbolizer, diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index 6e168aae6..2c86a8a4e 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -57,7 +57,7 @@ void agg_renderer::process(polygon_symbolizer const& sym, gamma_ = sym.get_gamma(); } agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); box2d clip_box = clipping_extent(); typedef boost::mpl::vector conv_types; vertex_converter, rasterizer, polygon_symbolizer, diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 5539939df..ce51fc304 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -315,7 +315,7 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym, context_.set_color(sym.get_fill(), sym.get_opacity()); agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); typedef boost::mpl::vector conv_types; vertex_converter, cairo_context, polygon_symbolizer, @@ -466,7 +466,7 @@ void cairo_renderer_base::process(line_symbolizer const& sym, } agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); box2d clipping_extent = query_extent_; if (sym.clip()) @@ -853,7 +853,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, //} agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); typedef boost::mpl::vector conv_types; vertex_converter, cairo_context, polygon_pattern_symbolizer, @@ -1161,7 +1161,7 @@ void cairo_renderer_base::process(markers_symbolizer const& sym, if (mark && *mark) { agg::trans_affine geom_tr; - evaluate_transform(geom_tr, feature, sym.get_transform()); + evaluate_transform(geom_tr, feature, sym.get_transform(), scale_factor_); box2d const& bbox = (*mark)->bounding_box(); setup_transform_scaling(tr, bbox.width(), bbox.height(), feature, sym); evaluate_transform(tr, feature, sym.get_image_transform()); diff --git a/src/grid/process_line_pattern_symbolizer.cpp b/src/grid/process_line_pattern_symbolizer.cpp index eeaa700a9..42684e57a 100644 --- a/src/grid/process_line_pattern_symbolizer.cpp +++ b/src/grid/process_line_pattern_symbolizer.cpp @@ -83,7 +83,7 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, int stroke_width = (*pat)->width(); agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); box2d clipping_extent = query_extent_; if (sym.clip()) diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp index c188b6473..737d92def 100644 --- a/src/grid/process_line_symbolizer.cpp +++ b/src/grid/process_line_symbolizer.cpp @@ -69,7 +69,7 @@ void grid_renderer::process(line_symbolizer const& sym, stroke const& stroke_ = sym.get_stroke(); agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); box2d clipping_extent = query_extent_; if (sym.clip()) diff --git a/src/grid/process_markers_symbolizer.cpp b/src/grid/process_markers_symbolizer.cpp index 81180f481..1bc66ca36 100644 --- a/src/grid/process_markers_symbolizer.cpp +++ b/src/grid/process_markers_symbolizer.cpp @@ -96,7 +96,7 @@ void grid_renderer::process(markers_symbolizer const& sym, { ras_ptr->reset(); agg::trans_affine geom_tr; - evaluate_transform(geom_tr, feature, sym.get_transform()); + evaluate_transform(geom_tr, feature, sym.get_transform(), scale_factor_); agg::trans_affine tr = agg::trans_affine_scaling(scale_factor_*(1.0/pixmap_.get_resolution())); if ((*mark)->is_vector()) diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp index da012dada..ec75b42b2 100644 --- a/src/grid/process_polygon_pattern_symbolizer.cpp +++ b/src/grid/process_polygon_pattern_symbolizer.cpp @@ -68,7 +68,7 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, ras_ptr->reset(); agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); typedef boost::mpl::vector conv_types; vertex_converter, grid_rasterizer, polygon_pattern_symbolizer, diff --git a/src/grid/process_polygon_symbolizer.cpp b/src/grid/process_polygon_symbolizer.cpp index 5195760f9..f6508fd2f 100644 --- a/src/grid/process_polygon_symbolizer.cpp +++ b/src/grid/process_polygon_symbolizer.cpp @@ -55,7 +55,7 @@ void grid_renderer::process(polygon_symbolizer const& sym, ras_ptr->reset(); agg::trans_affine tr; - evaluate_transform(tr, feature, sym.get_transform()); + evaluate_transform(tr, feature, sym.get_transform(), scale_factor_); typedef boost::mpl::vector conv_types; vertex_converter, grid_rasterizer, polygon_symbolizer, diff --git a/src/symbolizer.cpp b/src/symbolizer.cpp index 1a09e0ce8..31ac0dd5c 100644 --- a/src/symbolizer.cpp +++ b/src/symbolizer.cpp @@ -29,7 +29,7 @@ namespace mapnik { void evaluate_transform(agg::trans_affine& tr, feature_impl const& feature, - transform_list_ptr const& trans_expr) + transform_list_ptr const& trans_expr, double scale_factor) { if (trans_expr) { @@ -37,7 +37,7 @@ void evaluate_transform(agg::trans_affine& tr, feature_impl const& feature, MAPNIK_LOG_DEBUG(transform) << "transform: evaluate " << transform_processor_type::to_string(*trans_expr); #endif - transform_processor_type::evaluate(tr, feature, *trans_expr); + transform_processor_type::evaluate(tr, feature, *trans_expr, scale_factor); } } diff --git a/tests/visual_tests/images/geometry-transform-translate-200-200-2.0-agg-reference.png b/tests/visual_tests/images/geometry-transform-translate-200-200-2.0-agg-reference.png index c20472cfb..29338b517 100644 Binary files a/tests/visual_tests/images/geometry-transform-translate-200-200-2.0-agg-reference.png and b/tests/visual_tests/images/geometry-transform-translate-200-200-2.0-agg-reference.png differ