multirange_geometry.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2014-2023, Oracle and/or its affiliates.
  3. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  4. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  5. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  6. // Licensed under the Boost Software License version 1.0.
  7. // http://www.boost.org/users/license.html
  8. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIRANGE_GEOMETRY_HPP
  9. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIRANGE_GEOMETRY_HPP
  10. #include <algorithm>
  11. #include <boost/range/begin.hpp>
  12. #include <boost/range/end.hpp>
  13. #include <boost/range/value_type.hpp>
  14. #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
  15. namespace boost { namespace geometry
  16. {
  17. #ifndef DOXYGEN_NO_DETAIL
  18. namespace detail { namespace disjoint
  19. {
  20. template <typename Geometry, typename Strategy, typename BinaryPredicate>
  21. class unary_disjoint_geometry_to_query_geometry
  22. {
  23. public:
  24. unary_disjoint_geometry_to_query_geometry(Geometry const& geometry,
  25. Strategy const& strategy)
  26. : m_geometry(geometry)
  27. , m_strategy(strategy)
  28. {}
  29. template <typename QueryGeometry>
  30. inline bool operator()(QueryGeometry const& query_geometry) const
  31. {
  32. return BinaryPredicate::apply(query_geometry, m_geometry, m_strategy);
  33. }
  34. private:
  35. Geometry const& m_geometry;
  36. Strategy const& m_strategy;
  37. };
  38. template<typename MultiRange, typename ConstantSizeGeometry>
  39. struct multirange_constant_size_geometry
  40. {
  41. template <typename Strategy>
  42. static inline bool apply(MultiRange const& multirange,
  43. ConstantSizeGeometry const& constant_size_geometry,
  44. Strategy const& strategy)
  45. {
  46. using disjoint = unary_disjoint_geometry_to_query_geometry
  47. <
  48. ConstantSizeGeometry,
  49. Strategy,
  50. dispatch::disjoint
  51. <
  52. typename boost::range_value<MultiRange>::type,
  53. ConstantSizeGeometry
  54. >
  55. >;
  56. return std::all_of(boost::begin(multirange),
  57. boost::end(multirange),
  58. disjoint(constant_size_geometry, strategy));
  59. }
  60. template <typename Strategy>
  61. static inline bool apply(ConstantSizeGeometry const& constant_size_geometry,
  62. MultiRange const& multirange,
  63. Strategy const& strategy)
  64. {
  65. return apply(multirange, constant_size_geometry, strategy);
  66. }
  67. };
  68. }} // namespace detail::disjoint
  69. #endif // DOXYGEN_NO_DETAIL
  70. }} // namespace boost::geometry
  71. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_MULTIRANGE_GEOMETRY_HPP