From c2d00d86191ea4968ce6a70f5ee02a5a941ba102 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 7 Jun 2014 17:43:07 +0200 Subject: [PATCH] [unique] Move from multi/ and drop TypeOf dependency --- include/boost/geometry/algorithms/unique.hpp | 48 ++++++++++++-- .../geometry/multi/algorithms/unique.hpp | 66 ------------------- 2 files changed, 44 insertions(+), 70 deletions(-) diff --git a/include/boost/geometry/algorithms/unique.hpp b/include/boost/geometry/algorithms/unique.hpp index b64f7565c..5a7a11e80 100644 --- a/include/boost/geometry/algorithms/unique.hpp +++ b/include/boost/geometry/algorithms/unique.hpp @@ -17,10 +17,11 @@ #include #include -#include +#include #include #include +#include #include #include @@ -59,9 +60,14 @@ struct polygon_unique { range_unique::apply(exterior_ring(polygon), policy); - typename interior_return_type::type rings - = interior_rings(polygon); - for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it) + typedef typename interior_return_type::type rings_ref; + typedef typename boost::range_iterator + < + typename boost::remove_reference::type + >::type rings_iterator; + + rings_ref rings = interior_rings(polygon); + for (rings_iterator it = boost::begin(rings); it != boost::end(rings); ++it) { range_unique::apply(*it, policy); } @@ -69,6 +75,22 @@ struct polygon_unique }; +template +struct multi_unique +{ + template + static inline void apply(MultiGeometry& multi, ComparePolicy const& compare) + { + for (typename boost::range_iterator::type + it = boost::begin(multi); + it != boost::end(multi); + ++it) + { + Policy::apply(*it, compare); + } + } +}; + }} // namespace detail::unique #endif // DOXYGEN_NO_DETAIL @@ -111,6 +133,24 @@ struct unique {}; +// For points, unique is not applicable and does nothing +// (Note that it is not "spatially unique" but that it removes duplicate coordinates, +// like std::unique does). Spatially unique is "dissolve" which can (or will be) +// possible for multi-points as well, removing points at the same location. + + +template +struct unique + : detail::unique::multi_unique +{}; + + +template +struct unique + : detail::unique::multi_unique +{}; + + } // namespace dispatch #endif diff --git a/include/boost/geometry/multi/algorithms/unique.hpp b/include/boost/geometry/multi/algorithms/unique.hpp index d20de8ab7..fa063a312 100644 --- a/include/boost/geometry/multi/algorithms/unique.hpp +++ b/include/boost/geometry/multi/algorithms/unique.hpp @@ -15,73 +15,7 @@ #define BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP -#include - #include -#include -#include - - -namespace boost { namespace geometry -{ - - -#ifndef DOXYGEN_NO_DETAIL -namespace detail { namespace unique -{ - - -template -struct multi_unique -{ - template - static inline void apply(MultiGeometry& multi, ComparePolicy const& compare) - { - for (typename boost::range_iterator::type - it = boost::begin(multi); - it != boost::end(multi); - ++it) - { - Policy::apply(*it, compare); - } - } -}; - - -}} // namespace detail::unique -#endif // DOXYGEN_NO_DETAIL - - - -#ifndef DOXYGEN_NO_DISPATCH -namespace dispatch -{ - - -// For points, unique is not applicable and does nothing -// (Note that it is not "spatially unique" but that it removes duplicate coordinates, -// like std::unique does). Spatially unique is "dissolve" which can (or will be) -// possible for multi-points as well, removing points at the same location. - - -template -struct unique - : detail::unique::multi_unique -{}; - - -template -struct unique - : detail::unique::multi_unique -{}; - - -} // namespace dispatch -#endif - - -}} // namespace boost::geometry - #endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP