1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 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 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/srs/spheroid.hpp> 16 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> 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 geographic_segment()42 inline geographic_segment() 43 : m_spheroid() 44 {} 45 geographic_segment(Spheroid const & spheroid)46 explicit inline geographic_segment(Spheroid const& spheroid) 47 : m_spheroid(spheroid) 48 {} 49 50 typedef strategy::expand::spherical_box box_expand_strategy_type; get_box_expand_strategy()51 static inline box_expand_strategy_type get_box_expand_strategy() 52 { 53 return box_expand_strategy_type(); 54 } 55 56 template <typename Point, typename Box> apply(Point const & point1,Point const & point2,Box & box) const57 inline void apply(Point const& point1, Point const& point2, Box& box) const 58 { 59 Point p1_normalized, p2_normalized; 60 strategy::normalize::spherical_point::apply(point1, p1_normalized); 61 strategy::normalize::spherical_point::apply(point2, p2_normalized); 62 63 geometry::strategy::azimuth::geographic 64 < 65 FormulaPolicy, 66 Spheroid, 67 CalculationType 68 > azimuth_geographic(m_spheroid); 69 70 typedef typename geometry::detail::cs_angular_units 71 < 72 Point 73 >::type units_type; 74 75 // first compute the envelope range for the first two coordinates 76 strategy::envelope::detail::envelope_segment_impl 77 < 78 geographic_tag 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), 83 box, 84 azimuth_geographic); 85 86 // now compute the envelope range for coordinates of 87 // dimension 2 and higher 88 strategy::envelope::detail::envelope_one_segment 89 < 90 2, dimension<Point>::value 91 >::apply(point1, point2, box); 92 } 93 94 private: 95 Spheroid m_spheroid; 96 }; 97 98 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS 99 100 namespace services 101 { 102 103 template <typename CalculationType> 104 struct default_strategy<segment_tag, geographic_tag, CalculationType> 105 { 106 typedef strategy::envelope::geographic_segment 107 < 108 strategy::andoyer, 109 srs::spheroid<double>, 110 CalculationType 111 > type; 112 }; 113 114 } 115 116 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS 117 118 119 }} // namespace strategy::envelope 120 121 }} //namepsace boost::geometry 122 123 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_ENVELOPE_SEGMENT_HPP 124