]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/geometry/strategies/spherical/point_in_point.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / geometry / strategies / spherical / point_in_point.hpp
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) 2013-2015 Adam Wulkiewicz, Lodz, Poland
7
8 // This file was modified by Oracle on 2013-2020.
9 // Modifications copyright (c) 2013-2020, Oracle and/or its affiliates.
10
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13
14 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
15 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
16
17 // Use, modification and distribution is subject to the Boost Software License,
18 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
19 // http://www.boost.org/LICENSE_1_0.txt)
20
21 #ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP
22 #define BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP
23
24
25 #include <cstddef>
26 #include <type_traits>
27
28 #include <boost/geometry/core/access.hpp>
29 #include <boost/geometry/core/radian_access.hpp>
30 #include <boost/geometry/core/coordinate_dimension.hpp>
31 #include <boost/geometry/core/coordinate_promotion.hpp>
32 #include <boost/geometry/core/coordinate_system.hpp>
33 #include <boost/geometry/core/coordinate_type.hpp>
34 #include <boost/geometry/core/cs.hpp>
35 #include <boost/geometry/core/tags.hpp>
36
37 #include <boost/geometry/algorithms/detail/normalize.hpp>
38 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
39 #include <boost/geometry/algorithms/transform.hpp>
40
41 #include <boost/geometry/geometries/helper_geometry.hpp>
42
43 #include <boost/geometry/strategies/cartesian/point_in_point.hpp>
44 #include <boost/geometry/strategies/covered_by.hpp>
45 #include <boost/geometry/strategies/strategy_transform.hpp>
46 #include <boost/geometry/strategies/within.hpp>
47
48 #include <boost/geometry/util/math.hpp>
49 #include <boost/geometry/util/select_most_precise.hpp>
50
51
52 namespace boost { namespace geometry
53 {
54
55 #ifndef DOXYGEN_NO_DETAIL
56 namespace detail { namespace within
57 {
58
59 class point_point_on_spheroid
60 {
61 public:
62 typedef spherical_tag cs_tag;
63
64 private:
65 template <typename Point1, typename Point2, bool SameUnits>
66 struct are_same_points
67 {
68 static inline bool apply(Point1 const& point1, Point2 const& point2)
69 {
70 typedef typename helper_geometry<Point1>::type helper_point_type1;
71 typedef typename helper_geometry<Point2>::type helper_point_type2;
72
73 helper_point_type1 point1_normalized;
74 strategy::normalize::spherical_point::apply(point1, point1_normalized);
75 helper_point_type2 point2_normalized;
76 strategy::normalize::spherical_point::apply(point2, point2_normalized);
77
78 return point_point_generic
79 <
80 0, dimension<Point1>::value
81 >::apply(point1_normalized, point2_normalized);
82 }
83 };
84
85 template <typename Point1, typename Point2>
86 struct are_same_points<Point1, Point2, false> // points have different units
87 {
88 static inline bool apply(Point1 const& point1, Point2 const& point2)
89 {
90 typedef typename geometry::select_most_precise
91 <
92 typename fp_coordinate_type<Point1>::type,
93 typename fp_coordinate_type<Point2>::type
94 >::type calculation_type;
95
96 typename helper_geometry
97 <
98 Point1, calculation_type, radian
99 >::type helper_point1, helper_point2;
100
101 Point1 point1_normalized;
102 strategy::normalize::spherical_point::apply(point1, point1_normalized);
103 Point2 point2_normalized;
104 strategy::normalize::spherical_point::apply(point2, point2_normalized);
105
106 geometry::transform(point1_normalized, helper_point1);
107 geometry::transform(point2_normalized, helper_point2);
108
109 return point_point_generic
110 <
111 0, dimension<Point1>::value
112 >::apply(helper_point1, helper_point2);
113 }
114 };
115
116 public:
117 template <typename Point1, typename Point2>
118 static inline bool apply(Point1 const& point1, Point2 const& point2)
119 {
120 return are_same_points
121 <
122 Point1,
123 Point2,
124 std::is_same
125 <
126 typename detail::cs_angular_units<Point1>::type,
127 typename detail::cs_angular_units<Point2>::type
128 >::value
129 >::apply(point1, point2);
130 }
131 };
132
133 }} // namespace detail::within
134 #endif // DOXYGEN_NO_DETAIL
135
136
137 namespace strategy { namespace within
138 {
139
140 struct spherical_point_point
141 : geometry::detail::within::point_point_on_spheroid
142 {};
143
144
145 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
146 namespace services
147 {
148
149 template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2>
150 struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, spherical_tag, spherical_tag>
151 {
152 typedef strategy::within::spherical_point_point type;
153 };
154
155 } // namespace services
156 #endif
157
158
159 }} // namespace strategy::within
160
161
162 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
163 namespace strategy { namespace covered_by { namespace services
164 {
165
166 template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2>
167 struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, spherical_tag, spherical_tag>
168 {
169 typedef strategy::within::spherical_point_point type;
170 };
171
172 }}} // namespace strategy::covered_by::services
173 #endif
174
175
176 }} // namespace boost::geometry
177
178
179 #endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP