From fbf9ac839992c611f307db6f8aececdfb521ca2a Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 14 Aug 2012 10:43:46 -0700 Subject: [PATCH] support new clipping extent padding method in cairo line_symbolizer rendering as per #1282 - partial revert of 76569cccb8c1cfc --- src/cairo_renderer.cpp | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/src/cairo_renderer.cpp b/src/cairo_renderer.cpp index cfe8f174c..6b2c4ffad 100644 --- a/src/cairo_renderer.cpp +++ b/src/cairo_renderer.cpp @@ -987,6 +987,9 @@ void cairo_renderer_base::process(line_symbolizer const& sym, mapnik::feature_impl & feature, proj_transform const& prj_trans) { + typedef boost::mpl::vector conv_types; cairo_context context(context_); mapnik::stroke const& stroke_ = sym.get_stroke(); context.set_operator(sym.comp_op()); @@ -1004,21 +1007,26 @@ void cairo_renderer_base::process(line_symbolizer const& sym, agg::trans_affine tr; evaluate_transform(tr, feature, sym.get_transform()); - box2d ext = query_extent_ * 1.1; - typedef boost::mpl::vector conv_types; + box2d clipping_extent = query_extent_; + if (sym.clip()) + { + double padding = (double)(query_extent_.width()/width_); + float half_stroke = stroke_.get_width()/2.0; + if (half_stroke > 1) + padding *= half_stroke; + if (fabs(sym.offset()) > 0) + padding *= fabs(sym.offset()) * 1.2; + double x0 = query_extent_.minx(); + double y0 = query_extent_.miny(); + double x1 = query_extent_.maxx(); + double y1 = query_extent_.maxy(); + clipping_extent.init(x0 - padding, y0 - padding, x1 + padding , y1 + padding); + } vertex_converter, cairo_context, line_symbolizer, CoordTransform, proj_transform, agg::trans_affine, conv_types> - converter(ext,context,sym,t_,prj_trans,tr,scale_factor_); + converter(clipping_extent,context,sym,t_,prj_trans,tr,scale_factor_); - if (sym.clip() && feature.paths().size() > 0) // optional clip (default: true) - { - eGeomType type = feature.paths()[0].type(); - if (type == Polygon) - converter.set(); - else if (type == LineString) - converter.set(); - // don't clip if type==Point - } + if (sym.clip()) converter.set(); // optional clip (default: true) converter.set(); // always transform if (fabs(sym.offset()) > 0.0) converter.set(); // parallel offset converter.set(); // optional affine transform