1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2017-2018 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
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)
11 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
12 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
15 #include <boost/geometry/srs/spheroid.hpp>
17 #include <boost/geometry/strategies/cartesian/envelope_segment.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 #include <boost/geometry/strategies/normalize.hpp>
22 #include <boost/geometry/strategies/spherical/envelope_segment.hpp>
23 #include <boost/geometry/strategies/spherical/expand_box.hpp>
25 namespace boost { namespace geometry
28 namespace strategy { namespace envelope
33 typename FormulaPolicy = strategy::andoyer,
34 typename Spheroid = geometry::srs::spheroid<double>,
35 typename CalculationType = void
37 class geographic_segment
40 typedef Spheroid model_type;
42 inline geographic_segment()
46 explicit inline geographic_segment(Spheroid const& spheroid)
47 : m_spheroid(spheroid)
50 typedef strategy::expand::spherical_box box_expand_strategy_type;
51 static inline box_expand_strategy_type get_box_expand_strategy()
53 return box_expand_strategy_type();
56 template <typename Point, typename Box>
57 inline void apply(Point const& point1, Point const& point2, Box& box) const
59 Point p1_normalized, p2_normalized;
60 strategy::normalize::spherical_point::apply(point1, p1_normalized);
61 strategy::normalize::spherical_point::apply(point2, p2_normalized);
63 geometry::strategy::azimuth::geographic
68 > azimuth_geographic(m_spheroid);
70 typedef typename geometry::detail::cs_angular_units
75 // first compute the envelope range for the first two coordinates
76 strategy::envelope::detail::envelope_segment_impl
79 >::template apply<units_type>(geometry::get<0>(p1_normalized),
80 geometry::get<1>(p1_normalized),
81 geometry::get<0>(p2_normalized),
82 geometry::get<1>(p2_normalized),
86 // now compute the envelope range for coordinates of
87 // dimension 2 and higher
88 strategy::envelope::detail::envelope_one_segment
90 2, dimension<Point>::value
91 >::apply(point1, point2, box);
98 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
103 template <typename CalculationType>
104 struct default_strategy<segment_tag, geographic_tag, CalculationType>
106 typedef strategy::envelope::geographic_segment
109 srs::spheroid<double>,
116 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
119 }} // namespace strategy::envelope
121 }} //namepsace boost::geometry
123 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP