Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / geometry / strategies / spherical / envelope.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, 2018, 2019.
8 // Modifications copyright (c) 2015-2019, 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 // 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_STRATEGIES_SPHERICAL_ENVELOPE_HPP
22 #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_HPP
23
24 #include <boost/geometry/algorithms/detail/envelope/initialize.hpp>
25 #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
26
27 #include <boost/geometry/iterators/segment_iterator.hpp>
28
29 #include <boost/geometry/strategies/spherical/envelope_box.hpp>
30 #include <boost/geometry/strategies/spherical/envelope_segment.hpp>
31 #include <boost/geometry/strategies/spherical/expand_box.hpp>
32 #include <boost/geometry/strategies/spherical/expand_segment.hpp>
33
34 namespace boost { namespace geometry
35 {
36
37 namespace strategy { namespace envelope
38 {
39
40 template <typename CalculationType = void>
41 class spherical
42 {
43 public:
44     typedef spherical_tag cs_tag;
45
46     typedef spherical_segment<CalculationType> element_envelope_strategy_type;
47     static inline element_envelope_strategy_type get_element_envelope_strategy()
48     {
49         return element_envelope_strategy_type();
50     }
51
52     typedef expand::spherical_segment<CalculationType> element_expand_strategy_type;
53     static inline element_expand_strategy_type get_element_expand_strategy()
54     {
55         return element_expand_strategy_type();
56     }
57
58     typedef strategy::expand::spherical_box box_expand_strategy_type;
59     static inline box_expand_strategy_type get_box_expand_strategy()
60     {
61         return box_expand_strategy_type();
62     }
63
64     // Linestring, Ring, Polygon
65
66     template <typename Range>
67     static inline geometry::segment_iterator<Range const> begin(Range const& range)
68     {
69         return geometry::segments_begin(range);
70     }
71
72     template <typename Range>
73     static inline geometry::segment_iterator<Range const> end(Range const& range)
74     {
75         return geometry::segments_end(range);
76     }
77
78     // MultiLinestring, MultiPolygon
79
80     template <typename Box>
81     struct multi_state
82     {
83         void apply(Box const& single_box)
84         {
85             m_boxes.push_back(single_box);
86         }
87
88         void result(Box & box)
89         {
90             if (!m_boxes.empty())
91             {
92                 geometry::detail::envelope::envelope_range_of_boxes::apply(m_boxes, box);
93             }
94             else
95             {
96                 geometry::detail::envelope::initialize<Box, 0, dimension<Box>::value>::apply(box);
97             }
98         }
99
100     private:
101         std::vector<Box> m_boxes;
102     };
103
104     // Segment
105
106     template <typename Point1, typename Point2, typename Box>
107     static inline void apply(Point1 const& point1, Point2 const& point2,
108                              Box& box)
109     {
110         spherical_segment<CalculationType>::apply(point1, point2, box);
111     }
112
113     // Box
114
115     template <typename BoxIn, typename Box>
116     static inline void apply(BoxIn const& box_in, Box& box)
117     {
118         spherical_box::apply(box_in, box);
119     }
120 };
121
122 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
123
124 namespace services
125 {
126
127 template <typename Tag, typename CalculationType>
128 struct default_strategy<Tag, spherical_equatorial_tag, CalculationType>
129 {
130     typedef strategy::envelope::spherical<CalculationType> type;
131 };
132
133 template <typename Tag, typename CalculationType>
134 struct default_strategy<Tag, spherical_polar_tag, CalculationType>
135 {
136     typedef strategy::envelope::spherical<CalculationType> type;
137 };
138
139 }
140
141 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
142
143
144 }} // namespace strategy::envelope
145
146 }} //namepsace boost::geometry
147
148 #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_HPP