diff --git a/bindings/python/mapnik_line_symbolizer.cpp b/bindings/python/mapnik_line_symbolizer.cpp index 062d52618..9c7053b90 100644 --- a/bindings/python/mapnik_line_symbolizer.cpp +++ b/bindings/python/mapnik_line_symbolizer.cpp @@ -62,5 +62,9 @@ void export_line_symbolizer() (&line_symbolizer::get_stroke, return_value_policy()), &line_symbolizer::set_stroke) + .add_property("smooth", + &line_symbolizer::smooth, + &line_symbolizer::set_smooth, + "smooth value (0..1.0)") ; } diff --git a/include/mapnik/line_symbolizer.hpp b/include/mapnik/line_symbolizer.hpp index 84c845098..bcb3ab971 100644 --- a/include/mapnik/line_symbolizer.hpp +++ b/include/mapnik/line_symbolizer.hpp @@ -44,17 +44,20 @@ struct MAPNIK_DECL line_symbolizer : public symbolizer_base explicit line_symbolizer() : symbolizer_base(), stroke_(), - rasterizer_p_(RASTERIZER_FULL) {} + rasterizer_p_(RASTERIZER_FULL), + smooth_(0.0) {} line_symbolizer(stroke const& stroke) : symbolizer_base(), stroke_(stroke), - rasterizer_p_(RASTERIZER_FULL) {} + rasterizer_p_(RASTERIZER_FULL), + smooth_(0.0) {} line_symbolizer(color const& pen,float width=1.0) : symbolizer_base(), stroke_(pen,width), - rasterizer_p_(RASTERIZER_FULL) {} + rasterizer_p_(RASTERIZER_FULL), + smooth_(0.0) {} stroke const& get_stroke() const { @@ -76,9 +79,20 @@ struct MAPNIK_DECL line_symbolizer : public symbolizer_base return rasterizer_p_; } + void set_smooth(double smooth) + { + smooth_ = smooth; + } + + double smooth() const + { + return smooth_; + } + private: stroke stroke_; line_rasterizer_e rasterizer_p_; + double smooth_; }; } diff --git a/src/agg/process_line_symbolizer.cpp b/src/agg/process_line_symbolizer.cpp index cc00d2f2e..d07f47a28 100644 --- a/src/agg/process_line_symbolizer.cpp +++ b/src/agg/process_line_symbolizer.cpp @@ -40,7 +40,7 @@ #include "agg_renderer_outline_aa.h" #include "agg_rasterizer_outline_aa.h" #include "agg_conv_clip_polyline.h" - +#include "agg_conv_smooth_poly1.h" // stl #include @@ -105,8 +105,6 @@ void agg_renderer::process(line_symbolizer const& sym, set_gamma_method(stroke_, ras_ptr); - - //metawriter_with_properties writer = sym.get_metawriter(); for (unsigned i=0;inum_geometries();++i) { @@ -137,14 +135,35 @@ void agg_renderer::process(line_symbolizer const& sym, } else { - clipped_geometry_type clipped(geom); - clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy()); - path_type path(t_,clipped,prj_trans); - agg::conv_stroke stroke(path); - set_join_caps(stroke_,stroke); - stroke.generator().miter_limit(4.0); - stroke.generator().width(stroke_.get_width() * scale_factor_); - ras_ptr->add_path(stroke); + if (sym.smooth() > 0.0) + { + typedef agg::conv_clip_polyline clipped_geometry_type; + typedef coord_transform2 path_type; + typedef agg::conv_smooth_poly1_curve smooth_type; + clipped_geometry_type clipped(geom); + clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy()); + path_type path(t_,clipped,prj_trans); + smooth_type smooth(path); + smooth.smooth_value(sym.smooth()); + agg::conv_stroke stroke(smooth); + set_join_caps(stroke_,stroke); + stroke.generator().miter_limit(4.0); + stroke.generator().width(stroke_.get_width() * scale_factor_); + ras_ptr->add_path(stroke); + } + else + { + typedef agg::conv_clip_polyline clipped_geometry_type; + typedef coord_transform2 path_type; + clipped_geometry_type clipped(geom); + clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy()); + path_type path(t_,clipped,prj_trans); + agg::conv_stroke stroke(path); + set_join_caps(stroke_,stroke); + stroke.generator().miter_limit(4.0); + stroke.generator().width(stroke_.get_width() * scale_factor_); + ras_ptr->add_path(stroke); + } //if (writer.first) writer.first->add_line(path, *feature, t_, writer.second); } } diff --git a/src/load_map.cpp b/src/load_map.cpp index 92787c83e..354817a36 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -1266,7 +1266,10 @@ void map_parser::parse_line_symbolizer( rule & rule, xml_node const & sym ) line_rasterizer_e rasterizer = sym.get_attr("rasterizer", RASTERIZER_FULL); //optional rasterizer_method = sym.get_opt_attr("full"); symbol.set_rasterizer(rasterizer); - + // smooth value + optional smooth = sym.get_opt_attr("smooth"); + if (smooth) symbol.set_smooth(*smooth); + // meta-writer parse_metawriter_in_symbolizer(symbol, sym); rule.append(symbol); } diff --git a/src/save_map.cpp b/src/save_map.cpp index d81508ad3..a890973ce 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -91,8 +91,12 @@ public: { set_attr( sym_node, "rasterizer", sym.get_rasterizer() ); } + if ( sym.smooth() != dfl.smooth() || explicit_defaults_ ) + { + set_attr( sym_node, "smooth", sym.smooth() ); + } } - + void operator () ( line_pattern_symbolizer const& sym ) { ptree & sym_node = rule_.push_back(