diff --git a/bindings/python/mapnik_point_symbolizer.cpp b/bindings/python/mapnik_point_symbolizer.cpp index 25d4a0c74..66ff27a15 100644 --- a/bindings/python/mapnik_point_symbolizer.cpp +++ b/bindings/python/mapnik_point_symbolizer.cpp @@ -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) ; } diff --git a/include/mapnik/point_symbolizer.hpp b/include/mapnik/point_symbolizer.hpp index 1ac2c24fe..d6fc15db6 100644 --- a/include/mapnik/point_symbolizer.hpp +++ b/include/mapnik/point_symbolizer.hpp @@ -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_; }; } diff --git a/src/agg_renderer.cpp b/src/agg_renderer.cpp index 80e7e22fb..83b3f67e6 100644 --- a/src/agg_renderer.cpp +++ b/src/agg_renderer.cpp @@ -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); } } diff --git a/src/load_map.cpp b/src/load_map.cpp index 30c539618..0817cfa8a 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -524,6 +524,8 @@ namespace mapnik optional type = get_opt_attr(sym, "type"); optional allow_overlap = get_opt_attr(sym, "allow_overlap"); + optional opacity = + get_opt_attr(sym, "opacity"); optional width = get_opt_attr(sym, "width"); optional height = get_opt_attr(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 ) diff --git a/src/point_symbolizer.cpp b/src/point_symbolizer.cpp index d9aee8ea2..cdb181f5f 100644 --- a/src/point_symbolizer.cpp +++ b/src/point_symbolizer.cpp @@ -35,7 +35,8 @@ namespace mapnik { point_symbolizer::point_symbolizer() : symbolizer_with_image(boost::shared_ptr(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)