]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Generic Geometry2 Library |
2 | // Unit Test | |
3 | ||
4 | // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. | |
5 | ||
b32b8144 FG |
6 | // This file was modified by Oracle on 2015, 2017. |
7 | // Modifications copyright (c) 2015-2017 Oracle and/or its affiliates. | |
7c673cae FG |
8 | // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle |
9 | ||
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 | ||
14 | #ifndef BOOST_GEOMETRY_TEST_OVERLAPS_HPP | |
15 | #define BOOST_GEOMETRY_TEST_OVERLAPS_HPP | |
16 | ||
17 | ||
18 | #include <geometry_test_common.hpp> | |
19 | ||
20 | #include <boost/geometry/core/ring_type.hpp> | |
21 | #include <boost/geometry/algorithms/overlaps.hpp> | |
22 | #include <boost/geometry/strategies/strategies.hpp> | |
23 | #include <boost/geometry/geometries/geometries.hpp> | |
24 | #include <boost/geometry/geometries/point_xy.hpp> | |
25 | ||
26 | #include <boost/geometry/io/wkt/read.hpp> | |
27 | ||
28 | ||
b32b8144 FG |
29 | struct no_strategy {}; |
30 | ||
31 | template <typename Geometry1, typename Geometry2, typename Strategy> | |
32 | bool call_overlaps(Geometry1 const& geometry1, | |
33 | Geometry2 const& geometry2, | |
34 | Strategy const& strategy) | |
35 | { | |
36 | return bg::overlaps(geometry1, geometry2, strategy); | |
37 | } | |
38 | ||
7c673cae | 39 | template <typename Geometry1, typename Geometry2> |
b32b8144 FG |
40 | bool call_overlaps(Geometry1 const& geometry1, |
41 | Geometry2 const& geometry2, | |
42 | no_strategy) | |
43 | { | |
44 | return bg::overlaps(geometry1, geometry2); | |
45 | } | |
46 | ||
47 | template <typename Geometry1, typename Geometry2, typename Strategy> | |
7c673cae FG |
48 | void test_geometry(Geometry1 const& geometry1, |
49 | Geometry2 const& geometry2, | |
50 | std::string const& wkt1, | |
51 | std::string const& wkt2, | |
b32b8144 FG |
52 | bool expected, |
53 | Strategy const& strategy) | |
7c673cae | 54 | { |
b32b8144 | 55 | bool detected = call_overlaps(geometry1, geometry2, strategy); |
7c673cae FG |
56 | |
57 | BOOST_CHECK_MESSAGE(detected == expected, | |
58 | "overlaps: " << wkt1 | |
59 | << " with " << wkt2 | |
60 | << " -> Expected: " << expected | |
61 | << " detected: " << detected); | |
62 | ||
b32b8144 | 63 | detected = call_overlaps(geometry2, geometry1, strategy); |
7c673cae FG |
64 | |
65 | BOOST_CHECK_MESSAGE(detected == expected, | |
b32b8144 FG |
66 | "overlaps: " << wkt2 |
67 | << " with " << wkt1 | |
7c673cae FG |
68 | << " -> Expected: " << expected |
69 | << " detected: " << detected); | |
70 | } | |
71 | ||
72 | template <typename Geometry1, typename Geometry2> | |
73 | void test_geometry(std::string const& wkt1, | |
74 | std::string const& wkt2, | |
75 | bool expected) | |
76 | { | |
77 | Geometry1 geometry1; | |
78 | Geometry2 geometry2; | |
79 | ||
80 | bg::read_wkt(wkt1, geometry1); | |
81 | bg::read_wkt(wkt2, geometry2); | |
82 | ||
b32b8144 FG |
83 | test_geometry(geometry1, geometry2, wkt1, wkt2, expected, no_strategy()); |
84 | ||
85 | typedef typename bg::strategy::relate::services::default_strategy | |
86 | < | |
87 | Geometry1, Geometry2 | |
88 | >::type strategy_type; | |
89 | ||
90 | test_geometry(geometry1, geometry2, wkt1, wkt2, expected, strategy_type()); | |
7c673cae FG |
91 | } |
92 | ||
93 | ||
94 | #endif |