]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
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 | ||
1e59de90 TL |
7 | // This file was modified by Oracle on 2015-2021. |
8 | // Modifications copyright (c) 2015-2021, Oracle and/or its affiliates. | |
b32b8144 FG |
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 | // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library | |
15 | // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. | |
16 | ||
17 | // Distributed under the Boost Software License, Version 1.0. | |
18 | // (See accompanying file LICENSE_1_0.txt or copy at | |
19 | // http://www.boost.org/LICENSE_1_0.txt) | |
20 | ||
21 | #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_INTERFACE_HPP | |
22 | #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_INTERFACE_HPP | |
23 | ||
92f5a8d4 | 24 | |
b32b8144 FG |
25 | #include <boost/geometry/algorithms/dispatch/envelope.hpp> |
26 | ||
92f5a8d4 TL |
27 | #include <boost/geometry/core/coordinate_system.hpp> |
28 | #include <boost/geometry/core/tag.hpp> | |
29 | #include <boost/geometry/core/tags.hpp> | |
1e59de90 | 30 | #include <boost/geometry/core/visit.hpp> |
92f5a8d4 | 31 | |
1e59de90 | 32 | #include <boost/geometry/geometries/adapted/boost_variant.hpp> // For backward compatibility |
92f5a8d4 TL |
33 | #include <boost/geometry/geometries/concepts/check.hpp> |
34 | ||
b32b8144 | 35 | #include <boost/geometry/strategies/default_strategy.hpp> |
20effc67 TL |
36 | #include <boost/geometry/strategies/detail.hpp> |
37 | #include <boost/geometry/strategies/envelope/services.hpp> | |
92f5a8d4 TL |
38 | |
39 | #include <boost/geometry/util/select_most_precise.hpp> | |
1e59de90 | 40 | #include <boost/geometry/util/type_traits_std.hpp> |
92f5a8d4 | 41 | |
b32b8144 FG |
42 | |
43 | namespace boost { namespace geometry | |
44 | { | |
45 | ||
46 | namespace resolve_strategy | |
47 | { | |
48 | ||
20effc67 TL |
49 | template |
50 | < | |
51 | typename Strategy, | |
52 | bool IsUmbrella = strategies::detail::is_umbrella_strategy<Strategy>::value | |
53 | > | |
b32b8144 FG |
54 | struct envelope |
55 | { | |
20effc67 | 56 | template <typename Geometry, typename Box> |
b32b8144 FG |
57 | static inline void apply(Geometry const& geometry, |
58 | Box& box, | |
59 | Strategy const& strategy) | |
60 | { | |
61 | dispatch::envelope<Geometry>::apply(geometry, box, strategy); | |
62 | } | |
20effc67 TL |
63 | }; |
64 | ||
65 | template <typename Strategy> | |
66 | struct envelope<Strategy, false> | |
67 | { | |
68 | template <typename Geometry, typename Box> | |
69 | static inline void apply(Geometry const& geometry, | |
70 | Box& box, | |
71 | Strategy const& strategy) | |
72 | { | |
73 | using strategies::envelope::services::strategy_converter; | |
74 | return dispatch::envelope | |
75 | < | |
76 | Geometry | |
77 | >::apply(geometry, box, strategy_converter<Strategy>::get(strategy)); | |
78 | } | |
79 | }; | |
b32b8144 | 80 | |
20effc67 TL |
81 | template <> |
82 | struct envelope<default_strategy, false> | |
83 | { | |
84 | template <typename Geometry, typename Box> | |
b32b8144 FG |
85 | static inline void apply(Geometry const& geometry, |
86 | Box& box, | |
87 | default_strategy) | |
88 | { | |
20effc67 | 89 | typedef typename strategies::envelope::services::default_strategy |
b32b8144 | 90 | < |
20effc67 | 91 | Geometry, Box |
b32b8144 FG |
92 | >::type strategy_type; |
93 | ||
94 | dispatch::envelope<Geometry>::apply(geometry, box, strategy_type()); | |
95 | } | |
96 | }; | |
97 | ||
98 | } // namespace resolve_strategy | |
99 | ||
1e59de90 | 100 | namespace resolve_dynamic |
b32b8144 FG |
101 | { |
102 | ||
1e59de90 | 103 | template <typename Geometry, typename Tag = typename tag<Geometry>::type> |
b32b8144 FG |
104 | struct envelope |
105 | { | |
106 | template <typename Box, typename Strategy> | |
107 | static inline void apply(Geometry const& geometry, | |
108 | Box& box, | |
109 | Strategy const& strategy) | |
110 | { | |
111 | concepts::check<Geometry const>(); | |
112 | concepts::check<Box>(); | |
113 | ||
20effc67 | 114 | resolve_strategy::envelope<Strategy>::apply(geometry, box, strategy); |
b32b8144 FG |
115 | } |
116 | }; | |
117 | ||
118 | ||
1e59de90 TL |
119 | template <typename Geometry> |
120 | struct envelope<Geometry, dynamic_geometry_tag> | |
b32b8144 FG |
121 | { |
122 | template <typename Box, typename Strategy> | |
1e59de90 TL |
123 | static inline void apply(Geometry const& geometry, |
124 | Box& box, | |
125 | Strategy const& strategy) | |
b32b8144 | 126 | { |
1e59de90 | 127 | traits::visit<Geometry>::apply([&](auto const& g) |
b32b8144 | 128 | { |
1e59de90 TL |
129 | envelope<util::remove_cref_t<decltype(g)>>::apply(g, box, strategy); |
130 | }, geometry); | |
b32b8144 FG |
131 | } |
132 | }; | |
133 | ||
1e59de90 | 134 | } // namespace resolve_dynamic |
b32b8144 | 135 | |
20effc67 | 136 | |
b32b8144 FG |
137 | /*! |
138 | \brief \brief_calc{envelope (with strategy)} | |
139 | \ingroup envelope | |
140 | \details \details_calc{envelope,\det_envelope}. | |
141 | \tparam Geometry \tparam_geometry | |
142 | \tparam Box \tparam_box | |
143 | \tparam Strategy \tparam_strategy{Envelope} | |
144 | \param geometry \param_geometry | |
145 | \param mbr \param_box \param_set{envelope} | |
146 | \param strategy \param_strategy{envelope} | |
147 | ||
148 | \qbk{distinguish,with strategy} | |
149 | \qbk{[include reference/algorithms/envelope.qbk]} | |
150 | \qbk{ | |
151 | [heading Example] | |
152 | [envelope] [envelope_output] | |
153 | } | |
154 | */ | |
155 | template<typename Geometry, typename Box, typename Strategy> | |
156 | inline void envelope(Geometry const& geometry, Box& mbr, Strategy const& strategy) | |
157 | { | |
1e59de90 | 158 | resolve_dynamic::envelope<Geometry>::apply(geometry, mbr, strategy); |
b32b8144 FG |
159 | } |
160 | ||
161 | /*! | |
162 | \brief \brief_calc{envelope} | |
163 | \ingroup envelope | |
164 | \details \details_calc{envelope,\det_envelope}. | |
165 | \tparam Geometry \tparam_geometry | |
166 | \tparam Box \tparam_box | |
167 | \param geometry \param_geometry | |
168 | \param mbr \param_box \param_set{envelope} | |
169 | ||
170 | \qbk{[include reference/algorithms/envelope.qbk]} | |
171 | \qbk{ | |
172 | [heading Example] | |
173 | [envelope] [envelope_output] | |
174 | } | |
175 | */ | |
176 | template<typename Geometry, typename Box> | |
177 | inline void envelope(Geometry const& geometry, Box& mbr) | |
178 | { | |
1e59de90 | 179 | resolve_dynamic::envelope<Geometry>::apply(geometry, mbr, default_strategy()); |
b32b8144 FG |
180 | } |
181 | ||
182 | ||
183 | /*! | |
184 | \brief \brief_calc{envelope} | |
185 | \ingroup envelope | |
186 | \details \details_calc{return_envelope,\det_envelope}. \details_return{envelope} | |
187 | \tparam Box \tparam_box | |
188 | \tparam Geometry \tparam_geometry | |
189 | \tparam Strategy \tparam_strategy{Envelope} | |
190 | \param geometry \param_geometry | |
191 | \param strategy \param_strategy{envelope} | |
192 | \return \return_calc{envelope} | |
193 | ||
194 | \qbk{distinguish,with strategy} | |
195 | \qbk{[include reference/algorithms/envelope.qbk]} | |
196 | \qbk{ | |
197 | [heading Example] | |
198 | [return_envelope] [return_envelope_output] | |
199 | } | |
200 | */ | |
201 | template<typename Box, typename Geometry, typename Strategy> | |
202 | inline Box return_envelope(Geometry const& geometry, Strategy const& strategy) | |
203 | { | |
204 | Box mbr; | |
1e59de90 | 205 | resolve_dynamic::envelope<Geometry>::apply(geometry, mbr, strategy); |
b32b8144 FG |
206 | return mbr; |
207 | } | |
208 | ||
209 | /*! | |
210 | \brief \brief_calc{envelope} | |
211 | \ingroup envelope | |
212 | \details \details_calc{return_envelope,\det_envelope}. \details_return{envelope} | |
213 | \tparam Box \tparam_box | |
214 | \tparam Geometry \tparam_geometry | |
215 | \param geometry \param_geometry | |
216 | \return \return_calc{envelope} | |
217 | ||
218 | \qbk{[include reference/algorithms/envelope.qbk]} | |
219 | \qbk{ | |
220 | [heading Example] | |
221 | [return_envelope] [return_envelope_output] | |
222 | } | |
223 | */ | |
224 | template<typename Box, typename Geometry> | |
225 | inline Box return_envelope(Geometry const& geometry) | |
226 | { | |
227 | Box mbr; | |
1e59de90 | 228 | resolve_dynamic::envelope<Geometry>::apply(geometry, mbr, default_strategy()); |
b32b8144 FG |
229 | return mbr; |
230 | } | |
231 | ||
232 | }} // namespace boost::geometry | |
233 | ||
234 | #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_INTERFACE_HPP |