1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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
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_STRATEGY_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
12 #define BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP
15 #include <boost/geometry/srs/spheroid.hpp>
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>
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 template <typename Point, typename Box>
51 inline void apply(Point const& point1, Point const& point2, Box& box) const
53 Point p1_normalized, p2_normalized;
54 strategy::normalize::spherical_point::apply(point1, p1_normalized);
55 strategy::normalize::spherical_point::apply(point2, p2_normalized);
57 geometry::strategy::azimuth::geographic
62 > azimuth_geographic(m_spheroid);
64 typedef typename geometry::detail::cs_angular_units
69 // first compute the envelope range for the first two coordinates
70 strategy::envelope::detail::envelope_segment_impl
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),
80 // now compute the envelope range for coordinates of
81 // dimension 2 and higher
82 strategy::envelope::detail::envelope_one_segment
84 2, dimension<Point>::value
85 >::apply(point1, point2, box);
88 Spheroid model() const
97 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
102 template <typename CalculationType>
103 struct default_strategy<segment_tag, geographic_tag, CalculationType>
105 typedef strategy::envelope::geographic_segment
108 srs::spheroid<double>,
115 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
118 }} // namespace strategy::envelope
120 }} //namepsace boost::geometry
122 #endif // BOOST_GEOMETRY_STRATEGY_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP