diff --git a/src/agg/process_line_pattern_symbolizer.cpp b/src/agg/process_line_pattern_symbolizer.cpp index c79410fb2..c2e466375 100644 --- a/src/agg/process_line_pattern_symbolizer.cpp +++ b/src/agg/process_line_pattern_symbolizer.cpp @@ -140,7 +140,7 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, clip_box.pad(padding); } - typedef boost::mpl::vector conv_types; + typedef boost::mpl::vector conv_types; vertex_converter, rasterizer_type, line_pattern_symbolizer, CoordTransform, proj_transform, agg::trans_affine, conv_types> converter(clip_box,ras,sym,t_,prj_trans,tr,scale_factor_); @@ -149,6 +149,7 @@ void agg_renderer::process(line_pattern_symbolizer const& sym, converter.set(); //always transform if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (std::fabs(sym.offset()) > 0.0) converter.set(); // parallel offset + converter.set(); // optional affine transform if (sym.smooth() > 0.0) converter.set(); // optional smooth converter BOOST_FOREACH(geometry_type & geom, feature.paths()) diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index 95ff2e056..ae82660d0 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -148,13 +148,14 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, agg::trans_affine tr; evaluate_transform(tr, feature, sym.get_transform()); - typedef boost::mpl::vector conv_types; + typedef boost::mpl::vector conv_types; vertex_converter, rasterizer, polygon_pattern_symbolizer, CoordTransform, proj_transform, agg::trans_affine, conv_types> converter(clip_box,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_); if (prj_trans.equal() && sym.clip()) converter.set(); //optional clip (default: true) converter.set(); //always transform + converter.set(); // optional affine transform if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter if (sym.smooth() > 0.0) converter.set(); // optional smooth converter diff --git a/src/grid/process_line_pattern_symbolizer.cpp b/src/grid/process_line_pattern_symbolizer.cpp index b79e39dd0..eeaa700a9 100644 --- a/src/grid/process_line_pattern_symbolizer.cpp +++ b/src/grid/process_line_pattern_symbolizer.cpp @@ -27,6 +27,10 @@ #include #include #include +#include +#include +#include +#include // agg #include "agg_rasterizer_scanline_aa.h" @@ -45,10 +49,27 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { + std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature); + + boost::optional mark = marker_cache::instance().find(filename,true); + if (!mark) return; + + if (!(*mark)->is_bitmap()) + { + MAPNIK_LOG_DEBUG(agg_renderer) << "agg_renderer: Only images (not '" << filename << "') are supported in the line_pattern_symbolizer"; + return; + } + + boost::optional pat = (*mark)->get_bitmap_data(); + if (!pat) return; + typedef coord_transform path_type; typedef typename grid_renderer_base_type::pixfmt_type pixfmt_type; typedef typename grid_renderer_base_type::pixfmt_type::color_type color_type; typedef agg::renderer_scanline_bin_solid renderer_type; + typedef boost::mpl::vector conv_types; agg::scanline_bin sl; grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_); @@ -59,19 +80,45 @@ void grid_renderer::process(line_pattern_symbolizer const& sym, ras_ptr->reset(); - // TODO - actually handle image dimensions - int stroke_width = 2; + int stroke_width = (*pat)->width(); - for (std::size_t i=0;i clipping_extent = query_extent_; + if (sym.clip()) + { + double padding = (double)(query_extent_.width()/pixmap_.width()); + double half_stroke = stroke_width/2.0; + if (half_stroke > 1) + padding *= half_stroke; + if (std::fabs(sym.offset()) > 0) + padding *= std::fabs(sym.offset()) * 1.2; + padding *= scale_factor_; + clipping_extent.pad(padding); + } + + // to avoid the complexity of using an agg pattern filter instead + // we create a line_symbolizer in order to fake the pattern + stroke str; + str.set_width(stroke_width); + line_symbolizer line(str); + vertex_converter, grid_rasterizer, line_symbolizer, + CoordTransform, proj_transform, agg::trans_affine, conv_types> + converter(clipping_extent,*ras_ptr,line,t_,prj_trans,tr,scale_factor_); + if (sym.clip()) converter.set(); // optional clip (default: true) + converter.set(); // always transform + if (std::fabs(sym.offset()) > 0.0) converter.set(); // parallel offset + converter.set(); // optional affine transform + if (sym.simplify_tolerance() > 0.0) converter.set(); // optional simplify converter + if (sym.smooth() > 0.0) converter.set(); // optional smooth converter + converter.set(); //always stroke + + BOOST_FOREACH( geometry_type & geom, feature.paths()) { - geometry_type & geom = feature.get_geometry(i); if (geom.size() > 1) { - path_type path(t_,geom,prj_trans); - agg::conv_stroke stroke(path); - stroke.generator().miter_limit(4.0); - stroke.generator().width(stroke_width * scale_factor_); - ras_ptr->add_path(stroke); + converter.apply(geom); } } diff --git a/src/grid/process_polygon_pattern_symbolizer.cpp b/src/grid/process_polygon_pattern_symbolizer.cpp index 38145858f..da012dada 100644 --- a/src/grid/process_polygon_pattern_symbolizer.cpp +++ b/src/grid/process_polygon_pattern_symbolizer.cpp @@ -31,6 +31,9 @@ #include #include #include +#include +#include +#include // agg #include "agg_rasterizer_scanline_aa.h" @@ -48,6 +51,20 @@ void grid_renderer::process(polygon_pattern_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { + std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature); + + boost::optional mark = marker_cache::instance().find(filename,true); + if (!mark) return; + + if (!(*mark)->is_bitmap()) + { + MAPNIK_LOG_DEBUG(agg_renderer) << "agg_renderer: Only images (not '" << filename << "') are supported in the line_pattern_symbolizer"; + return; + } + + boost::optional pat = (*mark)->get_bitmap_data(); + if (!pat) return; + ras_ptr->reset(); agg::trans_affine tr; diff --git a/tests/visual_tests/grids/geometry-transform-translate-patterns-200-200-1.0-grid-reference.json b/tests/visual_tests/grids/geometry-transform-translate-patterns-200-200-1.0-grid-reference.json new file mode 100644 index 000000000..5a7be5994 --- /dev/null +++ b/tests/visual_tests/grids/geometry-transform-translate-patterns-200-200-1.0-grid-reference.json @@ -0,0 +1,59 @@ +{ + "keys": [ + "", + "1" + ], + "data": {}, + "grid": [ + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!! !!!!!!!!!!! ", + " !!!!!!!!!!! !!!!!!!!!!! ", + " !!!!!!!!!!! !!!!!!!!!!! ", + " !!!!!!!!!!! !!!!!!!!!!! ", + " !!!!!!!!!!! !!!!!!!!!!! ", + " !!!!!!!!!!! !!!!!!!!!!! ", + " !!!!!!!!!!! !!!!!!!!!!! ", + " !!!!!!!!!!! !!!!!!!!!!! ", + " !!!!!!!!!!! !!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " " + ] +} \ No newline at end of file diff --git a/tests/visual_tests/grids/line-pattern-symbolizer-900-250-1.0-grid-reference.json b/tests/visual_tests/grids/line-pattern-symbolizer-900-250-1.0-grid-reference.json index c6af26426..8d2d83b97 100644 --- a/tests/visual_tests/grids/line-pattern-symbolizer-900-250-1.0-grid-reference.json +++ b/tests/visual_tests/grids/line-pattern-symbolizer-900-250-1.0-grid-reference.json @@ -32,33 +32,33 @@ " ", " ", " ", - " ", - " !!!!! ########### $$$$$$$$$$ %%%%%%% ", - " !!! !!! ### ### $$$ $$$ %%%% %%% ", - " !! !! ## ## $$ $$ %% %%% ", - " !! !! ## ## $ $$ %% % ", - " !! ! # # $$ $ % %% ", - " ! !! # # $$ $ %% % ", - " ! !! # # $ $ %% % ", - " !! ! # # $ $ % % ", - " ! ! # # $ $ % % ", - " ! ! # # $ $ % % ", - " ! ! # # $ $ % % ", - " ! ! &&&&& # $ $ % % ", - " ! '''''''''''''''''''''''''''''' # # $ $ % (((((((((((( ", - " ! ! # # $ $ % % ", - " ! ! # $ $ % ", - " ! # # $ % ", - " ! ! ## # $ $ % % ", - " ! ! # # $ $ % % ", - " !! ! # # $ $ % % ", - " !! ! ## ## $$ $ % % ", - " ! !! # # $ $$ %% %% ", - " !! !! ## ### $$ $$ %% %% ", - " !! !! ### ### $$$ $$$ %%% %%% ", - " !!!!! !!!!!! ######### $$$$$$$$$$ %%%%%%%%%%%% ", - " ", - " ", + " !!!!!!!!! ############# $$$$$$$$$$$$ %%%%%%%%%%% ", + " !!!!!!!!!!!!!!!!! ##################### $$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%% ", + " !!!!!!!!!!!!!!!!!!!!!!! ######################### $$$$$$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%%%%% ", + " !!!!!!!!!!! !!!!!!!!!!!! ######## ######### $$$$$$$$$ $$$$$$$$$$ %%%%%%%%%% %%%%%%%%%% ", + " !!!!!!! !!!!!!! ####### ####### $$$$$$ $$$$$$$ %%%%%%% %%%%%%%% ", + " !!!!!! !!!!!! ###### ###### $$$$$ $$$$$$ %%%%% %%%%%% ", + " !!!!!! !!!!! ##### ##### $$$$$ $$$$$ %%%%% %%%%% ", + " !!!! !!!!! ##### ##### $$$$ $$$$$ %%%% %%%%% ", + " !!!! !!!! #### #### $$$$ $$$$ %%%% %%%% ", + " !!!! !!!! #### #### $$$ $$$$ %%%% %%%% ", + " !!!! !!!! #### #### $$$$ $$$ %%%% %%%% ", + " !!! !!!! ### ### $$$$ $$$ %%%% %%% ", + " !!! !!! #&&&&& ### $$$ $$$ %%% %%% ", + " !!! ''''''''''''''''''''''''''''''! ### ### $$$ $$$ %%% ((((((((((((% ", + " !!! !!! ### ### $$$$ $$$ %%% %%% ", + " !!! !!!! #### #### $$$$ $$$ %%%% %%% ", + " !!!! !!! ### #### $$$ $$$$ %%% %%%% ", + " !!!! !!!! #### #### $$$$ $$$$ %%%% %%%% ", + " !!!! !!!!! #### #### $$$$ $$$$$ %%%% %%%%% ", + " !!!!! !!!!! ##### ##### $$$$ $$$$$ %%%%% %%%%% ", + " !!!!! !!!!! ###### ###### $$$$$$ $$$$$$ %%%%%% %%%%% ", + " !!!!!! !!!!!! ####### ####### $$$$$$ $$$$$$$ %%%%%%% %%%%%% ", + " !!!!!!!! !!!!!!!! ########## ########## $$$$$$$$$ $$$$$$$$$ %%%%%%%% %%%%%%%%% ", + " !!!!!!!!!!!!!!!!!!!!!!!!! ####################### $$$$$$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%%%%%%% ", + " !!!!!!!!!!!!!!!!!!!!! ################### $$$$$$$$$$$$$$$$$$$$ %%%%%%%%%%%%%%%%%%%%% ", + " !!!!!!!!!!!!!!! ########### $$$$$$$$$$$$$ %%%%%%%%%%%%%% ", + " !!! ", " ", " ", " ", diff --git a/tests/visual_tests/grids/line-pattern-symbolizer-opacity-512-512-1.0-grid-reference.json b/tests/visual_tests/grids/line-pattern-symbolizer-opacity-512-512-1.0-grid-reference.json index 1efa6d583..686cdf599 100644 --- a/tests/visual_tests/grids/line-pattern-symbolizer-opacity-512-512-1.0-grid-reference.json +++ b/tests/visual_tests/grids/line-pattern-symbolizer-opacity-512-512-1.0-grid-reference.json @@ -1,12 +1,12 @@ { "keys": [ "", - "4", "3", + "4", "2", "1", - "8", "7", + "8", "6", "5" ], @@ -67,24 +67,24 @@ " ", " ", " ", - " ", - " !!!!!!!! ##### ##### $$$$$$$$$$ %%%%%%%%% ", - " !! !! ### ## $$ $$ %% %% ", - " !! ! # # $$ $$ %% %% ", - " !! !! # # $$ $ % % ", - " ! !! # # $ $ % % ", - " ! ! # # $ $ % %", - "! ! # $ $ % ", - "! ! # $ $ % ", - "&&&&&&&&&&&&&&&&&&&&&&&&&& ''''''''''''''''''''''# (((((((((((((((((((((((((( )))))))))))))))))))))))))", - "! ! $ $ % ", - "! ! # # $ $ % %", - " ! ! ## # $ $ %% %", - " !! ! # # $ $ % % ", - " !! !! ## ## $ $ %% % ", - " ! ! ## # $$ $$ %% %% ", - " !!! !!! ### ### $$$ $$ %%% %% ", - " !!!!!!!!!! ##### $$$$$$$$ %%%%%%%% ", + " !! ", + " ########## !!!!!!!!!!!!! $$$$$$$$$$$$ %%%%%%%%%%% ", + " #### #### !!! !!! $$$ $$$ %%%% %%%% ", + " ### ### !!! !!! $$$ $$ %% %%% ", + " ## ## !! !! $$ $$ %% %% ", + " ## ## !! !! $$ $$ %% %%", + " # ## ! ! $$ $$ %% %", + "## # !! !! $ $ % %", + "# # !&&&& ! $ $ %% ", + "'''''''''''''''''''''''''' !&&&&&&&&&&&&&&&&&&&&&&&&&! (((((((((((((((((((((((((( %)))))))))))))))))))))))))", + "# # !! !! $ $ %% ", + "# # ! ! $$ $ % %", + "## ## !! !! $ $ %% %", + " ## ## !! !! $$ $$ %% %%", + " ## ## !! !! $$$ $$ %% %%% ", + " ### ### !!! !!! $$ $$$ %%% %% ", + " #### #### !!!!! !!!!! $$$$$ $$$$$ %%%% %%%%% ", + " ############ !!!!!!!!! $$$$$$$$$$ %%%%%%%%%%% ", " ", " ", " ", diff --git a/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-1.0-agg-reference.png b/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-1.0-agg-reference.png new file mode 100644 index 000000000..69c365944 Binary files /dev/null and b/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-1.0-agg-reference.png differ diff --git a/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-1.0-cairo-reference.png b/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-1.0-cairo-reference.png new file mode 100644 index 000000000..a29870306 Binary files /dev/null and b/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-1.0-cairo-reference.png differ diff --git a/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-2.0-agg-reference.png b/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-2.0-agg-reference.png new file mode 100644 index 000000000..446444e98 Binary files /dev/null and b/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-2.0-agg-reference.png differ diff --git a/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-2.0-cairo-reference.png b/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-2.0-cairo-reference.png new file mode 100644 index 000000000..b09dac05f Binary files /dev/null and b/tests/visual_tests/images/geometry-transform-translate-patterns-200-200-2.0-cairo-reference.png differ diff --git a/tests/visual_tests/styles/geometry-transform-translate-patterns.xml b/tests/visual_tests/styles/geometry-transform-translate-patterns.xml new file mode 100644 index 000000000..16702b98d --- /dev/null +++ b/tests/visual_tests/styles/geometry-transform-translate-patterns.xml @@ -0,0 +1,99 @@ + + + + + + + + polygon + + csv + +wkt +"POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1), (2 2, 2 3, 3 3, 3 2, 2 2))" + + + + + + line + + csv + +wkt +"LINESTRING (0.5 0.5, 4.5 4.5)" + + + + + + point + + csv + +wkt +"POINT (1 4)" + + + + + + + + + + frame + + csv + +x,y +0,0 +5,0 +0,5 +5,5 + + + + + diff --git a/tests/visual_tests/test.py b/tests/visual_tests/test.py index c2a3498ef..80bfea546 100755 --- a/tests/visual_tests/test.py +++ b/tests/visual_tests/test.py @@ -100,6 +100,7 @@ files = { 'shield-on-polygon': {'sizes':[(600,400)]}, 'shield-on-line-spacing-eq-width': {'sizes':[(600,400)]}, 'geometry-transform-translate': {'sizes':[(200,200)]}, + 'geometry-transform-translate-patterns': {'sizes':[(200,200)]}, 'marker-svg-opacity':{}, 'marker-svg-opacity2':{}, 'marker-svg-empty-g-element':{},