multirange_geometry.hpp 2.8 KB

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