Merge branch 'master' of github.com:mapnik/mapnik
This commit is contained in:
commit
8451e8897d
9 changed files with 127 additions and 77 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <mapnik/ctrans.hpp>
|
||||
#include <mapnik/memory_datasource.hpp>
|
||||
#include <mapnik/feature_kv_iterator.hpp>
|
||||
#include <mapnik/config_error.hpp>
|
||||
#include "mapwidget.hpp"
|
||||
#include "info_dialog.hpp"
|
||||
|
||||
|
@ -487,7 +488,7 @@ void MapWidget::updateMap()
|
|||
}
|
||||
catch (mapnik::config_error & ex)
|
||||
{
|
||||
std::cerr << ex.what() << std::endl;
|
||||
std::cerr << ex.what() << std::endl;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
|
57
include/mapnik/agg_helpers.hpp
Normal file
57
include/mapnik/agg_helpers.hpp
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*****************************************************************************
|
||||
*
|
||||
* 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_AGG_HELPERS_HPP
|
||||
#define MAPNIK_AGG_HELPERS_HPP
|
||||
|
||||
#include "agg_gamma_functions.h"
|
||||
|
||||
namespace mapnik {
|
||||
|
||||
template <typename T0, typename T1>
|
||||
void set_gamma_method(T0 const& obj, T1 & ras_ptr)
|
||||
{
|
||||
switch (obj.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(obj.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, obj.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(obj.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(obj.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(obj.get_gamma()));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif //MAPNIK_AGG_HELPERS_HPP
|
|
@ -35,7 +35,7 @@ namespace mapnik
|
|||
struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
|
||||
{
|
||||
polygon_symbolizer();
|
||||
polygon_symbolizer(color const& fill);
|
||||
explicit polygon_symbolizer(color const& fill);
|
||||
color const& get_fill() const;
|
||||
void set_fill(color const& fill);
|
||||
void set_opacity(double opacity);
|
||||
|
@ -44,12 +44,14 @@ struct MAPNIK_DECL polygon_symbolizer : public symbolizer_base
|
|||
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_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_helpers.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/line_symbolizer.hpp>
|
||||
|
||||
|
@ -71,7 +72,6 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
typedef agg::rasterizer_outline_aa<renderer_type> rasterizer_type;
|
||||
|
||||
agg::line_profile_aa profile;
|
||||
//agg::line_profile_aa profile(stroke_.get_width() * scale_factor_, agg::gamma_none());
|
||||
profile.width(stroke_.get_width() * scale_factor_);
|
||||
ren_base base_ren(pixf);
|
||||
renderer_type ren(base_ren, profile);
|
||||
|
@ -102,26 +102,10 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
ren_base renb(pixf);
|
||||
renderer ren(renb);
|
||||
ras_ptr->reset();
|
||||
switch (stroke_.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, stroke_.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(stroke_.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(stroke_.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(stroke_.get_gamma()));
|
||||
}
|
||||
|
||||
set_gamma_method(stroke_, ras_ptr);
|
||||
|
||||
|
||||
|
||||
//metawriter_with_properties writer = sym.get_metawriter();
|
||||
for (unsigned i=0;i<feature->num_geometries();++i)
|
||||
|
@ -129,12 +113,13 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
geometry_type & geom = feature->get_geometry(i);
|
||||
if (geom.num_points() > 1)
|
||||
{
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
|
||||
if (stroke_.has_dash())
|
||||
{
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
|
||||
agg::conv_dash<path_type> dash(path);
|
||||
dash_array const& d = stroke_.get_dash_array();
|
||||
dash_array::const_iterator itr = d.begin();
|
||||
|
@ -172,6 +157,10 @@ void agg_renderer<T>::process(line_symbolizer const& sym,
|
|||
}
|
||||
else
|
||||
{
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(ext.minx(),ext.miny(),ext.maxx(),ext.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
|
||||
agg::conv_stroke<path_type> stroke(path);
|
||||
line_join_e join=stroke_.get_line_join();
|
||||
if ( join == MITER_JOIN)
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_helpers.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/marker.hpp>
|
||||
#include <mapnik/marker_cache.hpp>
|
||||
|
@ -72,27 +73,8 @@ void agg_renderer<T>::process(polygon_pattern_symbolizer const& sym,
|
|||
|
||||
agg::scanline_u8 sl;
|
||||
ras_ptr->reset();
|
||||
switch (sym.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
}
|
||||
|
||||
set_gamma_method(sym,ras_ptr);
|
||||
|
||||
std::string filename = path_processor_type::evaluate( *sym.get_filename(), *feature);
|
||||
boost::optional<mapnik::marker_ptr> marker;
|
||||
if ( !filename.empty() )
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
// mapnik
|
||||
#include <mapnik/agg_renderer.hpp>
|
||||
#include <mapnik/agg_helpers.hpp>
|
||||
#include <mapnik/agg_rasterizer.hpp>
|
||||
#include <mapnik/polygon_symbolizer.hpp>
|
||||
|
||||
|
@ -35,6 +36,7 @@
|
|||
// for polygon_symbolizer
|
||||
#include "agg_renderer_scanline.h"
|
||||
#include "agg_conv_clip_polygon.h"
|
||||
#include "agg_conv_smooth_poly1.h"
|
||||
// stl
|
||||
#include <string>
|
||||
|
||||
|
@ -45,11 +47,10 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
mapnik::feature_ptr const& feature,
|
||||
proj_transform const& prj_trans)
|
||||
{
|
||||
typedef agg::conv_clip_polygon<geometry_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
typedef agg::renderer_base<agg::pixfmt_rgba32_plain> ren_base;
|
||||
typedef agg::renderer_scanline_aa_solid<ren_base> renderer;
|
||||
|
||||
box2d<double> query_extent = query_extent_ * 1.0;
|
||||
color const& fill_ = sym.get_fill();
|
||||
agg::scanline_u8 sl;
|
||||
|
||||
|
@ -65,37 +66,36 @@ void agg_renderer<T>::process(polygon_symbolizer const& sym,
|
|||
renderer ren(renb);
|
||||
|
||||
ras_ptr->reset();
|
||||
switch (sym.get_gamma_method())
|
||||
{
|
||||
case GAMMA_POWER:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_LINEAR:
|
||||
ras_ptr->gamma(agg::gamma_linear(0.0, sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_NONE:
|
||||
ras_ptr->gamma(agg::gamma_none());
|
||||
break;
|
||||
case GAMMA_THRESHOLD:
|
||||
ras_ptr->gamma(agg::gamma_threshold(sym.get_gamma()));
|
||||
break;
|
||||
case GAMMA_MULTIPLY:
|
||||
ras_ptr->gamma(agg::gamma_multiply(sym.get_gamma()));
|
||||
break;
|
||||
default:
|
||||
ras_ptr->gamma(agg::gamma_power(sym.get_gamma()));
|
||||
}
|
||||
|
||||
set_gamma_method(sym,ras_ptr);
|
||||
|
||||
//metawriter_with_properties writer = sym.get_metawriter();
|
||||
for (unsigned i=0;i<feature->num_geometries();++i)
|
||||
{
|
||||
geometry_type & geom=feature->get_geometry(i);
|
||||
if (geom.num_points() > 2)
|
||||
{
|
||||
clipped_geometry_type clipped(geom);
|
||||
clipped.clip_box(query_extent_.minx(),query_extent_.miny(),query_extent_.maxx(),query_extent_.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
ras_ptr->add_path(path);
|
||||
if (sym.smooth() > 0.0)
|
||||
{
|
||||
typedef agg::conv_smooth_poly1_curve<geometry_type> smooth_type;
|
||||
typedef agg::conv_clip_polygon<smooth_type> clipped_geometry_type;
|
||||
typedef coord_transform2<CoordTransform,clipped_geometry_type> path_type;
|
||||
smooth_type smooth(geom);
|
||||
smooth.smooth_value(sym.smooth());
|
||||
clipped_geometry_type clipped(smooth);
|
||||
clipped.clip_box(query_extent.minx(),query_extent.miny(),query_extent.maxx(),query_extent.maxy());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
ras_ptr->add_path(path);
|
||||
}
|
||||
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());
|
||||
path_type path(t_,clipped,prj_trans);
|
||||
ras_ptr->add_path(path);
|
||||
}
|
||||
//if (writer.first) writer.first->add_polygon(path, *feature, t_, writer.second);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1295,7 +1295,10 @@ void map_parser::parse_polygon_symbolizer( rule & rule, xml_node const & sym )
|
|||
// gamma method
|
||||
optional<gamma_method_e> gamma_method = sym.get_opt_attr<gamma_method_e>("gamma-method");
|
||||
if (gamma_method) poly_sym.set_gamma_method(*gamma_method);
|
||||
|
||||
// smooth value
|
||||
optional<double> smooth = sym.get_opt_attr<double>("smooth");
|
||||
if (smooth) poly_sym.set_smooth(*smooth);
|
||||
|
||||
parse_metawriter_in_symbolizer(poly_sym, sym);
|
||||
rule.append(poly_sym);
|
||||
}
|
||||
|
|
|
@ -32,14 +32,16 @@ polygon_symbolizer::polygon_symbolizer()
|
|||
fill_(color(128,128,128)),
|
||||
opacity_(1.0),
|
||||
gamma_(1.0),
|
||||
gamma_method_(GAMMA_POWER) {}
|
||||
gamma_method_(GAMMA_POWER),
|
||||
smooth_(0.0) {}
|
||||
|
||||
polygon_symbolizer::polygon_symbolizer(color const& fill)
|
||||
: symbolizer_base(),
|
||||
fill_(fill),
|
||||
opacity_(1.0),
|
||||
gamma_(1.0),
|
||||
gamma_method_(GAMMA_POWER) {}
|
||||
gamma_method_(GAMMA_POWER),
|
||||
smooth_(0.0) {}
|
||||
|
||||
color const& polygon_symbolizer::get_fill() const
|
||||
{
|
||||
|
@ -81,4 +83,14 @@ gamma_method_e polygon_symbolizer::get_gamma_method() const
|
|||
return gamma_method_;
|
||||
}
|
||||
|
||||
void polygon_symbolizer::set_smooth(double smooth)
|
||||
{
|
||||
smooth_ = smooth;
|
||||
}
|
||||
|
||||
double polygon_symbolizer::smooth() const
|
||||
{
|
||||
return smooth_;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -125,6 +125,10 @@ public:
|
|||
{
|
||||
set_attr( sym_node, "gamma-method", sym.get_gamma_method() );
|
||||
}
|
||||
if ( sym.smooth() != dfl.smooth() || explicit_defaults_ )
|
||||
{
|
||||
set_attr( sym_node, "smooth", sym.smooth() );
|
||||
}
|
||||
add_metawriter_attributes(sym_node, sym);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue