point_in_poly_winding.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
  4. // This file was modified by Oracle on 2013-2020.
  5. // Modifications copyright (c) 2013-2020 Oracle and/or its affiliates.
  6. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  7. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  8. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  9. // Use, modification and distribution is subject to the Boost Software License,
  10. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  11. // http://www.boost.org/LICENSE_1_0.txt)
  12. #ifndef BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
  13. #define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP
  14. #include <boost/geometry/core/cs.hpp>
  15. #include <boost/geometry/core/static_assert.hpp>
  16. #include <boost/geometry/core/tag_cast.hpp>
  17. #include <boost/geometry/core/tags.hpp>
  18. #include <boost/geometry/strategies/cartesian/point_in_poly_winding.hpp>
  19. #include <boost/geometry/strategies/side.hpp>
  20. #include <boost/geometry/strategies/spherical/point_in_poly_winding.hpp>
  21. namespace boost { namespace geometry
  22. {
  23. namespace strategy { namespace within
  24. {
  25. #ifndef DOXYGEN_NO_DETAIL
  26. namespace detail
  27. {
  28. template
  29. <
  30. typename Point,
  31. typename PointOfSegment,
  32. typename CalculationType,
  33. typename CSTag = typename tag_cast
  34. <
  35. typename cs_tag<Point>::type,
  36. spherical_tag
  37. >::type
  38. >
  39. struct winding_base_type
  40. {
  41. BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
  42. "Not implemented for this coordinate system.",
  43. Point, PointOfSegment, CSTag);
  44. };
  45. template <typename Point, typename PointOfSegment, typename CalculationType>
  46. struct winding_base_type<Point, PointOfSegment, CalculationType, cartesian_tag>
  47. {
  48. using type = within::detail::cartesian_winding_base
  49. <
  50. typename strategy::side::services::default_strategy
  51. <
  52. typename cs_tag<Point>::type
  53. >::type,
  54. CalculationType
  55. >;
  56. };
  57. template <typename Point, typename PointOfSegment, typename CalculationType>
  58. struct winding_base_type<Point, PointOfSegment, CalculationType, spherical_tag>
  59. {
  60. using type = within::detail::spherical_winding_base
  61. <
  62. typename strategy::side::services::default_strategy
  63. <
  64. typename cs_tag<Point>::type
  65. >::type,
  66. CalculationType
  67. >;
  68. };
  69. } // namespace detail
  70. #endif // DOXYGEN_NO_DETAIL
  71. /*!
  72. \brief Within detection using winding rule. Side strategy used internally is
  73. choosen based on Point's coordinate system.
  74. \ingroup strategies
  75. \tparam Point \tparam_point
  76. \tparam PointOfSegment \tparam_segment_point
  77. \tparam CalculationType \tparam_calculation
  78. \qbk{
  79. [heading See also]
  80. [link geometry.reference.algorithms.within.within_3_with_strategy within (with strategy)]
  81. }
  82. */
  83. template
  84. <
  85. typename Point,
  86. typename PointOfSegment = Point,
  87. typename CalculationType = void
  88. >
  89. class winding
  90. : public within::detail::winding_base_type
  91. <
  92. Point, PointOfSegment, CalculationType
  93. >::type
  94. {
  95. typedef typename within::detail::winding_base_type
  96. <
  97. Point, PointOfSegment, CalculationType
  98. >::type base_t;
  99. public:
  100. winding() {}
  101. template <typename Model>
  102. explicit winding(Model const& model)
  103. : base_t(model)
  104. {}
  105. };
  106. }} // namespace strategy::within
  107. }} // namespace boost::geometry
  108. #endif // BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_WINDING_HPP