]>
Commit | Line | Data |
---|---|---|
b32b8144 FG |
1 | // Boost.Geometry |
2 | ||
92f5a8d4 | 3 | // Copyright (c) 2017-2019 Oracle and/or its affiliates. |
b32b8144 FG |
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 | ||
92f5a8d4 TL |
32 | #include <boost/geometry/srs/spheroid.hpp> |
33 | ||
34 | // TODO: spherical_point_box currently defined in the same file as cartesian | |
35 | #include <boost/geometry/strategies/cartesian/point_in_box.hpp> | |
b32b8144 FG |
36 | #include <boost/geometry/strategies/disjoint.hpp> |
37 | #include <boost/geometry/strategies/geographic/azimuth.hpp> | |
38 | #include <boost/geometry/strategies/geographic/parameters.hpp> | |
92f5a8d4 TL |
39 | #include <boost/geometry/strategies/normalize.hpp> |
40 | #include <boost/geometry/strategies/spherical/disjoint_box_box.hpp> | |
b32b8144 FG |
41 | |
42 | ||
43 | namespace boost { namespace geometry { namespace strategy { namespace disjoint | |
44 | { | |
45 | ||
46 | // NOTE: This may be temporary place for this or corresponding strategy | |
47 | // It seems to be more appropriate to implement the opposite of it | |
48 | // e.g. intersection::segment_box because in disjoint() algorithm | |
49 | // other strategies that are used are intersection and covered_by strategies. | |
50 | template | |
51 | < | |
52 | typename FormulaPolicy = strategy::andoyer, | |
53 | typename Spheroid = srs::spheroid<double>, | |
54 | typename CalculationType = void | |
55 | > | |
56 | struct segment_box_geographic | |
57 | { | |
58 | public: | |
59 | typedef Spheroid model_type; | |
60 | ||
61 | inline segment_box_geographic() | |
62 | : m_spheroid() | |
63 | {} | |
64 | ||
65 | explicit inline segment_box_geographic(Spheroid const& spheroid) | |
66 | : m_spheroid(spheroid) | |
67 | {} | |
68 | ||
92f5a8d4 TL |
69 | typedef covered_by::spherical_point_box disjoint_point_box_strategy_type; |
70 | ||
71 | static inline disjoint_point_box_strategy_type get_disjoint_point_box_strategy() | |
b32b8144 | 72 | { |
92f5a8d4 | 73 | return disjoint_point_box_strategy_type(); |
b32b8144 FG |
74 | } |
75 | ||
76 | template <typename Segment, typename Box> | |
77 | inline bool apply(Segment const& segment, Box const& box) const | |
78 | { | |
79 | geometry::strategy::azimuth::geographic | |
80 | < | |
81 | FormulaPolicy, | |
82 | Spheroid, | |
83 | CalculationType | |
84 | > azimuth_geographic(m_spheroid); | |
85 | ||
86 | return geometry::detail::disjoint::disjoint_segment_box_sphere_or_spheroid | |
92f5a8d4 TL |
87 | < |
88 | geographic_tag | |
89 | >::apply(segment, box, | |
90 | azimuth_geographic, | |
91 | strategy::normalize::spherical_point(), | |
92 | strategy::covered_by::spherical_point_box(), | |
93 | strategy::disjoint::spherical_box_box()); | |
b32b8144 FG |
94 | } |
95 | ||
96 | private: | |
97 | Spheroid m_spheroid; | |
98 | }; | |
99 | ||
100 | ||
101 | #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS | |
102 | ||
103 | ||
104 | namespace services | |
105 | { | |
106 | ||
107 | template <typename Linear, typename Box, typename LinearTag> | |
108 | struct default_strategy<Linear, Box, LinearTag, box_tag, 1, 2, | |
109 | geographic_tag, geographic_tag> | |
110 | { | |
111 | typedef segment_box_geographic<> type; | |
112 | }; | |
113 | ||
114 | template <typename Box, typename Linear, typename LinearTag> | |
115 | struct default_strategy<Box, Linear, box_tag, LinearTag, 2, 1, | |
116 | geographic_tag, geographic_tag> | |
117 | { | |
118 | typedef segment_box_geographic<> type; | |
119 | }; | |
120 | ||
121 | ||
122 | } // namespace services | |
123 | ||
124 | ||
125 | #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS | |
126 | ||
127 | ||
128 | }}}} // namespace boost::geometry::strategy::disjoint | |
129 | ||
130 | ||
131 | #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISJOINT_SEGMENT_BOX_HPP |