unique.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  6. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  7. // Use, modification and distribution is subject to the Boost Software License,
  8. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  9. // http://www.boost.org/LICENSE_1_0.txt)
  10. #ifndef BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP
  11. #define BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP
  12. #include <boost/range.hpp>
  13. #include <boost/geometry/algorithms/unique.hpp>
  14. #include <boost/geometry/multi/core/tags.hpp>
  15. #include <boost/geometry/multi/geometries/concepts/check.hpp>
  16. namespace boost { namespace geometry
  17. {
  18. #ifndef DOXYGEN_NO_DETAIL
  19. namespace detail { namespace unique
  20. {
  21. template <typename Policy>
  22. struct multi_unique
  23. {
  24. template <typename MultiGeometry, typename ComparePolicy>
  25. static inline void apply(MultiGeometry& multi, ComparePolicy const& compare)
  26. {
  27. for (typename boost::range_iterator<MultiGeometry>::type
  28. it = boost::begin(multi);
  29. it != boost::end(multi);
  30. ++it)
  31. {
  32. Policy::apply(*it, compare);
  33. }
  34. }
  35. };
  36. }} // namespace detail::unique
  37. #endif // DOXYGEN_NO_DETAIL
  38. #ifndef DOXYGEN_NO_DISPATCH
  39. namespace dispatch
  40. {
  41. // For points, unique is not applicable and does nothing
  42. // (Note that it is not "spatially unique" but that it removes duplicate coordinates,
  43. // like std::unique does). Spatially unique is "dissolve" which can (or will be)
  44. // possible for multi-points as well, removing points at the same location.
  45. template <typename MultiLineString>
  46. struct unique<MultiLineString, multi_linestring_tag>
  47. : detail::unique::multi_unique<detail::unique::range_unique>
  48. {};
  49. template <typename MultiPolygon>
  50. struct unique<MultiPolygon, multi_polygon_tag>
  51. : detail::unique::multi_unique<detail::unique::polygon_unique>
  52. {};
  53. } // namespace dispatch
  54. #endif
  55. }} // namespace boost::geometry
  56. #endif // BOOST_GEOMETRY_MULTI_ALGORITHMS_UNIQUE_HPP