1.symbolizers refactored - split into hpp/cpp
(all AGG is private to libmapnik and not exposed to client code) 2.removed unused files (more todo) 3.added line pattern symbolizer to python bindings
This commit is contained in:
parent
390b9c4655
commit
245be985e2
24 changed files with 553 additions and 394 deletions
|
@ -25,5 +25,5 @@ agg_root = env['AGG_ROOT']
|
||||||
agg_headers = agg_root + '/include'
|
agg_headers = agg_root + '/include'
|
||||||
agg_src_dir = agg_root + '/src/'
|
agg_src_dir = agg_root + '/src/'
|
||||||
agg_src = glob.glob(agg_src_dir + '*.cpp')
|
agg_src = glob.glob(agg_src_dir + '*.cpp')
|
||||||
agg_lib = env.SharedLibrary('libagg',agg_src,LIBS=[],CPPPATH=agg_headers)
|
agg_lib = env.StaticLibrary('libagg',agg_src,LIBS=[],CPPPATH=agg_headers)
|
||||||
env.Install(prefix+'/lib',agg_lib)
|
env.Install(prefix+'/lib',agg_lib)
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include "style.hpp"
|
#include "color.hpp"
|
||||||
#include "gamma.hpp"
|
#include "gamma.hpp"
|
||||||
#include "image_data.hpp"
|
#include "image_data.hpp"
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#define IMAGE_SYMBOLIZER_HPP
|
#define IMAGE_SYMBOLIZER_HPP
|
||||||
|
|
||||||
#include "symbolizer.hpp"
|
#include "symbolizer.hpp"
|
||||||
#include "image_data.hpp"
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
|
@ -30,42 +29,15 @@ namespace mapnik
|
||||||
struct image_symbolizer : public symbolizer,
|
struct image_symbolizer : public symbolizer,
|
||||||
private boost::noncopyable
|
private boost::noncopyable
|
||||||
{
|
{
|
||||||
private:
|
|
||||||
ImageData32 symbol_;
|
|
||||||
public:
|
|
||||||
image_symbolizer(std::string const& file,
|
image_symbolizer(std::string const& file,
|
||||||
std::string const& type,
|
std::string const& type,
|
||||||
unsigned width,unsigned height)
|
unsigned width,unsigned height);
|
||||||
: symbolizer(),
|
|
||||||
symbol_(width,height)
|
void render(geometry_type& geom,Image32& image) const;
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::auto_ptr<ImageReader> reader(get_image_reader(type,file));
|
|
||||||
reader->read(0,0,symbol_);
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
std::cerr<<"exception caught..."<<std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~image_symbolizer() {}
|
private:
|
||||||
|
ImageData32 symbol_;
|
||||||
void render(geometry_type& geom,Image32& image) const
|
|
||||||
{
|
|
||||||
int w=symbol_.width();
|
|
||||||
int h=symbol_.height();
|
|
||||||
double x,y;
|
|
||||||
unsigned size = geom.num_points();
|
|
||||||
for (unsigned pos = 0; pos < size ;++pos)
|
|
||||||
{
|
|
||||||
geom.vertex(&x,&y);
|
|
||||||
int px=int(x - 0.5 * w);
|
|
||||||
int py=int(y - 0.5 * h);
|
|
||||||
image.set_rectangle_alpha(px,py,symbol_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
#include "geometry.hpp"
|
#include "geometry.hpp"
|
||||||
#include "graphics.hpp"
|
#include "graphics.hpp"
|
||||||
#include "style.hpp"
|
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
|
|
@ -22,91 +22,20 @@
|
||||||
#define LINE_PATTERN_SYMBOLIZER_HPP
|
#define LINE_PATTERN_SYMBOLIZER_HPP
|
||||||
|
|
||||||
#include "symbolizer.hpp"
|
#include "symbolizer.hpp"
|
||||||
#include "image_reader.hpp"
|
|
||||||
#include "agg_basics.h"
|
|
||||||
#include "agg_rendering_buffer.h"
|
|
||||||
#include "agg_rasterizer_scanline_aa.h"
|
|
||||||
#include "agg_scanline_p.h"
|
|
||||||
#include "agg_scanline_u.h"
|
|
||||||
#include "agg_renderer_scanline.h"
|
|
||||||
#include "agg_pixfmt_rgba.h"
|
|
||||||
#include "agg_path_storage.h"
|
|
||||||
#include "agg_span_allocator.h"
|
|
||||||
#include "agg_span_pattern_rgba.h"
|
|
||||||
#include "agg_image_accessors.h"
|
|
||||||
#include "agg_pattern_filters_rgba.h"
|
|
||||||
|
|
||||||
#include <boost/utility.hpp>
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
class pattern_source : private boost::noncopyable
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
pattern_source(ImageData32 const& pattern)
|
|
||||||
: pattern_(pattern) {}
|
|
||||||
|
|
||||||
unsigned int width() const
|
|
||||||
{
|
|
||||||
return pattern_.width();
|
|
||||||
}
|
|
||||||
unsigned int height() const
|
|
||||||
{
|
|
||||||
return pattern_.height();
|
|
||||||
}
|
|
||||||
agg::rgba8 pixel(int x, int y) const
|
|
||||||
{
|
|
||||||
unsigned c = pattern_(x,y);
|
|
||||||
return agg::rgba8(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff,(c >> 24) & 0xff);
|
|
||||||
}
|
|
||||||
private:
|
|
||||||
ImageData32 const& pattern_;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct line_pattern_symbolizer : public symbolizer,
|
struct line_pattern_symbolizer : public symbolizer,
|
||||||
private boost::noncopyable
|
private boost::noncopyable
|
||||||
{
|
{
|
||||||
|
line_pattern_symbolizer(std::string const& file,
|
||||||
|
std::string const& type,
|
||||||
|
unsigned width,unsigned height);
|
||||||
|
void render(geometry_type& geom,Image32& image) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ImageData32 pattern_;
|
ImageData32 pattern_;
|
||||||
public:
|
|
||||||
line_pattern_symbolizer(std::string const& file,
|
|
||||||
std::string const& type,
|
|
||||||
unsigned width,unsigned height)
|
|
||||||
: symbolizer(),
|
|
||||||
pattern_(width,height)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::auto_ptr<ImageReader> reader(get_image_reader(type,file));
|
|
||||||
reader->read(0,0,pattern_);
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
std::cerr<<"exception caught..."<<std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~line_pattern_symbolizer() {}
|
|
||||||
|
|
||||||
void render(geometry_type& geom,Image32& image) const
|
|
||||||
{
|
|
||||||
typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
|
|
||||||
typedef agg::renderer_base<agg::pixfmt_rgba32> renderer_base;
|
|
||||||
typedef agg::renderer_outline_image<renderer_base, pattern_type> renderer_type;
|
|
||||||
typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
|
|
||||||
unsigned int width=image.width();
|
|
||||||
unsigned int height=image.height();
|
|
||||||
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(), width, height,width*4);
|
|
||||||
agg::pixfmt_rgba32 pixf(buf);
|
|
||||||
renderer_base ren_base(pixf);
|
|
||||||
agg::pattern_filter_bilinear_rgba8 filter;
|
|
||||||
pattern_source source(pattern_);
|
|
||||||
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(geom);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,27 +21,6 @@
|
||||||
#ifndef LINE_SYMBOLIZER_HPP
|
#ifndef LINE_SYMBOLIZER_HPP
|
||||||
#define LINE_SYMBOLIZER_HPP
|
#define LINE_SYMBOLIZER_HPP
|
||||||
|
|
||||||
#include "agg_basics.h"
|
|
||||||
#include "agg_rendering_buffer.h"
|
|
||||||
#include "agg_rasterizer_scanline_aa.h"
|
|
||||||
#include "agg_conv_stroke.h"
|
|
||||||
#include "agg_conv_dash.h"
|
|
||||||
#include "agg_conv_contour.h"
|
|
||||||
#include "agg_vcgen_stroke.h"
|
|
||||||
#include "agg_conv_adaptor_vcgen.h"
|
|
||||||
#include "agg_conv_smooth_poly1.h"
|
|
||||||
#include "agg_conv_marker.h"
|
|
||||||
#include "agg_arrowhead.h"
|
|
||||||
#include "agg_vcgen_markers_term.h"
|
|
||||||
#include "agg_scanline_p.h"
|
|
||||||
#include "agg_scanline_u.h"
|
|
||||||
#include "agg_renderer_scanline.h"
|
|
||||||
#include "agg_pixfmt_rgba.h"
|
|
||||||
#include "agg_path_storage.h"
|
|
||||||
#include "agg_renderer_outline_aa.h"
|
|
||||||
#include "agg_rasterizer_outline_aa.h"
|
|
||||||
#include "agg_rasterizer_outline.h"
|
|
||||||
#include "agg_renderer_outline_image.h"
|
|
||||||
|
|
||||||
#include "symbolizer.hpp"
|
#include "symbolizer.hpp"
|
||||||
#include "stroke.hpp"
|
#include "stroke.hpp"
|
||||||
|
@ -53,124 +32,11 @@ namespace mapnik
|
||||||
struct line_symbolizer : public symbolizer,
|
struct line_symbolizer : public symbolizer,
|
||||||
private boost::noncopyable
|
private boost::noncopyable
|
||||||
{
|
{
|
||||||
|
line_symbolizer(stroke const& stroke);
|
||||||
|
line_symbolizer(const Color& pen,float width=1.0);
|
||||||
|
void render(geometry_type& geom, Image32& image) const;
|
||||||
private:
|
private:
|
||||||
stroke stroke_;
|
stroke stroke_;
|
||||||
public:
|
|
||||||
|
|
||||||
line_symbolizer(stroke const& stroke)
|
|
||||||
: symbolizer(),
|
|
||||||
stroke_(stroke) {}
|
|
||||||
|
|
||||||
line_symbolizer(const Color& pen,float width=1.0)
|
|
||||||
: symbolizer(),
|
|
||||||
stroke_(pen,width) {}
|
|
||||||
|
|
||||||
void render(geometry_type& geom, Image32& image) const
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
|
|
||||||
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;
|
|
||||||
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);
|
|
||||||
|
|
||||||
ren_oaa.color(agg::rgba8(r, g, b, int(255*stroke_.get_opacity())));
|
|
||||||
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())
|
|
||||||
{
|
|
||||||
|
|
||||||
agg::conv_dash<geometry<vertex2d> > dash(geom);
|
|
||||||
dash_array const& d = stroke_.get_dash_array();
|
|
||||||
dash_array::const_iterator itr = d.begin();
|
|
||||||
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
|
|
||||||
{
|
|
||||||
agg::conv_stroke<geometry<vertex2d> > stroke(geom);
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,9 +34,7 @@
|
||||||
#include "comparison.hpp"
|
#include "comparison.hpp"
|
||||||
#include "regex_filter.hpp"
|
#include "regex_filter.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include "style.hpp"
|
|
||||||
#include "symbolizer.hpp"
|
#include "symbolizer.hpp"
|
||||||
#include "style_cache.hpp"
|
|
||||||
#include "geometry.hpp"
|
#include "geometry.hpp"
|
||||||
#include "geom_util.hpp"
|
#include "geom_util.hpp"
|
||||||
#include "raster.hpp"
|
#include "raster.hpp"
|
||||||
|
@ -48,8 +46,9 @@
|
||||||
#include "image_reader.hpp"
|
#include "image_reader.hpp"
|
||||||
#include "line_symbolizer.hpp"
|
#include "line_symbolizer.hpp"
|
||||||
#include "polygon_symbolizer.hpp"
|
#include "polygon_symbolizer.hpp"
|
||||||
|
#include "polygon_pattern_symbolizer.hpp"
|
||||||
#include "line_pattern_symbolizer.hpp"
|
#include "line_pattern_symbolizer.hpp"
|
||||||
//#include "image_symbolizer.hpp"
|
#include "image_symbolizer.hpp"
|
||||||
#include "image_util.hpp"
|
#include "image_util.hpp"
|
||||||
#include "datasource.hpp"
|
#include "datasource.hpp"
|
||||||
#include "layer.hpp"
|
#include "layer.hpp"
|
||||||
|
@ -57,6 +56,7 @@
|
||||||
#include "wkb.hpp"
|
#include "wkb.hpp"
|
||||||
#include "map.hpp"
|
#include "map.hpp"
|
||||||
#include "feature_type_style.hpp"
|
#include "feature_type_style.hpp"
|
||||||
|
#include "named_style_cache.hpp"
|
||||||
#include "feature_factory.hpp"
|
#include "feature_factory.hpp"
|
||||||
#include "math_expr.hpp"
|
#include "math_expr.hpp"
|
||||||
#include "value.hpp"
|
#include "value.hpp"
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#define STYLE_CACHE_HPP
|
#define STYLE_CACHE_HPP
|
||||||
|
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include "style.hpp"
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include "feature_type_style.hpp"
|
#include "feature_type_style.hpp"
|
||||||
|
|
|
@ -16,11 +16,28 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//$Id: style.cpp 17 2005-03-08 23:58:43Z pavlenko $
|
//$Id$
|
||||||
|
|
||||||
#include "style.hpp"
|
#ifndef POLYGON_PATTERN_SYMBOLIZER_HPP
|
||||||
|
#define POLYGON_PATTERN_SYMBOLIZER_HPP
|
||||||
|
|
||||||
namespace mapnik
|
#include "symbolizer.hpp"
|
||||||
|
#include <boost/utility.hpp>
|
||||||
|
|
||||||
|
namespace mapnik
|
||||||
{
|
{
|
||||||
boost::shared_ptr<symbolizer> Style::zero_symbol_ = boost::shared_ptr<symbolizer>();
|
struct polygon_pattern_symbolizer : public symbolizer,
|
||||||
|
private boost::noncopyable
|
||||||
|
{
|
||||||
|
|
||||||
|
polygon_pattern_symbolizer(std::string const& file,
|
||||||
|
std::string const& type,
|
||||||
|
unsigned width,unsigned height);
|
||||||
|
|
||||||
|
void render(geometry_type& geom,Image32& image) const;
|
||||||
|
private:
|
||||||
|
ImageData32 pattern_;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif //POLYGON_PATTERN_SYMBOLIZER_HPP
|
|
@ -22,132 +22,18 @@
|
||||||
#define POLYGON_SYMBOLIZER_HPP
|
#define POLYGON_SYMBOLIZER_HPP
|
||||||
|
|
||||||
#include "symbolizer.hpp"
|
#include "symbolizer.hpp"
|
||||||
#include "image_reader.hpp"
|
#include <boost/utility.hpp>
|
||||||
#include "agg_basics.h"
|
|
||||||
#include "agg_rendering_buffer.h"
|
|
||||||
#include "agg_rasterizer_scanline_aa.h"
|
|
||||||
#include "agg_scanline_p.h"
|
|
||||||
#include "agg_scanline_u.h"
|
|
||||||
#include "agg_renderer_scanline.h"
|
|
||||||
#include "agg_pixfmt_rgba.h"
|
|
||||||
#include "agg_path_storage.h"
|
|
||||||
#include "agg_span_allocator.h"
|
|
||||||
#include "agg_span_pattern_rgba.h"
|
|
||||||
#include "agg_image_accessors.h"
|
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
struct polygon_symbolizer : public symbolizer
|
struct polygon_symbolizer : public symbolizer,
|
||||||
|
private boost::noncopyable
|
||||||
{
|
{
|
||||||
|
polygon_symbolizer(const Color& fill);
|
||||||
|
void render(geometry_type& geom,Image32& image) const;
|
||||||
private:
|
private:
|
||||||
Color fill_;
|
Color fill_;
|
||||||
public:
|
};
|
||||||
polygon_symbolizer(const Color& fill)
|
|
||||||
: symbolizer(),
|
|
||||||
fill_(fill) {}
|
|
||||||
|
|
||||||
virtual ~polygon_symbolizer() {}
|
|
||||||
|
|
||||||
void render(geometry_type& geom,Image32& image) const
|
|
||||||
{
|
|
||||||
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
|
||||||
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);
|
|
||||||
agg::pixfmt_rgba32 pixf(buf);
|
|
||||||
ren_base renb(pixf);
|
|
||||||
|
|
||||||
unsigned r=fill_.red();
|
|
||||||
unsigned g=fill_.green();
|
|
||||||
unsigned b=fill_.blue();
|
|
||||||
unsigned a=fill_.alpha();
|
|
||||||
renderer ren(renb);
|
|
||||||
|
|
||||||
agg::rasterizer_scanline_aa<> ras;
|
|
||||||
agg::scanline_u8 sl;
|
|
||||||
ras.clip_box(0,0,image.width(),image.height());
|
|
||||||
ras.add_path(geom);
|
|
||||||
ren.color(agg::rgba8(r, g, b, a));
|
|
||||||
agg::render_scanlines(ras, sl, ren);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
polygon_symbolizer(const polygon_symbolizer&);
|
|
||||||
polygon_symbolizer& operator=(const polygon_symbolizer&);
|
|
||||||
};
|
|
||||||
|
|
||||||
struct pattern_symbolizer : public symbolizer
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
ImageData32 pattern_;
|
|
||||||
public:
|
|
||||||
pattern_symbolizer(std::string const& file,
|
|
||||||
std::string const& type,
|
|
||||||
unsigned width,unsigned height)
|
|
||||||
: symbolizer(),
|
|
||||||
pattern_(width,height)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
std::auto_ptr<ImageReader> reader(get_image_reader(type,file));
|
|
||||||
reader->read(0,0,pattern_);
|
|
||||||
}
|
|
||||||
catch (...)
|
|
||||||
{
|
|
||||||
std::cerr<<"exception caught..."<<std::endl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual ~pattern_symbolizer() {}
|
|
||||||
|
|
||||||
void render(geometry_type& geom,Image32& image) const
|
|
||||||
{
|
|
||||||
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_y_type;
|
|
||||||
typedef agg::image_accessor_wrap<agg::pixfmt_rgba32,
|
|
||||||
wrap_x_type,
|
|
||||||
wrap_y_type> img_source_type;
|
|
||||||
|
|
||||||
typedef agg::span_pattern_rgba<img_source_type> span_gen_type;
|
|
||||||
|
|
||||||
typedef agg::renderer_scanline_aa<ren_base,
|
|
||||||
agg::span_allocator<agg::rgba8>,
|
|
||||||
span_gen_type> renderer_type;
|
|
||||||
|
|
||||||
double x0,y0;
|
|
||||||
geom.vertex(&x0,&y0);
|
|
||||||
geom.rewind(0);
|
|
||||||
|
|
||||||
unsigned offset_x = unsigned(image.width() - x0);
|
|
||||||
unsigned offset_y = unsigned(image.height() - y0);
|
|
||||||
|
|
||||||
agg::span_allocator<agg::rgba8> sa;
|
|
||||||
img_source_type img_src(pattern_rbuf);
|
|
||||||
span_gen_type sg(img_src, offset_x, offset_y);
|
|
||||||
renderer_type rp(renb,sa, sg);
|
|
||||||
|
|
||||||
agg::rasterizer_scanline_aa<> ras;
|
|
||||||
agg::scanline_u8 sl;
|
|
||||||
ras.clip_box(0,0,image.width(),image.height());
|
|
||||||
ras.add_path(geom);
|
|
||||||
agg::render_scanlines(ras, sl, rp);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
pattern_symbolizer(const pattern_symbolizer&);
|
|
||||||
pattern_symbolizer& operator=(const pattern_symbolizer&);
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // POLYGON_SYMBOLIZER_HPP
|
#endif // POLYGON_SYMBOLIZER_HPP
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#define RENDER_HPP
|
#define RENDER_HPP
|
||||||
|
|
||||||
#include <stack>
|
#include <stack>
|
||||||
#include "style.hpp"
|
|
||||||
#include "envelope.hpp"
|
#include "envelope.hpp"
|
||||||
#include "graphics.hpp"
|
#include "graphics.hpp"
|
||||||
#include "datasource.hpp"
|
#include "datasource.hpp"
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#ifndef STYLE_FACTORY_HPP
|
#ifndef STYLE_FACTORY_HPP
|
||||||
#define STYLE_FACTORY_HPP
|
#define STYLE_FACTORY_HPP
|
||||||
|
|
||||||
#include "style.hpp"
|
//#include "style.hpp"
|
||||||
|
|
||||||
namespace mapnik {
|
namespace mapnik {
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include FT_FREETYPE_H
|
#include FT_FREETYPE_H
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "style.hpp"
|
|
||||||
#include "graphics.hpp"
|
#include "graphics.hpp"
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
|
|
|
@ -45,9 +45,9 @@ lib_boost_python = env.SharedLibrary('libboost-python',boost_python_src,LIBS=[],
|
||||||
|
|
||||||
env.Install(prefix + '/lib',lib_boost_python)
|
env.Install(prefix + '/lib',lib_boost_python)
|
||||||
|
|
||||||
agg_root = env['AGG_ROOT']
|
#agg_root = env['AGG_ROOT']
|
||||||
agg_headers = agg_root +'/include'
|
#agg_headers = agg_root +'/include'
|
||||||
freetype2_root = env['FREETYPE2_ROOT']
|
#freetype2_root = env['FREETYPE2_ROOT']
|
||||||
|
|
||||||
|
|
||||||
def createPythonExtBuilder(env):
|
def createPythonExtBuilder(env):
|
||||||
|
@ -91,7 +91,7 @@ mapnik_python_src=Split(
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
headers =[ '#include',boost_root,freetype2_root,agg_headers,python_headers]
|
headers =[ '#include',boost_root,python_headers]
|
||||||
|
|
||||||
libraries=['mapnik','boost-python']
|
libraries=['mapnik','boost-python']
|
||||||
libpaths = [prefix+"/lib"]
|
libpaths = [prefix+"/lib"]
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include <boost/python/detail/api_placeholder.hpp>
|
#include <boost/python/detail/api_placeholder.hpp>
|
||||||
|
|
||||||
#include "mapnik.hpp"
|
#include "mapnik.hpp"
|
||||||
#include "image_symbolizer.hpp"
|
|
||||||
|
|
||||||
using namespace mapnik;
|
using namespace mapnik;
|
||||||
|
|
||||||
|
@ -68,6 +67,11 @@ boost::shared_ptr<symbolizer> create_line_symbolizer2(stroke const& strk)
|
||||||
return boost::shared_ptr<symbolizer>(new line_symbolizer(strk));
|
return boost::shared_ptr<symbolizer>(new line_symbolizer(strk));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boost::shared_ptr<symbolizer> create_line_symbolizer3(std::string const& file,unsigned w,unsigned h)
|
||||||
|
{
|
||||||
|
return boost::shared_ptr<symbolizer>(new line_pattern_symbolizer(file,"png",w,h));
|
||||||
|
}
|
||||||
|
|
||||||
boost::shared_ptr<symbolizer> create_polygon_symbolizer(const Color& fill)
|
boost::shared_ptr<symbolizer> create_polygon_symbolizer(const Color& fill)
|
||||||
{
|
{
|
||||||
return boost::shared_ptr<symbolizer>(new polygon_symbolizer(fill));
|
return boost::shared_ptr<symbolizer>(new polygon_symbolizer(fill));
|
||||||
|
@ -75,7 +79,7 @@ boost::shared_ptr<symbolizer> create_polygon_symbolizer(const Color& fill)
|
||||||
|
|
||||||
boost::shared_ptr<symbolizer> create_polygon_symbolizer2(std::string const& file,unsigned w,unsigned h)
|
boost::shared_ptr<symbolizer> create_polygon_symbolizer2(std::string const& file,unsigned w,unsigned h)
|
||||||
{
|
{
|
||||||
return boost::shared_ptr<symbolizer>(new pattern_symbolizer(file,"png",w,h));
|
return boost::shared_ptr<symbolizer>(new polygon_pattern_symbolizer(file,"png",w,h));
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_PYTHON_MODULE(_mapnik)
|
BOOST_PYTHON_MODULE(_mapnik)
|
||||||
|
@ -117,6 +121,7 @@ BOOST_PYTHON_MODULE(_mapnik)
|
||||||
def("point_symbolizer",&create_point_symbolizer);
|
def("point_symbolizer",&create_point_symbolizer);
|
||||||
def("line_symbolizer",&create_line_symbolizer);
|
def("line_symbolizer",&create_line_symbolizer);
|
||||||
def("line_symbolizer",&create_line_symbolizer2);
|
def("line_symbolizer",&create_line_symbolizer2);
|
||||||
|
def("line_symbolizer",&create_line_symbolizer3);
|
||||||
def("polygon_symbolizer",&create_polygon_symbolizer);
|
def("polygon_symbolizer",&create_polygon_symbolizer);
|
||||||
def("polygon_symbolizer",&create_polygon_symbolizer2);
|
def("polygon_symbolizer",&create_polygon_symbolizer2);
|
||||||
register_ptr_to_python<boost::shared_ptr<symbolizer> >();
|
register_ptr_to_python<boost::shared_ptr<symbolizer> >();
|
||||||
|
|
|
@ -49,11 +49,16 @@ source = Split(
|
||||||
plugin.cpp
|
plugin.cpp
|
||||||
png_reader.cpp
|
png_reader.cpp
|
||||||
render.cpp
|
render.cpp
|
||||||
style_cache.cpp
|
named_style_cache.cpp
|
||||||
style.cpp
|
|
||||||
text.cpp
|
text.cpp
|
||||||
tiff_reader.cpp
|
tiff_reader.cpp
|
||||||
wkb.cpp"""
|
wkb.cpp
|
||||||
|
line_symbolizer.cpp
|
||||||
|
line_pattern_symbolizer.cpp
|
||||||
|
polygon_symbolizer.cpp
|
||||||
|
polygon_pattern_symbolizer.cpp
|
||||||
|
image_symbolizer.cpp
|
||||||
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
lib_mapnik = env.SharedLibrary('libmapnik',source,CPPPATH=headers,LIBS=libraries,LIBPATH=libpaths,LINKFLAGS=linkflags)
|
lib_mapnik = env.SharedLibrary('libmapnik',source,CPPPATH=headers,LIBS=libraries,LIBPATH=libpaths,LINKFLAGS=linkflags)
|
||||||
|
|
59
src/image_symbolizer.cpp
Normal file
59
src/image_symbolizer.cpp
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
|
* Copyright (C) 2005 Artem Pavlenko
|
||||||
|
*
|
||||||
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//$Id$
|
||||||
|
|
||||||
|
#include "image_symbolizer.hpp"
|
||||||
|
#include "image_data.hpp"
|
||||||
|
#include "image_reader.hpp"
|
||||||
|
|
||||||
|
namespace mapnik
|
||||||
|
{
|
||||||
|
image_symbolizer::image_symbolizer(std::string const& file,
|
||||||
|
std::string const& type,
|
||||||
|
unsigned width,unsigned height)
|
||||||
|
: symbolizer(),
|
||||||
|
symbol_(width,height)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::auto_ptr<ImageReader> reader(get_image_reader(type,file));
|
||||||
|
reader->read(0,0,symbol_);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cerr<<"exception caught..." << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void image_symbolizer::render(geometry_type& geom,Image32& image) const
|
||||||
|
{
|
||||||
|
int w=symbol_.width();
|
||||||
|
int h=symbol_.height();
|
||||||
|
double x,y;
|
||||||
|
unsigned size = geom.num_points();
|
||||||
|
for (unsigned pos = 0; pos < size ;++pos)
|
||||||
|
{
|
||||||
|
geom.vertex(&x,&y);
|
||||||
|
int px=int(x - 0.5 * w);
|
||||||
|
int py=int(y - 0.5 * h);
|
||||||
|
image.set_rectangle_alpha(px,py,symbol_);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
101
src/line_pattern_symbolizer.cpp
Normal file
101
src/line_pattern_symbolizer.cpp
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
|
* Copyright (C) 2005 Artem Pavlenko
|
||||||
|
*
|
||||||
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//$Id$
|
||||||
|
|
||||||
|
#include "line_pattern_symbolizer.hpp"
|
||||||
|
#include "image_reader.hpp"
|
||||||
|
#include "agg_basics.h"
|
||||||
|
#include "agg_rendering_buffer.h"
|
||||||
|
#include "agg_rasterizer_scanline_aa.h"
|
||||||
|
#include "agg_rasterizer_outline_aa.h"
|
||||||
|
#include "agg_scanline_p.h"
|
||||||
|
#include "agg_scanline_u.h"
|
||||||
|
#include "agg_renderer_scanline.h"
|
||||||
|
#include "agg_pixfmt_rgba.h"
|
||||||
|
#include "agg_path_storage.h"
|
||||||
|
#include "agg_span_allocator.h"
|
||||||
|
#include "agg_span_pattern_rgba.h"
|
||||||
|
#include "agg_image_accessors.h"
|
||||||
|
#include "agg_pattern_filters_rgba.h"
|
||||||
|
#include "agg_renderer_outline_image.h"
|
||||||
|
|
||||||
|
namespace mapnik
|
||||||
|
{
|
||||||
|
class pattern_source : private boost::noncopyable
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
pattern_source(ImageData32 const& pattern)
|
||||||
|
: pattern_(pattern) {}
|
||||||
|
|
||||||
|
unsigned int width() const
|
||||||
|
{
|
||||||
|
return pattern_.width();
|
||||||
|
}
|
||||||
|
unsigned int height() const
|
||||||
|
{
|
||||||
|
return pattern_.height();
|
||||||
|
}
|
||||||
|
agg::rgba8 pixel(int x, int y) const
|
||||||
|
{
|
||||||
|
unsigned c = pattern_(x,y);
|
||||||
|
return agg::rgba8(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff,(c >> 24) & 0xff);
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
ImageData32 const& pattern_;
|
||||||
|
};
|
||||||
|
|
||||||
|
line_pattern_symbolizer::line_pattern_symbolizer(std::string const& file,
|
||||||
|
std::string const& type,
|
||||||
|
unsigned width,unsigned height)
|
||||||
|
: symbolizer(),
|
||||||
|
pattern_(width,height)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::auto_ptr<ImageReader> reader(get_image_reader(type,file));
|
||||||
|
reader->read(0,0,pattern_);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cerr<<"exception caught..."<<std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void line_pattern_symbolizer::render(geometry_type& geom,Image32& image) const
|
||||||
|
{
|
||||||
|
|
||||||
|
typedef agg::line_image_pattern<agg::pattern_filter_bilinear_rgba8> pattern_type;
|
||||||
|
typedef agg::renderer_base<agg::pixfmt_rgba32> renderer_base;
|
||||||
|
typedef agg::renderer_outline_image<renderer_base, pattern_type> renderer_type;
|
||||||
|
typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
|
||||||
|
|
||||||
|
unsigned int width=image.width();
|
||||||
|
unsigned int height=image.height();
|
||||||
|
agg::row_ptr_cache<agg::int8u> buf(image.raw_data(), width, height,width*4);
|
||||||
|
agg::pixfmt_rgba32 pixf(buf);
|
||||||
|
renderer_base ren_base(pixf);
|
||||||
|
agg::pattern_filter_bilinear_rgba8 filter;
|
||||||
|
pattern_source source(pattern_);
|
||||||
|
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(geom);
|
||||||
|
}
|
||||||
|
}
|
161
src/line_symbolizer.cpp
Normal file
161
src/line_symbolizer.cpp
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
|
* Copyright (C) 2005 Artem Pavlenko
|
||||||
|
*
|
||||||
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//$Id$
|
||||||
|
|
||||||
|
#include "line_symbolizer.hpp"
|
||||||
|
|
||||||
|
#include "agg_basics.h"
|
||||||
|
#include "agg_rendering_buffer.h"
|
||||||
|
#include "agg_rasterizer_scanline_aa.h"
|
||||||
|
#include "agg_conv_stroke.h"
|
||||||
|
#include "agg_conv_dash.h"
|
||||||
|
#include "agg_conv_contour.h"
|
||||||
|
#include "agg_vcgen_stroke.h"
|
||||||
|
#include "agg_conv_adaptor_vcgen.h"
|
||||||
|
#include "agg_conv_smooth_poly1.h"
|
||||||
|
#include "agg_conv_marker.h"
|
||||||
|
#include "agg_arrowhead.h"
|
||||||
|
#include "agg_vcgen_markers_term.h"
|
||||||
|
#include "agg_scanline_p.h"
|
||||||
|
#include "agg_scanline_u.h"
|
||||||
|
#include "agg_renderer_scanline.h"
|
||||||
|
#include "agg_pixfmt_rgba.h"
|
||||||
|
#include "agg_path_storage.h"
|
||||||
|
#include "agg_renderer_outline_aa.h"
|
||||||
|
#include "agg_rasterizer_outline_aa.h"
|
||||||
|
#include "agg_rasterizer_outline.h"
|
||||||
|
#include "agg_renderer_outline_image.h"
|
||||||
|
|
||||||
|
namespace mapnik
|
||||||
|
{
|
||||||
|
line_symbolizer::line_symbolizer(stroke const& stroke)
|
||||||
|
: symbolizer(),
|
||||||
|
stroke_(stroke) {}
|
||||||
|
|
||||||
|
line_symbolizer::line_symbolizer(const Color& pen,float width)
|
||||||
|
: symbolizer(),
|
||||||
|
stroke_(pen,width) {}
|
||||||
|
|
||||||
|
void line_symbolizer::render(geometry_type& geom, Image32& image) const
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
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;
|
||||||
|
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);
|
||||||
|
|
||||||
|
ren_oaa.color(agg::rgba8(r, g, b, int(255*stroke_.get_opacity())));
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
|
||||||
|
agg::conv_dash<geometry<vertex2d> > dash(geom);
|
||||||
|
dash_array const& d = stroke_.get_dash_array();
|
||||||
|
dash_array::const_iterator itr = d.begin();
|
||||||
|
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
|
||||||
|
{
|
||||||
|
agg::conv_stroke<geometry<vertex2d> > stroke(geom);
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -59,3 +59,5 @@ namespace mapnik
|
||||||
ia >> m;
|
ia >> m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -18,8 +18,7 @@
|
||||||
|
|
||||||
//$Id: style_cache.cpp 37 2005-04-07 17:09:38Z pavlenko $
|
//$Id: style_cache.cpp 37 2005-04-07 17:09:38Z pavlenko $
|
||||||
|
|
||||||
#include "style_cache.hpp"
|
#include "named_style_cache.hpp"
|
||||||
#include "line_symbolizer.hpp"
|
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
97
src/polygon_pattern_symbolizer.cpp
Normal file
97
src/polygon_pattern_symbolizer.cpp
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
|
* Copyright (C) 2005 Artem Pavlenko
|
||||||
|
*
|
||||||
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//$Id$
|
||||||
|
|
||||||
|
#include "polygon_pattern_symbolizer.hpp"
|
||||||
|
|
||||||
|
#include "image_reader.hpp"
|
||||||
|
#include "agg_basics.h"
|
||||||
|
#include "agg_rendering_buffer.h"
|
||||||
|
#include "agg_rasterizer_scanline_aa.h"
|
||||||
|
#include "agg_scanline_p.h"
|
||||||
|
#include "agg_scanline_u.h"
|
||||||
|
#include "agg_renderer_scanline.h"
|
||||||
|
#include "agg_pixfmt_rgba.h"
|
||||||
|
#include "agg_path_storage.h"
|
||||||
|
#include "agg_span_allocator.h"
|
||||||
|
#include "agg_span_pattern_rgba.h"
|
||||||
|
#include "agg_image_accessors.h"
|
||||||
|
|
||||||
|
namespace mapnik
|
||||||
|
{
|
||||||
|
polygon_pattern_symbolizer::polygon_pattern_symbolizer(std::string const& file,
|
||||||
|
std::string const& type,
|
||||||
|
unsigned width,unsigned height)
|
||||||
|
: symbolizer(),
|
||||||
|
pattern_(width,height)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
std::auto_ptr<ImageReader> reader(get_image_reader(type,file));
|
||||||
|
reader->read(0,0,pattern_);
|
||||||
|
}
|
||||||
|
catch (...)
|
||||||
|
{
|
||||||
|
std::cerr<<"exception caught..."<<std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void polygon_pattern_symbolizer::render(geometry_type& geom,Image32& image) const
|
||||||
|
{
|
||||||
|
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_y_type;
|
||||||
|
typedef agg::image_accessor_wrap<agg::pixfmt_rgba32,
|
||||||
|
wrap_x_type,
|
||||||
|
wrap_y_type> img_source_type;
|
||||||
|
|
||||||
|
typedef agg::span_pattern_rgba<img_source_type> span_gen_type;
|
||||||
|
|
||||||
|
typedef agg::renderer_scanline_aa<ren_base,
|
||||||
|
agg::span_allocator<agg::rgba8>,
|
||||||
|
span_gen_type> renderer_type;
|
||||||
|
|
||||||
|
double x0,y0;
|
||||||
|
geom.vertex(&x0,&y0);
|
||||||
|
geom.rewind(0);
|
||||||
|
|
||||||
|
unsigned offset_x = unsigned(image.width() - x0);
|
||||||
|
unsigned offset_y = unsigned(image.height() - y0);
|
||||||
|
|
||||||
|
agg::span_allocator<agg::rgba8> sa;
|
||||||
|
img_source_type img_src(pattern_rbuf);
|
||||||
|
span_gen_type sg(img_src, offset_x, offset_y);
|
||||||
|
renderer_type rp(renb,sa, sg);
|
||||||
|
|
||||||
|
agg::rasterizer_scanline_aa<> ras;
|
||||||
|
agg::scanline_u8 sl;
|
||||||
|
ras.clip_box(0,0,image.width(),image.height());
|
||||||
|
ras.add_path(geom);
|
||||||
|
agg::render_scanlines(ras, sl, rp);
|
||||||
|
}
|
||||||
|
}
|
63
src/polygon_symbolizer.cpp
Normal file
63
src/polygon_symbolizer.cpp
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
/* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
|
* Copyright (C) 2005 Artem Pavlenko
|
||||||
|
*
|
||||||
|
* Mapnik is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
//$Id$
|
||||||
|
|
||||||
|
#include "polygon_symbolizer.hpp"
|
||||||
|
|
||||||
|
#include "agg_basics.h"
|
||||||
|
#include "agg_rendering_buffer.h"
|
||||||
|
#include "agg_rasterizer_scanline_aa.h"
|
||||||
|
#include "agg_scanline_p.h"
|
||||||
|
#include "agg_scanline_u.h"
|
||||||
|
#include "agg_renderer_scanline.h"
|
||||||
|
#include "agg_pixfmt_rgba.h"
|
||||||
|
#include "agg_path_storage.h"
|
||||||
|
#include "agg_span_allocator.h"
|
||||||
|
#include "agg_span_pattern_rgba.h"
|
||||||
|
#include "agg_image_accessors.h"
|
||||||
|
|
||||||
|
namespace mapnik
|
||||||
|
{
|
||||||
|
polygon_symbolizer::polygon_symbolizer(const Color& fill)
|
||||||
|
: symbolizer(),
|
||||||
|
fill_(fill) {}
|
||||||
|
|
||||||
|
void polygon_symbolizer::render(geometry_type& geom,Image32& image) const
|
||||||
|
{
|
||||||
|
typedef agg::renderer_base<agg::pixfmt_rgba32> ren_base;
|
||||||
|
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);
|
||||||
|
agg::pixfmt_rgba32 pixf(buf);
|
||||||
|
ren_base renb(pixf);
|
||||||
|
|
||||||
|
unsigned r=fill_.red();
|
||||||
|
unsigned g=fill_.green();
|
||||||
|
unsigned b=fill_.blue();
|
||||||
|
unsigned a=fill_.alpha();
|
||||||
|
renderer ren(renb);
|
||||||
|
|
||||||
|
agg::rasterizer_scanline_aa<> ras;
|
||||||
|
agg::scanline_u8 sl;
|
||||||
|
ras.clip_box(0,0,image.width(),image.height());
|
||||||
|
ras.add_path(geom);
|
||||||
|
ren.color(agg::rgba8(r, g, b, a));
|
||||||
|
agg::render_scanlines(ras, sl, ren);
|
||||||
|
}
|
||||||
|
}
|
|
@ -21,7 +21,7 @@
|
||||||
#include "render.hpp"
|
#include "render.hpp"
|
||||||
#include "image_util.hpp"
|
#include "image_util.hpp"
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
#include "style_cache.hpp"
|
#include "named_style_cache.hpp"
|
||||||
#include "symbolizer.hpp"
|
#include "symbolizer.hpp"
|
||||||
#include "query.hpp"
|
#include "query.hpp"
|
||||||
#include "feature_layer_desc.hpp"
|
#include "feature_layer_desc.hpp"
|
||||||
|
|
Loading…
Reference in a new issue