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 // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
7 
8 // This file was modified by Oracle on 2015, 2016.
9 // Modifications copyright (c) 2015-2016, Oracle and/or its affiliates.
10 
11 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
12 // Contributed and/or modified by Menelaos Karavelas, 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_EXPAND_BOX_HPP
19 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_BOX_HPP
20 
21 #include <cstddef>
22 #include <algorithm>
23 
24 #include <boost/mpl/assert.hpp>
25 #include <boost/type_traits/is_same.hpp>
26 
27 #include <boost/geometry/core/coordinate_dimension.hpp>
28 #include <boost/geometry/core/tags.hpp>
29 
30 #include <boost/geometry/algorithms/detail/envelope/box.hpp>
31 #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
32 
33 #include <boost/geometry/algorithms/detail/expand/indexed.hpp>
34 
35 #include <boost/geometry/algorithms/dispatch/expand.hpp>
36 
37 
38 namespace boost { namespace geometry
39 {
40 
41 #ifndef DOXYGEN_NO_DETAIL
42 namespace detail { namespace expand
43 {
44 
45 
46 struct box_on_spheroid
47 {
48     template <typename BoxOut, typename BoxIn, typename Strategy>
applyboost::geometry::detail::expand::box_on_spheroid49     static inline void apply(BoxOut& box_out,
50                              BoxIn const& box_in,
51                              Strategy const& strategy)
52     {
53         // normalize both boxes and convert box-in to be of type of box-out
54         BoxOut mbrs[2];
55         detail::envelope::envelope_box_on_spheroid::apply(box_in, mbrs[0], strategy);
56         detail::envelope::envelope_box_on_spheroid::apply(box_out, mbrs[1], strategy);
57 
58         // compute the envelope of the two boxes
59         detail::envelope::envelope_range_of_boxes::apply(mbrs, box_out, strategy);
60     }
61 };
62 
63 
64 }} // namespace detail::expand
65 #endif // DOXYGEN_NO_DETAIL
66 
67 #ifndef DOXYGEN_NO_DISPATCH
68 namespace dispatch
69 {
70 
71 
72 // Box + box -> new box containing two input boxes
73 template
74 <
75     typename BoxOut, typename BoxIn,
76     typename StrategyLess, typename StrategyGreater,
77     typename CSTagOut, typename CSTag
78 >
79 struct expand
80     <
81         BoxOut, BoxIn,
82         StrategyLess, StrategyGreater,
83         box_tag, box_tag,
84         CSTagOut, CSTag
85     > : detail::expand::expand_indexed
86         <
87             0, dimension<BoxIn>::value, StrategyLess, StrategyGreater
88         >
89 {
90     BOOST_MPL_ASSERT_MSG((boost::is_same<CSTagOut, CSTag>::value),
91                          COORDINATE_SYSTEMS_MUST_BE_THE_SAME,
92                          (types<CSTagOut, CSTag>()));
93 };
94 
95 template
96 <
97     typename BoxOut, typename BoxIn,
98     typename StrategyLess, typename StrategyGreater
99 >
100 struct expand
101     <
102         BoxOut, BoxIn,
103         StrategyLess, StrategyGreater,
104         box_tag, box_tag,
105         spherical_equatorial_tag, spherical_equatorial_tag
106     > : detail::expand::box_on_spheroid
107 {};
108 
109 template
110 <
111     typename BoxOut, typename BoxIn,
112     typename StrategyLess, typename StrategyGreater
113 >
114 struct expand
115     <
116         BoxOut, BoxIn,
117         StrategyLess, StrategyGreater,
118         box_tag, box_tag,
119         geographic_tag, geographic_tag
120     > : detail::expand::box_on_spheroid
121 {};
122 
123 
124 } // namespace dispatch
125 #endif // DOXYGEN_NO_DISPATCH
126 
127 }} // namespace boost::geometry
128 
129 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP
130