remove filter_factor as option to gdal datasource, clean up pass down from query object - closes #1488 - refs #625
This commit is contained in:
parent
a6a16304cc
commit
032e33cc9f
6 changed files with 23 additions and 69 deletions
|
@ -107,8 +107,11 @@ private:
|
|||
|
||||
struct symbolizer_attributes : public boost::static_visitor<>
|
||||
{
|
||||
symbolizer_attributes(std::set<std::string>& names)
|
||||
: names_(names), f_attr(names) {}
|
||||
symbolizer_attributes(std::set<std::string>& names,
|
||||
double & filter_factor)
|
||||
: names_(names),
|
||||
filter_factor_(filter_factor),
|
||||
f_attr(names) {}
|
||||
|
||||
template <typename T>
|
||||
void operator () (T const&) const {}
|
||||
|
@ -217,10 +220,15 @@ struct symbolizer_attributes : public boost::static_visitor<>
|
|||
}
|
||||
collect_transform(sym.get_transform());
|
||||
}
|
||||
// TODO - support remaining syms
|
||||
|
||||
void operator () (raster_symbolizer const& sym)
|
||||
{
|
||||
filter_factor_ = sym.calculate_filter_factor();
|
||||
}
|
||||
|
||||
private:
|
||||
std::set<std::string>& names_;
|
||||
double & filter_factor_;
|
||||
expression_attributes<std::set<std::string> > f_attr;
|
||||
void collect_transform(transform_list_ptr const& trans_expr)
|
||||
{
|
||||
|
@ -236,18 +244,20 @@ class attribute_collector : public mapnik::noncopyable
|
|||
{
|
||||
private:
|
||||
std::set<std::string>& names_;
|
||||
double filter_factor_;
|
||||
expression_attributes<std::set<std::string> > f_attr;
|
||||
public:
|
||||
|
||||
attribute_collector(std::set<std::string>& names)
|
||||
: names_(names), f_attr(names) {}
|
||||
|
||||
: names_(names),
|
||||
filter_factor_(1.0),
|
||||
f_attr(names) {}
|
||||
template <typename RuleType>
|
||||
void operator() (RuleType const& r)
|
||||
{
|
||||
typename RuleType::symbolizers const& symbols = r.get_symbolizers();
|
||||
typename RuleType::symbolizers::const_iterator symIter=symbols.begin();
|
||||
symbolizer_attributes s_attr(names_);
|
||||
symbolizer_attributes s_attr(names_,filter_factor_);
|
||||
while (symIter != symbols.end())
|
||||
{
|
||||
boost::apply_visitor(s_attr,*symIter++);
|
||||
|
@ -256,22 +266,11 @@ public:
|
|||
expression_ptr const& expr = r.get_filter();
|
||||
boost::apply_visitor(f_attr,*expr);
|
||||
}
|
||||
};
|
||||
|
||||
struct directive_collector : public boost::static_visitor<>
|
||||
{
|
||||
directive_collector(double & filter_factor)
|
||||
: filter_factor_(filter_factor) {}
|
||||
|
||||
template <typename T>
|
||||
void operator () (T const&) const {}
|
||||
|
||||
void operator () (raster_symbolizer const& sym)
|
||||
double get_filter_factor() const
|
||||
{
|
||||
filter_factor_ = sym.calculate_filter_factor();
|
||||
return filter_factor_;
|
||||
}
|
||||
private:
|
||||
double & filter_factor_;
|
||||
};
|
||||
|
||||
} // namespace mapnik
|
||||
|
|
|
@ -353,8 +353,6 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
|||
query q(layer_ext,res,scale_denom,extent);
|
||||
std::vector<feature_type_style const*> active_styles;
|
||||
attribute_collector collector(names);
|
||||
double filt_factor = 1.0;
|
||||
directive_collector d_collector(filt_factor);
|
||||
boost::ptr_vector<rule_cache> rule_caches;
|
||||
|
||||
// iterate through all named styles collecting active styles and attribute names
|
||||
|
@ -379,11 +377,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
|||
{
|
||||
rc->add_rule(r);
|
||||
active_rules = true;
|
||||
if (ds->type() == datasource::Vector)
|
||||
{
|
||||
collector(r);
|
||||
}
|
||||
// TODO - in the future rasters should be able to be filtered.
|
||||
collector(r);
|
||||
}
|
||||
}
|
||||
if (active_rules)
|
||||
|
@ -411,26 +405,7 @@ void feature_style_processor<Processor>::apply_to_layer(layer const& lay, Proces
|
|||
q.add_property_name(name);
|
||||
}
|
||||
}
|
||||
|
||||
// Update filter_factor for all enabled raster layers.
|
||||
BOOST_FOREACH (feature_type_style const* style, active_styles)
|
||||
{
|
||||
BOOST_FOREACH(rule const& r, style->get_rules())
|
||||
{
|
||||
if (r.active(scale_denom) &&
|
||||
ds->type() == datasource::Raster &&
|
||||
ds->params().get<double>("filter_factor",0.0) == 0.0)
|
||||
{
|
||||
BOOST_FOREACH (rule::symbolizers::value_type sym, r.get_symbolizers())
|
||||
{
|
||||
// if multiple raster symbolizers, last will be respected
|
||||
// should we warn or throw?
|
||||
boost::apply_visitor(d_collector,sym);
|
||||
}
|
||||
q.set_filter_factor(filt_factor);
|
||||
}
|
||||
}
|
||||
}
|
||||
q.set_filter_factor(collector.get_filter_factor());
|
||||
|
||||
// Also query the group by attribute
|
||||
std::string const& group_by = lay.group_by();
|
||||
|
|
|
@ -77,7 +77,6 @@ inline GDALDataset* gdal_datasource::open_dataset() const
|
|||
gdal_datasource::gdal_datasource(parameters const& params)
|
||||
: datasource(params),
|
||||
desc_(*params.get<std::string>("type"), "utf-8"),
|
||||
filter_factor_(*params.get<double>("filter_factor", 0.0)),
|
||||
nodata_value_(params.get<double>("nodata"))
|
||||
{
|
||||
MAPNIK_LOG_DEBUG(gdal) << "gdal_datasource: Initializing...";
|
||||
|
@ -228,7 +227,6 @@ featureset_ptr gdal_datasource::features(query const& q) const
|
|||
nbands_,
|
||||
dx_,
|
||||
dy_,
|
||||
filter_factor_,
|
||||
nodata_value_));
|
||||
}
|
||||
|
||||
|
@ -250,6 +248,5 @@ featureset_ptr gdal_datasource::features_at_point(coord2d const& pt, double tol)
|
|||
nbands_,
|
||||
dx_,
|
||||
dy_,
|
||||
filter_factor_,
|
||||
nodata_value_));
|
||||
}
|
||||
|
|
|
@ -66,7 +66,6 @@ private:
|
|||
double dy_;
|
||||
int nbands_;
|
||||
bool shared_dataset_;
|
||||
double filter_factor_;
|
||||
boost::optional<double> nodata_value_;
|
||||
};
|
||||
|
||||
|
|
|
@ -61,7 +61,6 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset,
|
|||
int nbands,
|
||||
double dx,
|
||||
double dy,
|
||||
double filter_factor,
|
||||
boost::optional<double> const& nodata)
|
||||
: dataset_(dataset),
|
||||
ctx_(boost::make_shared<mapnik::context_type>()),
|
||||
|
@ -73,7 +72,6 @@ gdal_featureset::gdal_featureset(GDALDataset& dataset,
|
|||
dx_(dx),
|
||||
dy_(dy),
|
||||
nbands_(nbands),
|
||||
filter_factor_(filter_factor),
|
||||
nodata_value_(nodata),
|
||||
first_(true)
|
||||
{
|
||||
|
@ -203,21 +201,9 @@ feature_ptr gdal_featureset::get_feature(mapnik::query const& q)
|
|||
int im_width = int(width_res * intersect.width() + 0.5);
|
||||
int im_height = int(height_res * intersect.height() + 0.5);
|
||||
|
||||
// if layer-level filter_factor is set, apply it
|
||||
if (filter_factor_)
|
||||
{
|
||||
im_width = int(im_width * filter_factor_ + 0.5);
|
||||
im_height = int(im_height * filter_factor_ + 0.5);
|
||||
|
||||
MAPNIK_LOG_DEBUG(gdal) << "gdal_featureset: Applying layer filter_factor=" << filter_factor_;
|
||||
}
|
||||
// otherwise respect symbolizer level factor applied to query, default of 1.0
|
||||
else
|
||||
{
|
||||
double sym_downsample_factor = q.get_filter_factor();
|
||||
im_width = int(im_width * sym_downsample_factor + 0.5);
|
||||
im_height = int(im_height * sym_downsample_factor + 0.5);
|
||||
}
|
||||
double sym_downsample_factor = q.get_filter_factor();
|
||||
im_width = int(im_width * sym_downsample_factor + 0.5);
|
||||
im_height = int(im_height * sym_downsample_factor + 0.5);
|
||||
|
||||
// case where we need to avoid upsampling so that the
|
||||
// image can be later scaled within raster_symbolizer
|
||||
|
|
|
@ -49,7 +49,6 @@ public:
|
|||
int nbands,
|
||||
double dx,
|
||||
double dy,
|
||||
double filter_factor,
|
||||
boost::optional<double> const& nodata);
|
||||
virtual ~gdal_featureset();
|
||||
mapnik::feature_ptr next();
|
||||
|
@ -72,7 +71,6 @@ private:
|
|||
double dx_;
|
||||
double dy_;
|
||||
int nbands_;
|
||||
double filter_factor_;
|
||||
boost::optional<double> nodata_value_;
|
||||
bool first_;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue