Permalink
Browse files

sync agg with grid renderer for polygon patterns - refs #1309

  • Loading branch information...
1 parent eecffc2 commit 57363c13c151bbb680063dab5147079063b81eca Dane Springmeyer committed Aug 23, 2012
Showing with 28 additions and 13 deletions.
  1. +28 −13 src/grid/process_polygon_pattern_symbolizer.cpp
@@ -20,13 +20,17 @@
*
*****************************************************************************/
+// boost
+#include <boost/foreach.hpp>
+
// mapnik
#include <mapnik/grid/grid_rasterizer.hpp>
#include <mapnik/grid/grid_renderer.hpp>
#include <mapnik/grid/grid_pixfmt.hpp>
#include <mapnik/grid/grid_pixel.hpp>
#include <mapnik/grid/grid.hpp>
#include <mapnik/polygon_pattern_symbolizer.hpp>
+#include <mapnik/vertex_converters.hpp>
// agg
#include "agg_rasterizer_scanline_aa.h"
@@ -44,31 +48,42 @@ void grid_renderer<T>::process(polygon_pattern_symbolizer const& sym,
mapnik::feature_impl & feature,
proj_transform const& prj_trans)
{
- typedef coord_transform<CoordTransform,geometry_type> path_type;
- typedef agg::renderer_base<mapnik::pixfmt_gray32> ren_base;
- typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
- agg::scanline_bin sl;
+ ras_ptr->reset();
- grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
- mapnik::pixfmt_gray32 pixf(buf);
+ agg::trans_affine tr;
+ evaluate_transform(tr, feature, sym.get_transform());
- ren_base renb(pixf);
- renderer ren(renb);
+ typedef boost::mpl::vector<clip_poly_tag,transform_tag,affine_transform_tag,smooth_tag> conv_types;
+ vertex_converter<box2d<double>, grid_rasterizer, polygon_pattern_symbolizer,
+ CoordTransform, proj_transform, agg::trans_affine, conv_types>
+ converter(query_extent_,*ras_ptr,sym,t_,prj_trans,tr,scale_factor_);
+
+ if (sym.clip()) converter.set<clip_poly_tag>(); //optional clip (default: true)
+ converter.set<transform_tag>(); //always transform
+ converter.set<affine_transform_tag>();
+ if (sym.smooth() > 0.0) converter.set<smooth_tag>(); // optional smooth converter
- ras_ptr->reset();
- for (unsigned i=0;i<feature.num_geometries();++i)
+ BOOST_FOREACH( geometry_type & geom, feature.paths())
{
- geometry_type & geom = feature.get_geometry(i);
if (geom.size() > 2)
{
- path_type path(t_,geom,prj_trans);
- ras_ptr->add_path(path);
+ converter.apply(geom);
}
}
+ typedef agg::renderer_base<mapnik::pixfmt_gray32> ren_base;
+ typedef agg::renderer_scanline_bin_solid<ren_base> renderer;
+
+ grid_rendering_buffer buf(pixmap_.raw_data(), width_, height_, width_);
+ mapnik::pixfmt_gray32 pixf(buf);
+
+ ren_base renb(pixf);
+ renderer ren(renb);
+
// render id
ren.color(mapnik::gray32(feature.id()));
+ agg::scanline_bin sl;
agg::render_scanlines(*ras_ptr, sl, ren);
// add feature properties to grid cache

0 comments on commit 57363c1

Please sign in to comment.