disjoint_segment_box.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Boost.Geometry
  2. // Copyright (c) 2017-2018 Oracle and/or its affiliates.
  3. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  4. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  5. // Use, modification and distribution is subject to the Boost Software License,
  6. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_SEGMENT_BOX_HPP
  9. #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_SEGMENT_BOX_HPP
  10. #include <cstddef>
  11. #include <utility>
  12. #include <boost/numeric/conversion/cast.hpp>
  13. #include <boost/geometry/util/math.hpp>
  14. #include <boost/geometry/util/calculation_type.hpp>
  15. #include <boost/geometry/core/access.hpp>
  16. #include <boost/geometry/core/tags.hpp>
  17. #include <boost/geometry/core/coordinate_dimension.hpp>
  18. #include <boost/geometry/core/point_type.hpp>
  19. #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
  20. #include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
  21. // TODO: spherical_point_box currently defined in the same file as cartesian
  22. #include <boost/geometry/strategies/cartesian/point_in_box.hpp>
  23. #include <boost/geometry/strategies/disjoint.hpp>
  24. #include <boost/geometry/strategies/normalize.hpp>
  25. #include <boost/geometry/strategies/spherical/azimuth.hpp>
  26. #include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
  27. namespace boost { namespace geometry { namespace strategy { namespace disjoint
  28. {
  29. // NOTE: This may be temporary place for this or corresponding strategy
  30. // It seems to be more appropriate to implement the opposite of it
  31. // e.g. intersection::segment_box because in disjoint() algorithm
  32. // other strategies that are used are intersection and covered_by strategies.
  33. struct segment_box_spherical
  34. {
  35. template <typename Segment, typename Box>
  36. struct point_in_geometry_strategy
  37. : services::default_strategy
  38. <
  39. typename point_type<Segment>::type,
  40. Box
  41. >
  42. {};
  43. template <typename Segment, typename Box>
  44. static inline typename point_in_geometry_strategy<Segment, Box>::type
  45. get_point_in_geometry_strategy()
  46. {
  47. typedef typename point_in_geometry_strategy<Segment, Box>::type strategy_type;
  48. return strategy_type();
  49. }
  50. template <typename Segment, typename Box>
  51. static inline bool apply(Segment const& segment, Box const& box)
  52. {
  53. typedef typename point_type<Segment>::type segment_point_type;
  54. typedef typename coordinate_type<segment_point_type>::type CT;
  55. geometry::strategy::azimuth::spherical<CT> azimuth_strategy;
  56. return geometry::detail::disjoint::disjoint_segment_box_sphere_or_spheroid
  57. <
  58. spherical_equatorial_tag
  59. >::apply(segment, box,
  60. azimuth_strategy,
  61. strategy::normalize::spherical_point(),
  62. strategy::covered_by::spherical_point_box(),
  63. strategy::disjoint::spherical_box_box());
  64. }
  65. };
  66. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  67. namespace services
  68. {
  69. template <typename Linear, typename Box, typename LinearTag>
  70. struct default_strategy<Linear, Box, LinearTag, box_tag, 1, 2,
  71. spherical_equatorial_tag, spherical_equatorial_tag>
  72. {
  73. typedef segment_box_spherical type;
  74. };
  75. template <typename Box, typename Linear, typename LinearTag>
  76. struct default_strategy<Box, Linear, box_tag, LinearTag, 2, 1,
  77. spherical_equatorial_tag, spherical_equatorial_tag>
  78. {
  79. typedef segment_box_spherical type;
  80. };
  81. } // namespace services
  82. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  83. }}}} // namespace boost::geometry::strategy::disjoint
  84. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_SEGMENT_BOX_HPP