From 834a74b1ed50788c5d110902727ba1c68fccfd04 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Tue, 24 Mar 2015 18:43:05 -0700 Subject: [PATCH] make geometry_correct more flexible but harder to misuse --- include/mapnik/geometry_correct.hpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/include/mapnik/geometry_correct.hpp b/include/mapnik/geometry_correct.hpp index 59da9d172..9c9f0ec6d 100644 --- a/include/mapnik/geometry_correct.hpp +++ b/include/mapnik/geometry_correct.hpp @@ -27,6 +27,8 @@ #include #include +#include + namespace mapnik { namespace geometry { namespace detail { @@ -35,6 +37,11 @@ struct geometry_correct { using result_type = void; + result_type operator() (geometry & geom) const + { + mapnik::util::apply_visitor(*this, geom); + } + result_type operator() (geometry_collection & collection) const { for (auto & geom : collection) @@ -45,12 +52,12 @@ struct geometry_correct result_type operator() (polygon & poly) const { - return boost::geometry::correct(poly); + boost::geometry::correct(poly); } result_type operator() (multi_polygon & multi_poly) const { - return boost::geometry::correct(multi_poly); + boost::geometry::correct(multi_poly); } template @@ -58,13 +65,16 @@ struct geometry_correct { //no-op } + }; } -inline void correct(mapnik::geometry::geometry & geom) +template +inline void correct(GeomType & geom) { - return mapnik::util::apply_visitor(detail::geometry_correct(), geom); + static_assert(!std::is_const::value,"mapnik::geometry::correct on const& is invalid"); + detail::geometry_correct()(geom); } }}