File indexing completed on 2025-01-18 09:35:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_FUNCTIONS_HPP
0014 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_FUNCTIONS_HPP
0015
0016 #include <boost/geometry/core/access.hpp>
0017 #include <boost/geometry/core/coordinate_type.hpp>
0018 #include <boost/geometry/algorithms/detail/recalculate.hpp>
0019 #include <boost/geometry/policies/robustness/robust_point_type.hpp>
0020
0021
0022 #include <boost/geometry/strategies/cartesian/point_in_box.hpp>
0023
0024 #include <boost/geometry/util/select_coordinate_type.hpp>
0025
0026
0027 namespace boost { namespace geometry
0028 {
0029
0030 #ifndef DOXYGEN_NO_DETAIL
0031 namespace detail { namespace section
0032 {
0033
0034
0035
0036 template
0037 <
0038 std::size_t Dimension,
0039 typename Geometry,
0040 typename CastedCSTag = typename tag_cast
0041 <
0042 typename cs_tag<Geometry>::type,
0043 spherical_tag
0044 >::type
0045 >
0046 struct preceding_check
0047 {
0048 template <typename Point, typename Box>
0049 static inline bool apply(int dir, Point const& point, Box const& , Box const& other_box)
0050 {
0051 return (dir == 1 && get<Dimension>(point) < get<min_corner, Dimension>(other_box))
0052 || (dir == -1 && get<Dimension>(point) > get<max_corner, Dimension>(other_box));
0053 }
0054 };
0055
0056 template <typename Geometry>
0057 struct preceding_check<0, Geometry, spherical_tag>
0058 {
0059 template <typename Point, typename Box>
0060 static inline bool apply(int dir, Point const& point, Box const& point_box, Box const& other_box)
0061 {
0062 typedef typename select_coordinate_type
0063 <
0064 Point, Box
0065 >::type calc_t;
0066 typedef typename coordinate_system<Point>::type::units units_t;
0067
0068 calc_t const c0 = 0;
0069
0070 calc_t const value = get<0>(point);
0071 calc_t const other_min = get<min_corner, 0>(other_box);
0072 calc_t const other_max = get<max_corner, 0>(other_box);
0073
0074 bool const pt_covered = strategy::within::detail::covered_by_range
0075 <
0076 Point, 0, spherical_tag
0077 >::apply(value,
0078 other_min,
0079 other_max);
0080
0081 if (pt_covered)
0082 {
0083 return false;
0084 }
0085
0086 if (dir == 1)
0087 {
0088 calc_t const diff_min = math::longitude_distance_signed
0089 <
0090 units_t, calc_t
0091 >(other_min, value);
0092
0093 calc_t const diff_min_min = math::longitude_distance_signed
0094 <
0095 units_t, calc_t
0096 >(other_min, get<min_corner, 0>(point_box));
0097
0098 return diff_min < c0 && diff_min_min <= c0 && diff_min_min <= diff_min;
0099 }
0100 else if (dir == -1)
0101 {
0102 calc_t const diff_max = math::longitude_distance_signed
0103 <
0104 units_t, calc_t
0105 >(other_max, value);
0106
0107 calc_t const diff_max_max = math::longitude_distance_signed
0108 <
0109 units_t, calc_t
0110 >(other_max, get<max_corner, 0>(point_box));
0111
0112 return diff_max > c0 && diff_max_max >= c0 && diff_max <= diff_max_max;
0113 }
0114
0115 return false;
0116 }
0117 };
0118
0119
0120 template
0121 <
0122 std::size_t Dimension,
0123 typename Point,
0124 typename Box,
0125 typename RobustPolicy
0126 >
0127 inline bool preceding(int dir,
0128 Point const& point,
0129 Box const& point_box,
0130 Box const& other_box,
0131 RobustPolicy const& robust_policy)
0132 {
0133 using box_point_type = typename geometry::point_type<Box>::type;
0134 typename geometry::robust_point_type<box_point_type, RobustPolicy>::type robust_point;
0135 geometry::recalculate(robust_point, point, robust_policy);
0136
0137
0138 assert_coordinate_type_equal(robust_point, point_box);
0139
0140 return preceding_check<Dimension, Box>::apply(dir, robust_point,
0141 point_box,
0142 other_box);
0143 }
0144
0145 template
0146 <
0147 std::size_t Dimension,
0148 typename Point,
0149 typename Box,
0150 typename RobustPolicy
0151 >
0152 inline bool exceeding(int dir,
0153 Point const& point,
0154 Box const& point_box,
0155 Box const& other_box,
0156 RobustPolicy const& robust_policy)
0157 {
0158 return preceding<Dimension>(-dir, point, point_box, other_box, robust_policy);
0159 }
0160
0161
0162 }}
0163 #endif
0164
0165
0166 }}
0167
0168 #endif