implementation.hpp 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
  5. // This file was modified by Oracle on 2013, 2014, 2017, 2019.
  6. // Modifications copyright (c) 2013-2019 Oracle and/or its affiliates.
  7. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  8. // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
  9. // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
  10. // Use, modification and distribution is subject to the Boost Software License,
  11. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_COVERED_BY_IMPLEMENTATION_HPP
  14. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_COVERED_BY_IMPLEMENTATION_HPP
  15. #include <cstddef>
  16. #include <boost/core/ignore_unused.hpp>
  17. #include <boost/geometry/algorithms/detail/covered_by/interface.hpp>
  18. #include <boost/geometry/algorithms/detail/within/implementation.hpp>
  19. namespace boost { namespace geometry
  20. {
  21. #ifndef DOXYGEN_NO_DETAIL
  22. namespace detail { namespace covered_by {
  23. struct use_point_in_geometry
  24. {
  25. template <typename Geometry1, typename Geometry2, typename Strategy>
  26. static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
  27. {
  28. return detail::within::covered_by_point_geometry(geometry1, geometry2, strategy);
  29. }
  30. };
  31. struct use_relate
  32. {
  33. template <typename Geometry1, typename Geometry2, typename Strategy>
  34. static inline bool apply(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy const& strategy)
  35. {
  36. typedef typename detail::de9im::static_mask_covered_by_type
  37. <
  38. Geometry1, Geometry2
  39. >::type covered_by_mask;
  40. return geometry::relate(geometry1, geometry2, covered_by_mask(), strategy);
  41. }
  42. };
  43. }} // namespace detail::covered_by
  44. #endif // DOXYGEN_NO_DETAIL
  45. #ifndef DOXYGEN_NO_DISPATCH
  46. namespace dispatch
  47. {
  48. template <typename Point, typename Box>
  49. struct covered_by<Point, Box, point_tag, box_tag>
  50. {
  51. template <typename Strategy>
  52. static inline bool apply(Point const& point, Box const& box, Strategy const& strategy)
  53. {
  54. ::boost::ignore_unused(strategy);
  55. return strategy.apply(point, box);
  56. }
  57. };
  58. template <typename Box1, typename Box2>
  59. struct covered_by<Box1, Box2, box_tag, box_tag>
  60. {
  61. template <typename Strategy>
  62. static inline bool apply(Box1 const& box1, Box2 const& box2, Strategy const& strategy)
  63. {
  64. assert_dimension_equal<Box1, Box2>();
  65. ::boost::ignore_unused(strategy);
  66. return strategy.apply(box1, box2);
  67. }
  68. };
  69. // P/P
  70. template <typename Point1, typename Point2>
  71. struct covered_by<Point1, Point2, point_tag, point_tag>
  72. : public detail::covered_by::use_point_in_geometry
  73. {};
  74. template <typename Point, typename MultiPoint>
  75. struct covered_by<Point, MultiPoint, point_tag, multi_point_tag>
  76. : public detail::covered_by::use_point_in_geometry
  77. {};
  78. template <typename MultiPoint, typename Point>
  79. struct covered_by<MultiPoint, Point, multi_point_tag, point_tag>
  80. : public detail::within::multi_point_point
  81. {};
  82. template <typename MultiPoint1, typename MultiPoint2>
  83. struct covered_by<MultiPoint1, MultiPoint2, multi_point_tag, multi_point_tag>
  84. : public detail::within::multi_point_multi_point
  85. {};
  86. // P/L
  87. template <typename Point, typename Segment>
  88. struct covered_by<Point, Segment, point_tag, segment_tag>
  89. : public detail::covered_by::use_point_in_geometry
  90. {};
  91. template <typename Point, typename Linestring>
  92. struct covered_by<Point, Linestring, point_tag, linestring_tag>
  93. : public detail::covered_by::use_point_in_geometry
  94. {};
  95. template <typename Point, typename MultiLinestring>
  96. struct covered_by<Point, MultiLinestring, point_tag, multi_linestring_tag>
  97. : public detail::covered_by::use_point_in_geometry
  98. {};
  99. template <typename MultiPoint, typename Segment>
  100. struct covered_by<MultiPoint, Segment, multi_point_tag, segment_tag>
  101. : public detail::within::multi_point_single_geometry<false>
  102. {};
  103. template <typename MultiPoint, typename Linestring>
  104. struct covered_by<MultiPoint, Linestring, multi_point_tag, linestring_tag>
  105. : public detail::within::multi_point_single_geometry<false>
  106. {};
  107. template <typename MultiPoint, typename MultiLinestring>
  108. struct covered_by<MultiPoint, MultiLinestring, multi_point_tag, multi_linestring_tag>
  109. : public detail::within::multi_point_multi_geometry<false>
  110. {};
  111. // P/A
  112. template <typename Point, typename Ring>
  113. struct covered_by<Point, Ring, point_tag, ring_tag>
  114. : public detail::covered_by::use_point_in_geometry
  115. {};
  116. template <typename Point, typename Polygon>
  117. struct covered_by<Point, Polygon, point_tag, polygon_tag>
  118. : public detail::covered_by::use_point_in_geometry
  119. {};
  120. template <typename Point, typename MultiPolygon>
  121. struct covered_by<Point, MultiPolygon, point_tag, multi_polygon_tag>
  122. : public detail::covered_by::use_point_in_geometry
  123. {};
  124. template <typename MultiPoint, typename Ring>
  125. struct covered_by<MultiPoint, Ring, multi_point_tag, ring_tag>
  126. : public detail::within::multi_point_single_geometry<false>
  127. {};
  128. template <typename MultiPoint, typename Polygon>
  129. struct covered_by<MultiPoint, Polygon, multi_point_tag, polygon_tag>
  130. : public detail::within::multi_point_single_geometry<false>
  131. {};
  132. template <typename MultiPoint, typename MultiPolygon>
  133. struct covered_by<MultiPoint, MultiPolygon, multi_point_tag, multi_polygon_tag>
  134. : public detail::within::multi_point_multi_geometry<false>
  135. {};
  136. // L/L
  137. template <typename Linestring1, typename Linestring2>
  138. struct covered_by<Linestring1, Linestring2, linestring_tag, linestring_tag>
  139. : public detail::covered_by::use_relate
  140. {};
  141. template <typename Linestring, typename MultiLinestring>
  142. struct covered_by<Linestring, MultiLinestring, linestring_tag, multi_linestring_tag>
  143. : public detail::covered_by::use_relate
  144. {};
  145. template <typename MultiLinestring, typename Linestring>
  146. struct covered_by<MultiLinestring, Linestring, multi_linestring_tag, linestring_tag>
  147. : public detail::covered_by::use_relate
  148. {};
  149. template <typename MultiLinestring1, typename MultiLinestring2>
  150. struct covered_by<MultiLinestring1, MultiLinestring2, multi_linestring_tag, multi_linestring_tag>
  151. : public detail::covered_by::use_relate
  152. {};
  153. // L/A
  154. template <typename Linestring, typename Ring>
  155. struct covered_by<Linestring, Ring, linestring_tag, ring_tag>
  156. : public detail::covered_by::use_relate
  157. {};
  158. template <typename MultiLinestring, typename Ring>
  159. struct covered_by<MultiLinestring, Ring, multi_linestring_tag, ring_tag>
  160. : public detail::covered_by::use_relate
  161. {};
  162. template <typename Linestring, typename Polygon>
  163. struct covered_by<Linestring, Polygon, linestring_tag, polygon_tag>
  164. : public detail::covered_by::use_relate
  165. {};
  166. template <typename MultiLinestring, typename Polygon>
  167. struct covered_by<MultiLinestring, Polygon, multi_linestring_tag, polygon_tag>
  168. : public detail::covered_by::use_relate
  169. {};
  170. template <typename Linestring, typename MultiPolygon>
  171. struct covered_by<Linestring, MultiPolygon, linestring_tag, multi_polygon_tag>
  172. : public detail::covered_by::use_relate
  173. {};
  174. template <typename MultiLinestring, typename MultiPolygon>
  175. struct covered_by<MultiLinestring, MultiPolygon, multi_linestring_tag, multi_polygon_tag>
  176. : public detail::covered_by::use_relate
  177. {};
  178. // A/A
  179. template <typename Ring1, typename Ring2>
  180. struct covered_by<Ring1, Ring2, ring_tag, ring_tag>
  181. : public detail::covered_by::use_relate
  182. {};
  183. template <typename Ring, typename Polygon>
  184. struct covered_by<Ring, Polygon, ring_tag, polygon_tag>
  185. : public detail::covered_by::use_relate
  186. {};
  187. template <typename Polygon, typename Ring>
  188. struct covered_by<Polygon, Ring, polygon_tag, ring_tag>
  189. : public detail::covered_by::use_relate
  190. {};
  191. template <typename Polygon1, typename Polygon2>
  192. struct covered_by<Polygon1, Polygon2, polygon_tag, polygon_tag>
  193. : public detail::covered_by::use_relate
  194. {};
  195. template <typename Ring, typename MultiPolygon>
  196. struct covered_by<Ring, MultiPolygon, ring_tag, multi_polygon_tag>
  197. : public detail::covered_by::use_relate
  198. {};
  199. template <typename MultiPolygon, typename Ring>
  200. struct covered_by<MultiPolygon, Ring, multi_polygon_tag, ring_tag>
  201. : public detail::covered_by::use_relate
  202. {};
  203. template <typename Polygon, typename MultiPolygon>
  204. struct covered_by<Polygon, MultiPolygon, polygon_tag, multi_polygon_tag>
  205. : public detail::covered_by::use_relate
  206. {};
  207. template <typename MultiPolygon, typename Polygon>
  208. struct covered_by<MultiPolygon, Polygon, multi_polygon_tag, polygon_tag>
  209. : public detail::covered_by::use_relate
  210. {};
  211. template <typename MultiPolygon1, typename MultiPolygon2>
  212. struct covered_by<MultiPolygon1, MultiPolygon2, multi_polygon_tag, multi_polygon_tag>
  213. : public detail::covered_by::use_relate
  214. {};
  215. } // namespace dispatch
  216. #endif // DOXYGEN_NO_DISPATCH
  217. }} // namespace boost::geometry
  218. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_COVERED_BY_IMPLEMENTATION_HPP