Permalink
Browse files

+ supprt polygon smoothing in cairo backend

  • Loading branch information...
1 parent 3e4733c commit f0bc1064c6c0ba6da1e9f5f4495126ad59fed4fa @artemp artemp committed Mar 14, 2012
Showing with 25 additions and 10 deletions.
  1. +25 −10 src/cairo_renderer.cpp
View
@@ -53,6 +53,7 @@
// agg
#include "agg_conv_clip_polyline.h"
#include "agg_conv_clip_polygon.h"
+#include "agg_conv_smooth_poly1.h"
// stl
#ifdef MAPNIK_DEBUG
@@ -725,23 +726,37 @@ void cairo_renderer_base::start_map_processing(Map const& map)
proj_transform const& prj_trans)
{
- typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
- typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
-
cairo_context context(context_);
-
context.set_color(sym.get_fill(), sym.get_opacity());
-
+ box2d<double> inflated_extent = query_extent_ * 1.1;
for (unsigned i = 0; i < feature->num_geometries(); ++i)
{
geometry_type & geom = feature->get_geometry(i);
if (geom.num_points() > 2)
{
- clipped_geometry_type clipped(geom);
- clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
- path_type path(t_,clipped,prj_trans);
- context.add_path(path);
- context.fill();
+ if (sym.smooth() > 0.0)
+ {
+ typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
+ typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
+ typedef agg::conv_smooth_poly1_curve<path_type> smooth_type;
+ clipped_geometry_type clipped(geom);
+ clipped.clip_box(inflated_extent.minx(),inflated_extent.miny(),inflated_extent.maxx(),inflated_extent.maxy());
+ path_type path(t_,clipped,prj_trans);
+ smooth_type smooth(path);
+ smooth.smooth_value(sym.smooth());
+ context.add_agg_path(smooth);
+ context.fill();
+ }
+ else
+ {
+ typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
+ typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
+ clipped_geometry_type clipped(geom);
+ clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
+ path_type path(t_,clipped,prj_trans);
+ context.add_path(path);
+ context.fill();
+ }
}
}
}

0 comments on commit f0bc106

Please sign in to comment.