]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/sections/section_functions.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / sections / section_functions.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2015 Barend Gehrels, Amsterdam, the Netherlands.
4
5 // This file was modified by Oracle on 2015, 2017.
6 // Modifications copyright (c) 2015-2017, Oracle and/or its affiliates.
7
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
9
10 // Use, modification and distribution is subject to the Boost Software License,
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
12 // http://www.boost.org/LICENSE_1_0.txt)
13
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_FUNCTIONS_HPP
15 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_FUNCTIONS_HPP
16
17
18 #include <boost/geometry/core/access.hpp>
19 #include <boost/geometry/algorithms/detail/recalculate.hpp>
20 #include <boost/geometry/policies/robustness/robust_point_type.hpp>
21
22 // For spherical/geographic longitudes covered_by point/box
23 #include <boost/geometry/strategies/cartesian/point_in_box.hpp>
24
25
26 namespace boost { namespace geometry
27 {
28
29 #ifndef DOXYGEN_NO_DETAIL
30 namespace detail { namespace section
31 {
32
33 template
34 <
35 std::size_t Dimension,
36 typename Geometry,
37 typename CastedCSTag = typename tag_cast
38 <
39 typename cs_tag<Geometry>::type,
40 spherical_tag
41 >::type
42 >
43 struct preceding_check
44 {
45 template <typename Point, typename Box>
46 static inline bool apply(int dir, Point const& point, Box const& /*point_box*/, Box const& other_box)
47 {
48 return (dir == 1 && get<Dimension>(point) < get<min_corner, Dimension>(other_box))
49 || (dir == -1 && get<Dimension>(point) > get<max_corner, Dimension>(other_box));
50 }
51 };
52
53 template <typename Geometry>
54 struct preceding_check<0, Geometry, spherical_tag>
55 {
56 template <typename Point, typename Box>
57 static inline bool apply(int dir, Point const& point, Box const& point_box, Box const& other_box)
58 {
59 typedef typename select_coordinate_type
60 <
61 Point, Box
62 >::type calc_t;
63 typedef typename coordinate_system<Point>::type::units units_t;
64
65 calc_t const c0 = 0;
66
67 calc_t const value = get<0>(point);
68 calc_t const other_min = get<min_corner, 0>(other_box);
69 calc_t const other_max = get<max_corner, 0>(other_box);
70
71 bool const pt_covered = strategy::within::covered_by_range
72 <
73 Point, 0, spherical_tag
74 >::apply(value,
75 other_min,
76 other_max);
77
78 if (pt_covered)
79 {
80 return false;
81 }
82
83 if (dir == 1)
84 {
85 calc_t const diff_min = math::longitude_distance_signed
86 <
87 units_t, calc_t
88 >(other_min, value);
89
90 calc_t const diff_min_min = math::longitude_distance_signed
91 <
92 units_t, calc_t
93 >(other_min, get<min_corner, 0>(point_box));
94
95 return diff_min < c0 && diff_min_min <= c0 && diff_min_min <= diff_min;
96 }
97 else if (dir == -1)
98 {
99 calc_t const diff_max = math::longitude_distance_signed
100 <
101 units_t, calc_t
102 >(other_max, value);
103
104 calc_t const diff_max_max = math::longitude_distance_signed
105 <
106 units_t, calc_t
107 >(other_max, get<max_corner, 0>(point_box));
108
109 return diff_max > c0 && diff_max_max >= c0 && diff_max <= diff_max_max;
110 }
111
112 return false;
113 }
114 };
115
116
117 template
118 <
119 std::size_t Dimension,
120 typename Point,
121 typename RobustBox,
122 typename RobustPolicy
123 >
124 static inline bool preceding(int dir,
125 Point const& point,
126 RobustBox const& point_robust_box,
127 RobustBox const& other_robust_box,
128 RobustPolicy const& robust_policy)
129 {
130 typename geometry::robust_point_type<Point, RobustPolicy>::type robust_point;
131 geometry::recalculate(robust_point, point, robust_policy);
132 return preceding_check<Dimension, Point>::apply(dir, robust_point, point_robust_box, other_robust_box);
133 }
134
135 template
136 <
137 std::size_t Dimension,
138 typename Point,
139 typename RobustBox,
140 typename RobustPolicy
141 >
142 static inline bool exceeding(int dir,
143 Point const& point,
144 RobustBox const& point_robust_box,
145 RobustBox const& other_robust_box,
146 RobustPolicy const& robust_policy)
147 {
148 return preceding<Dimension>(-dir, point, point_robust_box, other_robust_box, robust_policy);
149 }
150
151
152 }} // namespace detail::section
153 #endif
154
155
156 }} // namespace boost::geometry
157
158 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_FUNCTIONS_HPP