diff --git a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp index cf9009781..99ecb13d5 100644 --- a/bindings/python/mapnik_polygon_pattern_symbolizer.cpp +++ b/bindings/python/mapnik_polygon_pattern_symbolizer.cpp @@ -62,23 +62,24 @@ struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite static boost::python::tuple getstate(const polygon_pattern_symbolizer& p) { - return boost::python::make_tuple(p.get_alignment()); + return boost::python::make_tuple(p.get_alignment(),p.get_gamma()); } static void setstate (polygon_pattern_symbolizer& p, boost::python::tuple state) { using namespace boost::python; - if (len(state) != 1) + if (len(state) != 2) { PyErr_SetObject(PyExc_ValueError, - ("expected 1-item tuple in call to __setstate__; got %s" + ("expected 2-item tuple in call to __setstate__; got %s" % state).ptr() ); throw_error_already_set(); } p.set_alignment(extract(state[0])); + p.set_gamma(extract(state[1])); } }; @@ -105,5 +106,8 @@ void export_polygon_pattern_symbolizer() .add_property("filename", &get_filename, &set_filename) + .add_property("gamma", + &polygon_pattern_symbolizer::get_gamma, + &polygon_pattern_symbolizer::set_gamma) ; } diff --git a/include/mapnik/polygon_pattern_symbolizer.hpp b/include/mapnik/polygon_pattern_symbolizer.hpp index a8f3d73b6..0c389e36d 100644 --- a/include/mapnik/polygon_pattern_symbolizer.hpp +++ b/include/mapnik/polygon_pattern_symbolizer.hpp @@ -47,9 +47,12 @@ struct MAPNIK_DECL polygon_pattern_symbolizer : polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs); pattern_alignment_e get_alignment() const; void set_alignment(pattern_alignment_e align); + void set_gamma(double gamma); + double get_gamma() const; private: pattern_alignment_e alignment_; + double gamma_; }; } diff --git a/src/agg/process_polygon_pattern_symbolizer.cpp b/src/agg/process_polygon_pattern_symbolizer.cpp index f7d73c085..ebd87f621 100644 --- a/src/agg/process_polygon_pattern_symbolizer.cpp +++ b/src/agg/process_polygon_pattern_symbolizer.cpp @@ -70,7 +70,7 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, agg::scanline_u8 sl; ras_ptr->reset(); - ras_ptr->gamma(agg::gamma_linear()); + ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma())); std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature); boost::optional marker; @@ -78,8 +78,13 @@ void agg_renderer::process(polygon_pattern_symbolizer const& sym, { marker = marker_cache::instance()->find(filename, true); } + else + { + std::clog << "### Warning: file not found: " << filename << "\n"; + } if (!marker || !(*marker)->is_bitmap()) return; + boost::optional pat = (*marker)->get_bitmap_data(); diff --git a/src/load_map.cpp b/src/load_map.cpp index daf89f2da..d68ebfb25 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -1139,7 +1139,7 @@ void map_parser::parse_line_pattern_symbolizer( rule & rule, ptree const & sym ) void map_parser::parse_polygon_pattern_symbolizer( rule & rule, ptree const & sym ) { - ensure_attrs(sym, "PolygonPatternSymbolizer", "file,base,alignment,meta-writer,meta-output"); + ensure_attrs(sym, "PolygonPatternSymbolizer", "file,base,alignment,gamma,meta-writer,meta-output"); try { std::string file = get_attr(sym, "file"); @@ -1164,6 +1164,10 @@ void map_parser::parse_polygon_pattern_symbolizer( rule & rule, pattern_alignment_e p_alignment = get_attr(sym, "alignment",LOCAL_ALIGNMENT); symbol.set_alignment(p_alignment); + // gamma + optional gamma = get_opt_attr(sym, "gamma"); + if (gamma) symbol.set_gamma(*gamma); + parse_metawriter_in_symbolizer(symbol, sym); rule.append(symbol); } diff --git a/src/polygon_pattern_symbolizer.cpp b/src/polygon_pattern_symbolizer.cpp index 6af6506e8..4519670b6 100644 --- a/src/polygon_pattern_symbolizer.cpp +++ b/src/polygon_pattern_symbolizer.cpp @@ -37,11 +37,13 @@ IMPLEMENT_ENUM( pattern_alignment_e, pattern_alignment_strings ) polygon_pattern_symbolizer::polygon_pattern_symbolizer(path_expression_ptr file) : symbolizer_with_image(file), symbolizer_base(), - alignment_(LOCAL_ALIGNMENT) {} + alignment_(LOCAL_ALIGNMENT), + gamma_(1.0) {} polygon_pattern_symbolizer::polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs) : symbolizer_with_image(rhs), symbolizer_base(rhs), - alignment_(rhs.alignment_) {} + alignment_(rhs.alignment_), + gamma_(rhs.gamma_) {} pattern_alignment_e polygon_pattern_symbolizer::get_alignment() const { @@ -53,5 +55,15 @@ void polygon_pattern_symbolizer::set_alignment(pattern_alignment_e align) alignment_ = align; } +double polygon_pattern_symbolizer::get_gamma() const +{ + return gamma_; +} + +void polygon_pattern_symbolizer::set_gamma(double gamma) +{ + gamma_ = gamma; +} + } diff --git a/src/save_map.cpp b/src/save_map.cpp index 8800514c6..0534fd2a0 100644 --- a/src/save_map.cpp +++ b/src/save_map.cpp @@ -127,6 +127,11 @@ public: set_attr( sym_node, "alignment", sym.get_alignment() ); } + if ( sym.get_gamma() != dfl.get_gamma() || explicit_defaults_ ) + { + set_attr( sym_node, "gamma", sym.get_gamma() ); + } + add_image_attributes( sym_node, sym ); add_metawriter_attributes(sym_node, sym); }