mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-12 12:12:10 +00:00
[unique] Move from multi/ and drop TypeOf dependency
This commit is contained in:
@@ -17,10 +17,11 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include <boost/range.hpp>
|
||||
#include <boost/typeof/typeof.hpp>
|
||||
#include <boost/type_traits/remove_reference.hpp>
|
||||
|
||||
#include <boost/geometry/core/interior_rings.hpp>
|
||||
#include <boost/geometry/core/mutable_range.hpp>
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
#include <boost/geometry/policies/compare.hpp>
|
||||
|
||||
@@ -59,9 +60,14 @@ struct polygon_unique
|
||||
{
|
||||
range_unique::apply(exterior_ring(polygon), policy);
|
||||
|
||||
typename interior_return_type<Polygon>::type rings
|
||||
= interior_rings(polygon);
|
||||
for (BOOST_AUTO_TPL(it, boost::begin(rings)); it != boost::end(rings); ++it)
|
||||
typedef typename interior_return_type<Polygon>::type rings_ref;
|
||||
typedef typename boost::range_iterator
|
||||
<
|
||||
typename boost::remove_reference<rings_ref>::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 <typename Policy>
|
||||
struct multi_unique
|
||||
{
|
||||
template <typename MultiGeometry, typename ComparePolicy>
|
||||
static inline void apply(MultiGeometry& multi, ComparePolicy const& compare)
|
||||
{
|
||||
for (typename boost::range_iterator<MultiGeometry>::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<Polygon, polygon_tag>
|
||||
{};
|
||||
|
||||
|
||||
// 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 <typename MultiLineString>
|
||||
struct unique<MultiLineString, multi_linestring_tag>
|
||||
: detail::unique::multi_unique<detail::unique::range_unique>
|
||||
{};
|
||||
|
||||
|
||||
template <typename MultiPolygon>
|
||||
struct unique<MultiPolygon, multi_polygon_tag>
|
||||
: detail::unique::multi_unique<detail::unique::polygon_unique>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif
|
||||
|
||||
|
||||
@@ -15,73 +15,7 @@
|
||||
#define BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP
|
||||
|
||||
|
||||
#include <boost/range.hpp>
|
||||
|
||||
#include <boost/geometry/algorithms/unique.hpp>
|
||||
|
||||
#include <boost/geometry/core/tags.hpp>
|
||||
#include <boost/geometry/geometries/concepts/check.hpp>
|
||||
|
||||
|
||||
namespace boost { namespace geometry
|
||||
{
|
||||
|
||||
|
||||
#ifndef DOXYGEN_NO_DETAIL
|
||||
namespace detail { namespace unique
|
||||
{
|
||||
|
||||
|
||||
template <typename Policy>
|
||||
struct multi_unique
|
||||
{
|
||||
template <typename MultiGeometry, typename ComparePolicy>
|
||||
static inline void apply(MultiGeometry& multi, ComparePolicy const& compare)
|
||||
{
|
||||
for (typename boost::range_iterator<MultiGeometry>::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 <typename MultiLineString>
|
||||
struct unique<MultiLineString, multi_linestring_tag>
|
||||
: detail::unique::multi_unique<detail::unique::range_unique>
|
||||
{};
|
||||
|
||||
|
||||
template <typename MultiPolygon>
|
||||
struct unique<MultiPolygon, multi_polygon_tag>
|
||||
: detail::unique::multi_unique<detail::unique::polygon_unique>
|
||||
{};
|
||||
|
||||
|
||||
} // namespace dispatch
|
||||
#endif
|
||||
|
||||
|
||||
}} // namespace boost::geometry
|
||||
|
||||
|
||||
#endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP
|
||||
|
||||
Reference in New Issue
Block a user