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, 2014, 2015, 2017, 2018, 2019. 9 // Modifications copyright (c) 2013-2019, 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 22 #ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_POINT_IN_POINT_HPP 23 #define BOOST_GEOMETRY_STRATEGY_CARTESIAN_POINT_IN_POINT_HPP 24 25 #include <cstddef> 26 27 #include <boost/geometry/core/access.hpp> 28 #include <boost/geometry/core/coordinate_dimension.hpp> 29 #include <boost/geometry/core/tags.hpp> 30 31 #include <boost/geometry/util/math.hpp> 32 33 #include <boost/geometry/strategies/covered_by.hpp> 34 #include <boost/geometry/strategies/within.hpp> 35 36 37 namespace boost { namespace geometry 38 { 39 40 #ifndef DOXYGEN_NO_DETAIL 41 namespace detail { namespace within 42 { 43 44 45 template <std::size_t Dimension, std::size_t DimensionCount> 46 struct point_point_generic 47 { 48 template <typename Point1, typename Point2> applyboost::geometry::detail::within::point_point_generic49 static inline bool apply(Point1 const& p1, Point2 const& p2) 50 { 51 if (! geometry::math::equals(get<Dimension>(p1), get<Dimension>(p2))) 52 { 53 return false; 54 } 55 return 56 point_point_generic<Dimension + 1, DimensionCount>::apply(p1, p2); 57 } 58 }; 59 60 template <std::size_t DimensionCount> 61 struct point_point_generic<DimensionCount, DimensionCount> 62 { 63 template <typename Point1, typename Point2> applyboost::geometry::detail::within::point_point_generic64 static inline bool apply(Point1 const&, Point2 const& ) 65 { 66 return true; 67 } 68 }; 69 70 }} // namespace detail::within 71 #endif // DOXYGEN_NO_DETAIL 72 73 74 namespace strategy { namespace within 75 { 76 77 struct cartesian_point_point 78 { 79 typedef cartesian_tag cs_tag; 80 81 template <typename Point1, typename Point2> applyboost::geometry::strategy::within::cartesian_point_point82 static inline bool apply(Point1 const& point1, Point2 const& point2) 83 { 84 return geometry::detail::within::point_point_generic 85 < 86 0, dimension<Point1>::type::value 87 >::apply(point1, point2); 88 } 89 }; 90 91 92 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS 93 namespace services 94 { 95 96 template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2> 97 struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, cartesian_tag, cartesian_tag> 98 { 99 typedef strategy::within::cartesian_point_point type; 100 }; 101 102 } // namespace services 103 #endif 104 105 106 }} // namespace strategy::within 107 108 109 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS 110 namespace strategy { namespace covered_by { namespace services 111 { 112 113 template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2> 114 struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, cartesian_tag, cartesian_tag> 115 { 116 typedef strategy::within::cartesian_point_point type; 117 }; 118 119 }}} // namespace strategy::covered_by::services 120 #endif 121 122 123 }} // namespace boost::geometry 124 125 126 #endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_POINT_IN_POINT_HPP 127