envelope_range.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. // Licensed under the Boost Software License version 1.0.
  5. // http://www.boost.org/users/license.html
  6. #ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_RANGE_HPP
  7. #define BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_RANGE_HPP
  8. #include <boost/range/begin.hpp>
  9. #include <boost/range/end.hpp>
  10. #include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
  11. #include <boost/geometry/strategy/cartesian/envelope_point.hpp>
  12. #include <boost/geometry/strategy/cartesian/expand_point.hpp>
  13. namespace boost { namespace geometry
  14. {
  15. namespace strategy { namespace envelope
  16. {
  17. class cartesian_range
  18. {
  19. public:
  20. template <typename Range, typename Box>
  21. static inline void apply(Range const& range, Box& mbr)
  22. {
  23. auto it = boost::begin(range);
  24. auto const end = boost::end(range);
  25. if (it == end)
  26. {
  27. // initialize box (assign inverse)
  28. geometry::detail::envelope::initialize<Box>::apply(mbr);
  29. return;
  30. }
  31. // initialize box with the first point
  32. envelope::cartesian_point::apply(*it, mbr);
  33. // consider now the remaining points in the range (if any)
  34. for (++it; it != end; ++it)
  35. {
  36. expand::cartesian_point::apply(mbr, *it);
  37. }
  38. }
  39. };
  40. }} // namespace strategy::envelope
  41. }} //namepsace boost::geometry
  42. #endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_ENVELOPE_RANGE_HPP