1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 
3 // Copyright (c) 2017 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_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
12 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
13 
14 
15 #include <boost/geometry/algorithms/detail/envelope/segment.hpp>
16 #include <boost/geometry/algorithms/detail/normalize.hpp>
17 #include <boost/geometry/core/srs.hpp>
18 #include <boost/geometry/strategies/envelope.hpp>
19 #include <boost/geometry/strategies/geographic/azimuth.hpp>
20 #include <boost/geometry/strategies/geographic/parameters.hpp>
21 
22 
23 namespace boost { namespace geometry
24 {
25 
26 namespace strategy { namespace envelope
27 {
28 
29 template
30 <
31     typename FormulaPolicy = strategy::andoyer,
32     typename Spheroid = geometry::srs::spheroid<double>,
33     typename CalculationType = void
34 >
35 class geographic_segment
36 {
37 public:
38     typedef Spheroid model_type;
39 
geographic_segment()40     inline geographic_segment()
41         : m_spheroid()
42     {}
43 
geographic_segment(Spheroid const & spheroid)44     explicit inline geographic_segment(Spheroid const& spheroid)
45         : m_spheroid(spheroid)
46     {}
47 
48     template <typename Point1, typename Point2, typename Box>
apply(Point1 const & point1,Point2 const & point2,Box & box) const49     inline void apply(Point1 const& point1, Point2 const& point2, Box& box) const
50     {
51         Point1 p1_normalized = detail::return_normalized<Point1>(point1);
52         Point2 p2_normalized = detail::return_normalized<Point2>(point2);
53 
54         geometry::strategy::azimuth::geographic
55             <
56                 FormulaPolicy,
57                 Spheroid,
58                 CalculationType
59             > azimuth_geographic(m_spheroid);
60 
61         typedef typename coordinate_system<Point1>::type::units units_type;
62 
63         detail::envelope::envelope_segment_impl
64             <
65                 geographic_tag
66             >::template apply<units_type>(geometry::get<0>(p1_normalized),
67                                           geometry::get<1>(p1_normalized),
68                                           geometry::get<0>(p2_normalized),
69                                           geometry::get<1>(p2_normalized),
70                                           box,
71                                           azimuth_geographic);
72 
73     }
74 
75 private:
76     Spheroid m_spheroid;
77 };
78 
79 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
80 
81 namespace services
82 {
83 
84 template <typename CalculationType>
85 struct default_strategy<geographic_tag, CalculationType>
86 {
87     typedef strategy::envelope::geographic_segment
88         <
89             strategy::andoyer,
90             srs::spheroid<double>,
91             CalculationType
92         > type;
93 };
94 
95 }
96 
97 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
98 
99 
100 }} // namespace strategy::envelope
101 
102 }} //namepsace boost::geometry
103 
104 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
105