+ add filter_factor on mapnik::query and allow setting of factor for image scaling modes which demand high quality resampling - bilinear requires 2x, others in future like lanzcos may require 3-4x - addresses #563

This commit is contained in:
Dane Springmeyer 2010-06-20 04:01:59 +00:00
parent 74850a4839
commit 182628e3ab
2 changed files with 49 additions and 3 deletions

View file

@ -180,7 +180,11 @@ private:
{
active_rules=true;
// collect unique attribute names
collector(*ruleIter);
// TODO - in the future rasters should be able to be filtered...
if (ds->type() == datasource::Vector)
{
collector(*ruleIter);
}
if (ruleIter->has_else_filter())
{
else_rules.push_back(const_cast<rule_type*>(&(*ruleIter)));
@ -189,6 +193,34 @@ private:
{
if_rules.push_back(const_cast<rule_type*>(&(*ruleIter)));
}
if (ds->type() == datasource::Raster)
{
if (ds->params().get<double>("filter_factor",0.0) == 0.0)
{
const rule_type::symbolizers& symbols = ruleIter->get_symbolizers();
rule_type::symbolizers::const_iterator symIter = symbols.begin();
rule_type::symbolizers::const_iterator symEnd = symbols.end();
for (;symIter != symEnd;++symIter)
{
try
{
raster_symbolizer sym = boost::get<raster_symbolizer>(*symIter);
std::string scaling = sym.get_scaling();
if (scaling == "bilinear" || scaling == "bilinear8" )
{
// todo - allow setting custom value in symbolizer property?
q.filter_factor(2.0);
}
}
catch (const boost::bad_get &v)
{
// case where useless symbolizer is attached to raster layer
//throw config_error("Invalid Symbolizer type supplied, only RasterSymbolizer is supported");
}
}
}
}
}
}
std::set<std::string>::const_iterator namesIter=names.begin();

View file

@ -46,19 +46,22 @@ private:
box2d<double> bbox_;
resolution_type resolution_;
double scale_denominator_;
double filter_factor_;
std::set<std::string> names_;
public:
query(box2d<double> const& bbox, resolution_type const& resolution, double scale_denominator = 1.0)
: bbox_(bbox),
resolution_(resolution),
scale_denominator_(scale_denominator)
scale_denominator_(scale_denominator),
filter_factor_(1.0)
{}
query(query const& other)
: bbox_(other.bbox_),
resolution_(other.resolution_),
scale_denominator_(other.scale_denominator_),
filter_factor_(other.filter_factor_),
names_(other.names_)
{}
@ -68,6 +71,7 @@ public:
bbox_=other.bbox_;
resolution_=other.resolution_;
scale_denominator_=other.scale_denominator_;
filter_factor_=other.filter_factor_;
names_=other.names_;
return *this;
}
@ -86,7 +90,17 @@ public:
{
return bbox_;
}
double get_filter_factor() const
{
return filter_factor_;
}
void filter_factor(double factor)
{
filter_factor_ = factor;
}
void add_property_name(std::string const& name)
{
names_.insert(name);