more const strictness, update to work with latest mapbox::variant/visitor-no-copy branch

This commit is contained in:
artemp 2016-01-27 14:50:17 +01:00
parent c7a964abf6
commit d027ed67c7
21 changed files with 113 additions and 113 deletions

2
deps/mapbox/variant vendored

@ -1 +1 @@
Subproject commit 9afd6406065440e02b6bf42db4633b815846db0d Subproject commit f7b63cc1501bf9d9f740e9a8957a25bc9be5f1ca

View file

@ -178,12 +178,12 @@ struct geom_reproj_copy_visitor
: proj_trans_(proj_trans), : proj_trans_(proj_trans),
n_err_(n_err) {} n_err_(n_err) {}
geometry<T> operator() (geometry_empty const&) geometry<T> operator() (geometry_empty const&) const
{ {
return geometry_empty(); return geometry_empty();
} }
geometry<T> operator() (point<T> const& p) geometry<T> operator() (point<T> const& p) const
{ {
geometry<T> geom; // default empty geometry<T> geom; // default empty
unsigned int intial_err = n_err_; unsigned int intial_err = n_err_;
@ -193,7 +193,7 @@ struct geom_reproj_copy_visitor
return geom; return geom;
} }
geometry<T> operator() (line_string<T> const& ls) geometry<T> operator() (line_string<T> const& ls) const
{ {
geometry<T> geom; // default empty geometry<T> geom; // default empty
unsigned int intial_err = n_err_; unsigned int intial_err = n_err_;
@ -203,7 +203,7 @@ struct geom_reproj_copy_visitor
return geom; return geom;
} }
geometry<T> operator() (polygon<T> const& poly) geometry<T> operator() (polygon<T> const& poly) const
{ {
geometry<T> geom; // default empty geometry<T> geom; // default empty
polygon<T> new_poly = reproject_internal(poly, proj_trans_, n_err_); polygon<T> new_poly = reproject_internal(poly, proj_trans_, n_err_);
@ -212,7 +212,7 @@ struct geom_reproj_copy_visitor
return geom; return geom;
} }
geometry<T> operator() (multi_point<T> const& mp) geometry<T> operator() (multi_point<T> const& mp) const
{ {
geometry<T> geom; // default empty geometry<T> geom; // default empty
multi_point<T> new_mp = reproject_internal(mp, proj_trans_, n_err_); multi_point<T> new_mp = reproject_internal(mp, proj_trans_, n_err_);
@ -221,7 +221,7 @@ struct geom_reproj_copy_visitor
return geom; return geom;
} }
geometry<T> operator() (multi_line_string<T> const& mls) geometry<T> operator() (multi_line_string<T> const& mls) const
{ {
geometry<T> geom; // default empty geometry<T> geom; // default empty
multi_line_string<T> new_mls = reproject_internal(mls, proj_trans_, n_err_); multi_line_string<T> new_mls = reproject_internal(mls, proj_trans_, n_err_);
@ -230,7 +230,7 @@ struct geom_reproj_copy_visitor
return geom; return geom;
} }
geometry<T> operator() (multi_polygon<T> const& mpoly) geometry<T> operator() (multi_polygon<T> const& mpoly) const
{ {
geometry<T> geom; // default empty geometry<T> geom; // default empty
multi_polygon<T> new_mpoly = reproject_internal(mpoly, proj_trans_, n_err_); multi_polygon<T> new_mpoly = reproject_internal(mpoly, proj_trans_, n_err_);
@ -239,7 +239,7 @@ struct geom_reproj_copy_visitor
return geom; return geom;
} }
geometry<T> operator() (geometry_collection<T> const& c) geometry<T> operator() (geometry_collection<T> const& c) const
{ {
geometry<T> geom; // default empty geometry<T> geom; // default empty
geometry_collection<T> new_c = reproject_internal(c, proj_trans_, n_err_); geometry_collection<T> new_c = reproject_internal(c, proj_trans_, n_err_);
@ -284,15 +284,15 @@ struct geom_reproj_visitor {
: proj_trans_(proj_trans) {} : proj_trans_(proj_trans) {}
template <typename T> template <typename T>
bool operator() (geometry<T> & geom) bool operator() (geometry<T> & geom) const
{ {
return mapnik::util::apply_visitor((*this), geom); return mapnik::util::apply_visitor((*this), geom);
} }
bool operator() (geometry_empty &) { return true; } bool operator() (geometry_empty &) const { return true; }
template <typename T> template <typename T>
bool operator() (point<T> & p) bool operator() (point<T> & p) const
{ {
if (!proj_trans_.forward(p)) if (!proj_trans_.forward(p))
{ {
@ -302,7 +302,7 @@ struct geom_reproj_visitor {
} }
template <typename T> template <typename T>
bool operator() (line_string<T> & ls) bool operator() (line_string<T> & ls) const
{ {
if (proj_trans_.forward(ls) > 0) if (proj_trans_.forward(ls) > 0)
{ {
@ -312,7 +312,7 @@ struct geom_reproj_visitor {
} }
template <typename T> template <typename T>
bool operator() (polygon<T> & poly) bool operator() (polygon<T> & poly) const
{ {
if (proj_trans_.forward(poly.exterior_ring) > 0) if (proj_trans_.forward(poly.exterior_ring) > 0)
{ {
@ -330,13 +330,13 @@ struct geom_reproj_visitor {
} }
template <typename T> template <typename T>
bool operator() (multi_point<T> & mp) bool operator() (multi_point<T> & mp) const
{ {
return (*this) (static_cast<line_string<T> &>(mp)); return (*this) (static_cast<line_string<T> &>(mp));
} }
template <typename T> template <typename T>
bool operator() (multi_line_string<T> & mls) bool operator() (multi_line_string<T> & mls) const
{ {
for (auto & ls : mls) for (auto & ls : mls)
{ {
@ -349,7 +349,7 @@ struct geom_reproj_visitor {
} }
template <typename T> template <typename T>
bool operator() (multi_polygon<T> & mpoly) bool operator() (multi_polygon<T> & mpoly) const
{ {
for (auto & poly : mpoly) for (auto & poly : mpoly)
{ {
@ -362,7 +362,7 @@ struct geom_reproj_visitor {
} }
template <typename T> template <typename T>
bool operator() (geometry_collection<T> & c) bool operator() (geometry_collection<T> & c) const
{ {
for (auto & g : c) for (auto & g : c)
{ {

View file

@ -917,7 +917,7 @@ struct filter_visitor
: src_(src) {} : src_(src) {}
template <typename T> template <typename T>
void operator () (T const& filter) void operator () (T const& filter) const
{ {
apply_filter(src_, filter); apply_filter(src_, filter);
} }
@ -931,9 +931,9 @@ struct filter_radius_visitor
filter_radius_visitor(int & radius) filter_radius_visitor(int & radius)
: radius_(radius) {} : radius_(radius) {}
template <typename T> template <typename T>
void operator () (T const& /*filter*/) {} void operator () (T const& /*filter*/) const {}
void operator () (agg_stack_blur const& op) void operator () (agg_stack_blur const& op) const
{ {
if (static_cast<int>(op.rx) > radius_) radius_ = static_cast<int>(op.rx); if (static_cast<int>(op.rx) > radius_) radius_ = static_cast<int>(op.rx);
if (static_cast<int>(op.ry) > radius_) radius_ = static_cast<int>(op.ry); if (static_cast<int>(op.ry) > radius_) radius_ = static_cast<int>(op.ry);

View file

@ -31,7 +31,7 @@ struct apply_vertex_converter
apply_vertex_converter(VertexConverter & converter, Processor & proc) apply_vertex_converter(VertexConverter & converter, Processor & proc)
: converter_(converter), proc_(proc) {} : converter_(converter), proc_(proc) {}
template <typename Adapter> template <typename Adapter>
void operator() (Adapter const& adapter) const void operator() (Adapter const& adapter)
{ {
converter_.apply(adapter, proc_); converter_.apply(adapter, proc_);
} }

View file

@ -62,9 +62,9 @@ struct render_marker_symbolizer_visitor
clip_box_(clip_box), clip_box_(clip_box),
renderer_context_(renderer_context) {} renderer_context_(renderer_context) {}
void operator() (marker_null const&) {} void operator() (marker_null const&) const {}
void operator() (marker_svg const& mark) void operator() (marker_svg const& mark) const
{ {
using namespace mapnik::svg; using namespace mapnik::svg;
bool clip = get<value_bool, keys::clip>(sym_, feature_, common_.vars_); bool clip = get<value_bool, keys::clip>(sym_, feature_, common_.vars_);
@ -179,7 +179,7 @@ struct render_marker_symbolizer_visitor
} }
} }
void operator() (marker_rgba8 const& mark) void operator() (marker_rgba8 const& mark) const
{ {
using namespace mapnik::svg; using namespace mapnik::svg;
bool clip = get<value_bool, keys::clip>(sym_, feature_, common_.vars_); bool clip = get<value_bool, keys::clip>(sym_, feature_, common_.vars_);

View file

@ -111,11 +111,11 @@ struct transform_processor
vars_(v), vars_(v),
scale_factor_(scale_factor) {} scale_factor_(scale_factor) {}
void operator() (identity_node const&) void operator() (identity_node const&) const
{ {
} }
void operator() (matrix_node const& node) void operator() (matrix_node const& node) const
{ {
double a = eval(node.a_); // scale x; double a = eval(node.a_); // scale x;
double b = eval(node.b_); double b = eval(node.b_);
@ -126,21 +126,21 @@ struct transform_processor
transform_.multiply(agg::trans_affine(a, b, c, d, e, f)); transform_.multiply(agg::trans_affine(a, b, c, d, e, f));
} }
void operator() (translate_node const& node) void operator() (translate_node const& node) const
{ {
double tx = eval(node.tx_) * scale_factor_; double tx = eval(node.tx_) * scale_factor_;
double ty = eval(node.ty_, 0.0) * scale_factor_; double ty = eval(node.ty_, 0.0) * scale_factor_;
transform_.translate(tx, ty); transform_.translate(tx, ty);
} }
void operator() (scale_node const& node) void operator() (scale_node const& node) const
{ {
double sx = eval(node.sx_); double sx = eval(node.sx_);
double sy = eval(node.sy_, sx); double sy = eval(node.sy_, sx);
transform_.scale(sx, sy); transform_.scale(sx, sy);
} }
void operator() (rotate_node const& node) void operator() (rotate_node const& node) const
{ {
double angle = deg2rad(eval(node.angle_)); double angle = deg2rad(eval(node.angle_));
double cx = eval(node.cx_, 0.0); double cx = eval(node.cx_, 0.0);
@ -150,7 +150,7 @@ struct transform_processor
transform_.translate(cx, cy); transform_.translate(cx, cy);
} }
void operator() (skewX_node const& node) void operator() (skewX_node const& node) const
{ {
auto degrees = std::fmod(eval(node.angle_),90.0); auto degrees = std::fmod(eval(node.angle_),90.0);
if (degrees < -89.0) degrees = -89.0; if (degrees < -89.0) degrees = -89.0;
@ -159,7 +159,7 @@ struct transform_processor
transform_.multiply(agg::trans_affine_skewing(angle, 0.0)); transform_.multiply(agg::trans_affine_skewing(angle, 0.0));
} }
void operator() (skewY_node const& node) void operator() (skewY_node const& node) const
{ {
auto degrees = std::fmod(eval(node.angle_),90.0); auto degrees = std::fmod(eval(node.angle_),90.0);
if (degrees < -89.0) degrees = -89.0; if (degrees < -89.0) degrees = -89.0;

View file

@ -46,30 +46,31 @@ public:
// unary visitor interface // unary visitor interface
// const // const
template <typename V, typename F> template <typename F, typename V>
auto VARIANT_INLINE static apply_visitor(F f, V const& v) -> decltype(V::visit(v, f)) auto VARIANT_INLINE static apply_visitor(F && f, V const& v) -> decltype(V::visit(v, f))
{ {
return V::visit(v, f); return V::visit(v, std::forward<F>(f));
} }
// non-const // non-const
template <typename V, typename F> template <typename F, typename V>
auto VARIANT_INLINE static apply_visitor(F f, V & v) -> decltype(V::visit(v, f)) auto VARIANT_INLINE static apply_visitor(F && f, V & v) -> decltype(V::visit(v, f))
{ {
return V::visit(v, f); return V::visit(v, std::forward<F>(f));
} }
// binary visitor interface // binary visitor interface
// const // const
template <typename V, typename F> template <typename F, typename V>
auto VARIANT_INLINE static apply_visitor(F f, V const& v0, V const& v1) -> decltype(V::binary_visit(v0, v1, f)) auto VARIANT_INLINE static apply_visitor(F && f, V const& v0, V const& v1) -> decltype(V::binary_visit(v0, v1, f))
{ {
return V::binary_visit(v0, v1, f); return V::binary_visit(v0, v1, std::forward<F>(f));
} }
// non-const // non-const
template <typename V, typename F> template <typename F, typename V>
auto VARIANT_INLINE static apply_visitor(F f, V & v0, V & v1) -> decltype(V::binary_visit(v0, v1, f)) auto VARIANT_INLINE static apply_visitor(F && f, V & v0, V & v1) -> decltype(V::binary_visit(v0, v1, f))
{ {
return V::binary_visit(v0, v1, f); return V::binary_visit(v0, v1, std::forward<F>(f));
} }
// getter interface // getter interface

View file

@ -35,38 +35,38 @@ struct vertex_processor
: proc_(proc) {} : proc_(proc) {}
template <typename Geometry> template <typename Geometry>
void operator() (Geometry const& geom) void operator() (Geometry const& geom) const
{ {
util::apply_visitor(*this, geom); util::apply_visitor(*this, geom);
} }
void operator() (geometry_empty const&) void operator() (geometry_empty const&) const
{ {
// no-op // no-op
} }
template <typename T1> template <typename T1>
void operator() (point<T1> const& pt) void operator() (point<T1> const& pt) const
{ {
point_vertex_adapter<T1> va(pt); point_vertex_adapter<T1> va(pt);
proc_(va); proc_(va);
} }
template <typename T1> template <typename T1>
void operator() (line_string<T1> const& line) void operator() (line_string<T1> const& line) const
{ {
line_string_vertex_adapter<T1> va(line); line_string_vertex_adapter<T1> va(line);
proc_(va); proc_(va);
} }
template <typename T1> template <typename T1>
void operator() (polygon<T1> const& poly) void operator() (polygon<T1> const& poly) const
{ {
polygon_vertex_adapter<T1> va(poly); polygon_vertex_adapter<T1> va(poly);
proc_(va); proc_(va);
} }
template <typename T1> template <typename T1>
void operator() (multi_point<T1> const& multi_pt) void operator() (multi_point<T1> const& multi_pt) const
{ {
for (auto const& pt : multi_pt) for (auto const& pt : multi_pt)
{ {
@ -76,7 +76,7 @@ struct vertex_processor
} }
template <typename T1> template <typename T1>
void operator() (multi_line_string<T1> const& multi_line) void operator() (multi_line_string<T1> const& multi_line) const
{ {
for (auto const& line : multi_line) for (auto const& line : multi_line)
{ {
@ -86,7 +86,7 @@ struct vertex_processor
} }
template <typename T1> template <typename T1>
void operator() (multi_polygon<T1> const& multi_poly) void operator() (multi_polygon<T1> const& multi_poly) const
{ {
for ( auto const& poly : multi_poly) for ( auto const& poly : multi_poly)
{ {
@ -96,7 +96,7 @@ struct vertex_processor
} }
template <typename T1> template <typename T1>
void operator() (geometry_collection<T1> const& collection) void operator() (geometry_collection<T1> const& collection) const
{ {
for (auto const& geom : collection) for (auto const& geom : collection)
{ {

View file

@ -121,11 +121,11 @@ struct setup_agg_bg_visitor
mode_(mode), mode_(mode),
opacity_(opacity) {} opacity_(opacity) {}
void operator() (marker_null const&) {} void operator() (marker_null const&) const {}
void operator() (marker_svg const&) {} void operator() (marker_svg const&) const {}
void operator() (marker_rgba8 const& marker) void operator() (marker_rgba8 const& marker) const
{ {
mapnik::image_rgba8 const& bg_image = marker.get_data(); mapnik::image_rgba8 const& bg_image = marker.get_data();
std::size_t w = bg_image.width(); std::size_t w = bg_image.width();
@ -361,9 +361,9 @@ struct agg_render_marker_visitor
opacity_(opacity), opacity_(opacity),
comp_op_(comp_op) {} comp_op_(comp_op) {}
void operator() (marker_null const&) {} void operator() (marker_null const&) const {}
void operator() (marker_svg const& marker) void operator() (marker_svg const& marker) const
{ {
using color_type = agg::rgba8; using color_type = agg::rgba8;
using order_type = agg::order_rgba; using order_type = agg::order_rgba;
@ -414,7 +414,7 @@ struct agg_render_marker_visitor
svg_renderer.render(*ras_ptr_, sl, renb, mtx, opacity_, bbox); svg_renderer.render(*ras_ptr_, sl, renb, mtx, opacity_, bbox);
} }
void operator() (marker_rgba8 const& marker) void operator() (marker_rgba8 const& marker) const
{ {
using color_type = agg::rgba8; using color_type = agg::rgba8;
using order_type = agg::order_rgba; using order_type = agg::order_rgba;

View file

@ -165,12 +165,12 @@ struct RingRenderer {
}; };
template <typename BufferType> template <typename BufferType>
struct render_ring_visitor { struct render_ring_visitor
{
render_ring_visitor(RingRenderer<BufferType> & renderer) render_ring_visitor(RingRenderer<BufferType> & renderer)
: renderer_(renderer) {} : renderer_(renderer) {}
void operator()(mapnik::geometry::multi_polygon<double> const& geom) void operator()(mapnik::geometry::multi_polygon<double> const& geom) const
{ {
for (auto const& poly : geom) for (auto const& poly : geom)
{ {
@ -178,7 +178,7 @@ struct render_ring_visitor {
} }
} }
void operator()(mapnik::geometry::polygon<double> const& geom) void operator()(mapnik::geometry::polygon<double> const& geom) const
{ {
agg::rgba8 red(255,0,0,255); agg::rgba8 red(255,0,0,255);
agg::rgba8 green(0,255,255,255); agg::rgba8 green(0,255,255,255);
@ -199,7 +199,7 @@ struct render_ring_visitor {
} }
template<typename GeomType> template<typename GeomType>
void operator()(GeomType const&) {} void operator()(GeomType const&) const {}
RingRenderer<BufferType> & renderer_; RingRenderer<BufferType> & renderer_;
}; };

View file

@ -71,9 +71,9 @@ struct agg_renderer_process_visitor_l
feature_(feature), feature_(feature),
prj_trans_(prj_trans) {} prj_trans_(prj_trans) {}
void operator() (marker_null const&) {} void operator() (marker_null const&) const {}
void operator() (marker_svg const& marker) void operator() (marker_svg const& marker) const
{ {
using color = agg::rgba8; using color = agg::rgba8;
using order = agg::order_rgba; using order = agg::order_rgba;
@ -147,7 +147,7 @@ struct agg_renderer_process_visitor_l
mapnik::util::apply_visitor(vertex_processor_type(apply),feature_.get_geometry()); mapnik::util::apply_visitor(vertex_processor_type(apply),feature_.get_geometry());
} }
void operator() (marker_rgba8 const& marker) void operator() (marker_rgba8 const& marker) const
{ {
using color = agg::rgba8; using color = agg::rgba8;
using order = agg::order_rgba; using order = agg::order_rgba;

View file

@ -75,9 +75,9 @@ struct agg_renderer_process_visitor_p
feature_(feature), feature_(feature),
prj_trans_(prj_trans) {} prj_trans_(prj_trans) {}
void operator() (marker_null const&) {} void operator() (marker_null const&) const {}
void operator() (marker_svg const& marker) void operator() (marker_svg const& marker) const
{ {
agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_); agg::trans_affine image_tr = agg::trans_affine_scaling(common_.scale_factor_);
auto image_transform = get_optional<transform_type>(sym_, keys::image_transform); auto image_transform = get_optional<transform_type>(sym_, keys::image_transform);
@ -180,7 +180,7 @@ struct agg_renderer_process_visitor_p
agg::render_scanlines(*ras_ptr_, sl, rp); agg::render_scanlines(*ras_ptr_, sl, rp);
} }
void operator() (marker_rgba8 const& marker) void operator() (marker_rgba8 const& marker) const
{ {
using color = agg::rgba8; using color = agg::rgba8;
using order = agg::order_rgba; using order = agg::order_rgba;

View file

@ -104,10 +104,10 @@ struct setup_marker_visitor
setup_marker_visitor(cairo_context & context, renderer_common const& common) setup_marker_visitor(cairo_context & context, renderer_common const& common)
: context_(context), common_(common) {} : context_(context), common_(common) {}
void operator() (marker_null const &) {} void operator() (marker_null const &) const{}
void operator() (marker_svg const &) {} void operator() (marker_svg const &) const {}
void operator() (marker_rgba8 const& marker) void operator() (marker_rgba8 const& marker) const
{ {
mapnik::image_rgba8 const& bg_image = marker.get_data(); mapnik::image_rgba8 const& bg_image = marker.get_data();
std::size_t w = bg_image.width(); std::size_t w = bg_image.width();

View file

@ -190,7 +190,7 @@ struct composite_visitor
dy_(dy) {} dy_(dy) {}
template <typename T> template <typename T>
void operator() (T & dst); void operator() (T & dst) const;
private: private:
image_any const& src_; image_any const& src_;
@ -201,19 +201,19 @@ struct composite_visitor
}; };
template <typename T> template <typename T>
void composite_visitor::operator() (T & dst) void composite_visitor::operator() (T & dst) const
{ {
throw std::runtime_error("Error: Composite with " + std::string(typeid(dst).name()) + " is not supported"); throw std::runtime_error("Error: Composite with " + std::string(typeid(dst).name()) + " is not supported");
} }
template <> template <>
void composite_visitor::operator()<image_rgba8> (image_rgba8 & dst) void composite_visitor::operator()<image_rgba8> (image_rgba8 & dst) const
{ {
composite(dst, util::get<image_rgba8>(src_), mode_, opacity_, dx_, dy_); composite(dst, util::get<image_rgba8>(src_), mode_, opacity_, dx_, dy_);
} }
template <> template <>
void composite_visitor::operator()<image_gray32f> (image_gray32f & dst) void composite_visitor::operator()<image_gray32f> (image_gray32f & dst) const
{ {
composite(dst, util::get<image_gray32f>(src_), mode_, opacity_, dx_, dy_); composite(dst, util::get<image_gray32f>(src_), mode_, opacity_, dx_, dy_);
} }

View file

@ -37,7 +37,7 @@ struct visitor_image_copy
{ {
using dst_type = typename T0::pixel_type; using dst_type = typename T0::pixel_type;
T0 operator() (image_null const&) T0 operator() (image_null const&) const
{ {
throw std::runtime_error("Can not cast a null image"); throw std::runtime_error("Can not cast a null image");
} }
@ -48,7 +48,7 @@ struct visitor_image_copy
} }
template <typename T1> template <typename T1>
T0 operator() (T1 const& src) T0 operator() (T1 const& src) const
{ {
T0 dst(safe_cast<int>(src.width()), safe_cast<int>(src.height()), false); T0 dst(safe_cast<int>(src.width()), safe_cast<int>(src.height()), false);
for (std::size_t y = 0; y < dst.height(); ++y) for (std::size_t y = 0; y < dst.height(); ++y)
@ -75,7 +75,7 @@ struct visitor_image_copy_so
throw std::runtime_error("Can not cast a null image"); throw std::runtime_error("Can not cast a null image");
} }
T0 operator() (T0 const& src) T0 operator() (T0 const& src) const
{ {
if (offset_ == src.get_offset() && scaling_ == src.get_scaling()) if (offset_ == src.get_offset() && scaling_ == src.get_scaling())
{ {
@ -91,7 +91,7 @@ struct visitor_image_copy_so
} }
template <typename T1> template <typename T1>
T0 operator() (T1 const& src) T0 operator() (T1 const& src) const
{ {
double src_offset = src.get_offset(); double src_offset = src.get_offset();
double src_scaling = src.get_scaling(); double src_scaling = src.get_scaling();

View file

@ -2087,7 +2087,7 @@ struct visitor_view_to_stream
: os_(os) {} : os_(os) {}
template <typename T> template <typename T>
void operator() (T const& view) void operator() (T const& view) const
{ {
for (std::size_t i=0;i<view.height();i++) for (std::size_t i=0;i<view.height();i++)
{ {

View file

@ -118,19 +118,19 @@ namespace detail
struct visitor_create_marker struct visitor_create_marker
{ {
marker operator() (image_rgba8 & data) marker operator() (image_rgba8 & data) const
{ {
mapnik::premultiply_alpha(data); mapnik::premultiply_alpha(data);
return mapnik::marker(mapnik::marker_rgba8(data)); return mapnik::marker(mapnik::marker_rgba8(data));
} }
marker operator() (image_null &) marker operator() (image_null &) const
{ {
throw std::runtime_error("Can not make marker from null image data type"); throw std::runtime_error("Can not make marker from null image data type");
} }
template <typename T> template <typename T>
marker operator() (T &) marker operator() (T &) const
{ {
throw std::runtime_error("Can not make marker from this data type"); throw std::runtime_error("Can not make marker from this data type");
} }

View file

@ -181,10 +181,10 @@ struct warp_image_visitor
nodata_value_(nodata_value) nodata_value_(nodata_value)
{} {}
void operator() (image_null const&) {} void operator() (image_null const&) const {}
template <typename T> template <typename T>
void operator() (T const& source) void operator() (T const& source) const
{ {
using image_type = T; using image_type = T;
//source and target image data types must match //source and target image data types must match

View file

@ -89,26 +89,26 @@ void assert_g_equal(geometry<T> const& g1, geometry<T> const& g2);
struct geometry_equal_visitor struct geometry_equal_visitor
{ {
template <typename T1, typename T2> template <typename T1, typename T2>
void operator() (T1 const&, T2 const&) void operator() (T1 const&, T2 const&) const
{ {
// comparing two different types! // comparing two different types!
REQUIRE(false); REQUIRE(false);
} }
void operator() (geometry_empty const&, geometry_empty const&) void operator() (geometry_empty const&, geometry_empty const&) const
{ {
REQUIRE(true); REQUIRE(true);
} }
template <typename T> template <typename T>
void operator() (point<T> const& p1, point<T> const& p2) void operator() (point<T> const& p1, point<T> const& p2) const
{ {
REQUIRE(p1.x == Approx(p2.x)); REQUIRE(p1.x == Approx(p2.x));
REQUIRE(p1.y == Approx(p2.y)); REQUIRE(p1.y == Approx(p2.y));
} }
template <typename T> template <typename T>
void operator() (line_string<T> const& ls1, line_string<T> const& ls2) void operator() (line_string<T> const& ls1, line_string<T> const& ls2) const
{ {
if (ls1.size() != ls2.size()) if (ls1.size() != ls2.size())
{ {
@ -123,7 +123,7 @@ struct geometry_equal_visitor
} }
template <typename T> template <typename T>
void operator() (polygon<T> const& p1, polygon<T> const& p2) void operator() (polygon<T> const& p1, polygon<T> const& p2) const
{ {
(*this)(static_cast<line_string<T> const&>(p1.exterior_ring), static_cast<line_string<T> const&>(p2.exterior_ring)); (*this)(static_cast<line_string<T> const&>(p1.exterior_ring), static_cast<line_string<T> const&>(p2.exterior_ring));
@ -139,13 +139,13 @@ struct geometry_equal_visitor
} }
template <typename T> template <typename T>
void operator() (multi_point<T> const& mp1, multi_point<T> const& mp2) void operator() (multi_point<T> const& mp1, multi_point<T> const& mp2) const
{ {
(*this)(static_cast<line_string<T> const&>(mp1), static_cast<line_string<T> const&>(mp2)); (*this)(static_cast<line_string<T> const&>(mp1), static_cast<line_string<T> const&>(mp2));
} }
template <typename T> template <typename T>
void operator() (multi_line_string<T> const& mls1, multi_line_string<T> const& mls2) void operator() (multi_line_string<T> const& mls1, multi_line_string<T> const& mls2) const
{ {
if (mls1.size() != mls2.size()) if (mls1.size() != mls2.size())
{ {
@ -159,7 +159,7 @@ struct geometry_equal_visitor
} }
template <typename T> template <typename T>
void operator() (multi_polygon<T> const& mpoly1, multi_polygon<T> const& mpoly2) void operator() (multi_polygon<T> const& mpoly1, multi_polygon<T> const& mpoly2) const
{ {
if (mpoly1.size() != mpoly2.size()) if (mpoly1.size() != mpoly2.size())
{ {
@ -173,7 +173,7 @@ struct geometry_equal_visitor
} }
template <typename T> template <typename T>
void operator() (mapnik::util::recursive_wrapper<geometry_collection<T> > const& c1_, mapnik::util::recursive_wrapper<geometry_collection<T> > const& c2_) void operator() (mapnik::util::recursive_wrapper<geometry_collection<T> > const& c1_, mapnik::util::recursive_wrapper<geometry_collection<T> > const& c2_) const
{ {
geometry_collection<T> const& c1 = static_cast<geometry_collection<T> const&>(c1_); geometry_collection<T> const& c1 = static_cast<geometry_collection<T> const&>(c1_);
geometry_collection<T> const& c2 = static_cast<geometry_collection<T> const&>(c2_); geometry_collection<T> const& c2 = static_cast<geometry_collection<T> const&>(c2_);
@ -189,7 +189,7 @@ struct geometry_equal_visitor
} }
template <typename T> template <typename T>
void operator() (geometry_collection<T> const& c1, geometry_collection<T> const& c2) void operator() (geometry_collection<T> const& c1, geometry_collection<T> const& c2) const
{ {
if (c1.size() != c2.size()) if (c1.size() != c2.size())
{ {

View file

@ -57,13 +57,13 @@ public:
} }
template <typename T, typename std::enable_if<T::renderer_type::support_tiles>::type* = nullptr> template <typename T, typename std::enable_if<T::renderer_type::support_tiles>::type* = nullptr>
void operator()(T const & renderer) void operator()(T const& renderer) const
{ {
test(renderer); test(renderer);
} }
template <typename T, typename std::enable_if<!T::renderer_type::support_tiles>::type* = nullptr> template <typename T, typename std::enable_if<!T::renderer_type::support_tiles>::type* = nullptr>
void operator()(T const & renderer) void operator()(T const & renderer) const
{ {
if (tiles_.width == 1 && tiles_.height == 1) if (tiles_.width == 1 && tiles_.height == 1)
{ {
@ -73,7 +73,7 @@ public:
private: private:
template <typename T> template <typename T>
void test(T const & renderer) void test(T const & renderer) const
{ {
map_size size { map_.width(), map_.height() }; map_size size { map_.width(), map_.height() };
std::chrono::high_resolution_clock::time_point start(std::chrono::high_resolution_clock::now()); std::chrono::high_resolution_clock::time_point start(std::chrono::high_resolution_clock::now());
@ -96,7 +96,7 @@ private:
} }
template <typename T, typename std::enable_if<T::renderer_type::support_tiles>::type* = nullptr> template <typename T, typename std::enable_if<T::renderer_type::support_tiles>::type* = nullptr>
typename T::image_type render(T const & renderer) typename T::image_type render(T const& renderer) const
{ {
if (tiles_.width == 1 && tiles_.height == 1) if (tiles_.width == 1 && tiles_.height == 1)
{ {
@ -109,7 +109,7 @@ private:
} }
template <typename T, typename std::enable_if<!T::renderer_type::support_tiles>::type* = nullptr> template <typename T, typename std::enable_if<!T::renderer_type::support_tiles>::type* = nullptr>
typename T::image_type render(T const & renderer) typename T::image_type render(T const & renderer) const
{ {
return renderer.render(map_, scale_factor_); return renderer.render(map_, scale_factor_);
} }
@ -364,4 +364,3 @@ void runner::parse_map_sizes(std::string const & str, std::vector<map_size> & si
} }
} }

View file

@ -56,7 +56,7 @@ struct main_marker_visitor
verbose_(verbose), verbose_(verbose),
auto_open_(auto_open) {} auto_open_(auto_open) {}
int operator() (mapnik::marker_svg const& marker) int operator() (mapnik::marker_svg const& marker) const
{ {
using pixfmt = agg::pixfmt_rgba32_pre; using pixfmt = agg::pixfmt_rgba32_pre;
using renderer_base = agg::renderer_base<pixfmt>; using renderer_base = agg::renderer_base<pixfmt>;
@ -122,14 +122,14 @@ struct main_marker_visitor
// default // default
template <typename T> template <typename T>
int operator() (T const&) int operator() (T const&) const
{ {
std::clog << "svg2png error: '" << svg_name_ << "' is not a valid vector!\n"; std::clog << "svg2png error: '" << svg_name_ << "' is not a valid vector!\n";
return -1; return -1;
} }
private: private:
std::string const& svg_name_; std::string svg_name_;
bool verbose_; bool verbose_;
bool auto_open_; bool auto_open_;
}; };