From bf815512ccce4b04a5a0b3b9d70a10e4f66afe1c Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 14 Feb 2013 14:23:09 +0000 Subject: [PATCH] tests and examples files structure rearranged [SVN r82872] --- .../benchmark.cpp | 4 - .../glut_vis.cpp | 0 test/rtree/Jamfile.v2 | 19 +- test/rtree/exceptions/Jamfile.v2 | 13 + .../{ => exceptions}/rtree_exceptions.cpp | 2 +- .../test_rtree_exceptions.hpp | 2 +- test/rtree/{ => exceptions}/test_throwing.hpp | 0 test/rtree/generated/Jamfile.v2 | 113 +--- test/rtree/interprocess/Jamfile.v2 | 29 ++ .../rtree_interprocess_b2f_linear.cpp | 19 + .../rtree_interprocess_b2f_linear_rt.cpp | 19 + .../rtree_interprocess_b2f_quadratic.cpp | 19 + .../rtree_interprocess_b2f_quadratic_rt.cpp | 19 + .../rtree_interprocess_b2f_rstar.cpp | 19 + .../rtree_interprocess_b2f_rstar_rt.cpp | 19 + .../test_interprocess.hpp} | 14 - .../rtree}/rtree_test_generator.cpp | 0 tests/additional_sizes_and_times.cpp | 485 ------------------ 18 files changed, 173 insertions(+), 622 deletions(-) rename tests/additional_speed.cpp => example/benchmark.cpp (98%) rename tests/additional_glut_vis.cpp => example/glut_vis.cpp (100%) create mode 100644 test/rtree/exceptions/Jamfile.v2 rename test/rtree/{ => exceptions}/rtree_exceptions.cpp (99%) rename test/rtree/{ => exceptions}/test_rtree_exceptions.hpp (99%) rename test/rtree/{ => exceptions}/test_throwing.hpp (100%) create mode 100644 test/rtree/interprocess/Jamfile.v2 create mode 100644 test/rtree/interprocess/rtree_interprocess_b2f_linear.cpp create mode 100644 test/rtree/interprocess/rtree_interprocess_b2f_linear_rt.cpp create mode 100644 test/rtree/interprocess/rtree_interprocess_b2f_quadratic.cpp create mode 100644 test/rtree/interprocess/rtree_interprocess_b2f_quadratic_rt.cpp create mode 100644 test/rtree/interprocess/rtree_interprocess_b2f_rstar.cpp create mode 100644 test/rtree/interprocess/rtree_interprocess_b2f_rstar_rt.cpp rename test/rtree/{rtree_interprocess.cpp => interprocess/test_interprocess.hpp} (81%) rename {tests => test/rtree}/rtree_test_generator.cpp (100%) delete mode 100644 tests/additional_sizes_and_times.cpp diff --git a/tests/additional_speed.cpp b/example/benchmark.cpp similarity index 98% rename from tests/additional_speed.cpp rename to example/benchmark.cpp index 014ae3fbc..ec036560b 100644 --- a/tests/additional_speed.cpp +++ b/example/benchmark.cpp @@ -8,17 +8,13 @@ // http://www.boost.org/LICENSE_1_0.txt) #include -#include #include -#include #include #include #include -#include - int main() { boost::timer tim; diff --git a/tests/additional_glut_vis.cpp b/example/glut_vis.cpp similarity index 100% rename from tests/additional_glut_vis.cpp rename to example/glut_vis.cpp diff --git a/test/rtree/Jamfile.v2 b/test/rtree/Jamfile.v2 index e637ce08a..d906c8880 100644 --- a/test/rtree/Jamfile.v2 +++ b/test/rtree/Jamfile.v2 @@ -6,21 +6,6 @@ # Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at # http://www.boost.org/LICENSE_1_0.txt) +build-project exceptions ; +build-project interprocess ; build-project generated ; - -test-suite boost-geometry-index-rtree - : - [ run rtree_exceptions.cpp ] - ; - -test-suite boost-geometry-index-rtree_interprocess - : [ run rtree_interprocess.cpp /boost/thread//boost_thread - : # additional args - : # test-files - : # requirements - acc:-lrt - acc-pa_risc:-lrt - gcc-mingw:"-lole32 -loleaut32 -lpsapi -ladvapi32" - hpux,gcc:"-Wl,+as,mpas" - ] : multi - ; \ No newline at end of file diff --git a/test/rtree/exceptions/Jamfile.v2 b/test/rtree/exceptions/Jamfile.v2 new file mode 100644 index 000000000..dc5685ca6 --- /dev/null +++ b/test/rtree/exceptions/Jamfile.v2 @@ -0,0 +1,13 @@ +# Boost.Geometry Index +# +# 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) + +test-suite boost-geometry-index-rtree-exceptions + : + [ run rtree_exceptions.cpp ] + ; + diff --git a/test/rtree/rtree_exceptions.cpp b/test/rtree/exceptions/rtree_exceptions.cpp similarity index 99% rename from test/rtree/rtree_exceptions.cpp rename to test/rtree/exceptions/rtree_exceptions.cpp index edb6d5560..b28c7974b 100644 --- a/test/rtree/rtree_exceptions.cpp +++ b/test/rtree/exceptions/rtree_exceptions.cpp @@ -7,7 +7,7 @@ // 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 diff --git a/test/rtree/test_rtree_exceptions.hpp b/test/rtree/exceptions/test_rtree_exceptions.hpp similarity index 99% rename from test/rtree/test_rtree_exceptions.hpp rename to test/rtree/exceptions/test_rtree_exceptions.hpp index 97ba22037..b2149a82e 100644 --- a/test/rtree/test_rtree_exceptions.hpp +++ b/test/rtree/exceptions/test_rtree_exceptions.hpp @@ -16,7 +16,7 @@ #include -#include +#include namespace boost { namespace geometry { namespace index { diff --git a/test/rtree/test_throwing.hpp b/test/rtree/exceptions/test_throwing.hpp similarity index 100% rename from test/rtree/test_throwing.hpp rename to test/rtree/exceptions/test_throwing.hpp diff --git a/test/rtree/generated/Jamfile.v2 b/test/rtree/generated/Jamfile.v2 index 9a9b5e510..7d1cb2cfa 100644 --- a/test/rtree/generated/Jamfile.v2 +++ b/test/rtree/generated/Jamfile.v2 @@ -1,108 +1,21 @@ # Boost.Geometry Index # -# Copyright (c) 2011-2012 Adam Wulkiewicz, Lodz, Poland. +# 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) -test-suite boost-geometry-index-rtree-generated - : - [ run rtree_p2d_linear.cpp ] - [ run rtree_b2d_linear.cpp ] - [ run rtree_p2d_quadratic.cpp ] - [ run rtree_b2d_quadratic.cpp ] - [ run rtree_p2d_rstar.cpp ] - [ run rtree_b2d_rstar.cpp ] - [ run rtree_p2d_linear_rt.cpp ] - [ run rtree_b2d_linear_rt.cpp ] - [ run rtree_p2d_quadratic_rt.cpp ] - [ run rtree_b2d_quadratic_rt.cpp ] - [ run rtree_p2d_rstar_rt.cpp ] - [ run rtree_b2d_rstar_rt.cpp ] - [ run rtree_p2f_linear.cpp ] - [ run rtree_b2f_linear.cpp ] - [ run rtree_p2f_quadratic.cpp ] - [ run rtree_b2f_quadratic.cpp ] - [ run rtree_p2f_rstar.cpp ] - [ run rtree_b2f_rstar.cpp ] - [ run rtree_p2f_linear_rt.cpp ] - [ run rtree_b2f_linear_rt.cpp ] - [ run rtree_p2f_quadratic_rt.cpp ] - [ run rtree_b2f_quadratic_rt.cpp ] - [ run rtree_p2f_rstar_rt.cpp ] - [ run rtree_b2f_rstar_rt.cpp ] - [ run rtree_p2i_linear.cpp ] - [ run rtree_b2i_linear.cpp ] - [ run rtree_p2i_quadratic.cpp ] - [ run rtree_b2i_quadratic.cpp ] - [ run rtree_p2i_rstar.cpp ] - [ run rtree_b2i_rstar.cpp ] - [ run rtree_p2i_linear_rt.cpp ] - [ run rtree_b2i_linear_rt.cpp ] - [ run rtree_p2i_quadratic_rt.cpp ] - [ run rtree_b2i_quadratic_rt.cpp ] - [ run rtree_p2i_rstar_rt.cpp ] - [ run rtree_b2i_rstar_rt.cpp ] - [ run rtree_p2tt_linear.cpp ] - [ run rtree_b2tt_linear.cpp ] - [ run rtree_p2tt_quadratic.cpp ] - [ run rtree_b2tt_quadratic.cpp ] - [ run rtree_p2tt_rstar.cpp ] - [ run rtree_b2tt_rstar.cpp ] - [ run rtree_p2tt_linear_rt.cpp ] - [ run rtree_b2tt_linear_rt.cpp ] - [ run rtree_p2tt_quadratic_rt.cpp ] - [ run rtree_b2tt_quadratic_rt.cpp ] - [ run rtree_p2tt_rstar_rt.cpp ] - [ run rtree_b2tt_rstar_rt.cpp ] - [ run rtree_p3d_linear.cpp ] - [ run rtree_b3d_linear.cpp ] - [ run rtree_p3d_quadratic.cpp ] - [ run rtree_b3d_quadratic.cpp ] - [ run rtree_p3d_rstar.cpp ] - [ run rtree_b3d_rstar.cpp ] - [ run rtree_p3d_linear_rt.cpp ] - [ run rtree_b3d_linear_rt.cpp ] - [ run rtree_p3d_quadratic_rt.cpp ] - [ run rtree_b3d_quadratic_rt.cpp ] - [ run rtree_p3d_rstar_rt.cpp ] - [ run rtree_b3d_rstar_rt.cpp ] - [ run rtree_p3f_linear.cpp ] - [ run rtree_b3f_linear.cpp ] - [ run rtree_p3f_quadratic.cpp ] - [ run rtree_b3f_quadratic.cpp ] - [ run rtree_p3f_rstar.cpp ] - [ run rtree_b3f_rstar.cpp ] - [ run rtree_p3f_linear_rt.cpp ] - [ run rtree_b3f_linear_rt.cpp ] - [ run rtree_p3f_quadratic_rt.cpp ] - [ run rtree_b3f_quadratic_rt.cpp ] - [ run rtree_p3f_rstar_rt.cpp ] - [ run rtree_b3f_rstar_rt.cpp ] - [ run rtree_p3i_linear.cpp ] - [ run rtree_b3i_linear.cpp ] - [ run rtree_p3i_quadratic.cpp ] - [ run rtree_b3i_quadratic.cpp ] - [ run rtree_p3i_rstar.cpp ] - [ run rtree_b3i_rstar.cpp ] - [ run rtree_p3i_linear_rt.cpp ] - [ run rtree_b3i_linear_rt.cpp ] - [ run rtree_p3i_quadratic_rt.cpp ] - [ run rtree_b3i_quadratic_rt.cpp ] - [ run rtree_p3i_rstar_rt.cpp ] - [ run rtree_b3i_rstar_rt.cpp ] - [ run rtree_p3tt_linear.cpp ] - [ run rtree_b3tt_linear.cpp ] - [ run rtree_p3tt_quadratic.cpp ] - [ run rtree_b3tt_quadratic.cpp ] - [ run rtree_p3tt_rstar.cpp ] - [ run rtree_b3tt_rstar.cpp ] - [ run rtree_p3tt_linear_rt.cpp ] - [ run rtree_b3tt_linear_rt.cpp ] - [ run rtree_p3tt_quadratic_rt.cpp ] - [ run rtree_b3tt_quadratic_rt.cpp ] - [ run rtree_p3tt_rstar_rt.cpp ] - [ run rtree_b3tt_rstar_rt.cpp ] - ; +rule test_all +{ + local all_rules = ; + for local fileb in [ glob *.cpp ] + { + all_rules += [ run $(fileb) ] ; + } + + return $(all_rules) ; +} + +test-suite boost-geometry-index-rtree-generated : [ test_all r ] ; diff --git a/test/rtree/interprocess/Jamfile.v2 b/test/rtree/interprocess/Jamfile.v2 new file mode 100644 index 000000000..be709a43b --- /dev/null +++ b/test/rtree/interprocess/Jamfile.v2 @@ -0,0 +1,29 @@ +# Boost.Geometry Index +# +# 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) + +rule test_all +{ + local all_rules = ; + + for local fileb in [ glob *.cpp ] + { + all_rules += [ run $(fileb) /boost/thread//boost_thread + : # additional args + : # test-files + : # requirements + acc:-lrt + acc-pa_risc:-lrt + gcc-mingw:"-lole32 -loleaut32 -lpsapi -ladvapi32" + hpux,gcc:"-Wl,+as,mpas" + ] ; + } + + return $(all_rules) ; +} + +test-suite boost-geometry-index-rtree-interprocess : [ test_all r ] : multi ; diff --git a/test/rtree/interprocess/rtree_interprocess_b2f_linear.cpp b/test/rtree/interprocess/rtree_interprocess_b2f_linear.cpp new file mode 100644 index 000000000..72d22885c --- /dev/null +++ b/test/rtree/interprocess/rtree_interprocess_b2f_linear.cpp @@ -0,0 +1,19 @@ +// 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2f; + + test_rtree_interprocess(bgi::linear<32, 8>()); + + return 0; +} diff --git a/test/rtree/interprocess/rtree_interprocess_b2f_linear_rt.cpp b/test/rtree/interprocess/rtree_interprocess_b2f_linear_rt.cpp new file mode 100644 index 000000000..44c15b52d --- /dev/null +++ b/test/rtree/interprocess/rtree_interprocess_b2f_linear_rt.cpp @@ -0,0 +1,19 @@ +// 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2f; + + test_rtree_interprocess(bgi::runtime::linear(32, 8)); + + return 0; +} diff --git a/test/rtree/interprocess/rtree_interprocess_b2f_quadratic.cpp b/test/rtree/interprocess/rtree_interprocess_b2f_quadratic.cpp new file mode 100644 index 000000000..91a93a5e1 --- /dev/null +++ b/test/rtree/interprocess/rtree_interprocess_b2f_quadratic.cpp @@ -0,0 +1,19 @@ +// 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2f; + + test_rtree_interprocess(bgi::quadratic<32, 8>()); + + return 0; +} diff --git a/test/rtree/interprocess/rtree_interprocess_b2f_quadratic_rt.cpp b/test/rtree/interprocess/rtree_interprocess_b2f_quadratic_rt.cpp new file mode 100644 index 000000000..1bc58b2e7 --- /dev/null +++ b/test/rtree/interprocess/rtree_interprocess_b2f_quadratic_rt.cpp @@ -0,0 +1,19 @@ +// 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2f; + + test_rtree_interprocess(bgi::runtime::quadratic(32, 8)); + + return 0; +} diff --git a/test/rtree/interprocess/rtree_interprocess_b2f_rstar.cpp b/test/rtree/interprocess/rtree_interprocess_b2f_rstar.cpp new file mode 100644 index 000000000..a47d89903 --- /dev/null +++ b/test/rtree/interprocess/rtree_interprocess_b2f_rstar.cpp @@ -0,0 +1,19 @@ +// 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2f; + + test_rtree_interprocess(bgi::rstar<32, 8>()); + + return 0; +} diff --git a/test/rtree/interprocess/rtree_interprocess_b2f_rstar_rt.cpp b/test/rtree/interprocess/rtree_interprocess_b2f_rstar_rt.cpp new file mode 100644 index 000000000..4a4504f15 --- /dev/null +++ b/test/rtree/interprocess/rtree_interprocess_b2f_rstar_rt.cpp @@ -0,0 +1,19 @@ +// 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2f; + + test_rtree_interprocess(bgi::runtime::rstar(32, 8)); + + return 0; +} diff --git a/test/rtree/rtree_interprocess.cpp b/test/rtree/interprocess/test_interprocess.hpp similarity index 81% rename from test/rtree/rtree_interprocess.cpp rename to test/rtree/interprocess/test_interprocess.hpp index 82f524488..b0694aceb 100644 --- a/test/rtree/rtree_interprocess.cpp +++ b/test/rtree/interprocess/test_interprocess.hpp @@ -57,17 +57,3 @@ void test_rtree_interprocess(Parameters const& parameters = Parameters()) //segment.destroy_ptr(tree); } - -int test_main(int, char* []) -{ - typedef bg::model::point P2f; - - test_rtree_interprocess(bgi::linear<32, 8>()); - test_rtree_interprocess(bgi::runtime::linear(32, 8)); - test_rtree_interprocess(bgi::quadratic<32, 8>()); - test_rtree_interprocess(bgi::runtime::quadratic(32, 8)); - test_rtree_interprocess(bgi::rstar<32, 8>()); - test_rtree_interprocess(bgi::runtime::rstar(32, 8)); - - return 0; -} diff --git a/tests/rtree_test_generator.cpp b/test/rtree/rtree_test_generator.cpp similarity index 100% rename from tests/rtree_test_generator.cpp rename to test/rtree/rtree_test_generator.cpp diff --git a/tests/additional_sizes_and_times.cpp b/tests/additional_sizes_and_times.cpp deleted file mode 100644 index 8e2185746..000000000 --- a/tests/additional_sizes_and_times.cpp +++ /dev/null @@ -1,485 +0,0 @@ -// Boost.Geometry Index -// Additional tests - -// 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 - -#define BOOST_GEOMETRY_INDEX_ENABLE_DEBUG_INTERFACE -#include -#include - -#include -#include - -#include -#include -#include - -template -struct test_pred -{ - bool operator()(V const& v) const - { - return v.second % 2 != 0; - } -}; - -int main() -{ - boost::timer tim; - - namespace bg = boost::geometry; - namespace bgi = bg::index; - - //typedef bg::model::d2::point_xy P; - typedef bg::model::point P; - typedef bg::model::box

B; - typedef bgi::rtree< - std::pair, - bgi::linear<32, 8>, - bgi::translator::def< std::pair >/*, - boost::fast_pool_allocator< std::pair >*/ - > RT; - //typedef bgi::rtree, bgi::quadratic<32, 8> > RT; - //typedef bgi::rtree, bgi::rstar<32, 8> > RT; - /*typedef bgi::rtree< - std::pair, - bgi::options::rtree, bgi::reinsert_tag, bgi::choose_by_area_diff_tag, bgi::rstar_tag, bgi::default_tag> - > RT;*/ - - // load config file - std::ifstream file_cfg("config.txt"); - size_t values_count = 0; - size_t remove_count = 0; - size_t queries_count = 0; - std::string file_name(""); - file_cfg >> values_count; - file_cfg >> remove_count; - file_cfg >> queries_count; - file_cfg >> file_name; - std::cout << "v: " << values_count << ", r: " << remove_count << ", q: " << queries_count << "\n"; - - if ( values_count < remove_count ) - { - std::cout << "can't remove more data than was inserted\n"; - return 0; - } - - // prepare data buffer - std::vector< std::pair > coords; - coords.reserve(values_count); - - // load test coordinates - if ( file_name != "" ) - { - std::ifstream file(file_name.c_str()); - if ( !file.is_open() ) - { - std::cout << "can't open file containing coordinates\n"; - return 0; - } - - std::cout << "loading data\n"; - for ( size_t i = 0 ; i < values_count ; ++i ) - { - std::pair v; - file >> v.first; - file >> v.second; - coords.push_back(v); - } - std::cout << "loaded\n"; - - if ( coords.size() != values_count || coords.size() < remove_count ) - { - std::cout << "not enough coordinates loaded\n"; - return 0; - } - } - // randomize - else - { - boost::mt19937 rng; - //rng.seed(static_cast(std::time(0))); - float max_val = static_cast(values_count / 2); - boost::uniform_real range(-max_val, max_val); - boost::variate_generator > rnd(rng, range); - - //::srand( ::time(NULL) ); - //float factor = values_count / float(RAND_MAX); - //float comp = values_count / 2; - - std::cout << "randomizing data\n"; - for ( size_t i = 0 ; i < values_count ; ++i ) - { - coords.push_back(std::make_pair(rnd(), rnd())); - //float x = rand() * factor + comp; - //float y = rand() * factor + comp; - //coords.push_back( std::make_pair( x, y )); - } - std::cout << "randomized\n"; - } - - // create rtree - RT t; - - // elements inserting test - { - std::cout << "rtree inserting time test... (" - << values_count << ")\n"; - tim.restart(); - for (size_t i = 0 ; i < values_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - B b(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f)); - - t.insert(std::make_pair(b, i)); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - } - - // elements inserting test using insert_iterator - { - RT t; - - std::cout << "rtree inserting time test using insert_iterator<>... (" - << values_count << ")\n"; - bgi::insert_iterator ii = bgi::inserter(t); - tim.restart(); - for (size_t i = 0 ; i < values_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - B b(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f)); - - *ii++ = std::make_pair(b, i); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - } - - std::vector< std::pair > v; - - // elements inserting test - { - std::cout << "vector inserting time test... (" - << values_count << ")\n"; - tim.restart(); - for (size_t i = 0 ; i < values_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - B b(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f)); - - v.push_back(std::make_pair(b, i)); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - } - - // check - if ( bgi::detail::rtree::are_boxes_ok(t) ) - std::cout << "BOXES OK\n"; - else - std::cout << "WRONG BOXES\n"; - if ( bgi::detail::rtree::are_levels_ok(t) ) - std::cout << "LEVELS OK\n"; - else - std::cout << "WRONG LEVELS\n"; - - // searching test - { - std::cout << "query(intersects(B)) searching time test... (" - << queries_count << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - std::deque< std::pair > result; - t.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result)); - temp += result.size(); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - - // copying test - { - std::cout << "rtree copying time test... (" - << values_count << ")\n"; - tim.restart(); - RT t_copy(t); - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "new size: " << t_copy.size() << '\n'; - - // t_copy searching test - { - std::cout << "tree copy query(intersects(B)) searching time test... (" - << queries_count << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - std::deque< std::pair > result; - t_copy.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result)); - temp += result.size(); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - } - - // searching test - { - std::cout << "query(!disjoint(B)) searching time test... (" - << queries_count << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - std::deque< std::pair > result; - t.query(!bgi::disjoint(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result)); - temp += result.size(); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - - // searching test - { - std::cout << "query(B) searching time test... (" - << queries_count << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - std::deque< std::pair > result; - t.query(B(P(x - 10, y - 10), P(x + 10, y + 10)), std::back_inserter(result)); - temp += result.size(); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - - // searching test - { - std::cout << "pair: query(B) and value(odd index) searching time test... (" - << queries_count << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - std::deque< std::pair > result; - t.query( - B(P(x - 10, y - 10), P(x + 10, y + 10)) && bgi::value(test_pred< std::pair >()) - , std::back_inserter(result)); - temp += result.size(); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - - // searching test - { - std::cout << "tuple: query(B) and value(odd index) searching time test... (" - << queries_count << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - std::deque< std::pair > result; - t.query( - B(P(x - 10, y - 10), P(x + 10, y + 10)) && bgi::value(test_pred< std::pair >()) - , std::back_inserter(result)); - temp += result.size(); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - - // searching test - { - std::cout << "vector searching time test... (" - << queries_count / 1000 << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count / 1000 ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - std::deque< std::pair > result; - for ( std::vector< std::pair >::const_iterator it = v.begin(); - it != v.end() ; - ++it ) - { - if ( bg::intersects( - it->first, - B(P(x - 10, y - 10), P(x + 10, y + 10)) - ) - ) - result.push_back(*it); - } - temp += result.size(); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - - // searching test - { - std::cout << "nearest 5 searching time test... (" - << queries_count / 10 << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count / 10 ; ++i ) - { - float x = coords[i].first + 100; - float y = coords[i].second + 100; - std::vector< std::pair > result; - temp += t.query(bgi::nearest(P(x, y), 5), std::back_inserter(result)); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - - // searching test - { - std::cout << "vector nearest searching time test... (" - << queries_count / 1000 << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count / 1000 ; ++i ) - { - typedef bg::default_distance_result::type distance_type; - - float x = coords[i].first + 100; - float y = coords[i].second + 100; - std::pair result; - distance_type dist = (std::numeric_limits::max)(); - - for ( std::vector< std::pair >::const_iterator it = v.begin(); - it != v.end(); - ++it ) - { - distance_type cd = bgi::detail::comparable_distance_near(P(x, y), it->first); - - if ( cd < dist ) - { - result = *it; - dist = cd; - } - } - temp += dist < (std::numeric_limits::max)() ? 1 : 0; - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - - // elements removing test - { - std::cout << "removing time test... (" - << remove_count << ")\n"; - tim.restart(); - for (size_t i = 0 ; i < remove_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - B b(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f)); - - t.remove(std::make_pair(b, i)); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - } - - // check - if ( bgi::detail::rtree::are_boxes_ok(t) ) - std::cout << "BOXES OK\n"; - else - std::cout << "WRONG BOXES\n"; - if ( bgi::detail::rtree::are_levels_ok(t) ) - std::cout << "LEVELS OK\n"; - else - std::cout << "WRONG LEVELS\n"; - - // searching test - { - std::cout << "searching time test... (" - << queries_count << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - std::deque< std::pair > result; - t.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result)); - temp += result.size(); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - - // inserting test - { - std::cout << "inserting time test... (" - << remove_count << ")\n"; - tim.restart(); - for (size_t i = 0 ; i < remove_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - B b(P(x - 0.5f, y - 0.5f), P(x + 0.5f, y + 0.5f)); - - t.insert(std::make_pair(b, i)); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - } - - // check - if ( bgi::detail::rtree::are_boxes_ok(t) ) - std::cout << "BOXES OK\n"; - else - std::cout << "WRONG BOXES\n"; - if ( bgi::detail::rtree::are_levels_ok(t) ) - std::cout << "LEVELS OK\n"; - else - std::cout << "WRONG LEVELS\n"; - - // searching test - { - std::cout << "searching time test... (" - << queries_count << ")\n"; - tim.restart(); - size_t temp = 0; - for (size_t i = 0 ; i < queries_count ; ++i ) - { - float x = coords[i].first; - float y = coords[i].second; - std::deque< std::pair > result; - t.query(bgi::intersects(B(P(x - 10, y - 10), P(x + 10, y + 10))), std::back_inserter(result)); - temp += result.size(); - } - std::cout << "time: " << tim.elapsed() << "s\n"; - std::cout << "found: " << temp << "\n"; - } - - std::cin.get(); - - return 0; -}