remove CompositingSymbolizer

This commit is contained in:
Artem Pavlenko 2012-04-05 17:04:11 +01:00
parent 34c984b2b8
commit 738ff501fe
7 changed files with 11 additions and 350 deletions

View file

@ -103,10 +103,7 @@ public:
void process(markers_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans);
void process(compositing_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans);
inline bool process(rule::symbolizers const& /*syms*/,
mapnik::feature_ptr const& /*feature*/,
proj_transform const& /*prj_trans*/)

View file

@ -1,59 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2012 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
#ifndef MAPNIK_COMPOSITING_SYMBOLIZER_HPP
#define MAPNIK_COMPOSITING_SYMBOLIZER_HPP
// mapnik
#include <mapnik/color.hpp>
#include <mapnik/symbolizer.hpp>
#include <mapnik/enumeration.hpp>
#include <mapnik/gamma_method.hpp>
namespace mapnik
{
struct MAPNIK_DECL compositing_symbolizer : public symbolizer_base
{
compositing_symbolizer();
explicit compositing_symbolizer(color const& fill);
color const& get_fill() const;
void set_fill(color const& fill);
void set_opacity(double opacity);
double get_opacity() const;
void set_gamma(double gamma);
double get_gamma() const;
void set_gamma_method(gamma_method_e gamma_method);
gamma_method_e get_gamma_method() const;
void set_smooth(double smooth);
double smooth() const;
private:
color fill_;
double opacity_;
double gamma_;
gamma_method_e gamma_method_;
double smooth_;
};
}
#endif // MAPNIK_COMPOSITING_SYMBOLIZER_HPP

View file

@ -34,7 +34,6 @@
#include <mapnik/shield_symbolizer.hpp>
#include <mapnik/text_symbolizer.hpp>
#include <mapnik/markers_symbolizer.hpp>
#include <mapnik/compositing_symbolizer.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/expression.hpp>
#include <mapnik/expression_string.hpp>
@ -109,12 +108,6 @@ inline bool operator==(markers_symbolizer const& lhs,
return (&lhs == &rhs);
}
inline bool operator==(compositing_symbolizer const& lhs,
compositing_symbolizer const& rhs)
{
return (&lhs == &rhs);
}
typedef boost::variant<point_symbolizer,
line_symbolizer,
line_pattern_symbolizer,
@ -124,8 +117,7 @@ typedef boost::variant<point_symbolizer,
shield_symbolizer,
text_symbolizer,
building_symbolizer,
markers_symbolizer,
compositing_symbolizer> symbolizer;
markers_symbolizer> symbolizer;
class rule
{

View file

@ -1,133 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2012 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// mapnik
#include <mapnik/agg_renderer.hpp>
#include <mapnik/agg_helpers.hpp>
#include <mapnik/agg_rasterizer.hpp>
#include <mapnik/compositing_symbolizer.hpp>
// agg
#include "agg_basics.h"
#include "agg_rendering_buffer.h"
#include "agg_pixfmt_rgba.h"
#include "agg_rasterizer_scanline_aa.h"
#include "agg_scanline_u.h"
// for polygon_symbolizer
#include "agg_renderer_scanline.h"
#include "agg_conv_clip_polygon.h"
#include "agg_conv_smooth_poly1.h"
// stl
#include <string>
namespace mapnik {
template <typename T>
void agg_renderer<T>::process(compositing_symbolizer const& sym,
mapnik::feature_ptr const& feature,
proj_transform const& prj_trans)
{
typedef agg::rgba8 color_type;
typedef agg::order_rgba order_type;
typedef agg::pixel32_type pixel_type;
typedef agg::comp_op_adaptor_rgba<color_type, order_type> blender_type; // comp blender
typedef agg::pixfmt_custom_blend_rgba<blender_type, agg::rendering_buffer> pixfmt_comp_type;
typedef agg::renderer_base<pixfmt_comp_type> renderer_base;
typedef agg::renderer_scanline_aa_solid<renderer_base> renderer_type;
color const& fill_ = sym.get_fill();
unsigned r=fill_.red();
unsigned g=fill_.green();
unsigned b=fill_.blue();
unsigned a=fill_.alpha();
ras_ptr->reset();
set_gamma_method(sym,ras_ptr);
box2d<double> inflated_extent = query_extent_ * 1.1;
for (unsigned i=0;i<feature->num_geometries();++i)
{
geometry_type & geom=feature->get_geometry(i);
if (geom.num_points() > 2)
{
if (sym.smooth() > 0.0)
{
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
typedef agg::conv_smooth_poly1_curve<path_type> smooth_type;
clipped_geometry_type clipped(geom);
clipped.clip_box(inflated_extent.minx(),inflated_extent.miny(),inflated_extent.maxx(),inflated_extent.maxy());
path_type path(t_,clipped,prj_trans);
smooth_type smooth(path);
smooth.smooth_value(sym.smooth());
ras_ptr->add_path(smooth);
}
else
{
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
clipped_geometry_type clipped(geom);
//clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
// TEMP
clipped.clip_box(inflated_extent.minx(),inflated_extent.miny(),inflated_extent.maxx(),inflated_extent.maxy());
path_type path(t_,clipped,prj_trans);
ras_ptr->add_path(path);
}
}
}
agg::rendering_buffer buf(current_buffer_->raw_data(),width_,height_, width_ * 4);
if (sym.comp_op() == clear)
{
aa_renderer::pixfmt_type pixf(buf);
aa_renderer ren;
ren.attach(pixf);
ren.color(agg::rgba8(r, g, b, int(a * sym.get_opacity())));
ren.render(*ras_ptr);
}
else
{
pixfmt_comp_type pixf(buf);
pixf.comp_op(static_cast<agg::comp_op_e>(sym.comp_op()));
renderer_base renb(pixf);
renderer_type ren(renb);
ren.color(agg::rgba8(r, g, b, int(a * sym.get_opacity())));
agg::scanline_u8 sl;
agg::render_scanlines(*ras_ptr, sl, ren);
}
}
template void agg_renderer<image_32>::process(compositing_symbolizer const&,
mapnik::feature_ptr const&,
proj_transform const&);
}

View file

@ -105,7 +105,6 @@ else: # Linux and others
source = Split(
"""
color.cpp
compositing_symbolizer.cpp
conversions.cpp
image_compositing.cpp
box2d.cpp
@ -253,7 +252,6 @@ source += Split(
agg/process_raster_symbolizer.cpp
agg/process_shield_symbolizer.cpp
agg/process_markers_symbolizer.cpp
agg/process_compositing_symbolizer.cpp
"""
)

View file

@ -1,96 +0,0 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2012 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
// mapnik
#include <mapnik/compositing_symbolizer.hpp>
namespace mapnik
{
compositing_symbolizer::compositing_symbolizer()
: symbolizer_base(),
fill_(color(128,128,128)),
opacity_(1.0),
gamma_(1.0),
gamma_method_(GAMMA_POWER),
smooth_(0.0) {}
compositing_symbolizer::compositing_symbolizer(color const& fill)
: symbolizer_base(),
fill_(fill),
opacity_(1.0),
gamma_(1.0),
gamma_method_(GAMMA_POWER),
smooth_(0.0) {}
color const& compositing_symbolizer::get_fill() const
{
return fill_;
}
void compositing_symbolizer::set_fill(color const& fill)
{
fill_ = fill;
}
void compositing_symbolizer::set_opacity(double opacity)
{
opacity_ = opacity;
}
double compositing_symbolizer::get_opacity() const
{
return opacity_;
}
void compositing_symbolizer::set_gamma(double gamma)
{
gamma_ = gamma;
}
double compositing_symbolizer::get_gamma() const
{
return gamma_;
}
void compositing_symbolizer::set_gamma_method(gamma_method_e gamma_method)
{
gamma_method_ = gamma_method;
}
gamma_method_e compositing_symbolizer::get_gamma_method() const
{
return gamma_method_;
}
void compositing_symbolizer::set_smooth(double smooth)
{
smooth_ = smooth;
}
double compositing_symbolizer::smooth() const
{
return smooth_;
}
}

View file

@ -109,7 +109,6 @@ private:
void parse_shield_symbolizer(rule & rule, xml_node const& sym);
void parse_line_symbolizer(rule & rule, xml_node const& sym);
void parse_polygon_symbolizer(rule & rule, xml_node const& sym);
void parse_compositing_symbolizer(rule & rule, xml_node const& sym);
void parse_building_symbolizer(rule & rule, xml_node const& sym);
void parse_raster_symbolizer(rule & rule, xml_node const& sym);
void parse_markers_symbolizer(rule & rule, xml_node const& sym);
@ -414,7 +413,7 @@ void map_parser::parse_style(Map & map, xml_node const& sty)
filter_mode_e filter_mode = sty.get_attr<filter_mode_e>("filter-mode", FILTER_ALL);
style.set_filter_mode(filter_mode);
// compositing
optional<std::string> comp_op_name = sty.get_opt_attr<std::string>("comp-op");
if (comp_op_name)
@ -434,7 +433,7 @@ void map_parser::parse_style(Map & map, xml_node const& sty)
{
style.set_blur_radius_y(*blur_y);
}
xml_node::const_iterator ruleIter = sty.begin();
xml_node::const_iterator endRule = sty.end();
@ -571,7 +570,7 @@ void map_parser::parse_layer(Map & map, xml_node const& lay)
{
lyr.set_group_by(* group_by);
}
xml_node::const_iterator child = lay.begin();
xml_node::const_iterator end = lay.end();
@ -714,10 +713,6 @@ void map_parser::parse_rule(feature_type_style & style, xml_node const& r)
{
parse_polygon_pattern_symbolizer(rule, *symIter);
}
else if (symIter->is("CompositingSymbolizer"))
{
parse_compositing_symbolizer(rule, *symIter);
}
else if (symIter->is("TextSymbolizer"))
{
parse_text_symbolizer(rule, *symIter);
@ -768,14 +763,11 @@ void map_parser::parse_metawriter_in_symbolizer(symbolizer_base &sym, xml_node c
composite_mode_e comp_op = comp_op_from_string(*comp_op_name);
sym.set_comp_op(comp_op);
}
optional<std::string> writer = pt.get_opt_attr<std::string>("meta-writer");
if (!writer) return;
optional<std::string> output = pt.get_opt_attr<std::string>("meta-output");
sym.add_metawriter(*writer, output);
}
void map_parser::parse_point_symbolizer(rule & rule, xml_node const & sym)
@ -1266,17 +1258,17 @@ void map_parser::parse_stroke(stroke & strk, xml_node const & sym)
if (!dash_array.empty())
{
size_t size = dash_array.size();
if (size % 2 == 1)
if (size % 2 == 1)
dash_array.insert(dash_array.end(),dash_array.begin(),dash_array.end());
std::vector<double>::const_iterator pos = dash_array.begin();
while (pos != dash_array.end())
{
if (*pos > 0.0 || *(pos+1) > 0.0) // avoid both dash and gap eq 0.0
if (*pos > 0.0 || *(pos+1) > 0.0) // avoid both dash and gap eq 0.0
strk.add_dash(*pos,*(pos + 1));
pos +=2;
}
}
}
}
else
{
@ -1338,7 +1330,7 @@ void map_parser::parse_polygon_symbolizer(rule & rule, xml_node const & sym)
// to clip or not to clip value
//optional<bool> clip = sym.get_opt_attr<bool>("clip");
//if (clip) poly_sym.set_clip(*clip);
parse_metawriter_in_symbolizer(poly_sym, sym);
rule.append(poly_sym);
}
@ -1349,36 +1341,6 @@ void map_parser::parse_polygon_symbolizer(rule & rule, xml_node const & sym)
}
}
void map_parser::parse_compositing_symbolizer(rule & rule, xml_node const & sym)
{
try
{
compositing_symbolizer comp_sym;
// fill
optional<color> fill = sym.get_opt_attr<color>("fill");
if (fill) comp_sym.set_fill(*fill);
// fill-opacity
optional<double> opacity = sym.get_opt_attr<double>("fill-opacity");
if (opacity) comp_sym.set_opacity(*opacity);
// gamma
optional<double> gamma = sym.get_opt_attr<double>("gamma");
if (gamma) comp_sym.set_gamma(*gamma);
// gamma method
optional<gamma_method_e> gamma_method = sym.get_opt_attr<gamma_method_e>("gamma-method");
if (gamma_method) comp_sym.set_gamma_method(*gamma_method);
// smooth value
optional<double> smooth = sym.get_opt_attr<double>("smooth");
if (smooth) comp_sym.set_smooth(*smooth);
rule.append(comp_sym);
}
catch (const config_error & ex)
{
ex.append_context("in CompositingSymbolizer", sym);
throw;
}
}
void map_parser::parse_building_symbolizer(rule & rule, xml_node const & sym)
{
try