changed symbolizer interface to accept 'feature' and CoordTransform, instead of
geometry (feature centric OGC model:).
This commit is contained in:
parent
245be985e2
commit
a6f96ea5c1
14 changed files with 268 additions and 204 deletions
|
@ -27,7 +27,30 @@
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
typedef coord_array<coord2d> CoordinateArray;
|
typedef coord_array<coord2d> CoordinateArray;
|
||||||
|
|
||||||
|
template <typename Transform,typename Geometry>
|
||||||
|
struct coord_transform
|
||||||
|
{
|
||||||
|
coord_transform(Transform const& t,Geometry& geom)
|
||||||
|
: t_(t), geom_(geom) {}
|
||||||
|
|
||||||
|
unsigned vertex(double *x , double *y) const
|
||||||
|
{
|
||||||
|
unsigned command = geom_.vertex(x,y);
|
||||||
|
*x = t_.forward_x_(x);
|
||||||
|
*y = t_.forward_y_(y);
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
void rewind (unsigned pos)
|
||||||
|
{
|
||||||
|
geom_.rewind(pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Transform const& t_;
|
||||||
|
Geometry& geom_;
|
||||||
|
};
|
||||||
|
|
||||||
class CoordTransform
|
class CoordTransform
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -58,7 +81,17 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
*y = (extent.maxy() - *y) * scale_;
|
*y = (extent.maxy() - *y) * scale_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline double forward_x_(double* x) const
|
||||||
|
{
|
||||||
|
return (*x - extent.minx() ) * scale_;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline double forward_y_(double* y) const
|
||||||
|
{
|
||||||
|
return (extent.maxy() - *y) * scale_;
|
||||||
|
}
|
||||||
|
|
||||||
inline void backward_x(double* x) const
|
inline void backward_x(double* x) const
|
||||||
{
|
{
|
||||||
*x = extent.minx() + *x/scale_;
|
*x = extent.minx() + *x/scale_;
|
||||||
|
|
|
@ -77,7 +77,7 @@ namespace mapnik
|
||||||
geom_=geom;
|
geom_=geom;
|
||||||
}
|
}
|
||||||
|
|
||||||
geometry_type& get_geometry()
|
geometry_type const& get_geometry() const
|
||||||
{
|
{
|
||||||
return geom_;
|
return geom_;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,8 +34,7 @@ namespace mapnik
|
||||||
std::string const& type,
|
std::string const& type,
|
||||||
unsigned width,unsigned height);
|
unsigned width,unsigned height);
|
||||||
|
|
||||||
void render(geometry_type& geom,Image32& image) const;
|
void render(Feature const& feat, CoordTransform const& t,Image32& image) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImageData32 symbol_;
|
ImageData32 symbol_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -32,8 +32,7 @@ namespace mapnik
|
||||||
line_pattern_symbolizer(std::string const& file,
|
line_pattern_symbolizer(std::string const& file,
|
||||||
std::string const& type,
|
std::string const& type,
|
||||||
unsigned width,unsigned height);
|
unsigned width,unsigned height);
|
||||||
void render(geometry_type& geom,Image32& image) const;
|
void render(Feature const& feat, CoordTransform const& t,Image32& image) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImageData32 pattern_;
|
ImageData32 pattern_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,7 @@ namespace mapnik
|
||||||
{
|
{
|
||||||
line_symbolizer(stroke const& stroke);
|
line_symbolizer(stroke const& stroke);
|
||||||
line_symbolizer(const Color& pen,float width=1.0);
|
line_symbolizer(const Color& pen,float width=1.0);
|
||||||
void render(geometry_type& geom, Image32& image) const;
|
void render(Feature const& feat, CoordTransform const& t,Image32& image) const;
|
||||||
private:
|
private:
|
||||||
stroke stroke_;
|
stroke stroke_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -33,8 +33,8 @@ namespace mapnik
|
||||||
polygon_pattern_symbolizer(std::string const& file,
|
polygon_pattern_symbolizer(std::string const& file,
|
||||||
std::string const& type,
|
std::string const& type,
|
||||||
unsigned width,unsigned height);
|
unsigned width,unsigned height);
|
||||||
|
|
||||||
void render(geometry_type& geom,Image32& image) const;
|
void render(Feature const& feat, CoordTransform const& t,Image32& image) const;
|
||||||
private:
|
private:
|
||||||
ImageData32 pattern_;
|
ImageData32 pattern_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace mapnik
|
||||||
private boost::noncopyable
|
private boost::noncopyable
|
||||||
{
|
{
|
||||||
polygon_symbolizer(const Color& fill);
|
polygon_symbolizer(const Color& fill);
|
||||||
void render(geometry_type& geom,Image32& image) const;
|
void render(Feature const& feat, CoordTransform const& t,Image32& image) const;
|
||||||
private:
|
private:
|
||||||
Color fill_;
|
Color fill_;
|
||||||
};
|
};
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#define SYMBOLIZER_HPP
|
#define SYMBOLIZER_HPP
|
||||||
|
|
||||||
#include "graphics.hpp"
|
#include "graphics.hpp"
|
||||||
|
#include "feature.hpp"
|
||||||
#include "geometry.hpp"
|
#include "geometry.hpp"
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ namespace mapnik
|
||||||
|
|
||||||
struct symbolizer
|
struct symbolizer
|
||||||
{
|
{
|
||||||
virtual void render(geometry_type& geom, Image32& image) const=0;
|
virtual void render(Feature const& feat, CoordTransform const& t, Image32& image) const=0;
|
||||||
virtual ~symbolizer() {}
|
virtual ~symbolizer() {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,18 +41,24 @@ namespace mapnik
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void image_symbolizer::render(geometry_type& geom,Image32& image) const
|
void image_symbolizer::render(Feature const& feat,CoordTransform const& t,Image32& image) const
|
||||||
{
|
{
|
||||||
int w=symbol_.width();
|
typedef coord_transform<CoordTransform,geometry_type> path_type;
|
||||||
int h=symbol_.height();
|
geometry_ptr const& geom=feat.get_geometry();
|
||||||
double x,y;
|
if (geom)
|
||||||
unsigned size = geom.num_points();
|
|
||||||
for (unsigned pos = 0; pos < size ;++pos)
|
|
||||||
{
|
{
|
||||||
geom.vertex(&x,&y);
|
path_type path(t,*geom);
|
||||||
int px=int(x - 0.5 * w);
|
unsigned num_points=geom->num_points();
|
||||||
int py=int(y - 0.5 * h);
|
int w=symbol_.width();
|
||||||
image.set_rectangle_alpha(px,py,symbol_);
|
int h=symbol_.height();
|
||||||
|
double x,y;
|
||||||
|
for(unsigned i=0;i<num_points;++i)
|
||||||
|
{
|
||||||
|
path.vertex(&x,&y);
|
||||||
|
int px=int(x - 0.5 * w);
|
||||||
|
int py=int(y - 0.5 * h);
|
||||||
|
image.set_rectangle_alpha(px,py,symbol_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,29 +73,34 @@ namespace mapnik
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
std::cerr<<"exception caught..."<<std::endl;
|
std::cerr << "exception caught..." << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void line_pattern_symbolizer::render(geometry_type& geom,Image32& image) const
|
void line_pattern_symbolizer::render(Feature const& feat, CoordTransform const& t,Image32& image) const
|
||||||
{
|
{
|
||||||
|
typedef coord_transform<CoordTransform,geometry_type> path_type;
|
||||||
typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
|
typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
|
||||||
typedef agg::renderer_base<agg::pixfmt_rgba32> renderer_base;
|
typedef agg::renderer_base<agg::pixfmt_rgba32> renderer_base;
|
||||||
typedef agg::renderer_outline_image<renderer_base, pattern_type> renderer_type;
|
typedef agg::renderer_outline_image<renderer_base, pattern_type> renderer_type;
|
||||||
typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
|
typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
|
||||||
|
|
||||||
unsigned int width=image.width();
|
geometry_ptr const& geom=feat.get_geometry();
|
||||||
unsigned int height=image.height();
|
if (geom)
|
||||||
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(), width, height,width*4);
|
{
|
||||||
agg::pixfmt_rgba32 pixf(buf);
|
path_type path(t,*geom);
|
||||||
renderer_base ren_base(pixf);
|
unsigned int width=image.width();
|
||||||
agg::pattern_filter_bilinear_rgba8 filter;
|
unsigned int height=image.height();
|
||||||
pattern_source source(pattern_);
|
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(), width, height,width*4);
|
||||||
pattern_type pattern (filter,source);
|
agg::pixfmt_rgba32 pixf(buf);
|
||||||
renderer_type ren(ren_base, pattern);
|
renderer_base ren_base(pixf);
|
||||||
ren.clip_box(0,0,width,height);
|
agg::pattern_filter_bilinear_rgba8 filter;
|
||||||
rasterizer_type ras(ren);
|
pattern_source source(pattern_);
|
||||||
ras.add_path(geom);
|
pattern_type pattern (filter,source);
|
||||||
|
renderer_type ren(ren_base, pattern);
|
||||||
|
ren.clip_box(0,0,width,height);
|
||||||
|
rasterizer_type ras(ren);
|
||||||
|
ras.add_path(path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,109 +52,116 @@ namespace mapnik
|
||||||
: symbolizer(),
|
: symbolizer(),
|
||||||
stroke_(pen,width) {}
|
stroke_(pen,width) {}
|
||||||
|
|
||||||
void line_symbolizer::render(geometry_type& geom, Image32& image) const
|
void line_symbolizer::render(Feature const& feat, CoordTransform const& t,Image32& image) const
|
||||||
{
|
{
|
||||||
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
||||||
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(),image.width(),image.height(),
|
typedef coord_transform<CoordTransform,geometry_type> path_type;
|
||||||
image.width()*4);
|
geometry_ptr const& geom=feat.get_geometry();
|
||||||
agg::pixfmt_rgba32 pixf(buf);
|
if (geom)
|
||||||
ren_base renb(pixf);
|
|
||||||
|
|
||||||
Color const& col = stroke_.get_color();
|
|
||||||
unsigned r=col.red();
|
|
||||||
unsigned g=col.green();
|
|
||||||
unsigned b=col.blue();
|
|
||||||
|
|
||||||
if (0)//stroke_.get_width() <= 1.0)
|
|
||||||
{
|
{
|
||||||
typedef agg::renderer_outline_aa<ren_base> renderer_oaa;
|
path_type path(t,*geom);
|
||||||
typedef agg::rasterizer_outline_aa<renderer_oaa> rasterizer_outline_aa;
|
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(),image.width(),image.height(),
|
||||||
agg::line_profile_aa prof;
|
image.width()*4);
|
||||||
prof.width(stroke_.get_width());
|
agg::pixfmt_rgba32 pixf(buf);
|
||||||
renderer_oaa ren_oaa(renb, prof);
|
ren_base renb(pixf);
|
||||||
rasterizer_outline_aa ras_oaa(ren_oaa);
|
|
||||||
|
Color const& col = stroke_.get_color();
|
||||||
|
unsigned r=col.red();
|
||||||
|
unsigned g=col.green();
|
||||||
|
unsigned b=col.blue();
|
||||||
|
|
||||||
|
|
||||||
ren_oaa.color(agg::rgba8(r, g, b, int(255*stroke_.get_opacity())));
|
if (0)//stroke_.get_width() <= 1.0)
|
||||||
ren_oaa.clip_box(0,0,image.width(),image.height());
|
|
||||||
ras_oaa.add_path(geom);
|
|
||||||
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
|
||||||
renderer ren(renb);
|
|
||||||
agg::rasterizer_scanline_aa<> ras;
|
|
||||||
agg::scanline_u8 sl;
|
|
||||||
|
|
||||||
if (stroke_.has_dash())
|
|
||||||
{
|
{
|
||||||
|
typedef agg::renderer_outline_aa<ren_base> renderer_oaa;
|
||||||
|
typedef agg::rasterizer_outline_aa<renderer_oaa> rasterizer_outline_aa;
|
||||||
|
agg::line_profile_aa prof;
|
||||||
|
prof.width(stroke_.get_width());
|
||||||
|
renderer_oaa ren_oaa(renb, prof);
|
||||||
|
rasterizer_outline_aa ras_oaa(ren_oaa);
|
||||||
|
|
||||||
agg::conv_dash<geometry<vertex2d> > dash(geom);
|
ren_oaa.color(agg::rgba8(r, g, b, int(255*stroke_.get_opacity())));
|
||||||
dash_array const& d = stroke_.get_dash_array();
|
ren_oaa.clip_box(0,0,image.width(),image.height());
|
||||||
dash_array::const_iterator itr = d.begin();
|
ras_oaa.add_path(path);
|
||||||
dash_array::const_iterator end = d.end();
|
|
||||||
while (itr != end)
|
|
||||||
{
|
|
||||||
dash.add_dash(itr->first, itr->second);
|
|
||||||
++itr;
|
|
||||||
}
|
|
||||||
agg::conv_stroke<agg::conv_dash<geometry<vertex2d> > > stroke(dash);
|
|
||||||
|
|
||||||
line_join_e join=stroke_.get_line_join();
|
|
||||||
if ( join == MITER_JOIN)
|
|
||||||
stroke.generator().line_join(agg::miter_join);
|
|
||||||
else if( join == MITER_REVERT_JOIN)
|
|
||||||
stroke.generator().line_join(agg::miter_join);
|
|
||||||
else if( join == ROUND_JOIN)
|
|
||||||
stroke.generator().line_join(agg::round_join);
|
|
||||||
else
|
|
||||||
stroke.generator().line_join(agg::bevel_join);
|
|
||||||
|
|
||||||
line_cap_e cap=stroke_.get_line_cap();
|
|
||||||
if (cap == BUTT_CAP)
|
|
||||||
stroke.generator().line_cap(agg::butt_cap);
|
|
||||||
else if (cap == SQUARE_CAP)
|
|
||||||
stroke.generator().line_cap(agg::square_cap);
|
|
||||||
else
|
|
||||||
stroke.generator().line_cap(agg::round_cap);
|
|
||||||
|
|
||||||
stroke.generator().miter_limit(4.0);
|
|
||||||
stroke.generator().width(stroke_.get_width());
|
|
||||||
|
|
||||||
ras.clip_box(0,0,image.width(),image.height());
|
|
||||||
ras.add_path(stroke);
|
|
||||||
ren.color(agg::rgba8(r, g, b, int(255*stroke_.get_opacity())));
|
|
||||||
agg::render_scanlines(ras, sl, ren);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
agg::conv_stroke<geometry<vertex2d> > stroke(geom);
|
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||||
|
renderer ren(renb);
|
||||||
|
agg::rasterizer_scanline_aa<> ras;
|
||||||
|
agg::scanline_u8 sl;
|
||||||
|
|
||||||
line_join_e join=stroke_.get_line_join();
|
if (stroke_.has_dash())
|
||||||
if ( join == MITER_JOIN)
|
{
|
||||||
stroke.generator().line_join(agg::miter_join);
|
|
||||||
else if( join == MITER_REVERT_JOIN)
|
|
||||||
stroke.generator().line_join(agg::miter_join);
|
|
||||||
else if( join == ROUND_JOIN)
|
|
||||||
stroke.generator().line_join(agg::round_join);
|
|
||||||
else
|
|
||||||
stroke.generator().line_join(agg::bevel_join);
|
|
||||||
|
|
||||||
line_cap_e cap=stroke_.get_line_cap();
|
agg::conv_dash<path_type> dash(path);
|
||||||
if (cap == BUTT_CAP)
|
dash_array const& d = stroke_.get_dash_array();
|
||||||
stroke.generator().line_cap(agg::butt_cap);
|
dash_array::const_iterator itr = d.begin();
|
||||||
else if (cap == SQUARE_CAP)
|
dash_array::const_iterator end = d.end();
|
||||||
stroke.generator().line_cap(agg::square_cap);
|
while (itr != end)
|
||||||
|
{
|
||||||
|
dash.add_dash(itr->first, itr->second);
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
agg::conv_stroke<agg::conv_dash<path_type > > stroke(dash);
|
||||||
|
|
||||||
|
line_join_e join=stroke_.get_line_join();
|
||||||
|
if ( join == MITER_JOIN)
|
||||||
|
stroke.generator().line_join(agg::miter_join);
|
||||||
|
else if( join == MITER_REVERT_JOIN)
|
||||||
|
stroke.generator().line_join(agg::miter_join);
|
||||||
|
else if( join == ROUND_JOIN)
|
||||||
|
stroke.generator().line_join(agg::round_join);
|
||||||
|
else
|
||||||
|
stroke.generator().line_join(agg::bevel_join);
|
||||||
|
|
||||||
|
line_cap_e cap=stroke_.get_line_cap();
|
||||||
|
if (cap == BUTT_CAP)
|
||||||
|
stroke.generator().line_cap(agg::butt_cap);
|
||||||
|
else if (cap == SQUARE_CAP)
|
||||||
|
stroke.generator().line_cap(agg::square_cap);
|
||||||
|
else
|
||||||
|
stroke.generator().line_cap(agg::round_cap);
|
||||||
|
|
||||||
|
stroke.generator().miter_limit(4.0);
|
||||||
|
stroke.generator().width(stroke_.get_width());
|
||||||
|
|
||||||
|
ras.clip_box(0,0,image.width(),image.height());
|
||||||
|
ras.add_path(stroke);
|
||||||
|
ren.color(agg::rgba8(r, g, b, int(255*stroke_.get_opacity())));
|
||||||
|
agg::render_scanlines(ras, sl, ren);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
stroke.generator().line_cap(agg::round_cap);
|
{
|
||||||
|
agg::conv_stroke<path_type> stroke(path);
|
||||||
stroke.generator().miter_limit(4.0);
|
|
||||||
stroke.generator().width(stroke_.get_width());
|
|
||||||
|
|
||||||
ras.clip_box(0,0,image.width(),image.height());
|
line_join_e join=stroke_.get_line_join();
|
||||||
ras.add_path(stroke);
|
if ( join == MITER_JOIN)
|
||||||
ren.color(agg::rgba8(r, g, b, int(255*stroke_.get_opacity())));
|
stroke.generator().line_join(agg::miter_join);
|
||||||
agg::render_scanlines(ras, sl, ren);
|
else if( join == MITER_REVERT_JOIN)
|
||||||
|
stroke.generator().line_join(agg::miter_join);
|
||||||
|
else if( join == ROUND_JOIN)
|
||||||
|
stroke.generator().line_join(agg::round_join);
|
||||||
|
else
|
||||||
|
stroke.generator().line_join(agg::bevel_join);
|
||||||
|
|
||||||
|
line_cap_e cap=stroke_.get_line_cap();
|
||||||
|
if (cap == BUTT_CAP)
|
||||||
|
stroke.generator().line_cap(agg::butt_cap);
|
||||||
|
else if (cap == SQUARE_CAP)
|
||||||
|
stroke.generator().line_cap(agg::square_cap);
|
||||||
|
else
|
||||||
|
stroke.generator().line_cap(agg::round_cap);
|
||||||
|
|
||||||
|
stroke.generator().miter_limit(4.0);
|
||||||
|
stroke.generator().width(stroke_.get_width());
|
||||||
|
|
||||||
|
ras.clip_box(0,0,image.width(),image.height());
|
||||||
|
ras.add_path(stroke);
|
||||||
|
ren.color(agg::rgba8(r, g, b, int(255*stroke_.get_opacity())));
|
||||||
|
agg::render_scanlines(ras, sl, ren);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,18 +52,10 @@ namespace mapnik
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void polygon_pattern_symbolizer::render(geometry_type& geom,Image32& image) const
|
void polygon_pattern_symbolizer::render(Feature const& feat,CoordTransform const& t,Image32& image) const
|
||||||
{
|
{
|
||||||
|
typedef coord_transform<CoordTransform,geometry_type> path_type;
|
||||||
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
||||||
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(),image.width(),image.height(),
|
|
||||||
image.width()*4);
|
|
||||||
agg::pixfmt_rgba32 pixf(buf);
|
|
||||||
ren_base renb(pixf);
|
|
||||||
|
|
||||||
unsigned w=pattern_.width();
|
|
||||||
unsigned h=pattern_.height();
|
|
||||||
agg::row_ptr_cache<agg::int8u> pattern_rbuf((agg::int8u*)pattern_.getBytes(),w,h,w*4);
|
|
||||||
|
|
||||||
typedef agg::wrap_mode_repeat wrap_x_type;
|
typedef agg::wrap_mode_repeat wrap_x_type;
|
||||||
typedef agg::wrap_mode_repeat wrap_y_type;
|
typedef agg::wrap_mode_repeat wrap_y_type;
|
||||||
typedef agg::image_accessor_wrap<agg::pixfmt_rgba32,
|
typedef agg::image_accessor_wrap<agg::pixfmt_rgba32,
|
||||||
|
@ -75,23 +67,37 @@ namespace mapnik
|
||||||
typedef agg::renderer_scanline_aa<ren_base,
|
typedef agg::renderer_scanline_aa<ren_base,
|
||||||
agg::span_allocator<agg::rgba8>,
|
agg::span_allocator<agg::rgba8>,
|
||||||
span_gen_type> renderer_type;
|
span_gen_type> renderer_type;
|
||||||
|
geometry_ptr const& geom=feat.get_geometry();
|
||||||
|
if (geom)
|
||||||
|
{
|
||||||
|
path_type path(t,*geom);
|
||||||
|
|
||||||
|
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(),image.width(),image.height(),
|
||||||
|
image.width()*4);
|
||||||
|
agg::pixfmt_rgba32 pixf(buf);
|
||||||
|
ren_base renb(pixf);
|
||||||
|
|
||||||
double x0,y0;
|
unsigned w=pattern_.width();
|
||||||
geom.vertex(&x0,&y0);
|
unsigned h=pattern_.height();
|
||||||
geom.rewind(0);
|
agg::row_ptr_cache<agg::int8u> pattern_rbuf((agg::int8u*)pattern_.getBytes(),w,h,w*4);
|
||||||
|
|
||||||
|
double x0,y0;
|
||||||
|
path.vertex(&x0,&y0);
|
||||||
|
path.rewind(0);
|
||||||
|
|
||||||
unsigned offset_x = unsigned(image.width() - x0);
|
unsigned offset_x = unsigned(image.width() - x0);
|
||||||
unsigned offset_y = unsigned(image.height() - y0);
|
unsigned offset_y = unsigned(image.height() - y0);
|
||||||
|
|
||||||
agg::span_allocator<agg::rgba8> sa;
|
agg::span_allocator<agg::rgba8> sa;
|
||||||
img_source_type img_src(pattern_rbuf);
|
img_source_type img_src(pattern_rbuf);
|
||||||
span_gen_type sg(img_src, offset_x, offset_y);
|
span_gen_type sg(img_src, offset_x, offset_y);
|
||||||
renderer_type rp(renb,sa, sg);
|
renderer_type rp(renb,sa, sg);
|
||||||
|
|
||||||
agg::rasterizer_scanline_aa<> ras;
|
agg::rasterizer_scanline_aa<> ras;
|
||||||
agg::scanline_u8 sl;
|
agg::scanline_u8 sl;
|
||||||
ras.clip_box(0,0,image.width(),image.height());
|
ras.clip_box(0,0,image.width(),image.height());
|
||||||
ras.add_path(geom);
|
ras.add_path(path);
|
||||||
agg::render_scanlines(ras, sl, rp);
|
agg::render_scanlines(ras, sl, rp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,26 +38,34 @@ namespace mapnik
|
||||||
: symbolizer(),
|
: symbolizer(),
|
||||||
fill_(fill) {}
|
fill_(fill) {}
|
||||||
|
|
||||||
void polygon_symbolizer::render(geometry_type& geom,Image32& image) const
|
|
||||||
|
void polygon_symbolizer::render(Feature const& feat,CoordTransform const& t,Image32& image) const
|
||||||
{
|
{
|
||||||
|
typedef coord_transform<CoordTransform,geometry_type> path_type;
|
||||||
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
||||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||||
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(),image.width(),image.height(),
|
|
||||||
image.width()*4);
|
geometry_ptr const& geom=feat.get_geometry();
|
||||||
agg::pixfmt_rgba32 pixf(buf);
|
if (geom)
|
||||||
ren_base renb(pixf);
|
{
|
||||||
|
path_type path(t,*geom);
|
||||||
unsigned r=fill_.red();
|
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(),image.width(),image.height(),
|
||||||
unsigned g=fill_.green();
|
image.width()*4);
|
||||||
unsigned b=fill_.blue();
|
agg::pixfmt_rgba32 pixf(buf);
|
||||||
unsigned a=fill_.alpha();
|
ren_base renb(pixf);
|
||||||
renderer ren(renb);
|
|
||||||
|
unsigned r=fill_.red();
|
||||||
agg::rasterizer_scanline_aa<> ras;
|
unsigned g=fill_.green();
|
||||||
agg::scanline_u8 sl;
|
unsigned b=fill_.blue();
|
||||||
ras.clip_box(0,0,image.width(),image.height());
|
unsigned a=fill_.alpha();
|
||||||
ras.add_path(geom);
|
renderer ren(renb);
|
||||||
ren.color(agg::rgba8(r, g, b, a));
|
|
||||||
agg::render_scanlines(ras, sl, ren);
|
agg::rasterizer_scanline_aa<> ras;
|
||||||
|
agg::scanline_u8 sl;
|
||||||
|
ras.clip_box(0,0,image.width(),image.height());
|
||||||
|
ras.add_path(path);
|
||||||
|
ren.color(agg::rgba8(r, g, b, a));
|
||||||
|
agg::render_scanlines(ras, sl, ren);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,45 +96,45 @@ namespace mapnik
|
||||||
while ((feature = fs->next()))
|
while ((feature = fs->next()))
|
||||||
{
|
{
|
||||||
bool do_else=true;
|
bool do_else=true;
|
||||||
geometry_ptr& geom=feature->get_geometry();
|
//geometry_ptr& geom=feature->get_geometry();
|
||||||
if (geom)
|
//if (geom)
|
||||||
{
|
|
||||||
geom->transform(t);//todo: transform once
|
|
||||||
|
|
||||||
std::vector<rule_type*>::const_iterator itr=if_rules.begin();
|
//geom->transform(t);//todo: transform once
|
||||||
while (itr!=if_rules.end())
|
// coord_transform<CoordTransform,geometry_type> path(t,*geom);
|
||||||
|
|
||||||
|
std::vector<rule_type*>::const_iterator itr=if_rules.begin();
|
||||||
|
while (itr!=if_rules.end())
|
||||||
|
{
|
||||||
|
const filter_ptr& filter=(*itr)->get_filter();
|
||||||
|
if (filter->pass(*feature))
|
||||||
|
{
|
||||||
|
do_else=false;
|
||||||
|
const symbolizers& symbols = (*itr)->get_symbolizers();
|
||||||
|
symbolizers::const_iterator symIter=symbols.begin();
|
||||||
|
while (symIter!=symbols.end())
|
||||||
|
{
|
||||||
|
(*symIter)->render(*feature,t,image);
|
||||||
|
++symIter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
if (do_else)
|
||||||
|
{
|
||||||
|
//else filter
|
||||||
|
std::vector<rule_type*>::const_iterator itr=else_rules.begin();
|
||||||
|
while (itr != else_rules.end())
|
||||||
{
|
{
|
||||||
const filter_ptr& filter=(*itr)->get_filter();
|
const symbolizers& symbols = (*itr)->get_symbolizers();
|
||||||
if (filter->pass(*feature))
|
symbolizers::const_iterator symIter=symbols.begin();
|
||||||
{
|
while (symIter!=symbols.end())
|
||||||
do_else=false;
|
{
|
||||||
const symbolizers& symbols = (*itr)->get_symbolizers();
|
(*symIter)->render(*feature,t,image);
|
||||||
symbolizers::const_iterator symIter=symbols.begin();
|
++symIter;
|
||||||
while (symIter!=symbols.end())
|
}
|
||||||
{
|
|
||||||
(*symIter)->render(*geom,image);
|
|
||||||
++symIter;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++itr;
|
++itr;
|
||||||
}
|
}
|
||||||
if (do_else)
|
}
|
||||||
{
|
|
||||||
//else filter
|
|
||||||
std::vector<rule_type*>::const_iterator itr=else_rules.begin();
|
|
||||||
while (itr != else_rules.end())
|
|
||||||
{
|
|
||||||
const symbolizers& symbols = (*itr)->get_symbolizers();
|
|
||||||
symbolizers::const_iterator symIter=symbols.begin();
|
|
||||||
while (symIter!=symbols.end())
|
|
||||||
{
|
|
||||||
(*symIter)->render(*geom,image);
|
|
||||||
++symIter;
|
|
||||||
}
|
|
||||||
++itr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue