File indexing completed on 2025-01-18 09:36:48
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_BOX_BOX_HPP
0022 #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_BOX_BOX_HPP
0023
0024 #include <cstddef>
0025
0026 #include <boost/geometry/core/cs.hpp>
0027
0028 #include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
0029 #include <boost/geometry/strategies/disjoint.hpp>
0030
0031 #include <boost/geometry/util/normalize_spheroidal_coordinates.hpp>
0032 #include <boost/geometry/util/select_most_precise.hpp>
0033
0034
0035 namespace boost { namespace geometry { namespace strategy { namespace disjoint
0036 {
0037
0038 #ifndef DOXYGEN_NO_DETAIL
0039 namespace detail
0040 {
0041
0042 struct box_box_on_spheroid
0043 {
0044 template <typename Box1, typename Box2>
0045 static inline bool apply(Box1 const& box1, Box2 const& box2)
0046 {
0047 typedef typename geometry::select_most_precise
0048 <
0049 typename coordinate_type<Box1>::type,
0050 typename coordinate_type<Box2>::type
0051 >::type calc_t;
0052 typedef typename geometry::detail::cs_angular_units<Box1>::type units_t;
0053 typedef math::detail::constants_on_spheroid<calc_t, units_t> constants;
0054
0055 calc_t const b1_min = get<min_corner, 0>(box1);
0056 calc_t const b1_max = get<max_corner, 0>(box1);
0057 calc_t const b2_min = get<min_corner, 0>(box2);
0058 calc_t const b2_max = get<max_corner, 0>(box2);
0059
0060
0061 calc_t const diff1 = b1_max - b1_min;
0062 calc_t const diff2 = b2_max - b2_min;
0063
0064
0065 if (diff1 < constants::period() && diff2 < constants::period())
0066 {
0067
0068 calc_t const diff_min = math::longitude_distance_unsigned<units_t>(b1_min, b2_min);
0069 calc_t const b2_min_transl = b1_min + diff_min;
0070 calc_t b2_max_transl = b2_min_transl - constants::period() + diff2;
0071
0072
0073
0074
0075 if (math::abs(b2_max_transl - b2_max) < constants::period() / 2)
0076 {
0077 b2_max_transl = b2_max;
0078 }
0079
0080 if (b2_min_transl > b1_max
0081 && b2_max_transl < b1_min)
0082 {
0083 return true;
0084 }
0085 }
0086
0087 return box_box
0088 <
0089 Box1, Box2, 1
0090 >::apply(box1, box2);
0091 }
0092 };
0093
0094 }
0095 #endif
0096
0097
0098 struct spherical_box_box
0099 {
0100 template <typename Box1, typename Box2>
0101 static inline bool apply(Box1 const& box1, Box2 const& box2)
0102 {
0103 return detail::box_box_on_spheroid::apply(box1, box2);
0104 }
0105 };
0106
0107
0108 namespace services
0109 {
0110
0111 template <typename Box1, typename Box2, int TopDim1, int TopDim2>
0112 struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, spherical_equatorial_tag, spherical_equatorial_tag>
0113 {
0114 typedef disjoint::spherical_box_box type;
0115 };
0116
0117 template <typename Box1, typename Box2, int TopDim1, int TopDim2>
0118 struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, spherical_polar_tag, spherical_polar_tag>
0119 {
0120 typedef disjoint::spherical_box_box type;
0121 };
0122
0123 template <typename Box1, typename Box2, int TopDim1, int TopDim2>
0124 struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, geographic_tag, geographic_tag>
0125 {
0126 typedef disjoint::spherical_box_box type;
0127 };
0128
0129 }
0130
0131 }}}}
0132
0133
0134 #endif