Imported Upstream version 1.64.0
[platform/upstream/boost.git] / boost / geometry / algorithms / detail / expand / segment.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 // 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_SEGMENT_HPP
19 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_SEGMENT_HPP
20
21 #include <boost/mpl/assert.hpp>
22 #include <boost/type_traits/is_same.hpp>
23
24 #include <boost/geometry/core/coordinate_dimension.hpp>
25 #include <boost/geometry/core/tags.hpp>
26
27 #include <boost/geometry/algorithms/detail/envelope/box.hpp>
28 #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
29 #include <boost/geometry/algorithms/detail/envelope/segment.hpp>
30
31 #include <boost/geometry/algorithms/detail/expand/indexed.hpp>
32
33 #include <boost/geometry/algorithms/dispatch/expand.hpp>
34
35
36 namespace boost { namespace geometry
37 {
38
39 #ifndef DOXYGEN_NO_DETAIL
40 namespace detail { namespace expand
41 {
42
43 struct segment
44 {
45     template <typename Box, typename Segment, typename Strategy>
46     static inline void apply(Box& box,
47                              Segment const& segment,
48                              Strategy const& strategy)
49     {
50         Box mbrs[2];
51
52         // compute the envelope of the segment
53         typename point_type<Segment>::type p[2];
54         detail::assign_point_from_index<0>(segment, p[0]);
55         detail::assign_point_from_index<1>(segment, p[1]);
56         detail::envelope::envelope_segment
57             <
58                 dimension<Segment>::value
59             >::apply(p[0], p[1], mbrs[0], strategy);
60
61         // normalize the box
62         detail::envelope::envelope_box_on_spheroid::apply(box, mbrs[1], strategy);
63
64         // compute the envelope of the two boxes
65         detail::envelope::envelope_range_of_boxes::apply(mbrs, box, strategy);
66     }
67 };
68
69
70 }} // namespace detail::expand
71 #endif // DOXYGEN_NO_DETAIL
72
73 #ifndef DOXYGEN_NO_DISPATCH
74 namespace dispatch
75 {
76
77 template
78 <
79     typename Box, typename Segment,
80     typename StrategyLess, typename StrategyGreater,
81     typename CSTagOut, typename CSTag
82 >
83 struct expand
84     <
85         Box, Segment,
86         StrategyLess, StrategyGreater,
87         box_tag, segment_tag,
88         CSTagOut, CSTag
89     > : detail::expand::expand_indexed
90         <
91             0, dimension<Segment>::value, StrategyLess, StrategyGreater
92         >
93 {
94     BOOST_MPL_ASSERT_MSG((boost::is_same<CSTagOut, CSTag>::value),
95                          COORDINATE_SYSTEMS_MUST_BE_THE_SAME,
96                          (types<CSTagOut, CSTag>()));
97 };
98
99 template
100 <
101     typename Box, typename Segment,
102     typename StrategyLess, typename StrategyGreater
103 >
104 struct expand
105     <
106         Box, Segment,
107         StrategyLess, StrategyGreater,
108         box_tag, segment_tag,
109         spherical_equatorial_tag, spherical_equatorial_tag
110     > : detail::expand::segment
111 {};
112
113 template
114 <
115     typename Box, typename Segment,
116     typename StrategyLess, typename StrategyGreater
117 >
118 struct expand
119     <
120         Box, Segment,
121         StrategyLess, StrategyGreater,
122         box_tag, segment_tag,
123         geographic_tag, geographic_tag
124     > : detail::expand::segment
125 {};
126
127 } // namespace dispatch
128 #endif // DOXYGEN_NO_DISPATCH
129
130 }} // namespace boost::geometry
131
132
133 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_SEGMENT_HPP