Adding support for height as expression for building symbolizer
This commit is contained in:
parent
3ed2133e39
commit
8bf359451d
6 changed files with 36 additions and 11 deletions
|
@ -213,6 +213,12 @@ struct symbolizer_attributes : public boost::static_visitor<>
|
||||||
|
|
||||||
void operator () (building_symbolizer const& sym)
|
void operator () (building_symbolizer const& sym)
|
||||||
{
|
{
|
||||||
|
expression_ptr const& height_expr = sym.height();
|
||||||
|
if (height_expr)
|
||||||
|
{
|
||||||
|
expression_attributes f_attr(names_);
|
||||||
|
boost::apply_visitor(f_attr,*height_expr);
|
||||||
|
}
|
||||||
collect_metawriter(sym);
|
collect_metawriter(sym);
|
||||||
}
|
}
|
||||||
// TODO - support remaining syms
|
// TODO - support remaining syms
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
// mapnik
|
// mapnik
|
||||||
#include <mapnik/color.hpp>
|
#include <mapnik/color.hpp>
|
||||||
#include <mapnik/symbolizer.hpp>
|
#include <mapnik/symbolizer.hpp>
|
||||||
|
#include <mapnik/filter_factory.hpp>
|
||||||
|
|
||||||
namespace mapnik
|
namespace mapnik
|
||||||
{
|
{
|
||||||
|
@ -79,11 +80,10 @@ struct MAPNIK_DECL building_symbolizer : public symbolizer_base
|
||||||
explicit building_symbolizer()
|
explicit building_symbolizer()
|
||||||
: symbolizer_base(),
|
: symbolizer_base(),
|
||||||
fill_(color(128,128,128)),
|
fill_(color(128,128,128)),
|
||||||
height_(0.0),
|
|
||||||
opacity_(1.0)
|
opacity_(1.0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
building_symbolizer(color const& fill,double height)
|
building_symbolizer(color const& fill, expression_ptr height)
|
||||||
: symbolizer_base(),
|
: symbolizer_base(),
|
||||||
fill_(fill),
|
fill_(fill),
|
||||||
height_(height),
|
height_(height),
|
||||||
|
@ -97,11 +97,11 @@ struct MAPNIK_DECL building_symbolizer : public symbolizer_base
|
||||||
{
|
{
|
||||||
fill_ = fill;
|
fill_ = fill;
|
||||||
}
|
}
|
||||||
double height() const
|
expression_ptr height() const
|
||||||
{
|
{
|
||||||
return height_;
|
return height_;
|
||||||
}
|
}
|
||||||
void set_height(double height)
|
void set_height(expression_ptr height)
|
||||||
{
|
{
|
||||||
height_=height;
|
height_=height;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ struct MAPNIK_DECL building_symbolizer : public symbolizer_base
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
color fill_;
|
color fill_;
|
||||||
double height_;
|
expression_ptr height_;
|
||||||
double opacity_;
|
double opacity_;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <mapnik/agg_renderer.hpp>
|
#include <mapnik/agg_renderer.hpp>
|
||||||
#include <mapnik/agg_rasterizer.hpp>
|
#include <mapnik/agg_rasterizer.hpp>
|
||||||
#include <mapnik/segment.hpp>
|
#include <mapnik/segment.hpp>
|
||||||
|
#include <mapnik/expression_evaluator.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
@ -66,7 +67,13 @@ void agg_renderer<T>::process(building_symbolizer const& sym,
|
||||||
ras_ptr->reset();
|
ras_ptr->reset();
|
||||||
ras_ptr->gamma(agg::gamma_linear());
|
ras_ptr->gamma(agg::gamma_linear());
|
||||||
|
|
||||||
double height = sym.height() * scale_factor_;
|
double height = 0.0;
|
||||||
|
expression_ptr height_expr = sym.height();
|
||||||
|
if (height_expr)
|
||||||
|
{
|
||||||
|
value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr);
|
||||||
|
height = result.to_double() * scale_factor_;
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i=0;i<feature.num_geometries();++i)
|
for (unsigned i=0;i<feature.num_geometries();++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -779,7 +779,13 @@ void cairo_renderer_base::process(building_symbolizer const& sym,
|
||||||
cairo_context context(context_);
|
cairo_context context(context_);
|
||||||
|
|
||||||
color const& fill = sym.get_fill();
|
color const& fill = sym.get_fill();
|
||||||
double height = 0.7071 * sym.height(); // height in meters
|
double height = 0.0;
|
||||||
|
expression_ptr height_expr = sym.height();
|
||||||
|
if (height_expr)
|
||||||
|
{
|
||||||
|
value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr);
|
||||||
|
height = 0.7071 * result.to_double();
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < feature.num_geometries(); ++i)
|
for (unsigned i = 0; i < feature.num_geometries(); ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <mapnik/grid/grid_pixel.hpp>
|
#include <mapnik/grid/grid_pixel.hpp>
|
||||||
#include <mapnik/grid/grid.hpp>
|
#include <mapnik/grid/grid.hpp>
|
||||||
#include <mapnik/segment.hpp>
|
#include <mapnik/segment.hpp>
|
||||||
|
#include <mapnik/expression_evaluator.hpp>
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
@ -59,7 +60,13 @@ void grid_renderer<T>::process(building_symbolizer const& sym,
|
||||||
|
|
||||||
ras_ptr->reset();
|
ras_ptr->reset();
|
||||||
|
|
||||||
double height = sym.height() * scale_factor_;
|
double height = 0.0;
|
||||||
|
expression_ptr height_expr = sym.height();
|
||||||
|
if (height_expr)
|
||||||
|
{
|
||||||
|
value_type result = boost::apply_visitor(evaluate<Feature,value_type>(feature), *height_expr);
|
||||||
|
height = result.to_double() * scale_factor_;
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i=0;i<feature.num_geometries();++i)
|
for (unsigned i=0;i<feature.num_geometries();++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1915,9 +1915,8 @@ void map_parser::parse_building_symbolizer( rule & rule, ptree const & sym )
|
||||||
optional<double> opacity = get_opt_attr<double>(sym, "fill-opacity");
|
optional<double> opacity = get_opt_attr<double>(sym, "fill-opacity");
|
||||||
if (opacity) building_sym.set_opacity(*opacity);
|
if (opacity) building_sym.set_opacity(*opacity);
|
||||||
// height
|
// height
|
||||||
// TODO - expression
|
optional<std::string> height = get_opt_attr<std::string>(sym, "height");
|
||||||
optional<double> height = get_opt_attr<double>(sym, "height");
|
if (height) building_sym.set_height(parse_expression(*height, "utf8"));
|
||||||
if (height) building_sym.set_height(*height);
|
|
||||||
|
|
||||||
parse_metawriter_in_symbolizer(building_sym, sym);
|
parse_metawriter_in_symbolizer(building_sym, sym);
|
||||||
rule.append(building_sym);
|
rule.append(building_sym);
|
||||||
|
|
Loading…
Reference in a new issue