make geometry_correct more flexible but harder to misuse
This commit is contained in:
parent
93e825d727
commit
834a74b1ed
1 changed files with 14 additions and 4 deletions
|
@ -27,6 +27,8 @@
|
||||||
#include <mapnik/geometry_adapters.hpp>
|
#include <mapnik/geometry_adapters.hpp>
|
||||||
#include <boost/geometry/algorithms/correct.hpp>
|
#include <boost/geometry/algorithms/correct.hpp>
|
||||||
|
|
||||||
|
#include <type_traits>
|
||||||
|
|
||||||
namespace mapnik { namespace geometry {
|
namespace mapnik { namespace geometry {
|
||||||
|
|
||||||
namespace detail {
|
namespace detail {
|
||||||
|
@ -35,6 +37,11 @@ struct geometry_correct
|
||||||
{
|
{
|
||||||
using result_type = void;
|
using result_type = void;
|
||||||
|
|
||||||
|
result_type operator() (geometry & geom) const
|
||||||
|
{
|
||||||
|
mapnik::util::apply_visitor(*this, geom);
|
||||||
|
}
|
||||||
|
|
||||||
result_type operator() (geometry_collection & collection) const
|
result_type operator() (geometry_collection & collection) const
|
||||||
{
|
{
|
||||||
for (auto & geom : collection)
|
for (auto & geom : collection)
|
||||||
|
@ -45,12 +52,12 @@ struct geometry_correct
|
||||||
|
|
||||||
result_type operator() (polygon & poly) const
|
result_type operator() (polygon & poly) const
|
||||||
{
|
{
|
||||||
return boost::geometry::correct(poly);
|
boost::geometry::correct(poly);
|
||||||
}
|
}
|
||||||
|
|
||||||
result_type operator() (multi_polygon & multi_poly) const
|
result_type operator() (multi_polygon & multi_poly) const
|
||||||
{
|
{
|
||||||
return boost::geometry::correct(multi_poly);
|
boost::geometry::correct(multi_poly);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -58,13 +65,16 @@ struct geometry_correct
|
||||||
{
|
{
|
||||||
//no-op
|
//no-op
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void correct(mapnik::geometry::geometry & geom)
|
template <typename GeomType>
|
||||||
|
inline void correct(GeomType & geom)
|
||||||
{
|
{
|
||||||
return mapnik::util::apply_visitor(detail::geometry_correct(), geom);
|
static_assert(!std::is_const<GeomType>::value,"mapnik::geometry::correct on const& is invalid");
|
||||||
|
detail::geometry_correct()(geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
|
Loading…
Reference in a new issue