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, 2014, 2015, 2017, 2018, 2019.
9 // Modifications copyright (c) 2013-2019, 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)
22 #ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP
23 #define BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP
27 #include <boost/geometry/core/access.hpp>
28 #include <boost/geometry/core/radian_access.hpp>
29 #include <boost/geometry/core/coordinate_dimension.hpp>
30 #include <boost/geometry/core/coordinate_system.hpp>
31 #include <boost/geometry/core/coordinate_type.hpp>
32 #include <boost/geometry/core/cs.hpp>
33 #include <boost/geometry/core/tags.hpp>
35 #include <boost/geometry/algorithms/detail/normalize.hpp>
36 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
37 #include <boost/geometry/algorithms/transform.hpp>
39 #include <boost/geometry/geometries/helper_geometry.hpp>
41 #include <boost/geometry/strategies/cartesian/point_in_point.hpp>
42 #include <boost/geometry/strategies/covered_by.hpp>
43 #include <boost/geometry/strategies/strategy_transform.hpp>
44 #include <boost/geometry/strategies/within.hpp>
46 #include <boost/geometry/util/math.hpp>
47 #include <boost/geometry/util/select_most_precise.hpp>
50 namespace boost { namespace geometry
53 #ifndef DOXYGEN_NO_DETAIL
54 namespace detail { namespace within
57 class point_point_on_spheroid
60 typedef spherical_tag cs_tag;
63 template <typename Point1, typename Point2, bool SameUnits>
64 struct are_same_points
66 static inline bool apply(Point1 const& point1, Point2 const& point2)
68 typedef typename helper_geometry<Point1>::type helper_point_type1;
69 typedef typename helper_geometry<Point2>::type helper_point_type2;
71 helper_point_type1 point1_normalized;
72 strategy::normalize::spherical_point::apply(point1, point1_normalized);
73 helper_point_type2 point2_normalized;
74 strategy::normalize::spherical_point::apply(point2, point2_normalized);
76 return point_point_generic
78 0, dimension<Point1>::value
79 >::apply(point1_normalized, point2_normalized);
83 template <typename Point1, typename Point2>
84 struct are_same_points<Point1, Point2, false> // points have different units
86 static inline bool apply(Point1 const& point1, Point2 const& point2)
88 typedef typename geometry::select_most_precise
90 typename fp_coordinate_type<Point1>::type,
91 typename fp_coordinate_type<Point2>::type
92 >::type calculation_type;
94 typename helper_geometry
96 Point1, calculation_type, radian
97 >::type helper_point1, helper_point2;
99 Point1 point1_normalized;
100 strategy::normalize::spherical_point::apply(point1, point1_normalized);
101 Point2 point2_normalized;
102 strategy::normalize::spherical_point::apply(point2, point2_normalized);
104 geometry::transform(point1_normalized, helper_point1);
105 geometry::transform(point2_normalized, helper_point2);
107 return point_point_generic
109 0, dimension<Point1>::value
110 >::apply(helper_point1, helper_point2);
115 template <typename Point1, typename Point2>
116 static inline bool apply(Point1 const& point1, Point2 const& point2)
118 return are_same_points
124 typename detail::cs_angular_units<Point1>::type,
125 typename detail::cs_angular_units<Point2>::type
127 >::apply(point1, point2);
131 }} // namespace detail::within
132 #endif // DOXYGEN_NO_DETAIL
135 namespace strategy { namespace within
138 struct spherical_point_point
139 : geometry::detail::within::point_point_on_spheroid
143 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
147 template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2>
148 struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, spherical_tag, spherical_tag>
150 typedef strategy::within::spherical_point_point type;
153 } // namespace services
157 }} // namespace strategy::within
160 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
161 namespace strategy { namespace covered_by { namespace services
164 template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2>
165 struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, spherical_tag, spherical_tag>
167 typedef strategy::within::spherical_point_point type;
170 }}} // namespace strategy::covered_by::services
174 }} // namespace boost::geometry
177 #endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_POINT_IN_POINT_HPP