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.
9 // Modifications copyright (c) 2013-2015, 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_ALGORITHMS_DETAIL_DISJOINT_POINT_POINT_HPP
22 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_POINT_HPP
26 #include <boost/type_traits/is_same.hpp>
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_system.hpp>
32 #include <boost/geometry/core/coordinate_type.hpp>
33 #include <boost/geometry/core/cs.hpp>
34 #include <boost/geometry/core/tags.hpp>
36 #include <boost/geometry/util/math.hpp>
37 #include <boost/geometry/util/select_most_precise.hpp>
39 #include <boost/geometry/strategies/strategy_transform.hpp>
41 #include <boost/geometry/geometries/helper_geometry.hpp>
43 #include <boost/geometry/algorithms/transform.hpp>
45 #include <boost/geometry/algorithms/detail/normalize.hpp>
47 #include <boost/geometry/algorithms/dispatch/disjoint.hpp>
50 namespace boost { namespace geometry
54 #ifndef DOXYGEN_NO_DETAIL
55 namespace detail { namespace disjoint
59 template <std::size_t Dimension, std::size_t DimensionCount>
60 struct point_point_generic
62 template <typename Point1, typename Point2>
63 static inline bool apply(Point1 const& p1, Point2 const& p2)
65 if (! geometry::math::equals(get<Dimension>(p1), get<Dimension>(p2)))
70 point_point_generic<Dimension + 1, DimensionCount>::apply(p1, p2);
74 template <std::size_t DimensionCount>
75 struct point_point_generic<DimensionCount, DimensionCount>
77 template <typename Point1, typename Point2>
78 static inline bool apply(Point1 const&, Point2 const&)
85 class point_point_on_spheroid
88 template <typename Point1, typename Point2, bool SameUnits>
89 struct are_same_points
91 static inline bool apply(Point1 const& point1, Point2 const& point2)
93 typedef typename helper_geometry<Point1>::type helper_point_type1;
94 typedef typename helper_geometry<Point2>::type helper_point_type2;
96 helper_point_type1 point1_normalized
97 = return_normalized<helper_point_type1>(point1);
98 helper_point_type2 point2_normalized
99 = return_normalized<helper_point_type2>(point2);
101 return point_point_generic
103 0, dimension<Point1>::value
104 >::apply(point1_normalized, point2_normalized);
108 template <typename Point1, typename Point2>
109 struct are_same_points<Point1, Point2, false> // points have different units
111 static inline bool apply(Point1 const& point1, Point2 const& point2)
113 typedef typename geometry::select_most_precise
115 typename fp_coordinate_type<Point1>::type,
116 typename fp_coordinate_type<Point2>::type
117 >::type calculation_type;
119 typename helper_geometry
121 Point1, calculation_type, radian
122 >::type helper_point1, helper_point2;
124 Point1 point1_normalized = return_normalized<Point1>(point1);
125 Point2 point2_normalized = return_normalized<Point2>(point2);
127 geometry::transform(point1_normalized, helper_point1);
128 geometry::transform(point2_normalized, helper_point2);
130 return point_point_generic
132 0, dimension<Point1>::value
133 >::apply(helper_point1, helper_point2);
138 template <typename Point1, typename Point2>
139 static inline bool apply(Point1 const& point1, Point2 const& point2)
141 return are_same_points
147 typename coordinate_system<Point1>::type::units,
148 typename coordinate_system<Point2>::type::units
150 >::apply(point1, point2);
157 typename Point1, typename Point2,
158 std::size_t Dimension, std::size_t DimensionCount,
159 typename CSTag1 = typename cs_tag<Point1>::type,
160 typename CSTag2 = CSTag1
163 : point_point<Point1, Point2, Dimension, DimensionCount, cartesian_tag>
168 typename Point1, typename Point2,
169 std::size_t Dimension, std::size_t DimensionCount
173 Point1, Point2, Dimension, DimensionCount, spherical_equatorial_tag
174 > : point_point_on_spheroid
179 typename Point1, typename Point2,
180 std::size_t Dimension, std::size_t DimensionCount
184 Point1, Point2, Dimension, DimensionCount, geographic_tag
185 > : point_point_on_spheroid
190 typename Point1, typename Point2,
191 std::size_t Dimension, std::size_t DimensionCount
193 struct point_point<Point1, Point2, Dimension, DimensionCount, cartesian_tag>
194 : point_point_generic<Dimension, DimensionCount>
199 \brief Internal utility function to detect of points are disjoint
200 \note To avoid circular references
202 template <typename Point1, typename Point2>
203 inline bool disjoint_point_point(Point1 const& point1, Point2 const& point2)
208 0, dimension<Point1>::type::value
209 >::apply(point1, point2);
213 }} // namespace detail::disjoint
214 #endif // DOXYGEN_NO_DETAIL
219 #ifndef DOXYGEN_NO_DISPATCH
224 template <typename Point1, typename Point2, std::size_t DimensionCount>
225 struct disjoint<Point1, Point2, DimensionCount, point_tag, point_tag, false>
226 : detail::disjoint::point_point<Point1, Point2, 0, DimensionCount>
230 } // namespace dispatch
231 #endif // DOXYGEN_NO_DISPATCH
233 }} // namespace boost::geometry
235 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_POINT_POINT_HPP