]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategy/geographic/envelope_segment.hpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / boost / geometry / strategy / geographic / envelope_segment.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2
3 // Copyright (c) 2017-2020 Oracle and/or its affiliates.
4 // Contributed and/or modified by Vissarion Fisikopoulos, on behalf of Oracle
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
12 #define BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
13
14
15 #include <boost/geometry/srs/spheroid.hpp>
16
17 #include <boost/geometry/strategy/cartesian/envelope_segment.hpp>
18 #include <boost/geometry/strategy/envelope.hpp>
19 #include <boost/geometry/strategies/geographic/azimuth.hpp>
20 #include <boost/geometry/strategies/geographic/parameters.hpp>
21 #include <boost/geometry/strategies/normalize.hpp>
22 #include <boost/geometry/strategy/spherical/envelope_segment.hpp>
23 #include <boost/geometry/strategy/spherical/expand_box.hpp>
24
25 namespace boost { namespace geometry
26 {
27
28 namespace strategy { namespace envelope
29 {
30
31 template
32 <
33 typename FormulaPolicy = strategy::andoyer,
34 typename Spheroid = geometry::srs::spheroid<double>,
35 typename CalculationType = void
36 >
37 class geographic_segment
38 {
39 public:
40 typedef Spheroid model_type;
41
42 inline geographic_segment()
43 : m_spheroid()
44 {}
45
46 explicit inline geographic_segment(Spheroid const& spheroid)
47 : m_spheroid(spheroid)
48 {}
49
50 template <typename Point, typename Box>
51 inline void apply(Point const& point1, Point const& point2, Box& box) const
52 {
53 Point p1_normalized, p2_normalized;
54 strategy::normalize::spherical_point::apply(point1, p1_normalized);
55 strategy::normalize::spherical_point::apply(point2, p2_normalized);
56
57 geometry::strategy::azimuth::geographic
58 <
59 FormulaPolicy,
60 Spheroid,
61 CalculationType
62 > azimuth_geographic(m_spheroid);
63
64 typedef typename geometry::detail::cs_angular_units
65 <
66 Point
67 >::type units_type;
68
69 // first compute the envelope range for the first two coordinates
70 strategy::envelope::detail::envelope_segment_impl
71 <
72 geographic_tag
73 >::template apply<units_type>(geometry::get<0>(p1_normalized),
74 geometry::get<1>(p1_normalized),
75 geometry::get<0>(p2_normalized),
76 geometry::get<1>(p2_normalized),
77 box,
78 azimuth_geographic);
79
80 // now compute the envelope range for coordinates of
81 // dimension 2 and higher
82 strategy::envelope::detail::envelope_one_segment
83 <
84 2, dimension<Point>::value
85 >::apply(point1, point2, box);
86 }
87
88 Spheroid model() const
89 {
90 return m_spheroid;
91 }
92
93 private:
94 Spheroid m_spheroid;
95 };
96
97 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
98
99 namespace services
100 {
101
102 template <typename CalculationType>
103 struct default_strategy<segment_tag, geographic_tag, CalculationType>
104 {
105 typedef strategy::envelope::geographic_segment
106 <
107 strategy::andoyer,
108 srs::spheroid<double>,
109 CalculationType
110 > type;
111 };
112
113 }
114
115 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
116
117
118 }} // namespace strategy::envelope
119
120 }} //namepsace boost::geometry
121
122 #endif // BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP