123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_BOX_BOX_HPP
- #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_BOX_BOX_HPP
- #include <cstddef>
- #include <boost/geometry/core/cs.hpp>
- #include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
- #include <boost/geometry/strategies/disjoint.hpp>
- #include <boost/geometry/util/normalize_spheroidal_coordinates.hpp>
- #include <boost/geometry/util/select_most_precise.hpp>
- namespace boost { namespace geometry { namespace strategy { namespace disjoint
- {
- #ifndef DOXYGEN_NO_DETAIL
- namespace detail
- {
- struct box_box_on_spheroid
- {
- template <typename Box1, typename Box2>
- static inline bool apply(Box1 const& box1, Box2 const& box2)
- {
- typedef typename geometry::select_most_precise
- <
- typename coordinate_type<Box1>::type,
- typename coordinate_type<Box2>::type
- >::type calc_t;
- typedef typename geometry::detail::cs_angular_units<Box1>::type units_t;
- typedef math::detail::constants_on_spheroid<calc_t, units_t> constants;
- calc_t const b1_min = get<min_corner, 0>(box1);
- calc_t const b1_max = get<max_corner, 0>(box1);
- calc_t const b2_min = get<min_corner, 0>(box2);
- calc_t const b2_max = get<max_corner, 0>(box2);
-
- calc_t const diff1 = b1_max - b1_min;
- calc_t const diff2 = b2_max - b2_min;
-
- if (diff1 < constants::period() && diff2 < constants::period())
- {
-
- calc_t const diff_min = math::longitude_distance_unsigned<units_t>(b1_min, b2_min);
- calc_t const b2_min_transl = b1_min + diff_min;
- calc_t b2_max_transl = b2_min_transl - constants::period() + diff2;
-
-
-
- if (math::abs(b2_max_transl - b2_max) < constants::period() / 2)
- {
- b2_max_transl = b2_max;
- }
- if (b2_min_transl > b1_max
- && b2_max_transl < b1_min)
- {
- return true;
- }
- }
- return box_box
- <
- Box1, Box2, 1
- >::apply(box1, box2);
- }
- };
- }
- #endif
- struct spherical_box_box
- {
- template <typename Box1, typename Box2>
- static inline bool apply(Box1 const& box1, Box2 const& box2)
- {
- return detail::box_box_on_spheroid::apply(box1, box2);
- }
- };
- namespace services
- {
- template <typename Box1, typename Box2, int TopDim1, int TopDim2>
- struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, spherical_equatorial_tag, spherical_equatorial_tag>
- {
- typedef disjoint::spherical_box_box type;
- };
- template <typename Box1, typename Box2, int TopDim1, int TopDim2>
- struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, spherical_polar_tag, spherical_polar_tag>
- {
- typedef disjoint::spherical_box_box type;
- };
- template <typename Box1, typename Box2, int TopDim1, int TopDim2>
- struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, geographic_tag, geographic_tag>
- {
- typedef disjoint::spherical_box_box type;
- };
- }
- }}}}
- #endif
|