+ point symbolizer opacity patch from Brian (openstreetmap@brian.quinion.co.uk)

This commit is contained in:
Artem Pavlenko 2008-09-19 08:27:32 +00:00
parent 1947a1293e
commit 565da55742
5 changed files with 25 additions and 4 deletions

View file

@ -36,5 +36,8 @@ void export_point_symbolizer()
.add_property("allow_overlap",
&point_symbolizer::get_allow_overlap,
&point_symbolizer::set_allow_overlap)
.add_property("opacity",
&point_symbolizer::get_opacity,
&point_symbolizer::set_opacity)
;
}

View file

@ -40,8 +40,17 @@ namespace mapnik
point_symbolizer(point_symbolizer const& rhs);
void set_allow_overlap(bool overlap);
bool get_allow_overlap() const;
void set_opacity(float opacity)
{
opacity_ = opacity;
}
float get_opacity() const
{
return opacity_;
}
private:
float opacity_;
bool overlap_;
};
}

View file

@ -442,7 +442,7 @@ namespace mapnik
if (sym.get_allow_overlap() ||
detector_.has_placement(label_ext))
{
pixmap_.set_rectangle_alpha(px,py,*data);
pixmap_.set_rectangle_alpha2(*data,px,py,sym.get_opacity());
detector_.insert(label_ext);
}
}

View file

@ -524,6 +524,8 @@ namespace mapnik
optional<std::string> type = get_opt_attr<string>(sym, "type");
optional<boolean> allow_overlap =
get_opt_attr<boolean>(sym, "allow_overlap");
optional<float> opacity =
get_opt_attr<float>(sym, "opacity");
optional<unsigned> width = get_opt_attr<unsigned>(sym, "width");
optional<unsigned> height = get_opt_attr<unsigned>(sym, "height");
@ -545,6 +547,10 @@ namespace mapnik
{
symbol.set_allow_overlap( * allow_overlap );
}
if (opacity)
{
symbol.set_opacity( * opacity );
}
rule.append(symbol);
}
catch (ImageReaderException const & ex )

View file

@ -35,7 +35,8 @@ namespace mapnik
{
point_symbolizer::point_symbolizer()
: symbolizer_with_image(boost::shared_ptr<ImageData32>(new ImageData32(4,4))),
overlap_(false)
overlap_(false),
opacity_(1.0)
{
//default point symbol is black 4x4px square
image_->set(0xff000000);
@ -45,12 +46,14 @@ namespace mapnik
std::string const& type,
unsigned width,unsigned height)
: symbolizer_with_image(file, type, width, height),
overlap_(false)
overlap_(false),
opacity_(1.0)
{ }
point_symbolizer::point_symbolizer(point_symbolizer const& rhs)
: symbolizer_with_image(rhs),
overlap_(rhs.overlap_)
overlap_(rhs.overlap_),
opacity_(rhs.opacity_)
{}
void point_symbolizer::set_allow_overlap(bool overlap)