1 // Boost.Geometry
2 
3 // Copyright (c) 2017-2020, Oracle and/or its affiliates.
4 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
5 
6 // Use, modification and distribution is subject to the Boost Software License,
7 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
8 // http://www.boost.org/LICENSE_1_0.txt)
9 
10 #ifndef BOOST_GEOMETRY_STRATEGY_RELATE_HPP
11 #define BOOST_GEOMETRY_STRATEGY_RELATE_HPP
12 
13 
14 #include <type_traits>
15 
16 #include <boost/geometry/core/cs.hpp>
17 #include <boost/geometry/core/point_type.hpp>
18 #include <boost/geometry/core/static_assert.hpp>
19 #include <boost/geometry/core/topological_dimension.hpp>
20 
21 #include <boost/geometry/strategies/covered_by.hpp>
22 #include <boost/geometry/strategies/intersection.hpp>
23 #include <boost/geometry/strategies/within.hpp>
24 
25 
26 namespace boost { namespace geometry
27 {
28 
29 namespace strategy
30 {
31 
32 namespace point_in_geometry
33 {
34 
35 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
36 namespace services
37 {
38 
39 template
40 <
41     typename Point,
42     typename Geometry,
43     typename Tag1 = typename tag<Point>::type,
44     typename Tag2 = typename tag<Geometry>::type
45 >
46 struct default_strategy
47     : strategy::within::services::default_strategy
48         <
49             Point,
50             Geometry
51         >
52 {
53     typedef typename default_strategy::type within_strategy_type;
54 
55     typedef typename strategy::covered_by::services::default_strategy
56         <
57             Point,
58             Geometry
59         >::type covered_by_strategy_type;
60 
61     static const bool same_strategies = std::is_same<within_strategy_type, covered_by_strategy_type>::value;
62     BOOST_GEOMETRY_STATIC_ASSERT(same_strategies,
63         "Default within and covered_by strategies not compatible.",
64         within_strategy_type, covered_by_strategy_type);
65 };
66 
67 template<typename Point, typename Geometry>
68 struct default_strategy<Point, Geometry, point_tag, point_tag>
69     : strategy::within::services::default_strategy<Point, Geometry>
70 {};
71 
72 template<typename Point, typename Geometry>
73 struct default_strategy<Point, Geometry, point_tag, multi_point_tag>
74     : strategy::within::services::default_strategy<Point, Geometry>
75 {};
76 
77 
78 } // namespace services
79 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
80 
81 
82 } // namespace point_in_geometry
83 
84 namespace relate
85 {
86 
87 #ifndef DOXYGEN_NO_DETAIL
88 namespace detail
89 {
90 
91 template <typename Geometry>
92 struct default_intersection_strategy
93     : strategy::intersection::services::default_strategy
94         <
95             typename cs_tag<Geometry>::type
96         >
97 {};
98 
99 template <typename PointLike, typename Geometry>
100 struct default_point_in_geometry_strategy
101     : point_in_geometry::services::default_strategy
102         <
103             typename point_type<PointLike>::type,
104             Geometry
105         >
106 {};
107 
108 } // namespace detail
109 #endif // DOXYGEN_NO_DETAIL
110 
111 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
112 namespace services
113 {
114 
115 template
116 <
117     typename Geometry1,
118     typename Geometry2,
119     int TopDim1 = geometry::topological_dimension<Geometry1>::value,
120     int TopDim2 = geometry::topological_dimension<Geometry2>::value
121 >
122 struct default_strategy
123 {
124     BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
125         "Not implemented for these types.",
126         Geometry1, Geometry2);
127 };
128 
129 template <typename PointLike1, typename PointLike2>
130 struct default_strategy<PointLike1, PointLike2, 0, 0>
131     : detail::default_point_in_geometry_strategy<PointLike1, PointLike2>
132 {};
133 
134 template <typename PointLike, typename Geometry, int TopDim2>
135 struct default_strategy<PointLike, Geometry, 0, TopDim2>
136     : detail::default_point_in_geometry_strategy<PointLike, Geometry>
137 {};
138 
139 template <typename Geometry, typename PointLike, int TopDim1>
140 struct default_strategy<Geometry, PointLike, TopDim1, 0>
141     : detail::default_point_in_geometry_strategy<PointLike, Geometry>
142 {};
143 
144 template <typename Geometry1, typename Geometry2>
145 struct default_strategy<Geometry1, Geometry2, 1, 1>
146     : detail::default_intersection_strategy<Geometry1>
147 {};
148 
149 template <typename Geometry1, typename Geometry2>
150 struct default_strategy<Geometry1, Geometry2, 1, 2>
151     : detail::default_intersection_strategy<Geometry1>
152 {};
153 
154 template <typename Geometry1, typename Geometry2>
155 struct default_strategy<Geometry1, Geometry2, 2, 1>
156     : detail::default_intersection_strategy<Geometry1>
157 {};
158 
159 template <typename Geometry1, typename Geometry2>
160 struct default_strategy<Geometry1, Geometry2, 2, 2>
161     : detail::default_intersection_strategy<Geometry1>
162 {};
163 
164 } // namespace services
165 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
166 
167 } // namespace relate
168 
169 } // namespace strategy
170 
171 
172 }} // namespace boost::geometry
173 
174 
175 #endif // BOOST_GEOMETRY_STRATEGY_RELATE_HPP
176