geometry_collection_view.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Boost.Geometry
  2. // Copyright (c) 2022, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_VIEWS_GEOMETRY_COLLECTION_VIEW_HPP
  7. #define BOOST_GEOMETRY_VIEWS_GEOMETRY_COLLECTION_VIEW_HPP
  8. #include <boost/core/addressof.hpp>
  9. #include <boost/geometry/core/geometry_types.hpp>
  10. #include <boost/geometry/core/tag.hpp>
  11. #include <boost/geometry/core/tags.hpp>
  12. #include <boost/geometry/core/visit.hpp>
  13. #include <boost/geometry/util/sequence.hpp>
  14. namespace boost { namespace geometry
  15. {
  16. namespace detail
  17. {
  18. template <typename Geometry>
  19. class geometry_collection_view
  20. {
  21. public:
  22. using iterator = Geometry const*;
  23. using const_iterator = Geometry const*;
  24. explicit geometry_collection_view(Geometry const& geometry)
  25. : m_geometry(geometry)
  26. {}
  27. const_iterator begin() const { return boost::addressof(m_geometry); }
  28. const_iterator end() const { return boost::addressof(m_geometry) + 1; }
  29. private:
  30. Geometry const& m_geometry;
  31. };
  32. } // namespace detail
  33. #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  34. namespace traits
  35. {
  36. template <typename Geometry>
  37. struct tag<geometry::detail::geometry_collection_view<Geometry>>
  38. {
  39. using type = geometry_collection_tag;
  40. };
  41. template <typename Geometry>
  42. struct geometry_types<geometry::detail::geometry_collection_view<Geometry>>
  43. {
  44. using type = util::type_sequence<Geometry>;
  45. };
  46. template <typename Geometry>
  47. struct iter_visit<geometry::detail::geometry_collection_view<Geometry>>
  48. {
  49. template <typename Function, typename Iterator>
  50. static void apply(Function && function, Iterator iterator)
  51. {
  52. function(*iterator);
  53. }
  54. };
  55. } // namespace traits
  56. #endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
  57. }} // namespace boost::geometry
  58. #endif // BOOST_GEOMETRY_VIEWS_GEOMETRY_COLLECTION_VIEW_HPP