1 // Boost.Geometry (aka GGL, Generic Geometry Library)
4 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
5 // Copyright (c) 2014-2017 Adam Wulkiewicz, Lodz, Poland.
7 // This file was modified by Oracle on 2016-2017.
8 // Modifications copyright (c) 2016-2017 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_EQUALS_HPP
16 #define BOOST_GEOMETRY_TEST_EQUALS_HPP
19 #include <geometry_test_common.hpp>
21 #include <boost/geometry/core/ring_type.hpp>
22 #include <boost/geometry/algorithms/correct.hpp>
23 #include <boost/geometry/algorithms/equals.hpp>
24 #include <boost/geometry/strategies/strategies.hpp>
25 #include <boost/geometry/io/wkt/read.hpp>
26 #include <boost/variant/variant.hpp>
29 struct no_strategy {};
31 template <typename Geometry1, typename Geometry2, typename Strategy>
32 bool call_equals(Geometry1 const& geometry1,
33 Geometry2 const& geometry2,
34 Strategy const& strategy)
36 return bg::equals(geometry1, geometry2, strategy);
39 template <typename Geometry1, typename Geometry2>
40 bool call_equals(Geometry1 const& geometry1,
41 Geometry2 const& geometry2,
44 return bg::equals(geometry1, geometry2);
47 template <typename Geometry1, typename Geometry2, typename Strategy>
48 void check_geometry(Geometry1 const& geometry1,
49 Geometry2 const& geometry2,
50 std::string const& caseid,
51 std::string const& wkt1,
52 std::string const& wkt2,
54 Strategy const& strategy)
56 bool detected = call_equals(geometry1, geometry2, strategy);
58 BOOST_CHECK_MESSAGE(detected == expected,
60 << " equals: " << wkt1
62 << " -> Expected: " << expected
63 << " detected: " << detected);
65 detected = call_equals(geometry2, geometry1, strategy);
67 BOOST_CHECK_MESSAGE(detected == expected,
69 << " equals: " << wkt2
71 << " -> Expected: " << expected
72 << " detected: " << detected);
76 template <typename Geometry1, typename Geometry2>
77 void test_geometry(std::string const& caseid,
78 std::string const& wkt1,
79 std::string const& wkt2,
81 bool correct_geometries = false)
86 bg::read_wkt(wkt1, geometry1);
87 bg::read_wkt(wkt2, geometry2);
89 if (correct_geometries)
91 bg::correct(geometry1);
92 bg::correct(geometry2);
95 typedef typename bg::strategy::relate::services::default_strategy
98 >::type strategy_type;
100 check_geometry(geometry1, geometry2, caseid, wkt1, wkt2, expected, no_strategy());
101 check_geometry(geometry1, geometry2, caseid, wkt1, wkt2, expected, strategy_type());
102 check_geometry(boost::variant<Geometry1>(geometry1), geometry2, caseid, wkt1, wkt2, expected, no_strategy());
103 check_geometry(geometry1, boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected, no_strategy());
104 check_geometry(boost::variant<Geometry1>(geometry1), boost::variant<Geometry2>(geometry2), caseid, wkt1, wkt2, expected, no_strategy());
107 template <typename Geometry1, typename Geometry2>
108 void test_geometry(std::string const& wkt1,
109 std::string const& wkt2,
112 test_geometry<Geometry1, Geometry2>("", wkt1, wkt2, expected);