add gamma to polygon-pattern-symbolizer, useful for avoiding AA affects at tile edges so that global patterns can have seamless alignment
This commit is contained in:
parent
4dde8e8d9e
commit
476e04c4c7
6 changed files with 40 additions and 7 deletions
|
@ -62,23 +62,24 @@ struct polygon_pattern_symbolizer_pickle_suite : boost::python::pickle_suite
|
||||||
static boost::python::tuple
|
static boost::python::tuple
|
||||||
getstate(const polygon_pattern_symbolizer& p)
|
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
|
static void
|
||||||
setstate (polygon_pattern_symbolizer& p, boost::python::tuple state)
|
setstate (polygon_pattern_symbolizer& p, boost::python::tuple state)
|
||||||
{
|
{
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
if (len(state) != 1)
|
if (len(state) != 2)
|
||||||
{
|
{
|
||||||
PyErr_SetObject(PyExc_ValueError,
|
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()
|
% state).ptr()
|
||||||
);
|
);
|
||||||
throw_error_already_set();
|
throw_error_already_set();
|
||||||
}
|
}
|
||||||
|
|
||||||
p.set_alignment(extract<pattern_alignment_e>(state[0]));
|
p.set_alignment(extract<pattern_alignment_e>(state[0]));
|
||||||
|
p.set_gamma(extract<float>(state[1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -105,5 +106,8 @@ void export_polygon_pattern_symbolizer()
|
||||||
.add_property("filename",
|
.add_property("filename",
|
||||||
&get_filename,
|
&get_filename,
|
||||||
&set_filename)
|
&set_filename)
|
||||||
|
.add_property("gamma",
|
||||||
|
&polygon_pattern_symbolizer::get_gamma,
|
||||||
|
&polygon_pattern_symbolizer::set_gamma)
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,12 @@ struct MAPNIK_DECL polygon_pattern_symbolizer :
|
||||||
polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs);
|
polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs);
|
||||||
pattern_alignment_e get_alignment() const;
|
pattern_alignment_e get_alignment() const;
|
||||||
void set_alignment(pattern_alignment_e align);
|
void set_alignment(pattern_alignment_e align);
|
||||||
|
void set_gamma(double gamma);
|
||||||
|
double get_gamma() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
pattern_alignment_e alignment_;
|
pattern_alignment_e alignment_;
|
||||||
|
double gamma_;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
||||||
|
|
||||||
agg::scanline_u8 sl;
|
agg::scanline_u8 sl;
|
||||||
ras_ptr->reset();
|
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);
|
std::string filename = path_processor_type::evaluate( *sym.get_filename(), feature);
|
||||||
boost::optional<mapnik::marker_ptr> marker;
|
boost::optional<mapnik::marker_ptr> marker;
|
||||||
|
@ -78,8 +78,13 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
||||||
{
|
{
|
||||||
marker = marker_cache::instance()->find(filename, true);
|
marker = marker_cache::instance()->find(filename, true);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::clog << "### Warning: file not found: " << filename << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
if (!marker || !(*marker)->is_bitmap()) return;
|
if (!marker || !(*marker)->is_bitmap()) return;
|
||||||
|
|
||||||
|
|
||||||
boost::optional<image_ptr> pat = (*marker)->get_bitmap_data();
|
boost::optional<image_ptr> pat = (*marker)->get_bitmap_data();
|
||||||
|
|
||||||
|
|
|
@ -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,
|
void map_parser::parse_polygon_pattern_symbolizer( rule & rule,
|
||||||
ptree const & sym )
|
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
|
try
|
||||||
{
|
{
|
||||||
std::string file = get_attr<std::string>(sym, "file");
|
std::string file = get_attr<std::string>(sym, "file");
|
||||||
|
@ -1164,6 +1164,10 @@ void map_parser::parse_polygon_pattern_symbolizer( rule & rule,
|
||||||
pattern_alignment_e p_alignment = get_attr<pattern_alignment_e>(sym, "alignment",LOCAL_ALIGNMENT);
|
pattern_alignment_e p_alignment = get_attr<pattern_alignment_e>(sym, "alignment",LOCAL_ALIGNMENT);
|
||||||
symbol.set_alignment(p_alignment);
|
symbol.set_alignment(p_alignment);
|
||||||
|
|
||||||
|
// gamma
|
||||||
|
optional<double> gamma = get_opt_attr<double>(sym, "gamma");
|
||||||
|
if (gamma) symbol.set_gamma(*gamma);
|
||||||
|
|
||||||
parse_metawriter_in_symbolizer(symbol, sym);
|
parse_metawriter_in_symbolizer(symbol, sym);
|
||||||
rule.append(symbol);
|
rule.append(symbol);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,11 +37,13 @@ IMPLEMENT_ENUM( pattern_alignment_e, pattern_alignment_strings )
|
||||||
|
|
||||||
polygon_pattern_symbolizer::polygon_pattern_symbolizer(path_expression_ptr file)
|
polygon_pattern_symbolizer::polygon_pattern_symbolizer(path_expression_ptr file)
|
||||||
: symbolizer_with_image(file), symbolizer_base(),
|
: 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)
|
polygon_pattern_symbolizer::polygon_pattern_symbolizer(polygon_pattern_symbolizer const& rhs)
|
||||||
: symbolizer_with_image(rhs), symbolizer_base(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
|
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;
|
alignment_ = align;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double polygon_pattern_symbolizer::get_gamma() const
|
||||||
|
{
|
||||||
|
return gamma_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void polygon_pattern_symbolizer::set_gamma(double gamma)
|
||||||
|
{
|
||||||
|
gamma_ = gamma;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -127,6 +127,11 @@ public:
|
||||||
set_attr( sym_node, "alignment", sym.get_alignment() );
|
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_image_attributes( sym_node, sym );
|
||||||
add_metawriter_attributes(sym_node, sym);
|
add_metawriter_attributes(sym_node, sym);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue