1 // Boost.Geometry (aka GGL, Generic Geometry Library) 2 3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. 4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. 5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. 6 // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France. 7 8 // This file was modified by Oracle on 2015, 2016, 2017, 2018. 9 // Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. 10 11 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle 12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle 13 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle 14 15 // Distributed under the Boost Software License, Version 1.0. 16 // (See accompanying file LICENSE_1_0.txt or copy at 17 // http://www.boost.org/LICENSE_1_0.txt) 18 19 #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_SEGMENT_HPP 20 #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_SEGMENT_HPP 21 22 #include <cstddef> 23 #include <functional> 24 25 #include <boost/geometry/core/access.hpp> 26 #include <boost/geometry/core/tags.hpp> 27 28 #include <boost/geometry/util/select_coordinate_type.hpp> 29 30 #include <boost/geometry/algorithms/detail/envelope/box.hpp> 31 #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp> 32 #include <boost/geometry/algorithms/detail/envelope/segment.hpp> 33 34 #include <boost/geometry/strategies/expand.hpp> 35 #include <boost/geometry/strategies/spherical/envelope_segment.hpp> 36 37 38 namespace boost { namespace geometry 39 { 40 41 namespace strategy { namespace expand 42 { 43 44 #ifndef DOXYGEN_NO_DETAIL 45 namespace detail 46 { 47 48 struct segment_on_spheroid 49 { 50 template <typename Box, typename Segment, typename EnvelopeStrategy> applyboost::geometry::strategy::expand::detail::segment_on_spheroid51 static inline void apply(Box& box, Segment const& segment, EnvelopeStrategy const& strategy) 52 { 53 Box mbrs[2]; 54 55 // compute the envelope of the segment 56 typename point_type<Segment>::type p[2]; 57 geometry::detail::assign_point_from_index<0>(segment, p[0]); 58 geometry::detail::assign_point_from_index<1>(segment, p[1]); 59 geometry::detail::envelope::envelope_segment 60 < 61 dimension<Segment>::value 62 >::apply(p[0], p[1], mbrs[0], strategy); 63 64 // normalize the box 65 strategy::envelope::spherical_box::apply(box, mbrs[1]); 66 67 // compute the envelope of the two boxes 68 geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box); 69 } 70 }; 71 72 } // namespace detail 73 #endif // DOXYGEN_NO_DETAIL 74 75 76 template 77 < 78 typename CalculationType = void 79 > 80 class spherical_segment 81 { 82 public: 83 template <typename Box, typename Segment> apply(Box & box,Segment const & segment)84 static inline void apply(Box& box, Segment const& segment) 85 { 86 detail::segment_on_spheroid::apply(box, segment, 87 strategy::envelope::spherical_segment<CalculationType>()); 88 } 89 }; 90 91 92 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS 93 94 namespace services 95 { 96 97 template <typename CalculationType> 98 struct default_strategy<segment_tag, spherical_equatorial_tag, CalculationType> 99 { 100 typedef spherical_segment<CalculationType> type; 101 }; 102 103 template <typename CalculationType> 104 struct default_strategy<segment_tag, spherical_polar_tag, CalculationType> 105 { 106 typedef spherical_segment<CalculationType> type; 107 }; 108 109 } // namespace services 110 111 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS 112 113 114 }} // namespace strategy::expand 115 116 }} // namespace boost::geometry 117 118 #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_SEGMENT_HPP 119