geometry_collection.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Boost.Geometry
  2. // Copyright (c) 2021, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_GEOMETRY_COLLECTION_HPP
  8. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_GEOMETRY_COLLECTION_HPP
  9. #include <boost/geometry/algorithms/detail/visit.hpp>
  10. #include <boost/geometry/algorithms/dispatch/envelope.hpp>
  11. #include <boost/geometry/algorithms/is_empty.hpp>
  12. #include <boost/geometry/core/tags.hpp>
  13. namespace boost { namespace geometry
  14. {
  15. #ifndef DOXYGEN_NO_DISPATCH
  16. namespace dispatch
  17. {
  18. template <typename Collection>
  19. struct envelope<Collection, geometry_collection_tag>
  20. {
  21. template <typename Geometry, typename Box, typename Strategies>
  22. static inline void apply(Geometry const& geometry,
  23. Box& mbr,
  24. Strategies const& strategies)
  25. {
  26. using strategy_t = decltype(strategies.envelope(geometry, mbr));
  27. typename strategy_t::template state<Box> state;
  28. detail::visit_breadth_first([&](auto const& g)
  29. {
  30. if (! geometry::is_empty(g))
  31. {
  32. Box b;
  33. envelope<util::remove_cref_t<decltype(g)>>::apply(g, b, strategies);
  34. strategy_t::apply(state, b);
  35. }
  36. return true;
  37. }, geometry);
  38. strategy_t::result(state, mbr);
  39. }
  40. };
  41. } // namespace dispatch
  42. #endif // DOXYGEN_NO_DISPATCH
  43. }} // namespace boost::geometry
  44. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_GEOMETRY_COLLECTION_HPP