1 // Boost.Geometry 2 3 // Copyright (c) 2017 Oracle and/or its affiliates. 4 5 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle 6 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle 7 8 // Use, modification and distribution is subject to the Boost Software License, 9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 10 // http://www.boost.org/LICENSE_1_0.txt) 11 12 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISJOINT_SEGMENT_BOX_HPP 13 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISJOINT_SEGMENT_BOX_HPP 14 15 16 #include <cstddef> 17 #include <utility> 18 19 #include <boost/numeric/conversion/cast.hpp> 20 21 #include <boost/geometry/util/math.hpp> 22 #include <boost/geometry/util/calculation_type.hpp> 23 24 #include <boost/geometry/core/access.hpp> 25 #include <boost/geometry/core/tags.hpp> 26 #include <boost/geometry/core/coordinate_dimension.hpp> 27 #include <boost/geometry/core/point_type.hpp> 28 29 #include <boost/geometry/algorithms/detail/assign_indexed_point.hpp> 30 #include <boost/geometry/algorithms/detail/disjoint/segment_box.hpp> 31 32 #include <boost/geometry/strategies/disjoint.hpp> 33 #include <boost/geometry/strategies/geographic/azimuth.hpp> 34 #include <boost/geometry/strategies/geographic/parameters.hpp> 35 36 37 namespace boost { namespace geometry { namespace strategy { namespace disjoint 38 { 39 40 // NOTE: This may be temporary place for this or corresponding strategy 41 // It seems to be more appropriate to implement the opposite of it 42 // e.g. intersection::segment_box because in disjoint() algorithm 43 // other strategies that are used are intersection and covered_by strategies. 44 template 45 < 46 typename FormulaPolicy = strategy::andoyer, 47 typename Spheroid = srs::spheroid<double>, 48 typename CalculationType = void 49 > 50 struct segment_box_geographic 51 { 52 public: 53 typedef Spheroid model_type; 54 segment_box_geographicboost::geometry::strategy::disjoint::segment_box_geographic55 inline segment_box_geographic() 56 : m_spheroid() 57 {} 58 segment_box_geographicboost::geometry::strategy::disjoint::segment_box_geographic59 explicit inline segment_box_geographic(Spheroid const& spheroid) 60 : m_spheroid(spheroid) 61 {} 62 63 template <typename Segment, typename Box> 64 struct point_in_geometry_strategy 65 : services::default_strategy 66 < 67 typename point_type<Segment>::type, 68 Box 69 > 70 {}; 71 72 template <typename Segment, typename Box> 73 static inline typename point_in_geometry_strategy<Segment, Box>::type get_point_in_geometry_strategyboost::geometry::strategy::disjoint::segment_box_geographic74 get_point_in_geometry_strategy() 75 { 76 typedef typename point_in_geometry_strategy<Segment, Box>::type strategy_type; 77 78 return strategy_type(); 79 } 80 81 template <typename Segment, typename Box> applyboost::geometry::strategy::disjoint::segment_box_geographic82 inline bool apply(Segment const& segment, Box const& box) const 83 { 84 geometry::strategy::azimuth::geographic 85 < 86 FormulaPolicy, 87 Spheroid, 88 CalculationType 89 > azimuth_geographic(m_spheroid); 90 91 return geometry::detail::disjoint::disjoint_segment_box_sphere_or_spheroid 92 <geographic_tag>::apply(segment, box, azimuth_geographic); 93 } 94 95 private: 96 Spheroid m_spheroid; 97 }; 98 99 100 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS 101 102 103 namespace services 104 { 105 106 template <typename Linear, typename Box, typename LinearTag> 107 struct default_strategy<Linear, Box, LinearTag, box_tag, 1, 2, 108 geographic_tag, geographic_tag> 109 { 110 typedef segment_box_geographic<> type; 111 }; 112 113 template <typename Box, typename Linear, typename LinearTag> 114 struct default_strategy<Box, Linear, box_tag, LinearTag, 2, 1, 115 geographic_tag, geographic_tag> 116 { 117 typedef segment_box_geographic<> type; 118 }; 119 120 121 } // namespace services 122 123 124 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS 125 126 127 }}}} // namespace boost::geometry::strategy::disjoint 128 129 130 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISJOINT_SEGMENT_BOX_HPP 131