]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/geometry/test/algorithms/relational_operations/touches/test_touches.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / geometry / test / algorithms / relational_operations / touches / test_touches.hpp
CommitLineData
7c673cae
FG
1// Boost.Geometry (aka GGL, Generic Geometry Library)
2// Unit Test
3
4// Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
5
6// This file was modified by Oracle on 2013, 2015, 2016.
7// Modifications copyright (c) 2013-2016 Oracle and/or its affiliates.
8
9// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10
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)
14
15#ifndef BOOST_GEOMETRY_TEST_TOUCHES_HPP
16#define BOOST_GEOMETRY_TEST_TOUCHES_HPP
17
18
19#include <geometry_test_common.hpp>
20
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>
26
27#include <boost/geometry/io/wkt/read.hpp>
28#include <boost/variant/variant.hpp>
29
30template <typename Geometry1, typename Geometry2>
31void check_touches(Geometry1 const& geometry1,
32 Geometry2 const& geometry2,
33 std::string const& wkt1,
34 std::string const& wkt2,
35 bool expected)
36{
37 bool detected = bg::touches(geometry1, geometry2);
38
39 BOOST_CHECK_MESSAGE(detected == expected,
40 "touches: " << wkt1
41 << " with " << wkt2
42 << " -> Expected: " << expected
43 << " detected: " << detected);
44
45 detected = bg::touches(geometry2, geometry1);
46
47 BOOST_CHECK_MESSAGE(detected == expected,
48 "touches: " << wkt1
49 << " with " << wkt2
50 << " -> Expected: " << expected
51 << " detected: " << detected);
52}
53
54template <typename Geometry1, typename Geometry2>
55void test_touches(std::string const& wkt1,
56 std::string const& wkt2, bool expected)
57{
58 Geometry1 geometry1;
59 Geometry2 geometry2;
60
61 bg::read_wkt(wkt1, geometry1);
62 bg::read_wkt(wkt2, geometry2);
63
64 boost::variant<Geometry1> v1(geometry1);
65 boost::variant<Geometry2> v2(geometry2);
66
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);
71}
72
73template <typename Geometry1, typename Geometry2>
74void test_geometry(std::string const& wkt1,
75 std::string const& wkt2,
76 bool expected)
77{
78 test_touches<Geometry1, Geometry2>(wkt1, wkt2, expected);
79}
80
81
82template <typename Geometry>
83void check_self_touches(Geometry const& geometry,
84 std::string const& wkt,
85 bool expected)
86{
87 bool detected = bg::touches(geometry);
88
89 BOOST_CHECK_MESSAGE(detected == expected,
90 "touches: " << wkt
91 << " -> Expected: " << expected
92 << " detected: " << detected);
93}
94
95template <typename Geometry>
96void test_self_touches(std::string const& wkt, bool expected)
97{
98 Geometry geometry;
99 bg::read_wkt(wkt, geometry);
100 boost::variant<Geometry> v(geometry);
101
102 check_self_touches(geometry, wkt, expected);
103 check_self_touches(v, wkt, expected);
104}
105
106
107
108#endif