// Boost.Geometry // Copyright (c) 2018 Yaghyavardhan Singh Khangarot, Hyderabad, India. // Contributed and/or modified by Yaghyavardhan Singh Khangarot, // as part of Google Summer of Code 2018 program. // This file was modified by Oracle on 2018. // Modifications copyright (c) 2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) #ifndef BOOST_GEOMETRY_TEST_HAUSDORFF_DISTANCE_HPP #define BOOST_GEOMETRY_TEST_HAUSDORFF_DISTANCE_HPP #include #include #include #include #include template void test_hausdorff_distance(Geometry1 const& geometry1, Geometry2 const& geometry2, Expected const& expected_hausdorff_distance) { typedef typename bg::distance_result < typename bg::point_type::type, typename bg::point_type::type >::type result_type; result_type h_distance = bg::discrete_hausdorff_distance(geometry1, geometry2); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::ostringstream out; out << typeid(typename bg::coordinate_type::type).name() << std::endl << typeid(typename bg::coordinate_type::type).name() << std::endl << typeid(h_distance).name() << std::endl << "hausdorff_distance : " << h_distance << std::endl; std::cout << out.str(); #endif BOOST_CHECK_CLOSE(h_distance, result_type(expected_hausdorff_distance), 0.01); } template void test_geometry(std::string const& wkt1, std::string const& wkt2, Expected const& expected_hausdorff_distance) { Geometry1 geometry1; bg::read_wkt(wkt1, geometry1); Geometry2 geometry2; bg::read_wkt(wkt2, geometry2); test_hausdorff_distance(geometry1, geometry2, expected_hausdorff_distance); #if defined(BOOST_GEOMETRY_TEST_DEBUG) test_hausdorff_distance(boost::variant(geometry1), boost::variant(geometry2), expected_hausdorff_distance); #endif } template void test_hausdorff_distance(Geometry1 const& geometry1, Geometry2 const& geometry2, Strategy strategy, Expected const& expected_hausdorff_distance) { typedef typename bg::distance_result < typename bg::point_type::type, typename bg::point_type::type, Strategy >::type result_type; result_type h_distance = bg::discrete_hausdorff_distance(geometry1, geometry2, strategy); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::ostringstream out; out << typeid(typename bg::coordinate_type::type).name() << std::endl << typeid(typename bg::coordinate_type::type).name() << std::endl << typeid(h_distance).name() << std::endl << "hausdorff_distance : " << h_distance << std::endl; std::cout << out.str(); #endif BOOST_CHECK_CLOSE(h_distance, result_type(expected_hausdorff_distance), 0.01); } template void test_geometry(std::string const& wkt1, std::string const& wkt2, Strategy strategy, Expected const& expected_hausdorff_distance) { Geometry1 geometry1; bg::read_wkt(wkt1, geometry1); Geometry2 geometry2; bg::read_wkt(wkt2, geometry2); test_hausdorff_distance(geometry1, geometry2, strategy, expected_hausdorff_distance); #if defined(BOOST_GEOMETRY_TEST_DEBUG) test_hausdorff_distance(boost::variant(geometry1), boost::variant(geometry2), strategy, expected_hausdorff_distance); #endif } template void test_empty_input(Geometry1 const& geometry1, Geometry2 const& geometry2) { try { bg::discrete_hausdorff_distance(geometry1, geometry2); } catch(bg::empty_input_exception const& ) { return; } BOOST_CHECK_MESSAGE(false, "A empty_input_exception should have been thrown"); } #endif