3 // Copyright (c) 2017 Barend Gehrels, Amsterdam, the Netherlands.
5 // Use, modification and distribution is subject to the Boost Software License,
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
7 // http://www.boost.org/LICENSE_1_0.txt)
9 #ifndef BOOST_GEOMETRY_TEST_CHECK_VALIDITY_HPP
10 #define BOOST_GEOMETRY_TEST_CHECK_VALIDITY_HPP
12 #include <boost/foreach.hpp>
14 #include <boost/geometry/algorithms/is_valid.hpp>
16 template<typename Geometry, typename G1, typename G2>
17 inline bool is_output_valid(Geometry const& geometry,
18 std::string const& case_id,
19 G1 const& g1, G2 const& g2,
22 bool const result = bg::is_valid(geometry, message);
25 // Check if input was valid. If not, do not report output validity
26 if (! bg::is_valid(g1) || ! bg::is_valid(g2))
28 std::cout << "WARNING: Input is not considered as valid; "
29 << "this can cause that output is invalid: " << case_id
40 typename Tag = typename bg::tag<Geometry>::type
44 template <typename G1, typename G2>
46 bool apply(Geometry const& geometry,
47 std::string const& case_id,
48 G1 const& g1, G2 const& g2,
51 return is_output_valid(geometry, case_id, g1, g2, message);
55 // Specialization for vector of <geometry> (e.g. rings)
56 template <typename Geometry>
57 struct check_validity<Geometry, void>
59 template <typename G1, typename G2>
61 bool apply(Geometry const& geometry,
62 std::string const& case_id,
63 G1 const& g1, G2 const& g2,
66 typedef typename boost::range_value<Geometry>::type single_type;
67 BOOST_FOREACH(single_type const& element, geometry)
69 if (! is_output_valid(element, case_id, g1, g2, message))
79 #endif // BOOST_GEOMETRY_TEST_CHECK_VALIDITY_HPP