]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/algorithms/detail/envelope/box.hpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / boost / geometry / algorithms / detail / envelope / box.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
6
7 // This file was modified by Oracle on 2015, 2016, 2017.
8 // Modifications copyright (c) 2015-2017, Oracle and/or its affiliates.
9
10 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
13
14 // Distributed under the Boost Software License, Version 1.0.
15 // (See accompanying file LICENSE_1_0.txt or copy at
16 // http://www.boost.org/LICENSE_1_0.txt)
17
18 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_BOX_HPP
19 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_BOX_HPP
20
21 #include <cstddef>
22
23 #include <boost/geometry/core/cs.hpp>
24 #include <boost/geometry/core/coordinate_dimension.hpp>
25 #include <boost/geometry/core/coordinate_system.hpp>
26 #include <boost/geometry/core/tags.hpp>
27
28 #include <boost/geometry/views/detail/indexed_point_view.hpp>
29
30 #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
31 #include <boost/geometry/algorithms/detail/normalize.hpp>
32 #include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
33
34 #include <boost/geometry/algorithms/dispatch/envelope.hpp>
35
36
37 namespace boost { namespace geometry
38 {
39
40 #ifndef DOXYGEN_NO_DETAIL
41 namespace detail { namespace envelope
42 {
43
44
45 template
46 <
47 std::size_t Index,
48 std::size_t Dimension,
49 std::size_t DimensionCount
50 >
51 struct envelope_indexed_box
52 {
53 template <typename BoxIn, typename BoxOut>
54 static inline void apply(BoxIn const& box_in, BoxOut& mbr)
55 {
56 detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
57 detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
58
59 detail::conversion::point_to_point
60 <
61 detail::indexed_point_view<BoxIn const, Index>,
62 detail::indexed_point_view<BoxOut, Index>,
63 Dimension,
64 DimensionCount
65 >::apply(box_in_corner, mbr_corner);
66 }
67 };
68
69 template
70 <
71 std::size_t Index,
72 std::size_t DimensionCount
73 >
74 struct envelope_indexed_box_on_spheroid
75 {
76 template <typename BoxIn, typename BoxOut>
77 static inline void apply(BoxIn const& box_in, BoxOut& mbr)
78 {
79 // transform() does not work with boxes of dimension higher
80 // than 2; to account for such boxes we transform the min/max
81 // points of the boxes using the indexed_point_view
82 detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
83 detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
84
85 // first transform the units
86 transform_units(box_in_corner, mbr_corner);
87
88 // now transform the remaining coordinates
89 detail::conversion::point_to_point
90 <
91 detail::indexed_point_view<BoxIn const, Index>,
92 detail::indexed_point_view<BoxOut, Index>,
93 2,
94 DimensionCount
95 >::apply(box_in_corner, mbr_corner);
96 }
97 };
98
99
100 struct envelope_box
101 {
102 template<typename BoxIn, typename BoxOut, typename Strategy>
103 static inline void apply(BoxIn const& box_in,
104 BoxOut& mbr,
105 Strategy const&)
106 {
107 envelope_indexed_box
108 <
109 min_corner, 0, dimension<BoxIn>::value
110 >::apply(box_in, mbr);
111
112 envelope_indexed_box
113 <
114 max_corner, 0, dimension<BoxIn>::value
115 >::apply(box_in, mbr);
116 }
117 };
118
119
120 struct envelope_box_on_spheroid
121 {
122 template <typename BoxIn, typename BoxOut, typename Strategy>
123 static inline void apply(BoxIn const& box_in,
124 BoxOut& mbr,
125 Strategy const&)
126 {
127 BoxIn box_in_normalized = detail::return_normalized<BoxIn>(box_in);
128
129 envelope_indexed_box_on_spheroid
130 <
131 min_corner, dimension<BoxIn>::value
132 >::apply(box_in_normalized, mbr);
133
134 envelope_indexed_box_on_spheroid
135 <
136 max_corner, dimension<BoxIn>::value
137 >::apply(box_in_normalized, mbr);
138 }
139 };
140
141
142 }} // namespace detail::envelope
143 #endif // DOXYGEN_NO_DETAIL
144
145 #ifndef DOXYGEN_NO_DISPATCH
146 namespace dispatch
147 {
148
149
150 template <typename Box>
151 struct envelope<Box, box_tag, cartesian_tag>
152 : detail::envelope::envelope_box
153 {};
154
155
156 template <typename Box>
157 struct envelope<Box, box_tag, spherical_polar_tag>
158 : detail::envelope::envelope_box_on_spheroid
159 {};
160
161
162 template <typename Box>
163 struct envelope<Box, box_tag, spherical_equatorial_tag>
164 : detail::envelope::envelope_box_on_spheroid
165 {};
166
167
168 template <typename Box>
169 struct envelope<Box, box_tag, geographic_tag>
170 : detail::envelope::envelope_box_on_spheroid
171 {};
172
173
174 } // namespace dispatch
175 #endif // DOXYGEN_NO_DISPATCH
176
177 }} // namespace boost::geometry
178
179 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_BOX_HPP