1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
6 // This file was modified by Oracle on 2013, 2015, 2016.
7 // Modifications copyright (c) 2013-2016 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_GEOMETRY_TEST_TOUCHES_HPP
16 #define BOOST_GEOMETRY_TEST_TOUCHES_HPP
19 #include <geometry_test_common.hpp>
21 #include <boost/geometry/core/ring_type.hpp>
22 #include <boost/geometry/algorithms/touches.hpp>
23 #include <boost/geometry/strategies/strategies.hpp>
24 #include <boost/geometry/geometries/geometries.hpp>
25 #include <boost/geometry/geometries/point_xy.hpp>
27 #include <boost/geometry/io/wkt/read.hpp>
28 #include <boost/variant/variant.hpp>
30 template <typename Geometry1, typename Geometry2>
31 void check_touches(Geometry1 const& geometry1,
32 Geometry2 const& geometry2,
33 std::string const& wkt1,
34 std::string const& wkt2,
37 bool detected = bg::touches(geometry1, geometry2);
39 BOOST_CHECK_MESSAGE(detected == expected,
42 << " -> Expected: " << expected
43 << " detected: " << detected);
45 detected = bg::touches(geometry2, geometry1);
47 BOOST_CHECK_MESSAGE(detected == expected,
50 << " -> Expected: " << expected
51 << " detected: " << detected);
54 template <typename Geometry1, typename Geometry2>
55 void test_touches(std::string const& wkt1,
56 std::string const& wkt2, bool expected)
61 bg::read_wkt(wkt1, geometry1);
62 bg::read_wkt(wkt2, geometry2);
64 boost::variant<Geometry1> v1(geometry1);
65 boost::variant<Geometry2> v2(geometry2);
67 check_touches(geometry1, geometry2, wkt1, wkt2, expected);
68 check_touches(v1, geometry2, wkt1, wkt2, expected);
69 check_touches(geometry1, v2, wkt1, wkt2, expected);
70 check_touches(v1, v2, wkt1, wkt2, expected);
73 template <typename Geometry1, typename Geometry2>
74 void test_geometry(std::string const& wkt1,
75 std::string const& wkt2,
78 test_touches<Geometry1, Geometry2>(wkt1, wkt2, expected);
82 template <typename Geometry>
83 void check_self_touches(Geometry const& geometry,
84 std::string const& wkt,
87 bool detected = bg::touches(geometry);
89 BOOST_CHECK_MESSAGE(detected == expected,
91 << " -> Expected: " << expected
92 << " detected: " << detected);
95 template <typename Geometry>
96 void test_self_touches(std::string const& wkt, bool expected)
99 bg::read_wkt(wkt, geometry);
100 boost::variant<Geometry> v(geometry);
102 check_self_touches(geometry, wkt, expected);
103 check_self_touches(v, wkt, expected);