disjoint_segment_box.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // Boost.Geometry
  2. // Copyright (c) 2017-2019 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_GEOGRAPHIC_DISJOINT_SEGMENT_BOX_HPP
  9. #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISJOINT_SEGMENT_BOX_HPP
  10. #include <cstddef>
  11. #include <utility>
  12. #include <boost/geometry/util/math.hpp>
  13. #include <boost/geometry/util/calculation_type.hpp>
  14. #include <boost/geometry/core/access.hpp>
  15. #include <boost/geometry/core/tags.hpp>
  16. #include <boost/geometry/core/coordinate_dimension.hpp>
  17. #include <boost/geometry/core/point_type.hpp>
  18. #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp>
  19. #include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp>
  20. #include <boost/geometry/srs/spheroid.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/geographic/azimuth.hpp>
  25. #include <boost/geometry/strategies/geographic/parameters.hpp>
  26. #include <boost/geometry/strategies/normalize.hpp>
  27. #include <boost/geometry/strategies/spherical/disjoint_box_box.hpp>
  28. namespace boost { namespace geometry { namespace strategy { namespace disjoint
  29. {
  30. // NOTE: This may be temporary place for this or corresponding strategy
  31. // It seems to be more appropriate to implement the opposite of it
  32. // e.g. intersection::segment_box because in disjoint() algorithm
  33. // other strategies that are used are intersection and covered_by strategies.
  34. template
  35. <
  36. typename FormulaPolicy = strategy::andoyer,
  37. typename Spheroid = srs::spheroid<double>,
  38. typename CalculationType = void
  39. >
  40. struct segment_box_geographic
  41. {
  42. public:
  43. typedef Spheroid model_type;
  44. inline segment_box_geographic()
  45. : m_spheroid()
  46. {}
  47. explicit inline segment_box_geographic(Spheroid const& spheroid)
  48. : m_spheroid(spheroid)
  49. {}
  50. typedef covered_by::spherical_point_box disjoint_point_box_strategy_type;
  51. static inline disjoint_point_box_strategy_type get_disjoint_point_box_strategy()
  52. {
  53. return disjoint_point_box_strategy_type();
  54. }
  55. template <typename Segment, typename Box>
  56. inline bool apply(Segment const& segment, Box const& box) const
  57. {
  58. geometry::strategy::azimuth::geographic
  59. <
  60. FormulaPolicy,
  61. Spheroid,
  62. CalculationType
  63. > azimuth_geographic(m_spheroid);
  64. return geometry::detail::disjoint::disjoint_segment_box_sphere_or_spheroid
  65. <
  66. geographic_tag
  67. >::apply(segment, box,
  68. azimuth_geographic,
  69. strategy::normalize::spherical_point(),
  70. strategy::covered_by::spherical_point_box(),
  71. strategy::disjoint::spherical_box_box());
  72. }
  73. Spheroid const& model() const
  74. {
  75. return m_spheroid;
  76. }
  77. private:
  78. Spheroid m_spheroid;
  79. };
  80. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  81. namespace services
  82. {
  83. template <typename Linear, typename Box, typename LinearTag>
  84. struct default_strategy<Linear, Box, LinearTag, box_tag, 1, 2,
  85. geographic_tag, geographic_tag>
  86. {
  87. typedef segment_box_geographic<> type;
  88. };
  89. template <typename Box, typename Linear, typename LinearTag>
  90. struct default_strategy<Box, Linear, box_tag, LinearTag, 2, 1,
  91. geographic_tag, geographic_tag>
  92. {
  93. typedef segment_box_geographic<> type;
  94. };
  95. } // namespace services
  96. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  97. }}}} // namespace boost::geometry::strategy::disjoint
  98. #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISJOINT_SEGMENT_BOX_HPP