point_in_point.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  5. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland
  6. // This file was modified by Oracle on 2013, 2014, 2015, 2017, 2018, 2019.
  7. // Modifications copyright (c) 2013-2019, Oracle and/or its affiliates.
  8. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  9. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  10. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  11. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  12. // Use, modification and distribution is subject to the Boost Software License,
  13. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  14. // http://www.boost.org/LICENSE_1_0.txt)
  15. #ifndef BOOST_GEOMETRY_STRATEGY_CARTESIAN_POINT_IN_POINT_HPP
  16. #define BOOST_GEOMETRY_STRATEGY_CARTESIAN_POINT_IN_POINT_HPP
  17. #include <cstddef>
  18. #include <boost/geometry/core/access.hpp>
  19. #include <boost/geometry/core/coordinate_dimension.hpp>
  20. #include <boost/geometry/core/tags.hpp>
  21. #include <boost/geometry/util/math.hpp>
  22. #include <boost/geometry/strategies/covered_by.hpp>
  23. #include <boost/geometry/strategies/within.hpp>
  24. namespace boost { namespace geometry
  25. {
  26. #ifndef DOXYGEN_NO_DETAIL
  27. namespace detail { namespace within
  28. {
  29. template <std::size_t Dimension, std::size_t DimensionCount>
  30. struct point_point_generic
  31. {
  32. template <typename Point1, typename Point2>
  33. static inline bool apply(Point1 const& p1, Point2 const& p2)
  34. {
  35. if (! geometry::math::equals(get<Dimension>(p1), get<Dimension>(p2)))
  36. {
  37. return false;
  38. }
  39. return
  40. point_point_generic<Dimension + 1, DimensionCount>::apply(p1, p2);
  41. }
  42. };
  43. template <std::size_t DimensionCount>
  44. struct point_point_generic<DimensionCount, DimensionCount>
  45. {
  46. template <typename Point1, typename Point2>
  47. static inline bool apply(Point1 const&, Point2 const& )
  48. {
  49. return true;
  50. }
  51. };
  52. }} // namespace detail::within
  53. #endif // DOXYGEN_NO_DETAIL
  54. namespace strategy { namespace within
  55. {
  56. struct cartesian_point_point
  57. {
  58. typedef cartesian_tag cs_tag;
  59. template <typename Point1, typename Point2>
  60. static inline bool apply(Point1 const& point1, Point2 const& point2)
  61. {
  62. return geometry::detail::within::point_point_generic
  63. <
  64. 0, dimension<Point1>::type::value
  65. >::apply(point1, point2);
  66. }
  67. };
  68. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  69. namespace services
  70. {
  71. template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2>
  72. struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, cartesian_tag, cartesian_tag>
  73. {
  74. typedef strategy::within::cartesian_point_point type;
  75. };
  76. } // namespace services
  77. #endif
  78. }} // namespace strategy::within
  79. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  80. namespace strategy { namespace covered_by { namespace services
  81. {
  82. template <typename PointLike1, typename PointLike2, typename Tag1, typename Tag2>
  83. struct default_strategy<PointLike1, PointLike2, Tag1, Tag2, pointlike_tag, pointlike_tag, cartesian_tag, cartesian_tag>
  84. {
  85. typedef strategy::within::cartesian_point_point type;
  86. };
  87. }}} // namespace strategy::covered_by::services
  88. #endif
  89. }} // namespace boost::geometry
  90. #endif // BOOST_GEOMETRY_STRATEGY_CARTESIAN_POINT_IN_POINT_HPP