Imported Upstream version 1.57.0
[platform/upstream/boost.git] / libs / geometry / test / algorithms / test_intersects.hpp
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
2 // Unit Test
3
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2013 Adam Wulkiewicz, Lodz, Poland.
6
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
10
11 #ifndef BOOST_GEOMETRY_TEST_INTERSECTS_HPP
12 #define BOOST_GEOMETRY_TEST_INTERSECTS_HPP
13
14
15 #include <geometry_test_common.hpp>
16
17 #include <boost/geometry/core/ring_type.hpp>
18 #include <boost/geometry/algorithms/intersects.hpp>
19 #include <boost/geometry/strategies/strategies.hpp>
20 #include <boost/geometry/geometries/ring.hpp>
21 #include <boost/geometry/geometries/polygon.hpp>
22
23 #include <boost/geometry/io/wkt/read.hpp>
24
25 #include <boost/geometry/multi/core/geometry_id.hpp>
26 #include <boost/geometry/multi/core/point_order.hpp>
27 #include <boost/geometry/multi/core/ring_type.hpp>
28 #include <boost/geometry/multi/algorithms/covered_by.hpp>
29 #include <boost/geometry/multi/algorithms/detail/point_on_border.hpp>
30 #include <boost/geometry/multi/algorithms/detail/sections/sectionalize.hpp>
31 #include <boost/geometry/multi/algorithms/detail/sections/range_by_section.hpp>
32 #include <boost/geometry/multi/views/detail/range_type.hpp>
33 #include <boost/geometry/multi/geometries/multi_linestring.hpp>
34 #include <boost/geometry/multi/geometries/multi_polygon.hpp>
35
36 #include <boost/geometry/multi/io/wkt/read.hpp>
37
38 template <typename Geometry1, typename Geometry2>
39 void test_geometry(std::string const& wkt1,
40         std::string const& wkt2, bool expected)
41 {
42     Geometry1 geometry1;
43     Geometry2 geometry2;
44
45     bg::read_wkt(wkt1, geometry1);
46     bg::read_wkt(wkt2, geometry2);
47
48     bool detected = bg::intersects(geometry1, geometry2);
49     bool detected2 = bg::intersects(geometry2, geometry1);
50
51     BOOST_CHECK_MESSAGE(detected == expected,
52         "intersects: " << wkt1
53         << " with " << wkt2
54         << " -> Expected: " << expected
55         << " detected: " << detected);
56     BOOST_CHECK_MESSAGE(detected2 == expected,
57         "intersects: " << wkt1
58         << " with " << wkt2
59         << " -> Expected: " << expected
60         << " detected: " << detected2);
61 }
62
63
64 template <typename Geometry>
65 void test_self_intersects(std::string const& wkt, bool expected)
66 {
67     Geometry geometry;
68
69     bg::read_wkt(wkt, geometry);
70
71     bool detected = bg::intersects(geometry);
72
73     BOOST_CHECK_MESSAGE(detected == expected,
74         "intersects: " << wkt
75         << " -> Expected: " << expected
76         << " detected: " << detected);
77 }
78
79
80
81 #endif