From 130e621ace25fba4df536ed1bc32f02d9f8bd208 Mon Sep 17 00:00:00 2001 From: artemp Date: Fri, 26 Sep 2014 12:41:03 +0100 Subject: [PATCH 01/31] use c++11 in vertex_converters (work-in-progress) --- SConstruct | 2 +- .../process_markers_symbolizer.hpp | 30 +++-- include/mapnik/text/symbolizer_helpers.hpp | 5 +- include/mapnik/vertex_converters.hpp | 113 +++++++++++------- src/agg/process_line_pattern_symbolizer.cpp | 14 ++- src/agg/process_line_symbolizer.cpp | 24 ++-- .../process_polygon_pattern_symbolizer.cpp | 5 +- src/agg/process_polygon_symbolizer.cpp | 6 +- src/cairo/process_line_pattern_symbolizer.cpp | 3 +- src/cairo/process_line_symbolizer.cpp | 3 +- .../process_polygon_pattern_symbolizer.cpp | 3 +- src/cairo/process_polygon_symbolizer.cpp | 4 +- src/grid/process_line_pattern_symbolizer.cpp | 3 +- src/grid/process_line_symbolizer.cpp | 3 +- src/grid/process_markers_symbolizer.cpp | 1 - .../process_polygon_pattern_symbolizer.cpp | 3 +- src/grid/process_polygon_symbolizer.cpp | 4 +- tests/cpp_tests/geometry_converters_test.cpp | 6 +- 18 files changed, 124 insertions(+), 108 deletions(-) diff --git a/SConstruct b/SConstruct index 1e3d74e4e..be33646fe 100644 --- a/SConstruct +++ b/SConstruct @@ -1778,7 +1778,7 @@ if not preconfigured: # Common flags for g++/clang++ CXX compiler. # TODO: clean up code more to make -Wsign-conversion -Wconversion -Wshadow viable - common_cxx_flags = '-Wall -Wsign-compare %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread) + common_cxx_flags = '-Wall -Wsign-compare %s %s -ftemplate-depth-500 ' % (env['WARNING_CXXFLAGS'], pthread) if env['DEBUG']: env.Append(CXXFLAGS = common_cxx_flags + '-O0 -fno-inline') diff --git a/include/mapnik/renderer_common/process_markers_symbolizer.hpp b/include/mapnik/renderer_common/process_markers_symbolizer.hpp index afd93e250..9d0a7759d 100644 --- a/include/mapnik/renderer_common/process_markers_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_markers_symbolizer.hpp @@ -50,12 +50,6 @@ void render_markers_symbolizer(markers_symbolizer const& sym, using renderer_context_type = T2; using svg_attribute_type = agg::pod_bvector; - using conv_types = boost::mpl::vector; std::string filename = get(sym, keys::file, feature, common.vars_, "shape://ellipse"); bool clip = get(sym, keys::clip, feature, common.vars_, false); @@ -105,8 +99,12 @@ void render_markers_symbolizer(markers_symbolizer const& sym, snap_to_pixels, renderer_context); - vertex_converter, vector_dispatch_type, markers_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { @@ -145,8 +143,12 @@ void render_markers_symbolizer(markers_symbolizer const& sym, snap_to_pixels, renderer_context); - vertex_converter, vector_dispatch_type, markers_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { @@ -184,8 +186,12 @@ void render_markers_symbolizer(markers_symbolizer const& sym, common.vars_, renderer_context); - vertex_converter, raster_dispatch_type, markers_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) diff --git a/include/mapnik/text/symbolizer_helpers.hpp b/include/mapnik/text/symbolizer_helpers.hpp index 96b61b854..b124aadc0 100644 --- a/include/mapnik/text/symbolizer_helpers.hpp +++ b/include/mapnik/text/symbolizer_helpers.hpp @@ -56,10 +56,7 @@ struct placement_finder_adapter }; -using conv_types = boost::mpl::vector; -using vertex_converter_type = vertex_converter, placement_finder_adapter , symbolizer_base, - view_transform, proj_transform, agg::trans_affine, - conv_types, feature_impl>; +using vertex_converter_type = vertex_converter,clip_line_tag , transform_tag, affine_transform_tag, simplify_tag, smooth_tag>; class base_symbolizer_helper { diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index d215854a0..548875eb8 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -38,8 +38,10 @@ #include #include +#include + // boost -#include +//#include // mpl #include @@ -47,7 +49,7 @@ #include #include #include -#include +//#include #include // fusion @@ -107,7 +109,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); + auto const& sym = boost::fusion::at_c<2>(args); auto const& feat = boost::fusion::at_c<6>(args); auto const& vars = boost::fusion::at_c<7>(args); geom.smooth_value(get(sym, keys::smooth, feat, vars)); @@ -123,7 +125,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); + auto const& sym = boost::fusion::at_c<2>(args); auto const& feat = boost::fusion::at_c<6>(args); auto const& vars = boost::fusion::at_c<7>(args); geom.set_simplify_algorithm(static_cast(get(sym, keys::simplify_algorithm, feat, vars))); @@ -140,7 +142,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type box = boost::fusion::at_c<0>(args); + auto const& box = boost::fusion::at_c<0>(args); geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); } }; @@ -154,7 +156,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); + auto const& sym = boost::fusion::at_c<2>(args); auto const& feat = boost::fusion::at_c<6>(args); auto const& vars = boost::fusion::at_c<7>(args); double scale_factor = boost::fusion::at_c<8>(args); @@ -213,7 +215,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); + auto const& sym = boost::fusion::at_c<2>(args); auto const& feat = boost::fusion::at_c<6>(args); auto const& vars = boost::fusion::at_c<7>(args); set_join_caps(sym, geom, feat, vars); @@ -233,7 +235,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type box = boost::fusion::at_c<0>(args); + auto const& box = boost::fusion::at_c<0>(args); geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); //geom.set_clip_box(box); } @@ -292,7 +294,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - typename boost::mpl::at >::type sym = boost::fusion::at_c<2>(args); + auto const& sym = boost::fusion::at_c<2>(args); auto const& feat = boost::fusion::at_c<6>(args); auto const& vars = boost::fusion::at_c<7>(args); double offset = get(sym, keys::offset, feat, vars); @@ -312,7 +314,7 @@ struct converter_fwd using conv_type = typename detail::converter_traits::conv_type; conv_type conv(geom); detail::converter_traits::setup(conv,args); - base.template dispatch(conv, typename boost::is_same::type()); + base.template dispatch(conv, typename std::is_same::type()); } }; @@ -322,7 +324,7 @@ struct converter_fwd template static void forward(Base& base, T0 & geom,T1 const& args) { - base.template dispatch(geom, typename boost::is_same::type()); + base.template dispatch(geom, typename std::is_same::type()); } }; @@ -336,18 +338,17 @@ struct dispatcher dispatcher(args_type const& args) : args_(args) { - //std::memset(&vec_[0], 0, sizeof(unsigned)*vec_.size()); std::fill(vec_.begin(), vec_.end(), 0); } template - void dispatch(Geometry & geom, boost::mpl::true_) + void dispatch(Geometry & geom, std::true_type) { boost::fusion::at_c<1>(args_).add_path(geom); } template - void dispatch(Geometry & geom, boost::mpl::false_) + void dispatch(Geometry & geom, std::false_type) { using conv_tag = typename boost::mpl::deref::type; using conv_type = typename detail::converter_traits::conv_type; @@ -356,13 +357,12 @@ struct dispatcher std::size_t index = boost::mpl::distance::value - 1; if (vec_[index] == 1) { - converter_fwd::value>:: + converter_fwd::value>:: template forward(*this,geom,args_); } else { - converter_fwd:: - template forward(*this,geom,args_); + dispatch(geom, typename std::is_same::type()); } } @@ -371,26 +371,53 @@ struct dispatcher { using begin = typename boost::mpl::begin::type; using end = typename boost::mpl::end ::type; - dispatch(geom, boost::false_type()); + dispatch(geom, std::false_type()); } std::array::value> vec_; args_type args_; }; + +template +struct converter_setter; + +template +struct converter_setter +{ + static void set(Dispatcher & disp, int state) + { + if (std::is_same::value) + { + std::size_t index = sizeof...(ConverterTypes) ; + disp.vec_[index] = state; + } + else + { + converter_setter::set(disp, state); + } + } +}; + +template +struct converter_setter +{ + static void set(Dispatcher & disp, int state) {} +}; + } -template +template struct vertex_converter : private mapnik::noncopyable { - using conv_types = C; - using bbox_type = B; + using conv_types = boost::mpl::vector; + using bbox_type = box2d; using rasterizer_type = R; - using symbolizer_type = S; - using trans_type = T; - using proj_trans_type = P; - using affine_trans_type = A; - using feature_type = F; - using args_type = typename boost::fusion::vector< + using symbolizer_type = symbolizer_base; + using trans_type = view_transform; + using proj_trans_type = proj_transform; + using affine_trans_type = agg::trans_affine; + using feature_type = feature_impl; + using args_type = typename boost::fusion::vector< bbox_type const&, rasterizer_type&, symbolizer_type const&, @@ -402,6 +429,8 @@ struct vertex_converter : private mapnik::noncopyable double //scale-factor >; + using dispatcher_type = detail::dispatcher; + vertex_converter(bbox_type const& b, rasterizer_type & ras, symbolizer_type const& sym, @@ -411,14 +440,14 @@ struct vertex_converter : private mapnik::noncopyable feature_type const& feature, attributes const& vars, double scale_factor) - : 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), - boost::cref(vars), + : disp_(args_type(std::cref(b), + std::ref(ras), + std::cref(sym), + std::cref(tr), + std::cref(prj_trans), + std::cref(affine_trans), + std::cref(feature), + std::cref(vars), scale_factor)) {} template @@ -431,24 +460,16 @@ struct vertex_converter : private mapnik::noncopyable template void set() { - using iter = typename boost::mpl::find::type; - using end = typename boost::mpl::end::type; - std::size_t index = boost::mpl::distance::value - 1; - if (index < disp_.vec_.size()) - disp_.vec_[index]=1; + detail::converter_setter::set(disp_, 1); } template void unset() { - using iter = typename boost::mpl::find::type; - using end = typename boost::mpl::end::type; - std::size_t index = boost::mpl::distance::value - 1; - if (index < disp_.vec_.size()) - disp_.vec_[index]=0; + detail::converter_setter::set(disp_, 0); } - detail::dispatcher disp_; + dispatcher_type disp_; }; } diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index 18a2aa005..b45a7b39a 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -122,12 +122,14 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, clip_box.pad(padding); } - using conv_types = boost::mpl::vector; - vertex_converter, rasterizer_type, line_pattern_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + //using conv_types = boost::mpl::vector; + vertex_converter converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); //optional clip (default: true) diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index 110409484..844eb5ce5 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -116,11 +116,11 @@ void agg_renderer::process(line_symbolizer const& sym, using blender_type = agg::comp_op_adaptor_rgba_pre; // comp blender using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba; using renderer_base = agg::renderer_base; - using conv_types = boost::mpl::vector; + //using conv_types = boost::mpl::vector; pixfmt_comp_type pixf(buf); pixf.comp_op(static_cast(get(sym, keys::comp_op, feature, common_.vars_, src_over))); @@ -170,8 +170,11 @@ void agg_renderer::process(line_symbolizer const& sym, rasterizer_type ras(ren); set_join_caps_aa(sym, ras, feature, common_.vars_); - vertex_converter, rasterizer_type, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box,ras,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform @@ -190,8 +193,11 @@ void agg_renderer::process(line_symbolizer const& sym, } else { - vertex_converter, rasterizer, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index 0c6cdbdfe..4ca7045bc 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -158,9 +158,8 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, auto transform = get_optional(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); - using conv_types = boost::mpl::vector; - vertex_converter, rasterizer, polygon_pattern_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + //using conv_types = boost::mpl::vector; + vertex_converter converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index 0af6c4f6b..8f52db603 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -49,10 +49,8 @@ void agg_renderer::process(polygon_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - using conv_types = boost::mpl::vector; - using vertex_converter_type = vertex_converter, rasterizer, polygon_symbolizer, - view_transform, proj_transform, agg::trans_affine, - conv_types, feature_impl>; + //using conv_types = boost::mpl::vector; + using vertex_converter_type = vertex_converter; ras_ptr->reset(); double gamma = get(sym, keys::gamma, feature, common_.vars_, 1.0); diff --git a/src/cairo/process_line_pattern_symbolizer.cpp b/src/cairo/process_line_pattern_symbolizer.cpp index b254573bc..1dfb0682d 100644 --- a/src/cairo/process_line_pattern_symbolizer.cpp +++ b/src/cairo/process_line_pattern_symbolizer.cpp @@ -111,8 +111,7 @@ void cairo_renderer::process(line_pattern_symbolizer const& sym, using rasterizer_type = line_pattern_rasterizer; rasterizer_type ras(context_, *pattern, width, height); - vertex_converter, rasterizer_type, line_pattern_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clipping_extent, ras, sym, common_.t_, prj_trans, tr, feature, common_.vars_, common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) diff --git a/src/cairo/process_line_symbolizer.cpp b/src/cairo/process_line_symbolizer.cpp index b0cbbd9a2..18d01729c 100644 --- a/src/cairo/process_line_symbolizer.cpp +++ b/src/cairo/process_line_symbolizer.cpp @@ -84,8 +84,7 @@ void cairo_renderer::process(line_symbolizer const& sym, padding *= common_.scale_factor_; clipping_extent.pad(padding); } - vertex_converter, cairo_context, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clipping_extent,context_,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) diff --git a/src/cairo/process_polygon_pattern_symbolizer.cpp b/src/cairo/process_polygon_pattern_symbolizer.cpp index b8fe0cc1d..25274373c 100644 --- a/src/cairo/process_polygon_pattern_symbolizer.cpp +++ b/src/cairo/process_polygon_pattern_symbolizer.cpp @@ -103,8 +103,7 @@ void cairo_renderer::process(polygon_pattern_symbolizer const& sym, if (geom_transform) { evaluate_transform(tr, feature, common_.vars_, *geom_transform, common_.scale_factor_); } using conv_types = boost::mpl::vector; - vertex_converter, cairo_context, polygon_pattern_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clip_box, context_,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) diff --git a/src/cairo/process_polygon_symbolizer.cpp b/src/cairo/process_polygon_symbolizer.cpp index 9db05f60f..70b89490f 100644 --- a/src/cairo/process_polygon_symbolizer.cpp +++ b/src/cairo/process_polygon_symbolizer.cpp @@ -39,9 +39,7 @@ void cairo_renderer::process(polygon_symbolizer const& sym, proj_transform const& prj_trans) { using conv_types = boost::mpl::vector; - using vertex_converter_type = vertex_converter, cairo_context, polygon_symbolizer, - view_transform, proj_transform, agg::trans_affine, - conv_types, feature_impl>; + using vertex_converter_type = vertex_converter; cairo_save_restore guard(context_); composite_mode_e comp_op = get(sym, keys::comp_op, feature, common_.vars_, src_over); diff --git a/src/grid/process_line_pattern_symbolizer.cpp b/src/grid/process_line_pattern_symbolizer.cpp index e442e1466..d0ed58dde 100644 --- a/src/grid/process_line_pattern_symbolizer.cpp +++ b/src/grid/process_line_pattern_symbolizer.cpp @@ -119,8 +119,7 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, put(line, keys::simplify_tolerance, value_double(simplify_tolerance)); put(line, keys::smooth, value_double(smooth)); - vertex_converter, grid_rasterizer, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clipping_extent,*ras_ptr,line,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp index e9549894f..2b2ffc947 100644 --- a/src/grid/process_line_symbolizer.cpp +++ b/src/grid/process_line_symbolizer.cpp @@ -91,8 +91,7 @@ void grid_renderer::process(line_symbolizer const& sym, clipping_extent.pad(padding); } - vertex_converter, grid_rasterizer, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(clipping_extent,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform diff --git a/src/grid/process_markers_symbolizer.cpp b/src/grid/process_markers_symbolizer.cpp index 7b6e43eb5..bf0828cd4 100644 --- a/src/grid/process_markers_symbolizer.cpp +++ b/src/grid/process_markers_symbolizer.cpp @@ -53,7 +53,6 @@ porting notes --> #include #include -#include #include #include #include diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp index 6d4e319d5..ccb0a1560 100644 --- a/src/grid/process_polygon_pattern_symbolizer.cpp +++ b/src/grid/process_polygon_pattern_symbolizer.cpp @@ -78,8 +78,7 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, } using conv_types = boost::mpl::vector; - vertex_converter, grid_rasterizer, polygon_pattern_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(common_.query_extent_,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) diff --git a/src/grid/process_polygon_symbolizer.cpp b/src/grid/process_polygon_symbolizer.cpp index 2155c6fc4..08b50fddd 100644 --- a/src/grid/process_polygon_symbolizer.cpp +++ b/src/grid/process_polygon_symbolizer.cpp @@ -54,9 +54,7 @@ void grid_renderer::process(polygon_symbolizer const& sym, using pixfmt_type = typename grid_renderer_base_type::pixfmt_type; using color_type = typename grid_renderer_base_type::pixfmt_type::color_type; using conv_types = boost::mpl::vector; - using vertex_converter_type = vertex_converter, grid_rasterizer, polygon_symbolizer, - view_transform, proj_transform, agg::trans_affine, - conv_types, feature_impl>; + using vertex_converter_type = vertex_converter; ras_ptr->reset(); diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index 618c67c6e..68b63138d 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -63,8 +63,7 @@ boost::optional linestring_bbox_clipping(mapnik::box2d bbox using conv_types = boost::mpl::vector; mapnik::context_ptr ctx = std::make_shared(); mapnik::feature_impl f(ctx,0); - vertex_converter, output_geometry_backend, line_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(bbox, backend, sym, t, prj_trans, tr, f, attributes(), 1.0); converter.set(); @@ -107,8 +106,7 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, using conv_types = boost::mpl::vector; mapnik::context_ptr ctx = std::make_shared(); mapnik::feature_impl f(ctx,0); - vertex_converter, output_geometry_backend, polygon_symbolizer, - view_transform, proj_transform, agg::trans_affine, conv_types, feature_impl> + vertex_converter converter(bbox, backend, sym, t, prj_trans, tr, f, attributes(), 1.0); converter.set(); From 06d4f0aa113bff34b0f6469467ba809d66efe4f9 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 29 Sep 2014 11:57:01 +0100 Subject: [PATCH 02/31] revert template instantiation depth to 300 --- SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index be33646fe..1e3d74e4e 100644 --- a/SConstruct +++ b/SConstruct @@ -1778,7 +1778,7 @@ if not preconfigured: # Common flags for g++/clang++ CXX compiler. # TODO: clean up code more to make -Wsign-conversion -Wconversion -Wshadow viable - common_cxx_flags = '-Wall -Wsign-compare %s %s -ftemplate-depth-500 ' % (env['WARNING_CXXFLAGS'], pthread) + common_cxx_flags = '-Wall -Wsign-compare %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread) if env['DEBUG']: env.Append(CXXFLAGS = common_cxx_flags + '-O0 -fno-inline') From 83827514044a7644e3206dd9c3279ec736745e3a Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 29 Sep 2014 11:57:47 +0100 Subject: [PATCH 03/31] fix cpp_test --- tests/cpp_tests/geometry_converters_test.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/cpp_tests/geometry_converters_test.cpp b/tests/cpp_tests/geometry_converters_test.cpp index 68b63138d..7545b4728 100644 --- a/tests/cpp_tests/geometry_converters_test.cpp +++ b/tests/cpp_tests/geometry_converters_test.cpp @@ -60,10 +60,9 @@ boost::optional linestring_bbox_clipping(mapnik::box2d bbox mapnik::geometry_container output_paths; output_geometry_backend backend(output_paths, mapnik::geometry_type::types::LineString); - using conv_types = boost::mpl::vector; mapnik::context_ptr ctx = std::make_shared(); mapnik::feature_impl f(ctx,0); - vertex_converter + vertex_converter converter(bbox, backend, sym, t, prj_trans, tr, f, attributes(), 1.0); converter.set(); @@ -103,10 +102,9 @@ boost::optional polygon_bbox_clipping(mapnik::box2d bbox, mapnik::geometry_container output_paths; output_geometry_backend backend(output_paths, mapnik::geometry_type::types::Polygon); - using conv_types = boost::mpl::vector; mapnik::context_ptr ctx = std::make_shared(); mapnik::feature_impl f(ctx,0); - vertex_converter + vertex_converter converter(bbox, backend, sym, t, prj_trans, tr, f, attributes(), 1.0); converter.set(); From e57f66b97d3e8cb37427062314056a443c879399 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 29 Sep 2014 11:58:04 +0100 Subject: [PATCH 04/31] re-implement vertex_converters using c++11 feature (removes dependency on boost::mpl/boost::fusion) --- include/mapnik/vertex_converters.hpp | 276 +++++++++++---------------- 1 file changed, 110 insertions(+), 166 deletions(-) diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index 548875eb8..fce34509d 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -38,25 +38,9 @@ #include #include -#include - -// boost -//#include - -// mpl -#include -#include -#include -#include -#include -//#include -#include - // fusion -#include -#include - - +//#include +//#include // agg #include "agg_math_stroke.h" @@ -70,6 +54,7 @@ #include "agg_conv_transform.h" // stl +#include #include #include @@ -93,11 +78,6 @@ struct converter_traits { using geometry_type = T0; using conv_type = geometry_type; - template - static void setup(geometry_type & , Args const& ) - { - throw std::runtime_error("invalid call to setup"); - } }; template @@ -109,10 +89,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - auto const& sym = boost::fusion::at_c<2>(args); - auto const& feat = boost::fusion::at_c<6>(args); - auto const& vars = boost::fusion::at_c<7>(args); - geom.smooth_value(get(sym, keys::smooth, feat, vars)); + geom.smooth_value(get(args.sym, keys::smooth, args.feature, args.vars)); } }; @@ -125,11 +102,8 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - auto const& sym = boost::fusion::at_c<2>(args); - auto const& feat = boost::fusion::at_c<6>(args); - auto const& vars = boost::fusion::at_c<7>(args); - geom.set_simplify_algorithm(static_cast(get(sym, keys::simplify_algorithm, feat, vars))); - geom.set_simplify_tolerance(get(sym, keys::simplify_tolerance, feat, vars)); + geom.set_simplify_algorithm(static_cast(get(args.sym, keys::simplify_algorithm, args.feature, args.vars))); + geom.set_simplify_tolerance(get(args.sym, keys::simplify_tolerance,args.feature, args.vars)); } }; @@ -142,7 +116,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - auto const& box = boost::fusion::at_c<0>(args); + auto const& box = args.bbox; geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); } }; @@ -156,10 +130,10 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - auto const& sym = boost::fusion::at_c<2>(args); - auto const& feat = boost::fusion::at_c<6>(args); - auto const& vars = boost::fusion::at_c<7>(args); - double scale_factor = boost::fusion::at_c<8>(args); + auto const& sym = args.sym; + auto const& feat = args.feature; + auto const& vars = args.vars; + double scale_factor = args.scale_factor; auto dash = get_optional(sym, keys::stroke_dasharray, feat, vars); if (dash) { @@ -215,13 +189,13 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - auto const& sym = boost::fusion::at_c<2>(args); - auto const& feat = boost::fusion::at_c<6>(args); - auto const& vars = boost::fusion::at_c<7>(args); + auto const& sym = args.sym; + auto const& feat = args.feature; + auto const& vars = args.vars; set_join_caps(sym, geom, feat, vars); double miterlimit = get(sym, keys::stroke_miterlimit, feat, vars, 4.0); geom.generator().miter_limit(miterlimit); - double scale_factor = boost::fusion::at_c<8>(args); + double scale_factor = args.scale_factor; double width = get(sym, keys::stroke_width, feat, vars, 1.0); geom.generator().width(width * scale_factor); } @@ -235,7 +209,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - auto const& box = boost::fusion::at_c<0>(args); + auto const& box = args.bbox; geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); //geom.set_clip_box(box); } @@ -262,8 +236,8 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - geom.set_proj_trans(boost::fusion::at_c<4>(args)); - geom.set_trans(boost::fusion::at_c<3>(args)); + geom.set_proj_trans(args.prj_trans); + geom.set_trans(args.tr); } }; @@ -281,7 +255,7 @@ struct converter_traits template static void setup(geometry_type & geom, Args & args) { - geom.transformer(boost::fusion::at_c<5>(args)); + geom.transformer(args.affine_trans); } }; @@ -294,96 +268,21 @@ struct converter_traits template static void setup(geometry_type & geom, Args const& args) { - auto const& sym = boost::fusion::at_c<2>(args); - auto const& feat = boost::fusion::at_c<6>(args); - auto const& vars = boost::fusion::at_c<7>(args); + auto const& sym = args.sym; + auto const& feat = args.feature; + auto const& vars = args.vars; double offset = get(sym, keys::offset, feat, vars); - double scale_factor = boost::fusion::at_c<8>(args); - geom.set_offset(offset * scale_factor); + geom.set_offset(offset * args.scale_factor); } }; -template -struct converter_fwd -{ - template - static void forward(Base& base, T0 & geom,T1 const& args) - { - using geometry_type = T0; - using conv_tag = T2; - using conv_type = typename detail::converter_traits::conv_type; - conv_type conv(geom); - detail::converter_traits::setup(conv,args); - base.template dispatch(conv, typename std::is_same::type()); - } -}; - -template <> -struct converter_fwd -{ - template - static void forward(Base& base, T0 & geom,T1 const& args) - { - base.template dispatch(geom, typename std::is_same::type()); - } -}; - -template -struct dispatcher -{ - using this_type = dispatcher; - using args_type = A; - using conv_types = C; - - dispatcher(args_type const& args) - : args_(args) - { - std::fill(vec_.begin(), vec_.end(), 0); - } - - template - void dispatch(Geometry & geom, std::true_type) - { - boost::fusion::at_c<1>(args_).add_path(geom); - } - - template - void dispatch(Geometry & geom, std::false_type) - { - using conv_tag = typename boost::mpl::deref::type; - using conv_type = typename detail::converter_traits::conv_type; - using Next = typename boost::mpl::next::type; - - std::size_t index = boost::mpl::distance::value - 1; - if (vec_[index] == 1) - { - converter_fwd::value>:: - template forward(*this,geom,args_); - } - else - { - dispatch(geom, typename std::is_same::type()); - } - } - - template - void apply(Geometry & geom) - { - using begin = typename boost::mpl::begin::type; - using end = typename boost::mpl::end ::type; - dispatch(geom, std::false_type()); - } - - std::array::value> vec_; - args_type args_; -}; - -template -struct converter_setter; - -template -struct converter_setter +template +struct converters_helper; + +template +struct converters_helper { + template static void set(Dispatcher & disp, int state) { if (std::is_same::value) @@ -393,46 +292,100 @@ struct converter_setter } else { - converter_setter::set(disp, state); + converters_helper:: template set(disp, state); + } + } + + template + static void forward(Dispatcher & disp, Geometry & geom) + { + std::size_t index = sizeof...(ConverterTypes); + if (disp.vec_[index] == 1) + { + using conv_type = typename detail::converter_traits::conv_type; + conv_type conv(geom); + detail::converter_traits::setup(conv,disp.args_); + converters_helper::forward(disp, conv); + } + else + { + converters_helper::forward(disp, geom); } } }; -template -struct converter_setter +template +struct converters_helper { + template static void set(Dispatcher & disp, int state) {} + template + static void forward(Dispatcher & disp, Geometry & geom) + { + disp.args_.proc.add_path(geom); + } +}; + +template +struct dispatcher : mapnik::noncopyable +{ + using this_type = dispatcher; + using args_type = Args; + + dispatcher(args_type const& args) + : args_(args) + { + std::fill(vec_.begin(), vec_.end(), 0); + } + + std::array vec_; + args_type args_; +}; + +template +struct arguments //: mapnik::noncopyable +{ + arguments(Processor & proc, box2d const& bbox, symbolizer_base const& sym, view_transform const& tr, + proj_transform const& prj_trans, agg::trans_affine const& affine_trans, feature_impl const& feature, + attributes const& vars, double scale_factor) + : proc(proc), + bbox(bbox), + sym(sym), + tr(tr), + prj_trans(prj_trans), + affine_trans(affine_trans), + feature(feature), + vars(vars), + scale_factor(scale_factor) {} + + Processor & proc; + box2d const& bbox; + symbolizer_base const& sym; + view_transform const& tr; + proj_transform const& prj_trans; + agg::trans_affine const& affine_trans; + feature_impl const& feature; + attributes const& vars; + double scale_factor; }; } -template +template struct vertex_converter : private mapnik::noncopyable { - using conv_types = boost::mpl::vector; using bbox_type = box2d; - using rasterizer_type = R; + using processor_type = Processor; using symbolizer_type = symbolizer_base; using trans_type = view_transform; using proj_trans_type = proj_transform; using affine_trans_type = agg::trans_affine; using feature_type = feature_impl; - using args_type = typename boost::fusion::vector< - bbox_type const&, - rasterizer_type&, - symbolizer_type const&, - trans_type const&, - proj_trans_type const&, - affine_trans_type const&, - feature_type const&, - attributes const&, - double //scale-factor - >; + using args_type = detail::arguments; + using dispatcher_type = detail::dispatcher; - using dispatcher_type = detail::dispatcher; - - vertex_converter(bbox_type const& b, - rasterizer_type & ras, + vertex_converter(bbox_type const& bbox, + processor_type & proc, symbolizer_type const& sym, trans_type const& tr, proj_trans_type const& prj_trans, @@ -440,33 +393,24 @@ struct vertex_converter : private mapnik::noncopyable feature_type const& feature, attributes const& vars, double scale_factor) - : disp_(args_type(std::cref(b), - std::ref(ras), - std::cref(sym), - std::cref(tr), - std::cref(prj_trans), - std::cref(affine_trans), - std::cref(feature), - std::cref(vars), - scale_factor)) {} + : disp_(args_type(proc,bbox,sym,tr,prj_trans,affine_trans,feature,vars,scale_factor)) {} template void apply(Geometry & geom) { - using geometry_type = Geometry; - disp_.template apply(geom); + detail::converters_helper:: template forward(disp_, geom); } - template + template void set() { - detail::converter_setter::set(disp_, 1); + detail::converters_helper:: template set(disp_, 1); } - template + template void unset() { - detail::converter_setter::set(disp_, 0); + detail::converters_helper:: template set(disp_, 0); } dispatcher_type disp_; From 7f81fc914620e54efd53c80b4b722bb762f008d5 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 29 Sep 2014 12:22:39 +0100 Subject: [PATCH 05/31] cleanup --- include/mapnik/vertex_converters.hpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index fce34509d..b0c77bc92 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -211,7 +211,6 @@ struct converter_traits { auto const& box = args.bbox; geom.clip_box(box.minx(),box.miny(),box.maxx(),box.maxy()); - //geom.set_clip_box(box); } }; @@ -221,10 +220,7 @@ struct converter_traits using geometry_type = T; using conv_type = typename agg::conv_close_polygon; template - static void setup(geometry_type & , Args const&) - { - // no-op - } + static void setup(geometry_type & , Args const&) {} }; template From 4f67ec0fc7d69223893fb12aae365998e14744f7 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 29 Sep 2014 12:25:34 +0100 Subject: [PATCH 06/31] update cairo and grid renderers to use new vertex_converters --- src/cairo/process_line_pattern_symbolizer.cpp | 13 +++++-------- src/cairo/process_line_symbolizer.cpp | 14 +++++++------- src/cairo/process_polygon_pattern_symbolizer.cpp | 3 +-- src/cairo/process_polygon_symbolizer.cpp | 4 +--- src/grid/process_line_pattern_symbolizer.cpp | 9 +++++---- src/grid/process_line_symbolizer.cpp | 8 ++++---- src/grid/process_polygon_pattern_symbolizer.cpp | 3 +-- src/grid/process_polygon_symbolizer.cpp | 3 +-- 8 files changed, 25 insertions(+), 32 deletions(-) diff --git a/src/cairo/process_line_pattern_symbolizer.cpp b/src/cairo/process_line_pattern_symbolizer.cpp index 1dfb0682d..c51c56f9c 100644 --- a/src/cairo/process_line_pattern_symbolizer.cpp +++ b/src/cairo/process_line_pattern_symbolizer.cpp @@ -41,13 +41,6 @@ void cairo_renderer::process(line_pattern_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - - using conv_types = boost::mpl::vector; - std::string filename = get(sym, keys::file, feature, common_.vars_); composite_mode_e comp_op = get(sym, keys::comp_op, feature, common_.vars_, src_over); bool clip = get(sym, keys::clip, feature, common_.vars_, false); @@ -111,7 +104,11 @@ void cairo_renderer::process(line_pattern_symbolizer const& sym, using rasterizer_type = line_pattern_rasterizer; rasterizer_type ras(context_, *pattern, width, height); - vertex_converter + vertex_converter converter(clipping_extent, ras, sym, common_.t_, prj_trans, tr, feature, common_.vars_, common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) diff --git a/src/cairo/process_line_symbolizer.cpp b/src/cairo/process_line_symbolizer.cpp index 18d01729c..5a18e81ca 100644 --- a/src/cairo/process_line_symbolizer.cpp +++ b/src/cairo/process_line_symbolizer.cpp @@ -36,12 +36,6 @@ void cairo_renderer::process(line_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - using conv_types = boost::mpl::vector; - composite_mode_e comp_op = get(sym, keys::comp_op, feature, common_.vars_, src_over); bool clip = get(sym, keys::clip, feature, common_.vars_, false); double offset = get(sym, keys::offset, feature, common_.vars_, 0.0); @@ -84,7 +78,13 @@ void cairo_renderer::process(line_symbolizer const& sym, padding *= common_.scale_factor_; clipping_extent.pad(padding); } - vertex_converter + vertex_converter converter(clipping_extent,context_,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) diff --git a/src/cairo/process_polygon_pattern_symbolizer.cpp b/src/cairo/process_polygon_pattern_symbolizer.cpp index 25274373c..4911a40b3 100644 --- a/src/cairo/process_polygon_pattern_symbolizer.cpp +++ b/src/cairo/process_polygon_pattern_symbolizer.cpp @@ -102,8 +102,7 @@ void cairo_renderer::process(polygon_pattern_symbolizer const& sym, auto geom_transform = get_optional(sym, keys::geometry_transform); if (geom_transform) { evaluate_transform(tr, feature, common_.vars_, *geom_transform, common_.scale_factor_); } - using conv_types = boost::mpl::vector; - vertex_converter + vertex_converter converter(clip_box, context_,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) diff --git a/src/cairo/process_polygon_symbolizer.cpp b/src/cairo/process_polygon_symbolizer.cpp index 70b89490f..190b87e34 100644 --- a/src/cairo/process_polygon_symbolizer.cpp +++ b/src/cairo/process_polygon_symbolizer.cpp @@ -38,9 +38,7 @@ void cairo_renderer::process(polygon_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - using conv_types = boost::mpl::vector; - using vertex_converter_type = vertex_converter; - + using vertex_converter_type = vertex_converter; cairo_save_restore guard(context_); composite_mode_e comp_op = get(sym, keys::comp_op, feature, common_.vars_, src_over); context_.set_operator(comp_op); diff --git a/src/grid/process_line_pattern_symbolizer.cpp b/src/grid/process_line_pattern_symbolizer.cpp index d0ed58dde..64d3e70e9 100644 --- a/src/grid/process_line_pattern_symbolizer.cpp +++ b/src/grid/process_line_pattern_symbolizer.cpp @@ -73,9 +73,7 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, using pixfmt_type = typename grid_renderer_base_type::pixfmt_type; using color_type = typename grid_renderer_base_type::pixfmt_type::color_type; using renderer_type = agg::renderer_scanline_bin_solid; - using conv_types = boost::mpl::vector; + agg::scanline_bin sl; grid_rendering_buffer buf(pixmap_.raw_data(), common_.width_, common_.height_, common_.width_); @@ -119,7 +117,10 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, put(line, keys::simplify_tolerance, value_double(simplify_tolerance)); put(line, keys::smooth, value_double(smooth)); - vertex_converter + vertex_converter converter(clipping_extent,*ras_ptr,line,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform diff --git a/src/grid/process_line_symbolizer.cpp b/src/grid/process_line_symbolizer.cpp index 2b2ffc947..904322870 100644 --- a/src/grid/process_line_symbolizer.cpp +++ b/src/grid/process_line_symbolizer.cpp @@ -50,9 +50,7 @@ void grid_renderer::process(line_symbolizer const& sym, using pixfmt_type = typename grid_renderer_base_type::pixfmt_type; using color_type = typename grid_renderer_base_type::pixfmt_type::color_type; using renderer_type = agg::renderer_scanline_bin_solid; - using conv_types = boost::mpl::vector; + agg::scanline_bin sl; grid_rendering_buffer buf(pixmap_.raw_data(), common_.width_, common_.height_, common_.width_); @@ -91,7 +89,9 @@ void grid_renderer::process(line_symbolizer const& sym, clipping_extent.pad(padding); } - vertex_converter + vertex_converter converter(clipping_extent,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (clip) converter.set(); // optional clip (default: true) converter.set(); // always transform diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp index ccb0a1560..45492c1ec 100644 --- a/src/grid/process_polygon_pattern_symbolizer.cpp +++ b/src/grid/process_polygon_pattern_symbolizer.cpp @@ -77,8 +77,7 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); } - using conv_types = boost::mpl::vector; - vertex_converter + vertex_converter converter(common_.query_extent_,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); if (prj_trans.equal() && clip) converter.set(); //optional clip (default: true) diff --git a/src/grid/process_polygon_symbolizer.cpp b/src/grid/process_polygon_symbolizer.cpp index 08b50fddd..f06893e96 100644 --- a/src/grid/process_polygon_symbolizer.cpp +++ b/src/grid/process_polygon_symbolizer.cpp @@ -53,8 +53,7 @@ void grid_renderer::process(polygon_symbolizer const& sym, using renderer_type = agg::renderer_scanline_bin_solid; using pixfmt_type = typename grid_renderer_base_type::pixfmt_type; using color_type = typename grid_renderer_base_type::pixfmt_type::color_type; - using conv_types = boost::mpl::vector; - using vertex_converter_type = vertex_converter; + using vertex_converter_type = vertex_converter; ras_ptr->reset(); From 14ba64174be0e33d8aec0a88b8d29c506e894395 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 29 Sep 2014 14:07:39 +0100 Subject: [PATCH 07/31] make arguments noncopyable --- include/mapnik/vertex_converters.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index b0c77bc92..f943075db 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -328,8 +328,10 @@ struct dispatcher : mapnik::noncopyable using this_type = dispatcher; using args_type = Args; - dispatcher(args_type const& args) - : args_(args) + dispatcher(typename Args::processor_type & proc, box2d const& bbox, symbolizer_base const& sym, view_transform const& tr, + proj_transform const& prj_trans, agg::trans_affine const& affine_trans, feature_impl const& feature, + attributes const& vars, double scale_factor) + : args_(proc,bbox,sym,tr,prj_trans,affine_trans,feature,vars,scale_factor) { std::fill(vec_.begin(), vec_.end(), 0); } @@ -339,8 +341,9 @@ struct dispatcher : mapnik::noncopyable }; template -struct arguments //: mapnik::noncopyable +struct arguments : mapnik::noncopyable { + using processor_type = Processor; arguments(Processor & proc, box2d const& bbox, symbolizer_base const& sym, view_transform const& tr, proj_transform const& prj_trans, agg::trans_affine const& affine_trans, feature_impl const& feature, attributes const& vars, double scale_factor) @@ -389,7 +392,7 @@ struct vertex_converter : private mapnik::noncopyable feature_type const& feature, attributes const& vars, double scale_factor) - : disp_(args_type(proc,bbox,sym,tr,prj_trans,affine_trans,feature,vars,scale_factor)) {} + : disp_(proc,bbox,sym,tr,prj_trans,affine_trans,feature,vars,scale_factor) {} template void apply(Geometry & geom) From 953f4b700c4181d649edfee079972c52560d0d00 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 29 Sep 2014 19:29:44 +0100 Subject: [PATCH 08/31] remove unused mpl header --- include/mapnik/renderer_common/process_markers_symbolizer.hpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/include/mapnik/renderer_common/process_markers_symbolizer.hpp b/include/mapnik/renderer_common/process_markers_symbolizer.hpp index 9d0a7759d..59f500477 100644 --- a/include/mapnik/renderer_common/process_markers_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_markers_symbolizer.hpp @@ -31,9 +31,6 @@ #include #include -// boost -#include - namespace mapnik { template From 688e97e1487a17e59da2d76c59856f637ab5ec4e Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 12:07:15 -0700 Subject: [PATCH 09/31] move dasharray parser to cpp file - refs #2439 --- include/mapnik/symbolizer.hpp | 2 +- include/mapnik/symbolizer_utils.hpp | 3 ++- include/mapnik/util/dasharray_parser.hpp | 32 +----------------------- include/mapnik/vertex_converters.hpp | 4 --- src/build.py | 1 + 5 files changed, 5 insertions(+), 37 deletions(-) diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index c53b91417..c5e4271d0 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -410,7 +410,7 @@ struct evaluate_expression_wrapper dash_array dash; std::vector buf; std::string str = val.to_string(); - if (util::parse_dasharray(str.begin(),str.end(),buf)) + if (util::parse_dasharray(str,buf)) { util::add_dashes(buf,dash); } diff --git a/include/mapnik/symbolizer_utils.hpp b/include/mapnik/symbolizer_utils.hpp index d6bdd8939..1d094c4c2 100644 --- a/include/mapnik/symbolizer_utils.hpp +++ b/include/mapnik/symbolizer_utils.hpp @@ -37,6 +37,7 @@ #include #include #include +#include #include namespace mapnik { @@ -395,7 +396,7 @@ struct set_symbolizer_property_impl { std::vector buf; dash_array dash; - if (util::parse_dasharray((*str).begin(),(*str).end(),buf) && util::add_dashes(buf,dash)) + if (util::parse_dasharray(*str,buf) && util::add_dashes(buf,dash)) { put(sym,key,dash); } diff --git a/include/mapnik/util/dasharray_parser.hpp b/include/mapnik/util/dasharray_parser.hpp index 0cf0081dc..f22b927e7 100644 --- a/include/mapnik/util/dasharray_parser.hpp +++ b/include/mapnik/util/dasharray_parser.hpp @@ -23,42 +23,12 @@ #ifndef MAPNIK_UTIL_DASHARRAY_PARSER_HPP #define MAPNIK_UTIL_DASHARRAY_PARSER_HPP -#include -#include -#include -#include -#include - #include #include namespace mapnik { namespace util { -template -bool parse_dasharray(Iterator first, Iterator last, std::vector& dasharray) -{ - using namespace boost::spirit; - qi::double_type double_; - qi::_1_type _1; - qi::lit_type lit; - qi::char_type char_; - qi::ascii::space_type space; - qi::no_skip_type no_skip; - // SVG - // dasharray ::= (length | percentage) (comma-wsp dasharray)? - // no support for 'percentage' as viewport is unknown at load_map - // - bool r = qi::phrase_parse(first, last, - (double_[boost::phoenix::push_back(boost::phoenix::ref(dasharray), _1)] % - no_skip[char_(", ")] - | lit("none")), - space); - if (first != last) - { - return false; - } - return r; -} +bool parse_dasharray(std::string const& value, std::vector& dasharray); inline bool add_dashes(std::vector & buf, std::vector > & dash) { diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index f943075db..f034b91b4 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -38,10 +38,6 @@ #include #include -// fusion -//#include -//#include - // agg #include "agg_math_stroke.h" #include "agg_trans_affine.h" diff --git a/src/build.py b/src/build.py index 7854f6022..3d6d05d59 100644 --- a/src/build.py +++ b/src/build.py @@ -142,6 +142,7 @@ else: # unix, non-macos source = Split( """ + dasharray_parser.cpp expression_grammar.cpp fs.cpp request.cpp From b7b39d4444acb81cdee661aa2c2a76031ee026c2 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 12:11:03 -0700 Subject: [PATCH 10/31] add missing file --- src/dasharray_parser.cpp | 64 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 src/dasharray_parser.cpp diff --git a/src/dasharray_parser.cpp b/src/dasharray_parser.cpp new file mode 100644 index 000000000..47eeb8f99 --- /dev/null +++ b/src/dasharray_parser.cpp @@ -0,0 +1,64 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +// mapnik +#include +#include +#include +#include +#include +#include + +namespace mapnik { + +namespace util { + +bool parse_dasharray(std::string const& value, std::vector& dasharray) +{ + using namespace boost::spirit; + qi::double_type double_; + qi::_1_type _1; + qi::lit_type lit; + qi::char_type char_; + qi::ascii::space_type space; + qi::no_skip_type no_skip; + // SVG + // dasharray ::= (length | percentage) (comma-wsp dasharray)? + // no support for 'percentage' as viewport is unknown at load_map + // + auto first = value.begin(); + auto last = value.end(); + bool r = qi::phrase_parse(first, last, + (double_[boost::phoenix::push_back(boost::phoenix::ref(dasharray), _1)] % + no_skip[char_(", ")] + | lit("none")), + space); + if (first != last) + { + return false; + } + return r; +} + +} // end namespace util + +} // end namespace mapnik From 752d9def3c5271d5351b0529edccd3f0fcd7013f Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 29 Sep 2014 21:02:20 +0100 Subject: [PATCH 11/31] remove unused //#include --- include/mapnik/symbolizer.hpp | 1 - 1 file changed, 1 deletion(-) diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index c5e4271d0..7f67afe90 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include From 8ff17378a49daccb01a562a467c25a1869d70dd1 Mon Sep 17 00:00:00 2001 From: artemp Date: Mon, 29 Sep 2014 21:03:34 +0100 Subject: [PATCH 12/31] make index constexpr --- include/mapnik/vertex_converters.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/mapnik/vertex_converters.hpp b/include/mapnik/vertex_converters.hpp index f034b91b4..a41fab982 100644 --- a/include/mapnik/vertex_converters.hpp +++ b/include/mapnik/vertex_converters.hpp @@ -279,7 +279,7 @@ struct converters_helper { if (std::is_same::value) { - std::size_t index = sizeof...(ConverterTypes) ; + constexpr std::size_t index = sizeof...(ConverterTypes) ; disp.vec_[index] = state; } else @@ -291,7 +291,7 @@ struct converters_helper template static void forward(Dispatcher & disp, Geometry & geom) { - std::size_t index = sizeof...(ConverterTypes); + constexpr std::size_t index = sizeof...(ConverterTypes); if (disp.vec_[index] == 1) { using conv_type = typename detail::converter_traits::conv_type; From 89f64f6b9748293e4c1e8af1292104dec059b5de Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 13:12:38 -0700 Subject: [PATCH 13/31] avoid spirit usage in function_call.hpp - refs #2439 --- include/mapnik/expression_grammar.hpp | 11 +++ include/mapnik/expression_grammar_impl.hpp | 23 +++++ include/mapnik/expression_node.hpp | 4 +- include/mapnik/function_call.hpp | 102 +++++++++++++++++--- src/function_call.cpp | 106 --------------------- 5 files changed, 124 insertions(+), 122 deletions(-) diff --git a/include/mapnik/expression_grammar.hpp b/include/mapnik/expression_grammar.hpp index 6342fe23a..fd8663bb8 100644 --- a/include/mapnik/expression_grammar.hpp +++ b/include/mapnik/expression_grammar.hpp @@ -126,6 +126,17 @@ struct integer_parser using type = qi::int_parser; }; +struct unary_function_types : qi::symbols +{ + unary_function_types(); +}; + +struct binary_function_types : qi::symbols +{ + binary_function_types(); +}; + + #ifdef __GNUC__ template struct MAPNIK_DECL expression_grammar : qi::grammar diff --git a/include/mapnik/expression_grammar_impl.hpp b/include/mapnik/expression_grammar_impl.hpp index 2a79b4fc3..8edb01313 100644 --- a/include/mapnik/expression_grammar_impl.hpp +++ b/include/mapnik/expression_grammar_impl.hpp @@ -28,6 +28,7 @@ #include #include #include +#include // boost #include @@ -43,6 +44,28 @@ namespace mapnik { namespace mapnik { +unary_function_types::unary_function_types() +{ + add + ("sin", sin_impl()) + ("cos", cos_impl()) + ("tan", tan_impl()) + ("atan", atan_impl()) + ("exp", exp_impl()) + ("abs", abs_impl()) + ("length",length_impl()) + ; +} + +binary_function_types::binary_function_types() +{ + add + ("min", binary_function_impl(min_impl)) + ("max", binary_function_impl(max_impl)) + ("pow", binary_function_impl(pow_impl)) + ; +} + template expr_node regex_match_impl::operator() (T0 & node, T1 const& pattern) const { diff --git a/include/mapnik/expression_node.hpp b/include/mapnik/expression_node.hpp index ac3a8fe27..95e5fc1fc 100644 --- a/include/mapnik/expression_node.hpp +++ b/include/mapnik/expression_node.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include // boost @@ -123,9 +124,6 @@ struct regex_replace_node }; #endif -using unary_function_impl = std::function; -using binary_function_impl = std::function; - struct unary_function_call { using argument_type = expr_node; diff --git a/include/mapnik/function_call.hpp b/include/mapnik/function_call.hpp index 236ad0361..5453d92af 100644 --- a/include/mapnik/function_call.hpp +++ b/include/mapnik/function_call.hpp @@ -24,28 +24,104 @@ #define MAPNIK_FUNCTION_CALL_HPP #include -#include #include -#include +#include +#include namespace mapnik { using value_type = mapnik::value; -namespace qi = boost::spirit::qi; -struct unary_function_types : qi::symbols -{ - unary_function_types(); -}; - -struct binary_function_types : qi::symbols -{ - binary_function_types(); -}; +using unary_function_impl = std::function; +using binary_function_impl = std::function; char const* unary_function_name(unary_function_impl const& fun); char const* binary_function_name(binary_function_impl const& fun); +// functions +// exp +struct exp_impl +{ + //using type = T; + value_type operator() (value_type const& val) const + { + return std::exp(val.to_double()); + } + +}; + +// sin +struct sin_impl +{ + value_type operator() (value_type const& val) const + { + return std::sin(val.to_double()); + } +}; + +// cos +struct cos_impl +{ + value_type operator() (value_type const& val) const + { + return std::cos(val.to_double()); + } +}; + +// tan +struct tan_impl +{ + value_type operator() (value_type const& val) const + { + return std::tan(val.to_double()); + } +}; + +// atan +struct atan_impl +{ + value_type operator()(value_type const& val) const + { + return std::atan(val.to_double()); + } +}; + +// abs +struct abs_impl +{ + value_type operator() (value_type const& val) const + { + return std::fabs(val.to_double()); + } +}; + +// length +struct length_impl +{ + value_type operator() (value_type const& val) const + { + return val.to_unicode().length(); + } +}; + +// min +inline value_type min_impl(value_type const& arg1, value_type const& arg2) +{ + return std::min(arg1.to_double(), arg2.to_double()); +} + +// max +inline value_type max_impl(value_type const& arg1, value_type const& arg2) +{ + return std::max(arg1.to_double(), arg2.to_double()); +} + +// pow +inline value_type pow_impl(value_type const& arg1, value_type const& arg2) +{ + return std::pow(arg1.to_double(), arg2.to_double()); +} + } // namespace mapnik -#endif //MAPNIK_FUNCTION_CALL_HPP +#endif // MAPNIK_FUNCTION_CALL_HPP diff --git a/src/function_call.cpp b/src/function_call.cpp index 6febc0bfc..99b1435d7 100644 --- a/src/function_call.cpp +++ b/src/function_call.cpp @@ -24,87 +24,6 @@ namespace mapnik { - -// functions -// exp -//template -struct exp_impl -{ - //using type = T; - value_type operator() (value_type const& val) const - { - return std::exp(val.to_double()); - } - -}; - -// sin -struct sin_impl -{ - value_type operator() (value_type const& val) const - { - return std::sin(val.to_double()); - } -}; - -// cos -struct cos_impl -{ - value_type operator() (value_type const& val) const - { - return std::cos(val.to_double()); - } -}; - -// tan -struct tan_impl -{ - value_type operator() (value_type const& val) const - { - return std::tan(val.to_double()); - } -}; - -// atan -struct atan_impl -{ - value_type operator()(value_type const& val) const - { - return std::atan(val.to_double()); - } -}; - -// abs -struct abs_impl -{ - value_type operator() (value_type const& val) const - { - return std::fabs(val.to_double()); - } -}; - -// length -struct length_impl -{ - value_type operator() (value_type const& val) const - { - return val.to_unicode().length(); - } -}; - -unary_function_types::unary_function_types() -{ - add - ("sin", sin_impl()) - ("cos", cos_impl()) - ("tan", tan_impl()) - ("atan", atan_impl()) - ("exp", exp_impl()) - ("abs", abs_impl()) - ("length",length_impl()) - ; -} - char const* unary_function_name(unary_function_impl const& fun) { if (fun.target()) return "sin"; @@ -118,31 +37,6 @@ char const* unary_function_name(unary_function_impl const& fun) } // binary functions -// min -inline value_type min_impl(value_type const& arg1, value_type const& arg2) -{ - return std::min(arg1.to_double(), arg2.to_double()); -} -// max -inline value_type max_impl(value_type const& arg1, value_type const& arg2) -{ - return std::max(arg1.to_double(), arg2.to_double()); -} -// pow -inline value_type pow_impl(value_type const& arg1, value_type const& arg2) -{ - return std::pow(arg1.to_double(), arg2.to_double()); -} - -binary_function_types::binary_function_types() -{ - add - ("min", binary_function_impl(min_impl)) - ("max", binary_function_impl(max_impl)) - ("pow", binary_function_impl(pow_impl)) - ; -} - char const* binary_function_name(binary_function_impl const& fun) { value_type(*const* f_ptr)(value_type const&, value_type const&) = From a1b98e623858ac43b1c349e1418e8084a169e115 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 13:49:22 -0700 Subject: [PATCH 14/31] speed up compile / avoid boost/math - refs #2439 --- include/mapnik/offset_converter.hpp | 30 +++++++++++++---------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/include/mapnik/offset_converter.hpp b/include/mapnik/offset_converter.hpp index 28f690276..e01c1d7e6 100644 --- a/include/mapnik/offset_converter.hpp +++ b/include/mapnik/offset_converter.hpp @@ -26,22 +26,18 @@ #ifdef MAPNIK_LOG #include #endif +#include #include -#include #include -#include - -// boost -#include // stl #include +#include +#include namespace mapnik { -const double pi = boost::math::constants::pi(); - template struct MAPNIK_DECL offset_converter { @@ -176,13 +172,13 @@ private: static double explement_reflex_angle(double angle) { - if (angle > pi) + if (angle > M_PI) { - return angle - 2 * pi; + return angle - 2 * M_PI; } - else if (angle < -pi) + else if (angle < -M_PI) { - return angle + 2 * pi; + return angle + 2 * M_PI; } else { @@ -320,22 +316,22 @@ private: { if (joint_angle > 0.0) { - joint_angle = joint_angle - 2 * pi; + joint_angle = joint_angle - 2 * M_PI; } else { - bulge_steps = 1 + static_cast(std::floor(half_turns / pi)); + bulge_steps = 1 + static_cast(std::floor(half_turns / M_PI)); } } else { if (joint_angle < 0.0) { - joint_angle = joint_angle + 2 * pi; + joint_angle = joint_angle + 2 * M_PI; } else { - bulge_steps = 1 + static_cast(std::floor(half_turns / pi)); + bulge_steps = 1 + static_cast(std::floor(half_turns / M_PI)); } } @@ -344,14 +340,14 @@ private: { // inside turn (sharp/obtuse angle) MAPNIK_LOG_DEBUG(ctrans) << "offset_converter:" - << " Sharp joint [<< inside turn " << int(joint_angle*180/pi) + << " Sharp joint [<< inside turn " << int(joint_angle*180/M_PI) << " degrees >>]"; } else { // outside turn (reflex angle) MAPNIK_LOG_DEBUG(ctrans) << "offset_converter:" - << " Bulge joint >)) outside turn " << int(joint_angle*180/pi) + << " Bulge joint >)) outside turn " << int(joint_angle*180/M_PI) << " degrees ((< with " << bulge_steps << " segments"; } #endif From 848370c678108740637ef50d0a401f71f709ecd1 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 13:49:56 -0700 Subject: [PATCH 15/31] speed up compile / move iomanip to cpp - refs #2439 --- include/mapnik/box2d.hpp | 12 ++---------- src/box2d.cpp | 13 +++++++++++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/include/mapnik/box2d.hpp b/include/mapnik/box2d.hpp index 12906f847..b3bb22f10 100644 --- a/include/mapnik/box2d.hpp +++ b/include/mapnik/box2d.hpp @@ -30,9 +30,6 @@ // boost #include -// stl -#include - // agg // forward declare so that apps using mapnik do not need agg headers namespace agg { @@ -105,6 +102,7 @@ public: bool from_string(std::string const& str); bool valid() const; void move(T x, T y); + std::string to_string() const; // define some operators box2d_type& operator+=(box2d_type const& other); @@ -124,13 +122,7 @@ inline std::basic_ostream& operator << (std::basic_ostream& out, const box2d& e) { - std::basic_ostringstream s; - s.copyfmt(out); - s.width(0); - s << "box2d(" << std::fixed << std::setprecision(16) - << e.minx() << ',' << e.miny() << ',' - << e.maxx() << ',' << e.maxy() << ')'; - out << s.str(); + out << e.to_string(); return out; } } diff --git a/src/box2d.cpp b/src/box2d.cpp index 167503783..ca73f5551 100644 --- a/src/box2d.cpp +++ b/src/box2d.cpp @@ -26,6 +26,8 @@ // stl #include +#include +#include // boost // fusion @@ -360,6 +362,17 @@ void box2d::move(T x, T y) maxy_ += y; } +template +std::string box2d::to_string() const +{ + std::ostringstream s; + s << "box2d(" << std::fixed << std::setprecision(16) + << minx_ << ',' << miny_ << ',' + << maxx_ << ',' << maxy_ << ')'; + return s.str(); +} + + template box2d& box2d::operator+=(box2d const& other) { From ba689b379ebd09f6585aae44a7125a35a00e4843 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 13:50:14 -0700 Subject: [PATCH 16/31] iwyu --- include/mapnik/view_transform.hpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/include/mapnik/view_transform.hpp b/include/mapnik/view_transform.hpp index 0c4e07d88..683e97947 100644 --- a/include/mapnik/view_transform.hpp +++ b/include/mapnik/view_transform.hpp @@ -24,15 +24,10 @@ #define MAPNIK_VIEW_TRANSFORM_HPP // mapnik -#include #include #include -#include #include -// stl -#include - namespace mapnik { From a41978f439b9998d9041ae468ac08260b6ed75eb Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 13:50:21 -0700 Subject: [PATCH 17/31] iwyu --- include/mapnik/transform_path_adapter.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/mapnik/transform_path_adapter.hpp b/include/mapnik/transform_path_adapter.hpp index 054a69c4f..0a8d759c5 100644 --- a/include/mapnik/transform_path_adapter.hpp +++ b/include/mapnik/transform_path_adapter.hpp @@ -24,6 +24,10 @@ #define MAPNIK_TRANSFORM_PATH_ADAPTER_HPP #include +#include +#include + +#include namespace mapnik { From aaec8058faa66764e9746be92ebfc3f2dba6be6f Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 16:32:46 -0700 Subject: [PATCH 18/31] fix property name in error message --- src/text/font_feature_settings.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/text/font_feature_settings.cpp b/src/text/font_feature_settings.cpp index c4dce260a..0a985c20e 100644 --- a/src/text/font_feature_settings.cpp +++ b/src/text/font_feature_settings.cpp @@ -58,7 +58,7 @@ void font_feature_settings::from_string(std::string const& features) if (!qi::parse(features.begin(), features.end(), as_string[+(char_ - ',')][app] % ',')) { - throw config_error("failed to parse font-features: '" + features + "'"); + throw config_error("failed to parse font-feature-settings: '" + features + "'"); } } @@ -91,7 +91,7 @@ void font_feature_settings::append(std::string const& feature) if (!hb_feature_from_string(feature.c_str(), feature.length(), &*current_feature)) { features_.erase(current_feature); - throw config_error("failed to parse font-features: '" + feature + "'"); + throw config_error("failed to parse font-feature-settings: '" + feature + "'"); } } From 3ee609112a8de80edf87df6098899120b7711661 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 16:48:19 -0700 Subject: [PATCH 19/31] using pimpl to isolate boost::regex headers - refs #2439 --- include/mapnik/evaluate_global_attributes.hpp | 36 +---- include/mapnik/expression_evaluator.hpp | 21 +-- include/mapnik/expression_grammar_impl.hpp | 12 +- include/mapnik/expression_node.hpp | 67 +++------ src/expression_node.cpp | 142 +++++++++++++++--- src/expression_string.cpp | 32 +--- 6 files changed, 156 insertions(+), 154 deletions(-) diff --git a/include/mapnik/evaluate_global_attributes.hpp b/include/mapnik/evaluate_global_attributes.hpp index d3e3626df..f131ee7c1 100644 --- a/include/mapnik/evaluate_global_attributes.hpp +++ b/include/mapnik/evaluate_global_attributes.hpp @@ -34,12 +34,6 @@ #include #include -#if defined(BOOST_REGEX_HAS_ICU) -#include -#else -#include -#endif - namespace mapnik { namespace { @@ -107,24 +101,13 @@ struct evaluate_expression : util::static_visitor value_type operator() (regex_match_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_match(v.to_unicode(),x.pattern); -#else - return boost::regex_match(v.to_string(),x.pattern); -#endif - + return x.apply(v); } value_type operator() (regex_replace_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_replace(v.to_unicode(),x.pattern,x.format); -#else - std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format); - mapnik::transcoder tr_("utf8"); - return tr_.transcode(repl.c_str()); -#endif + return x.apply(v); } value_type operator() (unary_function_call const& call) const @@ -206,24 +189,13 @@ struct evaluate_expression : util::static_visitor value_type operator() (regex_match_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_match(v.to_unicode(),x.pattern); -#else - return boost::regex_match(v.to_string(),x.pattern); -#endif - + return x.apply(v); } value_type operator() (regex_replace_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_replace(v.to_unicode(),x.pattern,x.format); -#else - std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format); - mapnik::transcoder tr_("utf8"); - return tr_.transcode(repl.c_str()); -#endif + return x.apply(v); } value_type operator() (unary_function_call const& call) const diff --git a/include/mapnik/expression_evaluator.hpp b/include/mapnik/expression_evaluator.hpp index 01f9d7815..c8b94a95e 100644 --- a/include/mapnik/expression_evaluator.hpp +++ b/include/mapnik/expression_evaluator.hpp @@ -29,12 +29,6 @@ #include #include #include -// boost -#if defined(BOOST_REGEX_HAS_ICU) -#include -#else -#include -#endif namespace mapnik { @@ -130,24 +124,13 @@ struct evaluate : util::static_visitor value_type operator() (regex_match_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_match(v.to_unicode(),x.pattern); -#else - return boost::regex_match(v.to_string(),x.pattern); -#endif - + return x.apply(v); } value_type operator() (regex_replace_node const& x) const { value_type v = util::apply_visitor(*this, x.expr); -#if defined(BOOST_REGEX_HAS_ICU) - return boost::u32regex_replace(v.to_unicode(),x.pattern,x.format); -#else - std::string repl = boost::regex_replace(v.to_string(),x.pattern,x.format); - mapnik::transcoder tr_("utf8"); - return tr_.transcode(repl.c_str()); -#endif + return x.apply(v); } value_type operator() (unary_function_call const& call) const diff --git a/include/mapnik/expression_grammar_impl.hpp b/include/mapnik/expression_grammar_impl.hpp index 8edb01313..b56c2cf79 100644 --- a/include/mapnik/expression_grammar_impl.hpp +++ b/include/mapnik/expression_grammar_impl.hpp @@ -69,21 +69,13 @@ binary_function_types::binary_function_types() template expr_node regex_match_impl::operator() (T0 & node, T1 const& pattern) const { -#if defined(BOOST_REGEX_HAS_ICU) - return regex_match_node(node,tr_.transcode(pattern.c_str())); -#else - return regex_match_node(node,pattern); -#endif + return regex_match_node(tr_,node,pattern); } template expr_node regex_replace_impl::operator() (T0 & node, T1 const& pattern, T2 const& format) const { -#if defined(BOOST_REGEX_HAS_ICU) - return regex_replace_node(node,tr_.transcode(pattern.c_str()),tr_.transcode(format.c_str())); -#else - return regex_replace_node(node,pattern,format); -#endif + return regex_replace_node(tr_,node,pattern,format); } template diff --git a/include/mapnik/expression_node.hpp b/include/mapnik/expression_node.hpp index 95e5fc1fc..0eb093c5c 100644 --- a/include/mapnik/expression_node.hpp +++ b/include/mapnik/expression_node.hpp @@ -30,13 +30,6 @@ #include #include -// boost -#if defined(BOOST_REGEX_HAS_ICU) -#include -#else -#include -#endif - namespace mapnik { @@ -87,43 +80,6 @@ struct binary_node expr_node left,right; }; -#if defined(BOOST_REGEX_HAS_ICU) - -struct regex_match_node -{ - regex_match_node (expr_node const& a, mapnik::value_unicode_string const& ustr); - expr_node expr; - boost::u32regex pattern; -}; - - -struct regex_replace_node -{ - regex_replace_node (expr_node const& a, mapnik::value_unicode_string const& ustr, mapnik::value_unicode_string const& f); - expr_node expr; - boost::u32regex pattern; - mapnik::value_unicode_string format; -}; - -#else - -struct regex_match_node -{ - regex_match_node (expr_node const& a, std::string const& str); - expr_node expr; - boost::regex pattern; -}; - - -struct regex_replace_node -{ - regex_replace_node (expr_node const& a, std::string const& str, std::string const& f); - expr_node expr; - boost::regex pattern; - std::string format; -}; -#endif - struct unary_function_call { using argument_type = expr_node; @@ -146,6 +102,29 @@ struct binary_function_call argument_type arg2; }; +// pimpl +struct _regex_match_impl; +struct _regex_replace_impl; + +struct regex_match_node +{ + regex_match_node(transcoder const& tr, expr_node const& a, std::string const& ustr); + mapnik::value apply(mapnik::value const& v) const; + std::string to_string() const; + expr_node expr; + // TODO - use unique_ptr once https://github.com/mapnik/mapnik/issues/2457 is fixed + std::shared_ptr<_regex_match_impl> impl_; +}; + +struct regex_replace_node +{ + regex_replace_node(transcoder const& tr, expr_node const& a, std::string const& ustr, std::string const& f); + mapnik::value apply(mapnik::value const& v) const; + std::string to_string() const; + expr_node expr; + // TODO - use unique_ptr once https://github.com/mapnik/mapnik/issues/2457 is fixed + std::shared_ptr<_regex_replace_impl> impl_; +}; inline expr_node & operator- (expr_node& expr) { diff --git a/src/expression_node.cpp b/src/expression_node.cpp index aeae3d745..69cb53074 100644 --- a/src/expression_node.cpp +++ b/src/expression_node.cpp @@ -22,31 +22,135 @@ #include #include +#include + +#if defined(BOOST_REGEX_HAS_ICU) +#include +#else +#include +#endif namespace mapnik { +struct _regex_match_impl : noncopyable { #if defined(BOOST_REGEX_HAS_ICU) - -regex_match_node::regex_match_node (expr_node const& a, mapnik::value_unicode_string const& ustr) - : expr(a), - pattern(boost::make_u32regex(ustr)) {} - -regex_replace_node::regex_replace_node (expr_node const& a, mapnik::value_unicode_string const& ustr, mapnik::value_unicode_string const& f) - : expr(a), - pattern(boost::make_u32regex(ustr)), - format(f) {} - + _regex_match_impl(value_unicode_string const& ustr) : + pattern_(boost::make_u32regex(ustr)) {} + boost::u32regex pattern_; #else - -regex_match_node::regex_match_node (expr_node const& a, std::string const& str) - : expr(a), - pattern(str) {} - -regex_replace_node::regex_replace_node (expr_node const& a, std::string const& str, std::string const& f) - : expr(a), - pattern(str), - format(f) {} + _regex_match_impl(std::string const& ustr) : + pattern_(ustr) {} + boost::regex pattern_; #endif +}; +struct _regex_replace_impl : noncopyable { +#if defined(BOOST_REGEX_HAS_ICU) + _regex_replace_impl(value_unicode_string const& ustr, value_unicode_string const& f) : + pattern_(boost::make_u32regex(ustr)), + format_(f) {} + boost::u32regex pattern_; + value_unicode_string format_; +#else + _regex_replace_impl(std::string const& ustr,std::string const& f) : + pattern_(ustr), + format_(f) {} + boost::regex pattern_; + std::string format_; +#endif +}; + + +regex_match_node::regex_match_node(transcoder const& tr, + expr_node const& a, + std::string const& ustr) + : expr(a), + impl_(new _regex_match_impl( +#if defined(BOOST_REGEX_HAS_ICU) + tr.transcode(ustr.c_str()) +#else + ustr +#endif + )) {} + +value regex_match_node::apply(value const& v) const +{ + auto const& pattern = impl_.get()->pattern_; +#if defined(BOOST_REGEX_HAS_ICU) + return boost::u32regex_match(v.to_unicode(),pattern); +#else + return boost::regex_match(v.to_string(),pattern); +#endif } + +std::string regex_match_node::to_string() const +{ + std::string str_; + str_ +=".match('"; + auto const& pattern = impl_.get()->pattern_; +#if defined(BOOST_REGEX_HAS_ICU) + std::string utf8; + value_unicode_string ustr = value_unicode_string::fromUTF32( &pattern.str()[0], pattern.str().length()); + to_utf8(ustr,utf8); + str_ += utf8; +#else + str_ += pattern.str(); +#endif + str_ +="')"; + return str_; +} + +regex_replace_node::regex_replace_node(transcoder const& tr, + expr_node const& a, + std::string const& ustr, + std::string const& f) + : expr(a), + impl_(new _regex_replace_impl( +#if defined(BOOST_REGEX_HAS_ICU) + tr.transcode(ustr.c_str()), + tr.transcode(f.c_str()) +#else + ustr, + f +#endif + )) {} + +value regex_replace_node::apply(value const& v) const +{ + auto const& pattern = impl_.get()->pattern_; + auto const& format = impl_.get()->format_; +#if defined(BOOST_REGEX_HAS_ICU) + return boost::u32regex_replace(v.to_unicode(),pattern,format); +#else + std::string repl = boost::regex_replace(v.to_string(),pattern,format); + transcoder tr_("utf8"); + return tr_.transcode(repl.c_str()); +#endif +} + +std::string regex_replace_node::to_string() const +{ + std::string str_; + str_ +=".replace("; + str_ += "'"; + auto const& pattern = impl_.get()->pattern_; + auto const& format = impl_.get()->format_; +#if defined(BOOST_REGEX_HAS_ICU) + std::string utf8; + value_unicode_string ustr = value_unicode_string::fromUTF32( &pattern.str()[0], pattern.str().length()); + to_utf8(ustr,utf8); + str_ += utf8; + str_ +="','"; + to_utf8(format ,utf8); + str_ += utf8; +#else + str_ += pattern.str(); + str_ +="','"; + str_ += format; +#endif + str_ +="')"; + return str_; +} + +} \ No newline at end of file diff --git a/src/expression_string.cpp b/src/expression_string.cpp index 568c79ed4..a5d1386b7 100644 --- a/src/expression_string.cpp +++ b/src/expression_string.cpp @@ -29,10 +29,6 @@ #include #include #include -// boost -#if defined(BOOST_REGEX_HAS_ICU) -#include // for u32regex -#endif namespace mapnik { @@ -94,37 +90,13 @@ struct expression_string : util::static_visitor void operator() (regex_match_node const & x) const { util::apply_visitor(*this,x.expr); - str_ +=".match('"; -#if defined(BOOST_REGEX_HAS_ICU) - std::string utf8; - mapnik::value_unicode_string ustr = mapnik::value_unicode_string::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length()); - to_utf8(ustr,utf8); - str_ += utf8; -#else - str_ += x.pattern.str(); -#endif - str_ +="')"; + str_ += x.to_string(); } void operator() (regex_replace_node const & x) const { util::apply_visitor(*this,x.expr); - str_ +=".replace("; - str_ += "'"; -#if defined(BOOST_REGEX_HAS_ICU) - std::string utf8; - mapnik::value_unicode_string ustr = mapnik::value_unicode_string::fromUTF32( &x.pattern.str()[0] ,x.pattern.str().length()); - to_utf8(ustr,utf8); - str_ += utf8; - str_ +="','"; - to_utf8(x.format ,utf8); - str_ += utf8; -#else - str_ += x.pattern.str(); - str_ +="','"; - str_ += x.format; -#endif - str_ +="')"; + str_ += x.to_string(); } void operator() (unary_function_call const& call) const From 9b0d6fc70224a7b3d2c1c60324d2b0958bda45e9 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 17:01:40 -0700 Subject: [PATCH 20/31] iwyu --- include/mapnik/symbolizer.hpp | 5 +++++ include/mapnik/value.hpp | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/include/mapnik/symbolizer.hpp b/include/mapnik/symbolizer.hpp index 7f67afe90..649c47fcd 100644 --- a/include/mapnik/symbolizer.hpp +++ b/include/mapnik/symbolizer.hpp @@ -51,6 +51,11 @@ #include #include #include +#include +#include + +// boost +#include namespace agg { struct trans_affine; } diff --git a/include/mapnik/value.hpp b/include/mapnik/value.hpp index 0906db2ee..9a946233f 100644 --- a/include/mapnik/value.hpp +++ b/include/mapnik/value.hpp @@ -26,12 +26,9 @@ // mapnik #include #include -#include #include #include -// boost -#include // stl #include #include From d0b167affc208cf8bb628f7263fe2584d17b9f88 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 17:14:40 -0700 Subject: [PATCH 21/31] iwyu shuffle --- include/mapnik/expression_node.hpp | 1 + .../renderer_common/process_polygon_symbolizer.hpp | 4 ++++ include/mapnik/unicode.hpp | 14 ++------------ include/mapnik/value_hash.hpp | 7 +++++-- src/unicode.cpp | 3 +++ 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/include/mapnik/expression_node.hpp b/include/mapnik/expression_node.hpp index 0eb093c5c..7d2e6e701 100644 --- a/include/mapnik/expression_node.hpp +++ b/include/mapnik/expression_node.hpp @@ -26,6 +26,7 @@ // mapnik #include #include +#include #include #include #include diff --git a/include/mapnik/renderer_common/process_polygon_symbolizer.hpp b/include/mapnik/renderer_common/process_polygon_symbolizer.hpp index 901158d5b..05a076c79 100644 --- a/include/mapnik/renderer_common/process_polygon_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_polygon_symbolizer.hpp @@ -23,7 +23,11 @@ #ifndef MAPNIK_RENDERER_COMMON_PROCESS_POLYGON_SYMBOLIZER_HPP #define MAPNIK_RENDERER_COMMON_PROCESS_POLYGON_SYMBOLIZER_HPP +#include #include +#include +#include +#include namespace mapnik { diff --git a/include/mapnik/unicode.hpp b/include/mapnik/unicode.hpp index 4522c3b8e..4f84c74e9 100644 --- a/include/mapnik/unicode.hpp +++ b/include/mapnik/unicode.hpp @@ -26,15 +26,14 @@ //mapnik #include #include - -// icu #include -#include // stl #include #include +struct UConverter; + namespace mapnik { class MAPNIK_DECL transcoder : private mapnik::noncopyable @@ -49,13 +48,4 @@ private: }; } -namespace U_ICU_NAMESPACE { - -inline std::size_t hash_value(mapnik::value_unicode_string const& val) -{ - return val.hashCode(); -} - -} - #endif // MAPNIK_UNICODE_HPP diff --git a/include/mapnik/value_hash.hpp b/include/mapnik/value_hash.hpp index e9667915e..1a72108b4 100644 --- a/include/mapnik/value_hash.hpp +++ b/include/mapnik/value_hash.hpp @@ -26,10 +26,13 @@ // mapnik #include #include -#include + // stl #include +// icu +#include + namespace mapnik { namespace detail { template @@ -48,7 +51,7 @@ struct value_hasher: public util::static_visitor std::size_t operator() (value_unicode_string const& val) const { - return hash_value(val); + return val.hashCode(); } template diff --git a/src/unicode.cpp b/src/unicode.cpp index 22114d156..4c703a2cb 100644 --- a/src/unicode.cpp +++ b/src/unicode.cpp @@ -28,6 +28,9 @@ #include #include +// icu +#include + namespace mapnik { transcoder::transcoder (std::string const& encoding) From 24052580b951f1d58a5a0edaf81572b3e8267836 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 17:51:05 -0700 Subject: [PATCH 22/31] ditch boost/function --- include/mapnik/markers_placement.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/mapnik/markers_placement.hpp b/include/mapnik/markers_placement.hpp index 6db046a33..52aecc3d9 100644 --- a/include/mapnik/markers_placement.hpp +++ b/include/mapnik/markers_placement.hpp @@ -31,7 +31,9 @@ #include #include #include -#include + +// stl +#include namespace mapnik { @@ -86,7 +88,7 @@ private: Detector &detector, markers_placement_params const& params) { - static const std::map> factories = From d2a7fda55d001e8148d2862c822b26e41ac2a40b Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 18:12:39 -0700 Subject: [PATCH 23/31] fix visibility of regex_match/replace nodes --- include/mapnik/expression_node.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/mapnik/expression_node.hpp b/include/mapnik/expression_node.hpp index 7d2e6e701..c46e852f0 100644 --- a/include/mapnik/expression_node.hpp +++ b/include/mapnik/expression_node.hpp @@ -26,6 +26,7 @@ // mapnik #include #include +#include #include #include #include @@ -107,7 +108,7 @@ struct binary_function_call struct _regex_match_impl; struct _regex_replace_impl; -struct regex_match_node +struct MAPNIK_DECL regex_match_node { regex_match_node(transcoder const& tr, expr_node const& a, std::string const& ustr); mapnik::value apply(mapnik::value const& v) const; @@ -117,7 +118,7 @@ struct regex_match_node std::shared_ptr<_regex_match_impl> impl_; }; -struct regex_replace_node +struct MAPNIK_DECL regex_replace_node { regex_replace_node(transcoder const& tr, expr_node const& a, std::string const& ustr, std::string const& f); mapnik::value apply(mapnik::value const& v) const; From c654994dbc9d641b62a8f638638c1fda542c4a0c Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 18:23:46 -0700 Subject: [PATCH 24/31] remove obsolete text_path.hpp header --- include/mapnik/cairo/cairo_context.hpp | 1 - include/mapnik/text/text_path.hpp | 203 ------------------------- 2 files changed, 204 deletions(-) delete mode 100644 include/mapnik/text/text_path.hpp diff --git a/include/mapnik/cairo/cairo_context.hpp b/include/mapnik/cairo/cairo_context.hpp index fad1f12cd..78ee4bd86 100644 --- a/include/mapnik/cairo/cairo_context.hpp +++ b/include/mapnik/cairo/cairo_context.hpp @@ -51,7 +51,6 @@ namespace mapnik { -class text_path; template class box2d; using ErrorStatus = cairo_status_t; diff --git a/include/mapnik/text/text_path.hpp b/include/mapnik/text/text_path.hpp deleted file mode 100644 index 27991187b..000000000 --- a/include/mapnik/text/text_path.hpp +++ /dev/null @@ -1,203 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2013 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ - -#ifndef MAPNIK_TEXT_PATH_HPP -#define MAPNIK_TEXT_PATH_HPP - -// mapnik -#include -#include -#include -#include - -//stl -#include - -// boost -#include -#include - -namespace mapnik -{ - -class string_info : private mapnik::noncopyable -{ -protected: - using characters_t = std::vector; - characters_t characters_; - mapnik::value_unicode_string text_; - bool is_rtl; -public: - string_info(mapnik::value_unicode_string const& text) - : characters_(), - text_(text), - is_rtl(false) - { - - } - - string_info() - : characters_(), - text_(), - is_rtl(false) - { - - } - - void add_info(char_info const& info) - { - characters_.push_back(info); - } - - void add_text(mapnik::value_unicode_string const& text) - { - text_ += text; - } - - std::size_t num_characters() const - { - return characters_.size(); - } - - void set_rtl(bool value) - { - is_rtl = value; - } - - bool get_rtl() const - { - return is_rtl; - } - - char_info const& at(std::size_t i) const - { - return characters_[i]; - } - - char_info const& operator[](std::size_t i) const - { - return at(i); - } - - mapnik::value_unicode_string const& get_string() const - { - return text_; - } - - bool has_line_breaks() const - { - // uint16_t - UChar break_char = '\n'; - return (text_.indexOf(break_char) >= 0); - } - - // Resets object to initial state. - void clear() - { - text_.remove(); - characters_.clear(); - } -}; - -using char_info_ptr = char_info const *; - - -// List of all characters and their positions and formats for a placement. -class text_path : mapnik::noncopyable -{ - struct character_node - { - char_info_ptr c; - pixel_position pos; - double angle; - - character_node(char_info_ptr c_, double x_, double y_, double angle_) - : c(c_), - pos(x_, y_), - angle(angle_) - { - - } - - ~character_node() {} - - void vertex(char_info_ptr & c_, double & x_, double & y_, double & angle_) const - { - c_ = c; - x_ = pos.x; - y_ = pos.y; - angle_ = angle; - } - }; - - mutable int itr_; -public: - using character_nodes_t = std::vector; - pixel_position center; - character_nodes_t nodes_; - - text_path(double x, double y) - : itr_(0), - center(x,y), - nodes_() - { - - } - - ~text_path() {} - - /** Adds a new char to the list. */ - void add_node(char_info_ptr c, double x, double y, double angle) - { - nodes_.push_back(character_node(c, x, y, angle)); - } - - /** Return node. Always returns a new node. Has no way to report that there are no more nodes. */ - void vertex(char_info_ptr & c, double & x, double & y, double & angle) const - { - nodes_[itr_++].vertex(c, x, y, angle); - } - - /** Start again at first node. */ - void rewind() const - { - itr_ = 0; - } - - /** Number of nodes. */ - std::size_t num_nodes() const - { - return nodes_.size(); - } - - /** Delete all nodes. */ - void clear() - { - nodes_.clear(); - } -}; - -using text_path_ptr = std::shared_ptr; -using placements_type = boost::ptr_vector; -} - -#endif // MAPNIK_TEXT_PATH_HPP From dc57849b7dd11dd702804147ca34e909eb755fd3 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 18:40:57 -0700 Subject: [PATCH 25/31] geometry container typedef fixing --- bindings/python/mapnik_feature.cpp | 4 +- bindings/python/mapnik_geometry.cpp | 2 +- include/mapnik/feature.hpp | 1 + include/mapnik/geometry.hpp | 6 --- include/mapnik/geometry_container.hpp | 35 ++++++++++++++++ .../mapnik/json/feature_generator_grammar.hpp | 1 + include/mapnik/json/feature_grammar.hpp | 1 + include/mapnik/json/geometry_parser.hpp | 3 +- include/mapnik/util/container_adapter.hpp | 5 +-- include/mapnik/util/geometry_to_svg.hpp | 1 + include/mapnik/util/geometry_to_wkb.hpp | 9 ++-- include/mapnik/util/geometry_to_wkt.hpp | 1 + include/mapnik/wkb.hpp | 1 + include/mapnik/wkt/wkt_factory.hpp | 1 + include/mapnik/wkt/wkt_grammar.hpp | 1 + src/wkb.cpp | 42 +++++++++---------- utils/geometry_to_wkb/main.cpp | 2 +- 17 files changed, 77 insertions(+), 39 deletions(-) create mode 100644 include/mapnik/geometry_container.hpp diff --git a/bindings/python/mapnik_feature.cpp b/bindings/python/mapnik_feature.cpp index f5c80c579..b12bd1570 100644 --- a/bindings/python/mapnik_feature.cpp +++ b/bindings/python/mapnik_feature.cpp @@ -30,11 +30,9 @@ #include #include #include - #include // mapnik - #include #include #include @@ -56,7 +54,7 @@ using mapnik::context_ptr; using mapnik::feature_kv_iterator; mapnik::geometry_type const& (mapnik::feature_impl::*get_geometry_by_const_ref)(std::size_t) const = &mapnik::feature_impl::get_geometry; -boost::ptr_vector const& (mapnik::feature_impl::*get_paths_by_const_ref)() const = &mapnik::feature_impl::paths; +mapnik::geometry_container const& (mapnik::feature_impl::*get_paths_by_const_ref)() const = &mapnik::feature_impl::paths; void feature_add_geometries_from_wkb(mapnik::feature_impl & feature, std::string wkb) { diff --git a/bindings/python/mapnik_geometry.cpp b/bindings/python/mapnik_geometry.cpp index 2084dd888..1594c86a7 100644 --- a/bindings/python/mapnik_geometry.cpp +++ b/bindings/python/mapnik_geometry.cpp @@ -28,12 +28,12 @@ #include #include #include -#include #include #include // mapnik #include +#include #include // from_wkt #include #include // from_geojson diff --git a/include/mapnik/feature.hpp b/include/mapnik/feature.hpp index 9547ba86b..9a600b0f4 100644 --- a/include/mapnik/feature.hpp +++ b/include/mapnik/feature.hpp @@ -29,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/include/mapnik/geometry.hpp b/include/mapnik/geometry.hpp index b78f89aa3..471e043e8 100644 --- a/include/mapnik/geometry.hpp +++ b/include/mapnik/geometry.hpp @@ -28,10 +28,6 @@ #include #include -// boost -#include -#include - namespace mapnik { template class Container=vertex_vector> @@ -154,8 +150,6 @@ public: }; using geometry_type = geometry; -using geometry_ptr = std::shared_ptr; -using geometry_container = boost::ptr_vector; } diff --git a/include/mapnik/geometry_container.hpp b/include/mapnik/geometry_container.hpp new file mode 100644 index 000000000..c56eaa734 --- /dev/null +++ b/include/mapnik/geometry_container.hpp @@ -0,0 +1,35 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2011 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +#ifndef MAPNIK_GEOMETRY_CONTAINER_HPP +#define MAPNIK_GEOMETRY_CONTAINER_HPP + +// boost +#include + +namespace mapnik { + +using geometry_container = boost::ptr_vector; + +} + +#endif // MAPNIK_GEOMETRY_CONTAINER_HPP diff --git a/include/mapnik/json/feature_generator_grammar.hpp b/include/mapnik/json/feature_generator_grammar.hpp index d909f6a84..973c68243 100644 --- a/include/mapnik/json/feature_generator_grammar.hpp +++ b/include/mapnik/json/feature_generator_grammar.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/include/mapnik/json/feature_grammar.hpp b/include/mapnik/json/feature_grammar.hpp index 104c6b2e7..90f65b004 100644 --- a/include/mapnik/json/feature_grammar.hpp +++ b/include/mapnik/json/feature_grammar.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include diff --git a/include/mapnik/json/geometry_parser.hpp b/include/mapnik/json/geometry_parser.hpp index e40791fb9..57f5ac6c0 100644 --- a/include/mapnik/json/geometry_parser.hpp +++ b/include/mapnik/json/geometry_parser.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include // boost @@ -33,7 +34,7 @@ namespace mapnik { namespace json { -inline bool from_geojson(std::string const& json, boost::ptr_vector & paths) +inline bool from_geojson(std::string const& json, geometry_container & paths) { using namespace boost::spirit; static const geometry_grammar g; diff --git a/include/mapnik/util/container_adapter.hpp b/include/mapnik/util/container_adapter.hpp index cdd374bb5..8416e6093 100644 --- a/include/mapnik/util/container_adapter.hpp +++ b/include/mapnik/util/container_adapter.hpp @@ -25,11 +25,11 @@ // mapnik #include +#include #include // boost #include -#include namespace boost { namespace spirit { namespace traits { @@ -60,9 +60,8 @@ template <> struct end_container { static mapnik::util::path_iterator - call (mapnik::geometry_type const& g) + call (mapnik::geometry_type const&) { - boost::ignore_unused_variable_warning(g); return mapnik::util::path_iterator(); } }; diff --git a/include/mapnik/util/geometry_to_svg.hpp b/include/mapnik/util/geometry_to_svg.hpp index e18bc2ce7..6e207dbd8 100644 --- a/include/mapnik/util/geometry_to_svg.hpp +++ b/include/mapnik/util/geometry_to_svg.hpp @@ -26,6 +26,7 @@ // mapnik #include #include +#include #include // boost diff --git a/include/mapnik/util/geometry_to_wkb.hpp b/include/mapnik/util/geometry_to_wkb.hpp index 0f5ff9a13..bd90161b9 100644 --- a/include/mapnik/util/geometry_to_wkb.hpp +++ b/include/mapnik/util/geometry_to_wkb.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include // stl @@ -187,7 +188,7 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) using point_type = std::pair; using linear_ring = std::vector; - boost::ptr_vector rings; + std::vector rings; double x = 0; double y = 0; @@ -197,8 +198,10 @@ wkb_buffer_ptr to_polygon_wkb( GeometryType const& g, wkbByteOrder byte_order) unsigned command = g.vertex(i,&x,&y); if (command == SEG_MOVETO) { - rings.push_back(new linear_ring); // start new loop - rings.back().emplace_back(x,y); + linear_ring ring; + ring.reserve(1); + ring.emplace_back(x,y); + rings.push_back(std::move(ring)); // start new loop size += 4; // num_points size += 2 * 8; // point } diff --git a/include/mapnik/util/geometry_to_wkt.hpp b/include/mapnik/util/geometry_to_wkt.hpp index b861c1a33..5d4967fd0 100644 --- a/include/mapnik/util/geometry_to_wkt.hpp +++ b/include/mapnik/util/geometry_to_wkt.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include namespace mapnik { namespace util { diff --git a/include/mapnik/wkb.hpp b/include/mapnik/wkb.hpp index 7474a0182..2f3052c66 100644 --- a/include/mapnik/wkb.hpp +++ b/include/mapnik/wkb.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include namespace mapnik diff --git a/include/mapnik/wkt/wkt_factory.hpp b/include/mapnik/wkt/wkt_factory.hpp index 7fbbaf28d..c546d5953 100644 --- a/include/mapnik/wkt/wkt_factory.hpp +++ b/include/mapnik/wkt/wkt_factory.hpp @@ -25,6 +25,7 @@ // mapnik #include +#include #include // stl diff --git a/include/mapnik/wkt/wkt_grammar.hpp b/include/mapnik/wkt/wkt_grammar.hpp index 370b83c78..badaa720f 100644 --- a/include/mapnik/wkt/wkt_grammar.hpp +++ b/include/mapnik/wkt/wkt_grammar.hpp @@ -29,6 +29,7 @@ // mapnik #include +#include #include namespace mapnik { namespace wkt { diff --git a/src/wkb.cpp b/src/wkb.cpp index b85d1532b..2f028a5c2 100644 --- a/src/wkb.cpp +++ b/src/wkb.cpp @@ -128,7 +128,7 @@ public: needSwap_ = byteOrder_ ? wkbXDR : wkbNDR; } - void read(boost::ptr_vector & paths) + void read(geometry_container & paths) { int type = read_integer(); @@ -307,7 +307,7 @@ private: } } - void read_point(boost::ptr_vector & paths) + void read_point(geometry_container & paths) { double x = read_double(); double y = read_double(); @@ -316,7 +316,7 @@ private: paths.push_back(pt.release()); } - void read_multipoint(boost::ptr_vector & paths) + void read_multipoint(geometry_container & paths) { int num_points = read_integer(); for (int i = 0; i < num_points; ++i) @@ -326,7 +326,7 @@ private: } } - void read_point_xyz(boost::ptr_vector & paths) + void read_point_xyz(geometry_container & paths) { double x = read_double(); double y = read_double(); @@ -336,7 +336,7 @@ private: paths.push_back(pt.release()); } - void read_point_xyzm(boost::ptr_vector & paths) + void read_point_xyzm(geometry_container & paths) { double x = read_double(); double y = read_double(); @@ -346,7 +346,7 @@ private: paths.push_back(pt.release()); } - void read_multipoint_xyz(boost::ptr_vector & paths) + void read_multipoint_xyz(geometry_container & paths) { int num_points = read_integer(); for (int i = 0; i < num_points; ++i) @@ -356,7 +356,7 @@ private: } } - void read_multipoint_xyzm(boost::ptr_vector & paths) + void read_multipoint_xyzm(geometry_container & paths) { int num_points = read_integer(); for (int i = 0; i < num_points; ++i) @@ -366,7 +366,7 @@ private: } } - void read_linestring(boost::ptr_vector & paths) + void read_linestring(geometry_container & paths) { int num_points = read_integer(); if (num_points > 0) @@ -383,7 +383,7 @@ private: } } - void read_multilinestring(boost::ptr_vector & paths) + void read_multilinestring(geometry_container & paths) { int num_lines = read_integer(); for (int i = 0; i < num_lines; ++i) @@ -393,7 +393,7 @@ private: } } - void read_linestring_xyz(boost::ptr_vector & paths) + void read_linestring_xyz(geometry_container & paths) { int num_points = read_integer(); if (num_points > 0) @@ -410,7 +410,7 @@ private: } } - void read_linestring_xyzm(boost::ptr_vector & paths) + void read_linestring_xyzm(geometry_container & paths) { int num_points = read_integer(); if (num_points > 0) @@ -427,7 +427,7 @@ private: } } - void read_multilinestring_xyz(boost::ptr_vector & paths) + void read_multilinestring_xyz(geometry_container & paths) { int num_lines = read_integer(); for (int i = 0; i < num_lines; ++i) @@ -437,7 +437,7 @@ private: } } - void read_multilinestring_xyzm(boost::ptr_vector & paths) + void read_multilinestring_xyzm(geometry_container & paths) { int num_lines = read_integer(); for (int i = 0; i < num_lines; ++i) @@ -447,7 +447,7 @@ private: } } - void read_polygon(boost::ptr_vector & paths) + void read_polygon(geometry_container & paths) { int num_rings = read_integer(); if (num_rings > 0) @@ -473,7 +473,7 @@ private: } } - void read_multipolygon(boost::ptr_vector & paths) + void read_multipolygon(geometry_container & paths) { int num_polys = read_integer(); for (int i = 0; i < num_polys; ++i) @@ -483,7 +483,7 @@ private: } } - void read_polygon_xyz(boost::ptr_vector & paths) + void read_polygon_xyz(geometry_container & paths) { int num_rings = read_integer(); if (num_rings > 0) @@ -509,7 +509,7 @@ private: } } - void read_polygon_xyzm(boost::ptr_vector & paths) + void read_polygon_xyzm(geometry_container & paths) { int num_rings = read_integer(); if (num_rings > 0) @@ -535,7 +535,7 @@ private: } } - void read_multipolygon_xyz(boost::ptr_vector & paths) + void read_multipolygon_xyz(geometry_container & paths) { int num_polys = read_integer(); for (int i = 0; i < num_polys; ++i) @@ -545,7 +545,7 @@ private: } } - void read_multipolygon_xyzm(boost::ptr_vector & paths) + void read_multipolygon_xyzm(geometry_container & paths) { int num_polys = read_integer(); for (int i = 0; i < num_polys; ++i) @@ -555,7 +555,7 @@ private: } } - void read_collection(boost::ptr_vector & paths) + void read_collection(geometry_container & paths) { int num_geometries = read_integer(); for (int i = 0; i < num_geometries; ++i) @@ -607,7 +607,7 @@ private: }; -bool geometry_utils::from_wkb(boost::ptr_vector& paths, +bool geometry_utils::from_wkb(geometry_container& paths, const char* wkb, unsigned size, wkbFormat format) diff --git a/utils/geometry_to_wkb/main.cpp b/utils/geometry_to_wkb/main.cpp index b8048f283..76396ff24 100644 --- a/utils/geometry_to_wkb/main.cpp +++ b/utils/geometry_to_wkb/main.cpp @@ -81,7 +81,7 @@ int main (int argc, char ** argv ) while(f) { std::cerr << *f << std::endl; - boost::ptr_vector & paths = f->paths(); + mapnik::geometry_container const& paths = f->paths(); for (mapnik::geometry_type const& geom : paths) { // NDR From d111dcbed646b1240187dcc534499be31fcf8797 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 18:47:05 -0700 Subject: [PATCH 26/31] iwyu --- include/mapnik/geom_util.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/mapnik/geom_util.hpp b/include/mapnik/geom_util.hpp index 3114e59cb..c8fe3220e 100644 --- a/include/mapnik/geom_util.hpp +++ b/include/mapnik/geom_util.hpp @@ -32,6 +32,7 @@ // stl #include #include +#include namespace mapnik { From 40a11893578768653508715bfbf662c9e22755c1 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 19:32:22 -0700 Subject: [PATCH 27/31] chip away at complexity of marker_helpers.hpp --- include/mapnik/marker_helpers.hpp | 133 ++-------------- .../process_markers_symbolizer.hpp | 45 +++--- src/build.py | 1 + src/marker_helpers.cpp | 150 ++++++++++++++++++ 4 files changed, 186 insertions(+), 143 deletions(-) create mode 100644 src/marker_helpers.cpp diff --git a/include/mapnik/marker_helpers.hpp b/include/mapnik/marker_helpers.hpp index 76ce9992f..fd7462755 100644 --- a/include/mapnik/marker_helpers.hpp +++ b/include/mapnik/marker_helpers.hpp @@ -60,11 +60,14 @@ // stl #include #include // remove_reference +#include namespace mapnik { struct clip_poly_tag; +using svg_attribute_type = agg::pod_bvector; + template struct vector_markers_rasterizer_dispatch : mapnik::noncopyable { @@ -80,7 +83,7 @@ struct vector_markers_rasterizer_dispatch : mapnik::noncopyable attribute_source_type const& attrs, box2d const& bbox, agg::trans_affine const& marker_trans, - markers_symbolizer const& sym, + symbolizer_base const& sym, Detector & detector, double scale_factor, feature_impl & feature, @@ -145,7 +148,7 @@ private: RasterizerType & ras_; box2d const& bbox_; agg::trans_affine const& marker_trans_; - markers_symbolizer const& sym_; + symbolizer_base const& sym_; Detector & detector_; feature_impl & feature_; attributes const& vars_; @@ -168,7 +171,7 @@ struct raster_markers_rasterizer_dispatch : mapnik::noncopyable raster_markers_rasterizer_dispatch(image_data_32 const& src, agg::trans_affine const& marker_trans, - markers_symbolizer const& sym, + symbolizer_base const& sym, Detector & detector, double scale_factor, feature_impl & feature, @@ -299,7 +302,7 @@ private: RasterizerType & ras_; image_data_32 const& src_; agg::trans_affine const& marker_trans_; - markers_symbolizer const& sym_; + symbolizer_base const& sym_; Detector & detector_; feature_impl & feature_; attributes const& vars_; @@ -308,132 +311,24 @@ private: }; -template -void build_ellipse(T const& sym, mapnik::feature_impl & feature, attributes const& vars, svg_storage_type & marker_ellipse, svg::svg_path_adapter & svg_path) -{ - double width = 0.0; - double height = 0.0; - if (has_key(sym,keys::width) && has_key(sym,keys::height)) - { - width = get(sym, keys::width, feature, vars, 0.0); - height = get(sym, keys::height, feature, vars, 0.0); - } - else if (has_key(sym,keys::width)) - { - width = height = get(sym, keys::width, feature, vars, 0.0); - } - else if (has_key(sym,keys::height)) - { - width = height = get(sym, keys::height, feature, vars, 0.0); - } - svg::svg_converter_type styled_svg(svg_path, marker_ellipse.attributes()); - styled_svg.push_attr(); - styled_svg.begin_path(); - agg::ellipse c(0, 0, width/2.0, height/2.0); - styled_svg.storage().concat_path(c); - styled_svg.end_path(); - styled_svg.pop_attr(); - double lox,loy,hix,hiy; - styled_svg.bounding_rect(&lox, &loy, &hix, &hiy); - styled_svg.set_dimensions(width,height); - marker_ellipse.set_dimensions(width,height); - marker_ellipse.set_bounding_box(lox,loy,hix,hiy); -} +void build_ellipse(symbolizer_base const& sym, mapnik::feature_impl & feature, attributes const& vars, svg_storage_type & marker_ellipse, svg::svg_path_adapter & svg_path); -template -bool push_explicit_style(Attr const& src, Attr & dst, - markers_symbolizer const& sym, +bool push_explicit_style(svg_attribute_type const& src, + svg_attribute_type & dst, + symbolizer_base const& sym, feature_impl & feature, - attributes const& vars) -{ - auto fill_color = get_optional(sym, keys::fill, feature, vars); - auto fill_opacity = get_optional(sym, keys::fill_opacity, feature, vars); - auto stroke_color = get_optional(sym, keys::stroke, feature, vars); - auto stroke_width = get_optional(sym, keys::stroke_width, feature, vars); - auto stroke_opacity = get_optional(sym, keys::stroke_opacity, feature, vars); - if (fill_color || - fill_opacity || - stroke_color || - stroke_width || - stroke_opacity) - { - bool success = false; - for(unsigned i = 0; i < src.size(); ++i) - { - success = true; - dst.push_back(src[i]); - mapnik::svg::path_attributes & attr = dst.last(); - if (attr.stroke_flag) - { - if (stroke_width) - { - attr.stroke_width = *stroke_width; - } - if (stroke_color) - { - color const& s_color = *stroke_color; - attr.stroke_color = agg::rgba(s_color.red()/255.0, - s_color.green()/255.0, - s_color.blue()/255.0, - s_color.alpha()/255.0); - } - if (stroke_opacity) - { - attr.stroke_opacity = *stroke_opacity; - } - } - if (attr.fill_flag) - { - if (fill_color) - { - color const& f_color = *fill_color; - attr.fill_color = agg::rgba(f_color.red()/255.0, - f_color.green()/255.0, - f_color.blue()/255.0, - f_color.alpha()/255.0); - } - if (fill_opacity) - { - attr.fill_opacity = *fill_opacity; - } - } - } - return success; - } - return false; -} + attributes const& vars); -template void setup_transform_scaling(agg::trans_affine & tr, double svg_width, double svg_height, mapnik::feature_impl & feature, attributes const& vars, - T const& sym) -{ - double width = get(sym, keys::width, feature, vars, 0.0); - double height = get(sym, keys::height, feature, vars, 0.0); - if (width > 0 && height > 0) - { - double sx = width/svg_width; - double sy = height/svg_height; - tr *= agg::trans_affine_scaling(sx,sy); - } - else if (width > 0) - { - double sx = width/svg_width; - tr *= agg::trans_affine_scaling(sx); - } - else if (height > 0) - { - double sy = height/svg_height; - tr *= agg::trans_affine_scaling(sy); - } -} + symbolizer_base const& sym); // Apply markers to a feature with multiple geometries template -void apply_markers_multi(feature_impl const& feature, attributes const& vars, Converter & converter, markers_symbolizer const& sym) +void apply_markers_multi(feature_impl const& feature, attributes const& vars, Converter & converter, symbolizer_base const& sym) { std::size_t geom_count = feature.paths().size(); if (geom_count == 1) diff --git a/include/mapnik/renderer_common/process_markers_symbolizer.hpp b/include/mapnik/renderer_common/process_markers_symbolizer.hpp index 59f500477..3ef7a1f50 100644 --- a/include/mapnik/renderer_common/process_markers_symbolizer.hpp +++ b/include/mapnik/renderer_common/process_markers_symbolizer.hpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include #include @@ -46,8 +45,6 @@ void render_markers_symbolizer(markers_symbolizer const& sym, using raster_dispatch_type = T1; using renderer_context_type = T2; - using svg_attribute_type = agg::pod_bvector; - std::string filename = get(sym, keys::file, feature, common.vars_, "shape://ellipse"); bool clip = get(sym, keys::clip, feature, common.vars_, false); double offset = get(sym, keys::offset, feature, common.vars_, 0.0); @@ -96,13 +93,13 @@ void render_markers_symbolizer(markers_symbolizer const& sym, snap_to_pixels, renderer_context); - vertex_converter - converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); + using vertex_converter_type = vertex_converter; + vertex_converter_type converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { geometry_type::types type = feature.paths()[0].type(); @@ -140,13 +137,13 @@ void render_markers_symbolizer(markers_symbolizer const& sym, snap_to_pixels, renderer_context); - vertex_converter - converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); + using vertex_converter_type = vertex_converter; + vertex_converter_type converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { geometry_type::types type = feature.paths()[0].type(); @@ -183,13 +180,13 @@ void render_markers_symbolizer(markers_symbolizer const& sym, common.vars_, renderer_context); - vertex_converter - converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); + using vertex_converter_type = vertex_converter; + vertex_converter_type converter(clip_box, rasterizer_dispatch, sym,common.t_,prj_trans,geom_tr,feature,common.vars_,common.scale_factor_); if (clip && feature.paths().size() > 0) // optional clip (default: true) { diff --git a/src/build.py b/src/build.py index 3d6d05d59..f5da1c623 100644 --- a/src/build.py +++ b/src/build.py @@ -142,6 +142,7 @@ else: # unix, non-macos source = Split( """ + marker_helpers.cpp dasharray_parser.cpp expression_grammar.cpp fs.cpp diff --git a/src/marker_helpers.cpp b/src/marker_helpers.cpp new file mode 100644 index 000000000..dfc7e2f91 --- /dev/null +++ b/src/marker_helpers.cpp @@ -0,0 +1,150 @@ +/***************************************************************************** + * + * This file is part of Mapnik (c++ mapping toolkit) + * + * Copyright (C) 2014 Artem Pavlenko + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + *****************************************************************************/ + +// mapnik +#include + +namespace mapnik { + +void build_ellipse(symbolizer_base const& sym, mapnik::feature_impl & feature, attributes const& vars, svg_storage_type & marker_ellipse, svg::svg_path_adapter & svg_path) +{ + double width = 0.0; + double height = 0.0; + if (has_key(sym,keys::width) && has_key(sym,keys::height)) + { + width = get(sym, keys::width, feature, vars, 0.0); + height = get(sym, keys::height, feature, vars, 0.0); + } + else if (has_key(sym,keys::width)) + { + width = height = get(sym, keys::width, feature, vars, 0.0); + } + else if (has_key(sym,keys::height)) + { + width = height = get(sym, keys::height, feature, vars, 0.0); + } + svg::svg_converter_type styled_svg(svg_path, marker_ellipse.attributes()); + styled_svg.push_attr(); + styled_svg.begin_path(); + agg::ellipse c(0, 0, width/2.0, height/2.0); + styled_svg.storage().concat_path(c); + styled_svg.end_path(); + styled_svg.pop_attr(); + double lox,loy,hix,hiy; + styled_svg.bounding_rect(&lox, &loy, &hix, &hiy); + styled_svg.set_dimensions(width,height); + marker_ellipse.set_dimensions(width,height); + marker_ellipse.set_bounding_box(lox,loy,hix,hiy); +} + +bool push_explicit_style(svg_attribute_type const& src, + svg_attribute_type & dst, + symbolizer_base const& sym, + feature_impl & feature, + attributes const& vars) +{ + auto fill_color = get_optional(sym, keys::fill, feature, vars); + auto fill_opacity = get_optional(sym, keys::fill_opacity, feature, vars); + auto stroke_color = get_optional(sym, keys::stroke, feature, vars); + auto stroke_width = get_optional(sym, keys::stroke_width, feature, vars); + auto stroke_opacity = get_optional(sym, keys::stroke_opacity, feature, vars); + if (fill_color || + fill_opacity || + stroke_color || + stroke_width || + stroke_opacity) + { + bool success = false; + for(unsigned i = 0; i < src.size(); ++i) + { + success = true; + dst.push_back(src[i]); + mapnik::svg::path_attributes & attr = dst.last(); + if (attr.stroke_flag) + { + if (stroke_width) + { + attr.stroke_width = *stroke_width; + } + if (stroke_color) + { + color const& s_color = *stroke_color; + attr.stroke_color = agg::rgba(s_color.red()/255.0, + s_color.green()/255.0, + s_color.blue()/255.0, + s_color.alpha()/255.0); + } + if (stroke_opacity) + { + attr.stroke_opacity = *stroke_opacity; + } + } + if (attr.fill_flag) + { + if (fill_color) + { + color const& f_color = *fill_color; + attr.fill_color = agg::rgba(f_color.red()/255.0, + f_color.green()/255.0, + f_color.blue()/255.0, + f_color.alpha()/255.0); + } + if (fill_opacity) + { + attr.fill_opacity = *fill_opacity; + } + } + } + return success; + } + return false; +} + +void setup_transform_scaling(agg::trans_affine & tr, + double svg_width, + double svg_height, + mapnik::feature_impl & feature, + attributes const& vars, + symbolizer_base const& sym) +{ + double width = get(sym, keys::width, feature, vars, 0.0); + double height = get(sym, keys::height, feature, vars, 0.0); + if (width > 0 && height > 0) + { + double sx = width/svg_width; + double sy = height/svg_height; + tr *= agg::trans_affine_scaling(sx,sy); + } + else if (width > 0) + { + double sx = width/svg_width; + tr *= agg::trans_affine_scaling(sx); + } + else if (height > 0) + { + double sy = height/svg_height; + tr *= agg::trans_affine_scaling(sy); + } +} + + +} // end namespace mapnik From 5e250e0dd9237242e2bbc227db8b5ac05d6492f5 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 19:42:34 -0700 Subject: [PATCH 28/31] avoid boost stdint usage --- plugins/input/pgraster/pgraster_featureset.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plugins/input/pgraster/pgraster_featureset.cpp b/plugins/input/pgraster/pgraster_featureset.cpp index 056d997cf..164aaf7ad 100644 --- a/plugins/input/pgraster/pgraster_featureset.cpp +++ b/plugins/input/pgraster/pgraster_featureset.cpp @@ -245,12 +245,12 @@ pgraster_featureset::~pgraster_featureset() std::string numeric2string(const char* buf) { - boost::int16_t ndigits = int2net(buf); - boost::int16_t weight = int2net(buf+2); - boost::int16_t sign = int2net(buf+4); - boost::int16_t dscale = int2net(buf+6); + std::int16_t ndigits = int2net(buf); + std::int16_t weight = int2net(buf+2); + std::int16_t sign = int2net(buf+4); + std::int16_t dscale = int2net(buf+6); - boost::scoped_array digits(new boost::int16_t[ndigits]); + std::unique_ptr digits(new std::int16_t[ndigits]); for (int n=0; n < ndigits ;++n) { digits[n] = int2net(buf+8+n*2); @@ -260,7 +260,7 @@ std::string numeric2string(const char* buf) if (sign == 0x4000) ss << "-"; - int i = std::max(weight,boost::int16_t(0)); + int i = std::max(weight,std::int16_t(0)); int d = 0; // Each numeric "digit" is actually a value between 0000 and 9999 stored in a 16 bit field. From 41b0e0e16b07d6c03d485c1ed45065a2d39b664e Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 19:43:00 -0700 Subject: [PATCH 29/31] remove scoped_array include --- plugins/input/pgraster/pgraster_featureset.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/input/pgraster/pgraster_featureset.cpp b/plugins/input/pgraster/pgraster_featureset.cpp index 164aaf7ad..ee36cc4e6 100644 --- a/plugins/input/pgraster/pgraster_featureset.cpp +++ b/plugins/input/pgraster/pgraster_featureset.cpp @@ -41,7 +41,6 @@ #include #include #include // for int2net -#include // stl #include From 875227191006fc085ac658daae6df31f7d8166cf Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 19:59:59 -0700 Subject: [PATCH 30/31] code cleanup --- src/agg/process_line_pattern_symbolizer.cpp | 4 ---- src/agg/process_line_symbolizer.cpp | 5 ----- src/agg/process_polygon_pattern_symbolizer.cpp | 1 - src/agg/process_polygon_symbolizer.cpp | 1 - 4 files changed, 11 deletions(-) diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index b45a7b39a..0aec91a58 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -122,10 +122,6 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, clip_box.pad(padding); } - //using conv_types = boost::mpl::vector; vertex_converter::process(line_symbolizer const& sym, using blender_type = agg::comp_op_adaptor_rgba_pre; // comp blender using pixfmt_comp_type = agg::pixfmt_custom_blend_rgba; using renderer_base = agg::renderer_base; - //using conv_types = boost::mpl::vector; pixfmt_comp_type pixf(buf); pixf.comp_op(static_cast(get(sym, keys::comp_op, feature, common_.vars_, src_over))); diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index 4ca7045bc..c607dfa24 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -158,7 +158,6 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, auto transform = get_optional(sym, keys::geometry_transform); if (transform) evaluate_transform(tr, feature, common_.vars_, *transform, common_.scale_factor_); - //using conv_types = boost::mpl::vector; vertex_converter converter(clip_box,*ras_ptr,sym,common_.t_,prj_trans,tr,feature,common_.vars_,common_.scale_factor_); diff --git a/src/agg/process_polygon_symbolizer.cpp b/src/agg/process_polygon_symbolizer.cpp index 8f52db603..5a5fb492e 100644 --- a/src/agg/process_polygon_symbolizer.cpp +++ b/src/agg/process_polygon_symbolizer.cpp @@ -49,7 +49,6 @@ void agg_renderer::process(polygon_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { - //using conv_types = boost::mpl::vector; using vertex_converter_type = vertex_converter; ras_ptr->reset(); From 00382775a90c550e5a538dedf4aff2d9e02f1718 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Sep 2014 21:20:01 -0700 Subject: [PATCH 31/31] more make clean fixes --- SConstruct | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/SConstruct b/SConstruct index 1e3d74e4e..ab8a8ac8f 100644 --- a/SConstruct +++ b/SConstruct @@ -501,7 +501,8 @@ elif HELP_REQUESTED: # need no-op for clean on fresh checkout # https://github.com/mapnik/mapnik/issues/2112 -if not os.path.exists(SCONS_LOCAL_LOG) and ('-c' in command_line_args or '--clean' in command_line_args): +if not os.path.exists(SCONS_LOCAL_LOG) and not os.path.exists(SCONS_CONFIGURE_CACHE) \ + and ('-c' in command_line_args or '--clean' in command_line_args): print 'all good: nothing to clean, but you might want to run "make distclean"' Exit(0)