// Boost.Geometry Index // Unit Test // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // 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) #include #include #include #include #include #include #define BOOST_GEOMETRY_TEST_DEBUG template void test(Point const& pt, Indexable const& indexable, typename bg::default_distance_result::type expected_value) { typename bg::default_distance_result::type value = bgi::detail::minmaxdist(pt, indexable); #ifdef BOOST_GEOMETRY_TEST_DEBUG std::ostringstream out; out << typeid(typename bg::coordinate_type::type).name() << " " << typeid(typename bg::coordinate_type::type).name() << " " << typeid(bg::default_distance_result::type).name() << " " << "minmaxdist : " << value << std::endl; std::cout << out.str(); #endif BOOST_CHECK_CLOSE(value, expected_value, 0.0001); } template void test_indexable(Point const& pt, std::string const& wkt, typename bg::default_distance_result::type expected_value) { Indexable indexable; bg::read_wkt(wkt, indexable); test(pt, indexable, expected_value); } void test_large_integers() { typedef bg::model::point int_point_type; typedef bg::model::point double_point_type; int_point_type int_pt(0, 0); double_point_type double_pt(0, 0); bg::model::box int_box; bg::model::box double_box; std::string const box_li = "POLYGON((1536119 192000, 1872000 528000))"; bg::read_wkt(box_li, int_box); bg::read_wkt(box_li, double_box); BOOST_CHECK(bgi::detail::minmaxdist(int_pt, int_box) == bgi::detail::minmaxdist(double_pt, double_box)); } int test_main(int, char* []) { typedef bg::model::point P2ic; typedef bg::model::point P2fc; typedef bg::model::point P2dc; typedef bg::model::point P3ic; typedef bg::model::point P3fc; typedef bg::model::point P3dc; test_indexable >(P2ic(1, 2), "POLYGON((0 1,2 4))", 5.0); test_indexable >(P2fc(1, 2), "POLYGON((0 1,2 4))", 5.0); test_indexable >(P2dc(1, 2), "POLYGON((0 1,2 4))", 5.0); test_indexable >(P3ic(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0); test_indexable >(P3fc(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0); test_indexable >(P3dc(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0); test_indexable >(P2ic(1, 2), "POLYGON((1 2,3 5))", 4.0); #ifdef HAVE_TTMATH typedef bg::model::point P2ttmc; typedef bg::model::point P3ttmc; test_indexable >(P2ttmc(1, 2), "POLYGON((0 1,2 4))", 5.0); test_indexable >(P3ttmc(1, 2, 3), "POLYGON((0 1 2,2 4 6))", 14.0); #endif test_large_integers(); return 0; }