1 // Generic Geometry2 Library
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
6 // This file was modified by Oracle on 2014, 2017.
7 // Modifications copyright (c) 2014-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_CROSSES_HPP
15 #define BOOST_GEOMETRY_TEST_CROSSES_HPP
18 #include <geometry_test_common.hpp>
20 #include <boost/geometry/core/ring_type.hpp>
21 #include <boost/geometry/algorithms/crosses.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>
27 #include <boost/variant/variant.hpp>
30 struct no_strategy {};
32 template <typename Geometry1, typename Geometry2, typename Strategy>
33 bool call_crosses(Geometry1 const& geometry1,
34 Geometry2 const& geometry2,
35 Strategy const& strategy)
37 return bg::crosses(geometry1, geometry2, strategy);
40 template <typename Geometry1, typename Geometry2>
41 bool call_crosses(Geometry1 const& geometry1,
42 Geometry2 const& geometry2,
45 return bg::crosses(geometry1, geometry2);
48 template <typename Geometry1, typename Geometry2>
49 void test_geometry(std::string const& wkt1,
50 std::string const& wkt2, bool expected)
55 bg::read_wkt(wkt1, geometry1);
56 bg::read_wkt(wkt2, geometry2);
58 bool detected = call_crosses(geometry1, geometry2, no_strategy());
60 BOOST_CHECK_MESSAGE(detected == expected,
63 << " -> Expected: " << expected
64 << " detected: " << detected);
66 typedef typename bg::strategy::relate::services::default_strategy
69 >::type strategy_type;
71 detected = call_crosses(geometry1, geometry2, strategy_type());
73 BOOST_CHECK_MESSAGE(detected == expected,
76 << " -> Expected: " << expected
77 << " detected: " << detected);
79 #if !defined(BOOST_GEOMETRY_TEST_DEBUG)
80 detected = bg::crosses(geometry1,
81 boost::variant<Geometry2>(geometry2));
83 BOOST_CHECK_MESSAGE(detected == expected,
86 << " -> Expected: " << expected
87 << " detected: " << detected);
89 detected = bg::crosses(boost::variant<Geometry1>(geometry1),
92 BOOST_CHECK_MESSAGE(detected == expected,
95 << " -> Expected: " << expected
96 << " detected: " << detected);
98 detected = bg::crosses(boost::variant<Geometry1>(geometry1),
99 boost::variant<Geometry2>(geometry2));
101 BOOST_CHECK_MESSAGE(detected == expected,
104 << " -> Expected: " << expected
105 << " detected: " << detected);
110 #endif // BOOST_GEOMETRY_TEST_CROSSES_HPP