1 // Boost.Geometry (aka GGL, Generic Geometry Library)
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
8 // This file was modified by Oracle on 2013-2020.
9 // Modifications copyright (c) 2013-2020, Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
14 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
15 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
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)
21 #ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP
22 #define BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP
26 #include <type_traits>
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>
37 #include <boost/geometry/algorithms/detail/normalize.hpp>
38 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
39 #include <boost/geometry/algorithms/transform.hpp>
41 #include <boost/geometry/geometries/helper_geometry.hpp>
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>
48 #include <boost/geometry/util/math.hpp>
49 #include <boost/geometry/util/select_most_precise.hpp>
52 namespace boost { namespace geometry
55 #ifndef DOXYGEN_NO_DETAIL
56 namespace detail { namespace within
59 class point_point_on_spheroid
62 typedef spherical_tag cs_tag;
65 template <typename Point1, typename Point2, bool SameUnits>
66 struct are_same_points
68 static inline bool apply(Point1 const& point1, Point2 const& point2)
70 typedef typename helper_geometry<Point1>::type helper_point_type1;
71 typedef typename helper_geometry<Point2>::type helper_point_type2;
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);
78 return point_point_generic
80 0, dimension<Point1>::value
81 >::apply(point1_normalized, point2_normalized);
85 template <typename Point1, typename Point2>
86 struct are_same_points<Point1, Point2, false> // points have different units
88 static inline bool apply(Point1 const& point1, Point2 const& point2)
90 typedef typename geometry::select_most_precise
92 typename fp_coordinate_type<Point1>::type,
93 typename fp_coordinate_type<Point2>::type
94 >::type calculation_type;
96 typename helper_geometry
98 Point1, calculation_type, radian
99 >::type helper_point1, helper_point2;
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);
106 geometry::transform(point1_normalized, helper_point1);
107 geometry::transform(point2_normalized, helper_point2);
109 return point_point_generic
111 0, dimension<Point1>::value
112 >::apply(helper_point1, helper_point2);
117 template <typename Point1, typename Point2>
118 static inline bool apply(Point1 const& point1, Point2 const& point2)
120 return are_same_points
126 typename detail::cs_angular_units<Point1>::type,
127 typename detail::cs_angular_units<Point2>::type
129 >::apply(point1, point2);
133 }} // namespace detail::within
134 #endif // DOXYGEN_NO_DETAIL
137 namespace strategy { namespace within
140 struct spherical_point_point
141 : geometry::detail::within::point_point_on_spheroid
145 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
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>
152 typedef strategy::within::spherical_point_point type;
155 } // namespace services
159 }} // namespace strategy::within
162 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
163 namespace strategy { namespace covered_by { namespace services
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>
169 typedef strategy::within::spherical_point_point type;
172 }}} // namespace strategy::covered_by::services
176 }} // namespace boost::geometry
179 #endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP