1 // Boost.Geometry
2
3 // Copyright (c) 2019, Oracle and/or its affiliates.
4
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9
10 #ifndef BOOST_GEOMETRY_TEST_CS_UNDEFINED_TEST_RELOPS_HPP
11 #define BOOST_GEOMETRY_TEST_CS_UNDEFINED_TEST_RELOPS_HPP
12
13 #include "common.hpp"
14
15 #include <boost/geometry/algorithms/covered_by.hpp>
16 #include <boost/geometry/algorithms/crosses.hpp>
17 #include <boost/geometry/algorithms/disjoint.hpp>
18 #include <boost/geometry/algorithms/equals.hpp>
19 #include <boost/geometry/algorithms/intersects.hpp>
20 #include <boost/geometry/algorithms/overlaps.hpp>
21 #include <boost/geometry/algorithms/relate.hpp>
22 #include <boost/geometry/algorithms/relation.hpp>
23 #include <boost/geometry/algorithms/touches.hpp>
24 #include <boost/geometry/algorithms/within.hpp>
25
26 template
27 <
28 typename G1,
29 typename G2,
30 std::size_t Dim1 = bg::topological_dimension<G1>::value,
31 std::size_t Dim2 = bg::topological_dimension<G2>::value
32 >
33 struct call_equals
34 {
35 template <typename S>
applycall_equals36 static void apply(G1 const& g1, G2 const& g2, S const& s) {}
37 };
38
39 template <typename G1, typename G2, std::size_t Dim>
40 struct call_equals<G1, G2, Dim, Dim>
41 {
42 template <typename S>
applycall_equals43 static void apply(G1 const& g1, G2 const& g2, S const& s)
44 {
45 bg::equals(g1, g2, s);
46 }
47 };
48
49 template
50 <
51 typename G1,
52 typename G2,
53 std::size_t Dim1 = bg::topological_dimension<G1>::value,
54 std::size_t Dim2 = bg::topological_dimension<G2>::value
55 >
56 struct call_overlaps
57 {
58 template <typename S>
applycall_overlaps59 static void apply(G1 const& g1, G2 const& g2, S const& s) {}
60 };
61
62 template <typename G1, typename G2, std::size_t Dim>
63 struct call_overlaps<G1, G2, Dim, Dim>
64 {
65 template <typename S>
applycall_overlaps66 static void apply(G1 const& g1, G2 const& g2, S const& s)
67 {
68 bg::overlaps(g1, g2, s);
69 }
70 };
71
72 template
73 <
74 typename G1,
75 typename G2,
76 std::size_t Dim1 = bg::topological_dimension<G1>::value,
77 std::size_t Dim2 = bg::topological_dimension<G2>::value
78 >
79 struct call_touches
80 {
81 template <typename S>
applycall_touches82 static void apply(G1 const& g1, G2 const& g2, S const& s)
83 {
84 bg::touches(g1, g2, s);
85 }
86 };
87
88 template <typename G1, typename G2>
89 struct call_touches<G1, G2, 0, 0>
90 {
91 template <typename S>
applycall_touches92 static void apply(G1 const& g1, G2 const& g2, S const& s) {}
93 };
94
95 template
96 <
97 typename G1,
98 typename G2,
99 std::size_t Dim1 = bg::topological_dimension<G1>::value,
100 std::size_t Dim2 = bg::topological_dimension<G2>::value
101 >
102 struct call_crosses
103 {
104 template <typename S>
applycall_crosses105 static void apply(G1 const& g1, G2 const& g2, S const& s)
106 {
107 bg::crosses(g1, g2, s);
108 }
109 };
110
111 template <typename G1, typename G2>
112 struct call_crosses<G1, G2, 0, 0>
113 {
114 template <typename S>
applycall_crosses115 static void apply(G1 const& g1, G2 const& g2, S const& s) {}
116 };
117
118 template <typename G1, typename G2>
119 struct call_crosses<G1, G2, 2, 2>
120 {
121 template <typename S>
applycall_crosses122 static void apply(G1 const& g1, G2 const& g2, S const& s) {}
123 };
124
125 template <typename G1, typename G2, typename S>
rel(G1 const & g1,G2 const & g2,S const & s)126 inline void rel(G1 const& g1, G2 const& g2, S const& s)
127 {
128 bg::relation(g1, g2, s);
129 bg::relate(g1, g2, bg::de9im::mask("*********"), s);
130 bg::covered_by(g1, g2, s);
131 call_crosses<G1, G2>::apply(g1, g2, s);
132 bg::disjoint(g1, g2, s);
133 call_equals<G1, G2>::apply(g1, g2, s);
134 bg::intersects(g1, g2, s);
135 call_overlaps<G1, G2>::apply(g1, g2, s);
136 call_touches<G1, G2>::apply(g1, g2, s);
137 bg::within(g1, g2, s);
138 }
139
140 template <typename G1, typename G2>
rel_pp(G1 const & g1,G2 const & g2)141 inline void rel_pp(G1 const& g1, G2 const& g2)
142 {
143 ::rel(g1, g2, bg::strategy::within::cartesian_point_point());
144 ::rel(g1, g2, bg::strategy::within::spherical_point_point());
145 }
146
147 template <typename G1, typename G2>
rel_ps(G1 const & g1,G2 const & g2)148 inline void rel_ps(G1 const& g1, G2 const& g2)
149 {
150 typedef typename bg::point_type<G1>::type point;
151 ::rel(g1, g2, bg::strategy::within::cartesian_winding<point>());
152 ::rel(g1, g2, bg::strategy::within::spherical_winding<point>());
153 ::rel(g1, g2, bg::strategy::within::geographic_winding<point>());
154 }
155
156 template <typename G1, typename G2>
rel_ss(G1 const & g1,G2 const & g2)157 inline void rel_ss(G1 const& g1, G2 const& g2)
158 {
159 ::rel(g1, g2, bg::strategy::intersection::cartesian_segments<>());
160 ::rel(g1, g2, bg::strategy::intersection::spherical_segments<>());
161 ::rel(g1, g2, bg::strategy::intersection::geographic_segments<>());
162 }
163
164 #endif // BOOST_GEOMETRY_TEST_CS_UNDEFINED_TEST_RELOPS_HPP
165