From 89f72f02e8374569a145e67a88612ae1b2b41905 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sat, 8 Feb 2014 22:10:14 -0800 Subject: [PATCH 1/2] pass feature to vertex_converters - refs #2148/#2140 --- .../process_markers_symbolizer.hpp | 12 ++--- .../process_polygon_symbolizer.hpp | 2 +- include/mapnik/vertex_converters.hpp | 46 +++++++++++-------- src/agg/process_line_pattern_symbolizer.cpp | 4 +- src/agg/process_line_symbolizer.cpp | 8 ++-- .../process_polygon_pattern_symbolizer.cpp | 4 +- src/agg/process_polygon_symbolizer.cpp | 2 +- src/cairo_renderer.cpp | 8 ++-- src/grid/process_line_pattern_symbolizer.cpp | 4 +- src/grid/process_line_symbolizer.cpp | 8 +--- .../process_polygon_pattern_symbolizer.cpp | 4 +- src/grid/process_polygon_symbolizer.cpp | 2 +- tests/cpp_tests/geometry_converters_test.cpp | 13 ++++-- 13 files changed, 62 insertions(+), 55 deletions(-) diff --git a/include/mapnik/renderer_common/process_markers_symbolizer.hpp b/include/mapnik/renderer_common/process_markers_symbolizer.hpp index 26f08e9b2..c6bf5a2c0 100644 --- a/include/mapnik/renderer_common/process_markers_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_markers_symbolizer.hpp @@ -89,8 +89,8 @@ void render_markers_symbolizer(markers_symbolizer const &sym, typedef decltype(rasterizer_dispatch) dispatch_type; vertex_converter, dispatch_type, markers_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,tr,common.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,tr,feature,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { geometry_type::types type = feature.paths()[0].type(); @@ -121,8 +121,8 @@ void render_markers_symbolizer(markers_symbolizer const &sym, typedef decltype(rasterizer_dispatch) dispatch_type; vertex_converter, dispatch_type, markers_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,tr,common.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,tr,feature,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { geometry_type::types type = feature.paths()[0].type(); @@ -150,8 +150,8 @@ void render_markers_symbolizer(markers_symbolizer const &sym, typedef decltype(rasterizer_dispatch) dispatch_type; vertex_converter, dispatch_type, markers_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,tr,common.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,tr,feature,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { diff --git a/include/mapnik/renderer_common/process_polygon_symbolizer.hpp b/include/mapnik/renderer_common/process_polygon_symbolizer.hpp index e6104b6de..be5526957 100644 --- a/include/mapnik/renderer_common/process_polygon_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_polygon_symbolizer.hpp @@ -44,7 +44,7 @@ void render_polygon_symbolizer(polygon_symbolizer const &sym, double opacity = get(sym,keys::fill_opacity,feature, 1.0); vertex_converter_type converter(clip_box, ras, sym, common.t_, prj_trans, tr, - common.scale_factor_); + feature,common.scale_factor_); if (prj_trans.equal() && clip) converter.template set(); //optional clip (default: true) converter.template set(); //always transform diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index fd008b4ca..4510ab13b 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -98,7 +98,8 @@ struct converter_traits static void setup(geometry_type & geom, Args const& args) { typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); - geom.smooth_value(get(sym, keys::smooth)); + auto const& feat = boost::fusion::at_c<6>(args); + geom.smooth_value(get(sym, keys::smooth, feat)); } }; @@ -112,8 +113,9 @@ struct converter_traits static void setup(geometry_type & geom, Args const& args) { typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); - geom.set_simplify_algorithm(static_cast(get(sym,keys::simplify_algorithm))); - geom.set_simplify_tolerance(get(sym, keys::simplify_tolerance)); + auto const& feat = boost::fusion::at_c<6>(args); + geom.set_simplify_algorithm(static_cast(get(sym,keys::simplify_algorithm, feat))); + geom.set_simplify_tolerance(get(sym, keys::simplify_tolerance, feat)); } }; @@ -131,7 +133,6 @@ struct converter_traits } }; - template struct converter_traits { @@ -142,7 +143,7 @@ struct converter_traits static void setup(geometry_type & geom, Args const& args) { typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); - double scale_factor = boost::fusion::at_c<6>(args); + double scale_factor = boost::fusion::at_c<7>(args); auto dash = get_optional(sym, keys::stroke_dasharray); if (dash) { @@ -165,16 +166,16 @@ struct converter_traits static void setup(geometry_type & geom, Args const& args) { typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); + auto const& feat = boost::fusion::at_c<6>(args); set_join_caps(sym, geom); - double miterlimit = get(sym, keys::stroke_miterlimit, 4.0); - double width = get(sym, keys::stroke_width, 1.0); + double miterlimit = get(sym, keys::stroke_miterlimit, feat, 4.0); + double width = get(sym, keys::stroke_width, feat, 1.0); geom.generator().miter_limit(miterlimit); - double scale_factor = boost::fusion::at_c<6>(args); + double scale_factor = boost::fusion::at_c<7>(args); geom.generator().width(width * scale_factor); } }; - template struct converter_traits { @@ -214,7 +215,6 @@ struct converter_traits } }; - template struct converter_traits { @@ -245,8 +245,9 @@ struct converter_traits static void setup(geometry_type & geom, Args const& args) { typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); - double offset = get(sym, keys::offset); - double scale_factor = boost::fusion::at_c<6>(args); + auto const& feat = boost::fusion::at_c<6>(args); + double offset = get(sym, keys::offset, feat); + double scale_factor = boost::fusion::at_c<7>(args); geom.set_offset(offset * scale_factor); } }; @@ -313,7 +314,6 @@ struct dispatcher converter_fwd:: template forward(*this,geom,args_); } - } template @@ -329,9 +329,7 @@ struct dispatcher }; } - - -template +template struct vertex_converter : private mapnik::noncopyable { typedef C conv_types; @@ -341,6 +339,7 @@ struct vertex_converter : private mapnik::noncopyable typedef T trans_type; typedef P proj_trans_type; typedef A affine_trans_type; + typedef F feature_type; typedef typename boost::fusion::vector < bbox_type const&, @@ -349,18 +348,25 @@ struct vertex_converter : private mapnik::noncopyable trans_type const&, proj_trans_type const&, affine_trans_type const&, + feature_type const&, double //scale-factor > args_type; - vertex_converter(bbox_type const& b, rasterizer_type & ras, - symbolizer_type const& sym, trans_type & tr, + vertex_converter(bbox_type const& b, + rasterizer_type & ras, + symbolizer_type const& sym, + trans_type & tr, proj_trans_type const& prj_trans, affine_trans_type const& affine_trans, + feature_type const& feature, double scale_factor) - : disp_(args_type(boost::cref(b), boost::ref(ras), - boost::cref(sym), boost::cref(tr), + : disp_(args_type(boost::cref(b), + boost::ref(ras), + boost::cref(sym), + boost::cref(tr), boost::cref(prj_trans), boost::cref(affine_trans), + boost::cref(feature), scale_factor)) {} template diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index ee4a23d6f..b47422704 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -151,8 +151,8 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, typedef boost::mpl::vector conv_types; vertex_converter, rasterizer_type, line_pattern_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(clip_box,ras,sym,common_.t_,prj_trans,tr,common_.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.scale_factor_); if (clip) converter.set(); //optional clip (default: true) converter.set(); //always transform diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index 81b03d4fb..00a842b4a 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -136,8 +136,8 @@ void agg_renderer::process(line_symbolizer const& sym, set_join_caps_aa(sym , ras, feature); vertex_converter, rasterizer_type, line_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(clip_box,ras,sym,common_.t_,prj_trans,tr,common_.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform if (std::fabs(offset) > 0.0) converter.set(); // parallel offset @@ -156,8 +156,8 @@ void agg_renderer::process(line_symbolizer const& sym, else { vertex_converter, rasterizer, line_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,common_.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index afbf900ca..9e4871a95 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -160,8 +160,8 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, typedef boost::mpl::vector conv_types; vertex_converter, rasterizer, polygon_pattern_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,common_.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) converter.set(); //always transform diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index 5cca63dc3..26198b05e 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -52,7 +52,7 @@ void agg_renderer::process(polygon_symbolizer const& sym, typedef boost::mpl::vector conv_types; typedef vertex_converter, rasterizer, polygon_symbolizer, CoordTransform, proj_transform, agg::trans_affine, - conv_types> vertex_converter_type; + conv_types, feature_impl> vertex_converter_type; ras_ptr->reset(); double gamma = get(sym, keys::gamma, feature, 1.0); diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 2b53d3d76..597cec42c 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -271,7 +271,7 @@ void cairo_renderer_base::process(polygon_symbolizer const& sym, typedef boost::mpl::vector conv_types; typedef vertex_converter, cairo_context, polygon_symbolizer, CoordTransform, proj_transform, agg::trans_affine, - conv_types> vertex_converter_type; + conv_types, feature_impl> vertex_converter_type; cairo_save_restore guard(context_); composite_mode_e comp_op = get(sym, keys::comp_op, feature, src_over); @@ -376,8 +376,8 @@ void cairo_renderer_base::process(line_symbolizer const& sym, clipping_extent.pad(padding); } vertex_converter, cairo_context, line_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(clipping_extent,context_,sym,common_.t_,prj_trans,tr,common_.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(clipping_extent,context_,sym,common_.t_,prj_trans,tr,feature,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform @@ -726,7 +726,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, typedef boost::mpl::vector conv_types; vertex_converter, cairo_context, polygon_pattern_symbolizer, CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(common_.query_extent_,context_,sym,common_.t_,prj_trans,tr, common_.scale_factor_); + converter(common_.query_extent_,context_,sym,common_.t_,prj_trans,tr,feature,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) converter.set(); //always transform diff --git a/src/grid/process_line_pattern_symbolizer.cpp b/src/grid/process_line_pattern_symbolizer.cpp index ca104a45b..91b3951d2 100644 --- a/src/grid/process_line_pattern_symbolizer.cpp +++ b/src/grid/process_line_pattern_symbolizer.cpp @@ -115,8 +115,8 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, put(line, keys::smooth, value_double(smooth)); vertex_converter, grid_rasterizer, line_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(clipping_extent,*ras_ptr,line,common_.t_,prj_trans,tr,common_.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(clipping_extent,*ras_ptr,line,common_.t_,prj_trans,tr,feature,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform if (std::fabs(offset) > 0.0) converter.set(); // parallel offset diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp index 44b431283..90aa017cd 100644 --- a/src/grid/process_line_symbolizer.cpp +++ b/src/grid/process_line_symbolizer.cpp @@ -26,7 +26,6 @@ #include #include #include - #include // agg @@ -36,9 +35,6 @@ #include "agg_conv_stroke.h" #include "agg_conv_dash.h" -// boost - - // stl #include @@ -91,8 +87,8 @@ void grid_renderer::process(line_symbolizer const& sym, } vertex_converter, grid_rasterizer, line_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(clipping_extent,*ras_ptr,sym,common_.t_,prj_trans,tr,common_.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(clipping_extent,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform if (std::fabs(offset) > 0.0) converter.set(); // parallel offset diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp index 8af5522f1..ae0b7f5d1 100644 --- a/src/grid/process_polygon_pattern_symbolizer.cpp +++ b/src/grid/process_polygon_pattern_symbolizer.cpp @@ -76,8 +76,8 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, typedef boost::mpl::vector conv_types; vertex_converter, grid_rasterizer, polygon_pattern_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(common_.query_extent_,*ras_ptr,sym,common_.t_,prj_trans,tr,common_.scale_factor_); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(common_.query_extent_,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) converter.set(); //always transform diff --git a/src/grid/process_polygon_symbolizer.cpp b/src/grid/process_polygon_symbolizer.cpp index 9fffd3580..d096eb26e 100644 --- a/src/grid/process_polygon_symbolizer.cpp +++ b/src/grid/process_polygon_symbolizer.cpp @@ -54,7 +54,7 @@ void grid_renderer::process(polygon_symbolizer const& sym, typedef boost::mpl::vector conv_types; typedef vertex_converter, grid_rasterizer, polygon_symbolizer, CoordTransform, proj_transform, agg::trans_affine, - conv_types> vertex_converter_type; + conv_types, feature_impl> vertex_converter_type; ras_ptr->reset(); diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index cfb6bbe4f..21ff702d9 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -57,9 +58,11 @@ boost::optional linestring_bbox_clipping(mapnik::box2d bbox output_geometry_backend backend(output_paths, mapnik::geometry_type::types::LineString); typedef boost::mpl::vector conv_types; + mapnik::context_ptr ctx = std::make_shared(); + mapnik::feature_impl f(ctx,0); vertex_converter, output_geometry_backend, line_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(bbox, backend, sym, t, prj_trans, tr, 1.0); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(bbox, backend, sym, t, prj_trans, tr, f, 1.0); converter.set(); @@ -97,9 +100,11 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, output_geometry_backend backend(output_paths, mapnik::geometry_type::types::Polygon); typedef boost::mpl::vector conv_types; + mapnik::context_ptr ctx = std::make_shared(); + mapnik::feature_impl f(ctx,0); vertex_converter, output_geometry_backend, polygon_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(bbox, backend, sym, t, prj_trans, tr, 1.0); + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> + converter(bbox, backend, sym, t, prj_trans, tr, f, 1.0); converter.set(); From 9d6346aa9811215d9cda13cd01d99e18caca40a5 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Sun, 9 Feb 2014 11:30:26 -0800 Subject: [PATCH 2/2] fix compile - refs #2148 --- src/cairo_renderer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index 597cec42c..f736f3778 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -725,7 +725,7 @@ void cairo_renderer_base::process(polygon_pattern_symbolizer const& sym, typedef boost::mpl::vector conv_types; vertex_converter, cairo_context, polygon_pattern_symbolizer, - CoordTransform, proj_transform, agg::trans_affine, conv_types> + CoordTransform, proj_transform, agg::trans_affine, conv_types, feature_impl> converter(common_.query_extent_,context_,sym,common_.t_,prj_trans,tr,feature,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true)