// Boost.Geometry Index // Unit Test // Copyright (c) 2015 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) // Enable enlargement of Values' bounds by epsilon in the rtree // for Points and Segments #define BOOST_GEOMETRY_INDEX_EXPERIMENTAL_ENLARGE_BY_EPSILON #include #include #include #include template void test_rtree(unsigned vcount) { typedef bg::model::point point_t; std::vector values; double eps = std::numeric_limits::epsilon(); values.push_back(point_t(eps/2, eps/2)); for ( unsigned i = 1 ; i < vcount ; ++i ) { values.push_back(point_t(i, i)); } point_t qpt(0, 0); BOOST_CHECK(bg::intersects(qpt, values[0])); { bgi::rtree rt(values); std::vector result; rt.query(bgi::intersects(qpt), std::back_inserter(result)); BOOST_CHECK(result.size() == 1); rt.remove(values.begin() + vcount/2, values.end()); result.clear(); rt.query(bgi::intersects(qpt), std::back_inserter(result)); BOOST_CHECK(result.size() == 1); } { bgi::rtree rt; rt.insert(values); std::vector result; rt.query(bgi::intersects(qpt), std::back_inserter(result)); BOOST_CHECK(result.size() == 1); rt.remove(values.begin() + vcount/2, values.end()); result.clear(); rt.query(bgi::intersects(qpt), std::back_inserter(result)); BOOST_CHECK(result.size() == 1); } } template void test_rtree_all() { int pow = Max; for (int l = 0 ; l < 3 ; ++l) { pow *= Max; int vcount = (pow * 8) / 10; //std::cout << Max << " " << Min << " " << vcount << std::endl; test_rtree< bgi::linear >(vcount); test_rtree< bgi::quadratic >(vcount); test_rtree< bgi::rstar >(vcount); } } int test_main(int, char* []) { test_rtree_all<2, 1>(); test_rtree_all<4, 1>(); test_rtree_all<4, 2>(); test_rtree_all<5, 3>(); return 0; }