1 // Generic Geometry2 Library
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // This file was modified by Oracle on 2015, 2017.
7 // Modifications copyright (c) 2015-2017 Oracle and/or its affiliates.
8 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
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)
14 #ifndef BOOST_GEOMETRY_TEST_OVERLAPS_HPP
15 #define BOOST_GEOMETRY_TEST_OVERLAPS_HPP
18 #include <geometry_test_common.hpp>
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>
26 #include <boost/geometry/io/wkt/read.hpp>
29 struct no_strategy {};
31 template <typename Geometry1, typename Geometry2, typename Strategy>
32 bool call_overlaps(Geometry1 const& geometry1,
33 Geometry2 const& geometry2,
34 Strategy const& strategy)
36 return bg::overlaps(geometry1, geometry2, strategy);
39 template <typename Geometry1, typename Geometry2>
40 bool call_overlaps(Geometry1 const& geometry1,
41 Geometry2 const& geometry2,
44 return bg::overlaps(geometry1, geometry2);
47 template <typename Geometry1, typename Geometry2, typename Strategy>
48 void test_geometry(Geometry1 const& geometry1,
49 Geometry2 const& geometry2,
50 std::string const& wkt1,
51 std::string const& wkt2,
53 Strategy const& strategy)
55 bool detected = call_overlaps(geometry1, geometry2, strategy);
57 BOOST_CHECK_MESSAGE(detected == expected,
60 << " -> Expected: " << expected
61 << " detected: " << detected);
63 detected = call_overlaps(geometry2, geometry1, strategy);
65 BOOST_CHECK_MESSAGE(detected == expected,
68 << " -> Expected: " << expected
69 << " detected: " << detected);
72 template <typename Geometry1, typename Geometry2>
73 void test_geometry(std::string const& wkt1,
74 std::string const& wkt2,
80 bg::read_wkt(wkt1, geometry1);
81 bg::read_wkt(wkt2, geometry2);
83 test_geometry(geometry1, geometry2, wkt1, wkt2, expected, no_strategy());
85 typedef typename bg::strategy::relate::services::default_strategy
88 >::type strategy_type;
90 test_geometry(geometry1, geometry2, wkt1, wkt2, expected, strategy_type());