diff --git a/doc/html/geometry_index/r_tree/introduction.html b/doc/html/geometry_index/r_tree/introduction.html index 41dd3a17f..c326a0c36 100644 --- a/doc/html/geometry_index/r_tree/introduction.html +++ b/doc/html/geometry_index/r_tree/introduction.html @@ -31,7 +31,7 @@ by Antonin Guttman in 1984 [1] as an expansion of B-tree for multi-dimensional data. It may be used to store points or volumetric data in order to perform a spatial query later. This query may return objects that are inside some area or are - close to some point in space. + close to some point in space [2].

The R-tree structure is presented on the image below. Each R-tree's node @@ -51,7 +51,7 @@

The R-tree is a self-balanced data structure. The key part of balancing algorithm - is node splitting algorithm [2] [3]. Each algorithm produces different splits so the internal structure + is node splitting algorithm [3] [4]. Each algorithm produces different splits so the internal structure of a tree may be different for each one of them. In general more complex algorithms analyses elements better and produces less overlapping nodes. In the searching process less nodes must be traversed in order to find desired @@ -192,8 +192,9 @@ capable to store arbitrary Value type,

  • - sophisticated queries - e.g. search for 5 nearest values intersecting - some region but not within the other one. + advanced queries - e.g. search for 5 nearest values further than some + minimal distance and intersecting some region but not within the other + one.
  • @@ -203,10 +204,14 @@ Searching

    [2] + Cheung, K.; Fu, A. (1998). Enhanced Nearest Neighbour Search + on the R-tree +

    +

    [3] Greene, D. (1989). An implementation and performance analysis of spatial data access methods

    -

    [3] +

    [4] Beckmann, N.; Kriegel, H. P.; Schneider, R.; Seeger, B. (1990). The R*-tree: an efficient and robust access method for points and rectangles

    diff --git a/doc/html/index.html b/doc/html/index.html index ea9ad1961..8ff4a0cf7 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -56,7 +56,7 @@
    - +

    Last revised: November 26, 2012 at 22:11:47 GMT

    Last revised: November 27, 2012 at 12:09:04 GMT


    diff --git a/doc/rtree/introduction.qbk b/doc/rtree/introduction.qbk index 25f6f7ea0..18f613ac9 100644 --- a/doc/rtree/introduction.qbk +++ b/doc/rtree/introduction.qbk @@ -13,7 +13,8 @@ __rtree__ is a tree data structure used for spatial searching. It was proposed by Antonin Guttman in 1984 [footnote Guttman, A. (1984). /R-Trees: A Dynamic Index Structure for Spatial Searching/] as an expansion of B-tree for multi-dimensional data. It may be used to store points or volumetric data in order to -perform a spatial query later. This query may return objects that are inside some area or are close to some point in space. +perform a spatial query later. This query may return objects that are inside some area or are close to some point in space +[footnote Cheung, K.; Fu, A. (1998). /Enhanced Nearest Neighbour Search on the R-tree/]. The __rtree__ structure is presented on the image below. Each __rtree__'s node store a box descring the space occupied by its children nodes. At the bottom of the structure, there are leaf-nodes which contains values @@ -46,7 +47,7 @@ Key features of this implementation of the __rtree__ are: * three different creation algorithms - linear, quadratic or rstar, * parameters (including maximal and minimal number of elements) may be passed as compile- or run-time parameters - compile-time version is faster, * capable to store arbitrary __value__ type, -* sophisticated queries - e.g. search for 5 nearest values intersecting some region but not within the other one. +* advanced queries - e.g. search for 5 nearest values further than some minimal distance and intersecting some region but not within the other one. [endsect] diff --git a/include/boost/geometry/extensions/index/inserter.hpp b/include/boost/geometry/extensions/index/inserter.hpp index 186d62f9a..ef1e949cc 100644 --- a/include/boost/geometry/extensions/index/inserter.hpp +++ b/include/boost/geometry/extensions/index/inserter.hpp @@ -23,12 +23,12 @@ public: typedef Container container_type; inline explicit insert_iterator(Container & c) - : container(c) + : container(&c) {} insert_iterator & operator=(typename Container::value_type const& value) { - container.insert(value); + container->insert(value); return *this; } @@ -48,7 +48,7 @@ public: } private: - Container & container; + Container * container; }; template diff --git a/include/boost/geometry/extensions/index/rtree/rtree.hpp b/include/boost/geometry/extensions/index/rtree/rtree.hpp index dc2946fcc..4e7db8132 100644 --- a/include/boost/geometry/extensions/index/rtree/rtree.hpp +++ b/include/boost/geometry/extensions/index/rtree/rtree.hpp @@ -146,7 +146,7 @@ public: } catch(...) { - this->raw_destroy(*this, true); + this->raw_destroy(*this); throw; } } @@ -176,7 +176,7 @@ public: } catch(...) { - this->raw_destroy(*this, true); + this->raw_destroy(*this); throw; } } @@ -188,7 +188,7 @@ public: */ inline ~rtree() { - this->raw_destroy(*this, true); + this->raw_destroy(*this); } /*! @@ -586,7 +586,7 @@ public: */ inline void clear() { - this->raw_destroy(*this, false); + this->raw_destroy(*this); } /*! @@ -775,19 +775,12 @@ private: \param t The container which is going to be destroyed. */ - inline void raw_destroy(rtree & t, bool destroy_root = true) + inline void raw_destroy(rtree & t) { if ( t.m_root ) { - if ( destroy_root ) - { - detail::rtree::visitors::destroy del_v(t.m_root, t.m_allocators); - detail::rtree::apply_visitor(del_v, *t.m_root); - } - else - { - detail::rtree::clear_node::apply(*t.m_root, t.m_allocators); - } + detail::rtree::visitors::destroy del_v(t.m_root, t.m_allocators); + detail::rtree::apply_visitor(del_v, *t.m_root); t.m_root = 0; } diff --git a/test/rtree/Jamfile.v2 b/test/rtree/Jamfile.v2 index b2b98d998..b4f756d70 100644 --- a/test/rtree/Jamfile.v2 +++ b/test/rtree/Jamfile.v2 @@ -12,11 +12,19 @@ test-suite boost-geometry-index-rtree [ run rtree2d_linear_f.cpp ] [ run rtree2d_linear_d.cpp ] [ run rtree2d_linear_tt.cpp ] + [ run rtree2d_linear_i_rt.cpp ] + [ run rtree2d_linear_f_rt.cpp ] + [ run rtree2d_linear_d_rt.cpp ] + [ run rtree2d_linear_tt_rt.cpp ] [ run rtree2d_quadratic_i.cpp ] [ run rtree2d_quadratic_f.cpp ] [ run rtree2d_quadratic_d.cpp ] [ run rtree2d_quadratic_tt.cpp ] + [ run rtree2d_quadratic_i_rt.cpp ] + [ run rtree2d_quadratic_f_rt.cpp ] + [ run rtree2d_quadratic_d_rt.cpp ] + [ run rtree2d_quadratic_tt_rt.cpp ] [ run rtree2d_rstar_i.cpp ] [ run rtree2d_rstar_f.cpp ] @@ -31,11 +39,19 @@ test-suite boost-geometry-index-rtree [ run rtree3d_linear_f.cpp ] [ run rtree3d_linear_d.cpp ] [ run rtree3d_linear_tt.cpp ] + [ run rtree3d_linear_i_rt.cpp ] + [ run rtree3d_linear_f_rt.cpp ] + [ run rtree3d_linear_d_rt.cpp ] + [ run rtree3d_linear_tt_rt.cpp ] [ run rtree3d_quadratic_i.cpp ] [ run rtree3d_quadratic_f.cpp ] [ run rtree3d_quadratic_d.cpp ] [ run rtree3d_quadratic_tt.cpp ] + [ run rtree3d_quadratic_i_rt.cpp ] + [ run rtree3d_quadratic_f_rt.cpp ] + [ run rtree3d_quadratic_d_rt.cpp ] + [ run rtree3d_quadratic_tt_rt.cpp ] [ run rtree3d_rstar_i.cpp ] [ run rtree3d_rstar_f.cpp ] diff --git a/test/rtree/rtree2d_linear_d.cpp b/test/rtree/rtree2d_linear_d.cpp index a3e3fb47a..c73a356bc 100644 --- a/test/rtree/rtree2d_linear_d.cpp +++ b/test/rtree/rtree2d_linear_d.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P2dc; test_rtree >(); - test_rtree(bgi::runtime::linear(4, 2)); return 0; } diff --git a/test/rtree/rtree2d_linear_d_rt.cpp b/test/rtree/rtree2d_linear_d_rt.cpp new file mode 100644 index 000000000..09d7c449c --- /dev/null +++ b/test/rtree/rtree2d_linear_d_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2dc; + + test_rtree(bgi::runtime::linear(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree2d_linear_f.cpp b/test/rtree/rtree2d_linear_f.cpp index a1ce1268e..8ea8d04ff 100644 --- a/test/rtree/rtree2d_linear_f.cpp +++ b/test/rtree/rtree2d_linear_f.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P2fc; test_rtree >(); - test_rtree(bgi::runtime::linear(4, 2)); return 0; } diff --git a/test/rtree/rtree2d_linear_f_rt.cpp b/test/rtree/rtree2d_linear_f_rt.cpp new file mode 100644 index 000000000..dbb7723dc --- /dev/null +++ b/test/rtree/rtree2d_linear_f_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2fc; + + test_rtree(bgi::runtime::linear(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree2d_linear_i.cpp b/test/rtree/rtree2d_linear_i.cpp index 3fd9a5c30..f1ea68bd0 100644 --- a/test/rtree/rtree2d_linear_i.cpp +++ b/test/rtree/rtree2d_linear_i.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P2ic; test_rtree >(); - test_rtree(bgi::runtime::linear(4, 2)); return 0; } diff --git a/test/rtree/rtree2d_linear_i_rt.cpp b/test/rtree/rtree2d_linear_i_rt.cpp new file mode 100644 index 000000000..6ae2ffa34 --- /dev/null +++ b/test/rtree/rtree2d_linear_i_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2ic; + + test_rtree(bgi::runtime::linear(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree2d_linear_tt.cpp b/test/rtree/rtree2d_linear_tt.cpp index 0e0478a25..1d5de3635 100644 --- a/test/rtree/rtree2d_linear_tt.cpp +++ b/test/rtree/rtree2d_linear_tt.cpp @@ -20,7 +20,6 @@ int test_main(int, char* []) typedef bg::model::point P2ttmc; test_rtree >(); - test_rtree(bgi::runtime::linear(4, 2)); #endif diff --git a/test/rtree/rtree2d_linear_tt_rt.cpp b/test/rtree/rtree2d_linear_tt_rt.cpp new file mode 100644 index 000000000..7f832830f --- /dev/null +++ b/test/rtree/rtree2d_linear_tt_rt.cpp @@ -0,0 +1,27 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + +#ifdef HAVE_TTMATH + typedef bg::model::point P2ttmc; + + test_rtree(bgi::runtime::linear(4, 2)); + +#endif + + return 0; +} diff --git a/test/rtree/rtree2d_quadratic_d.cpp b/test/rtree/rtree2d_quadratic_d.cpp index 775f36846..0da13f9b3 100644 --- a/test/rtree/rtree2d_quadratic_d.cpp +++ b/test/rtree/rtree2d_quadratic_d.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P2dc; test_rtree >(); - test_rtree(bgi::runtime::quadratic(4, 2)); return 0; } diff --git a/test/rtree/rtree2d_quadratic_d_rt.cpp b/test/rtree/rtree2d_quadratic_d_rt.cpp new file mode 100644 index 000000000..2323ef2d0 --- /dev/null +++ b/test/rtree/rtree2d_quadratic_d_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2dc; + + test_rtree(bgi::runtime::quadratic(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree2d_quadratic_f.cpp b/test/rtree/rtree2d_quadratic_f.cpp index 3e9b2e1df..b7cd17f6c 100644 --- a/test/rtree/rtree2d_quadratic_f.cpp +++ b/test/rtree/rtree2d_quadratic_f.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P2fc; test_rtree >(); - test_rtree(bgi::runtime::quadratic(4, 2)); return 0; } diff --git a/test/rtree/rtree2d_quadratic_f_rt.cpp b/test/rtree/rtree2d_quadratic_f_rt.cpp new file mode 100644 index 000000000..2094a94a5 --- /dev/null +++ b/test/rtree/rtree2d_quadratic_f_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2fc; + + test_rtree(bgi::runtime::quadratic(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree2d_quadratic_i.cpp b/test/rtree/rtree2d_quadratic_i.cpp index 859d71a70..c3a5d9180 100644 --- a/test/rtree/rtree2d_quadratic_i.cpp +++ b/test/rtree/rtree2d_quadratic_i.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P2ic; test_rtree >(); - test_rtree(bgi::runtime::quadratic(4, 2)); return 0; } diff --git a/test/rtree/rtree2d_quadratic_i_rt.cpp b/test/rtree/rtree2d_quadratic_i_rt.cpp new file mode 100644 index 000000000..3ba08f4e1 --- /dev/null +++ b/test/rtree/rtree2d_quadratic_i_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P2ic; + + test_rtree(bgi::runtime::quadratic(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree2d_quadratic_tt.cpp b/test/rtree/rtree2d_quadratic_tt.cpp index b00faddc1..1ff26daa5 100644 --- a/test/rtree/rtree2d_quadratic_tt.cpp +++ b/test/rtree/rtree2d_quadratic_tt.cpp @@ -20,7 +20,6 @@ int test_main(int, char* []) typedef bg::model::point P2ttmc; test_rtree >(); - test_rtree(bgi::runtime::quadratic(4, 2)); #endif return 0; diff --git a/test/rtree/rtree2d_quadratic_tt_rt.cpp b/test/rtree/rtree2d_quadratic_tt_rt.cpp new file mode 100644 index 000000000..e7a61fe69 --- /dev/null +++ b/test/rtree/rtree2d_quadratic_tt_rt.cpp @@ -0,0 +1,26 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + +#ifdef HAVE_TTMATH + typedef bg::model::point P2ttmc; + + test_rtree(bgi::runtime::quadratic(4, 2)); +#endif + + return 0; +} diff --git a/test/rtree/rtree3d_linear_d.cpp b/test/rtree/rtree3d_linear_d.cpp index 3c28142e4..0f9fa35e6 100644 --- a/test/rtree/rtree3d_linear_d.cpp +++ b/test/rtree/rtree3d_linear_d.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P3dc; test_rtree >(); - test_rtree(bgi::runtime::linear(4, 2)); return 0; } diff --git a/test/rtree/rtree3d_linear_d_rt.cpp b/test/rtree/rtree3d_linear_d_rt.cpp new file mode 100644 index 000000000..609a36b70 --- /dev/null +++ b/test/rtree/rtree3d_linear_d_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P3dc; + + test_rtree(bgi::runtime::linear(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree3d_linear_f.cpp b/test/rtree/rtree3d_linear_f.cpp index 569b72938..12d54f332 100644 --- a/test/rtree/rtree3d_linear_f.cpp +++ b/test/rtree/rtree3d_linear_f.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P3fc; test_rtree >(); - test_rtree(bgi::runtime::linear(4, 2)); return 0; } diff --git a/test/rtree/rtree3d_linear_f_rt.cpp b/test/rtree/rtree3d_linear_f_rt.cpp new file mode 100644 index 000000000..0f0627197 --- /dev/null +++ b/test/rtree/rtree3d_linear_f_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P3fc; + + test_rtree(bgi::runtime::linear(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree3d_linear_i.cpp b/test/rtree/rtree3d_linear_i.cpp index 3b5771171..f715ed202 100644 --- a/test/rtree/rtree3d_linear_i.cpp +++ b/test/rtree/rtree3d_linear_i.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P3ic; test_rtree >(); - test_rtree(bgi::runtime::linear(4, 2)); return 0; } diff --git a/test/rtree/rtree3d_linear_i_rt.cpp b/test/rtree/rtree3d_linear_i_rt.cpp new file mode 100644 index 000000000..c97bb1ed8 --- /dev/null +++ b/test/rtree/rtree3d_linear_i_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P3ic; + + test_rtree(bgi::runtime::linear(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree3d_linear_tt.cpp b/test/rtree/rtree3d_linear_tt.cpp index ed750c2c1..12ddbd444 100644 --- a/test/rtree/rtree3d_linear_tt.cpp +++ b/test/rtree/rtree3d_linear_tt.cpp @@ -20,7 +20,6 @@ int test_main(int, char* []) typedef bg::model::point P3ttmc; test_rtree >(); - test_rtree(bgi::runtime::linear(4, 2)); #endif return 0; diff --git a/test/rtree/rtree3d_linear_tt_rt.cpp b/test/rtree/rtree3d_linear_tt_rt.cpp new file mode 100644 index 000000000..b478beb66 --- /dev/null +++ b/test/rtree/rtree3d_linear_tt_rt.cpp @@ -0,0 +1,26 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + +#ifdef HAVE_TTMATH + typedef bg::model::point P3ttmc; + + test_rtree(bgi::runtime::linear(4, 2)); +#endif + + return 0; +} diff --git a/test/rtree/rtree3d_quadratic_d.cpp b/test/rtree/rtree3d_quadratic_d.cpp index 733422555..721290dbe 100644 --- a/test/rtree/rtree3d_quadratic_d.cpp +++ b/test/rtree/rtree3d_quadratic_d.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P3dc; test_rtree >(); - test_rtree(bgi::runtime::quadratic(4, 2)); return 0; } diff --git a/test/rtree/rtree3d_quadratic_d_rt.cpp b/test/rtree/rtree3d_quadratic_d_rt.cpp new file mode 100644 index 000000000..e0ef632a9 --- /dev/null +++ b/test/rtree/rtree3d_quadratic_d_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P3dc; + + test_rtree(bgi::runtime::quadratic(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree3d_quadratic_f.cpp b/test/rtree/rtree3d_quadratic_f.cpp index 54a2fcbd1..9236da6fd 100644 --- a/test/rtree/rtree3d_quadratic_f.cpp +++ b/test/rtree/rtree3d_quadratic_f.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P3fc; test_rtree >(); - test_rtree(bgi::runtime::quadratic(4, 2)); return 0; } diff --git a/test/rtree/rtree3d_quadratic_f_rt.cpp b/test/rtree/rtree3d_quadratic_f_rt.cpp new file mode 100644 index 000000000..b3c161b6d --- /dev/null +++ b/test/rtree/rtree3d_quadratic_f_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P3fc; + + test_rtree(bgi::runtime::quadratic(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree3d_quadratic_i.cpp b/test/rtree/rtree3d_quadratic_i.cpp index b1e23bf9a..192be28ae 100644 --- a/test/rtree/rtree3d_quadratic_i.cpp +++ b/test/rtree/rtree3d_quadratic_i.cpp @@ -18,7 +18,6 @@ int test_main(int, char* []) typedef bg::model::point P3ic; test_rtree >(); - test_rtree(bgi::runtime::quadratic(4, 2)); return 0; } diff --git a/test/rtree/rtree3d_quadratic_i_rt.cpp b/test/rtree/rtree3d_quadratic_i_rt.cpp new file mode 100644 index 000000000..eaa400ec8 --- /dev/null +++ b/test/rtree/rtree3d_quadratic_i_rt.cpp @@ -0,0 +1,23 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + typedef bg::model::point P3ic; + + test_rtree(bgi::runtime::quadratic(4, 2)); + + return 0; +} diff --git a/test/rtree/rtree3d_quadratic_tt.cpp b/test/rtree/rtree3d_quadratic_tt.cpp index de52abd8a..9ed655257 100644 --- a/test/rtree/rtree3d_quadratic_tt.cpp +++ b/test/rtree/rtree3d_quadratic_tt.cpp @@ -20,7 +20,6 @@ int test_main(int, char* []) typedef bg::model::point P3ttmc; test_rtree >(); - test_rtree(bgi::runtime::quadratic(4, 2)); #endif return 0; diff --git a/test/rtree/rtree3d_quadratic_tt_rt.cpp b/test/rtree/rtree3d_quadratic_tt_rt.cpp new file mode 100644 index 000000000..3c2368ac4 --- /dev/null +++ b/test/rtree/rtree3d_quadratic_tt_rt.cpp @@ -0,0 +1,26 @@ +// Boost.Geometry Index +// Unit Test + +// Copyright (c) 2011-2012 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 + +int test_main(int, char* []) +{ + +#ifdef HAVE_TTMATH + typedef bg::model::point P3ttmc; + + test_rtree(bgi::runtime::quadratic(4, 2)); +#endif + + return 0; +} diff --git a/test/rtree/test_rtree.hpp b/test/rtree/test_rtree.hpp index 4bd8d77a5..90ee4acaf 100644 --- a/test/rtree/test_rtree.hpp +++ b/test/rtree/test_rtree.hpp @@ -187,6 +187,62 @@ struct generate_value< boost::tuple >, } }; +// shared_ptr value + +template +struct test_object +{ + test_object(Indexable const& indexable_) : indexable(indexable_) {} + Indexable indexable; +}; + +namespace boost { namespace geometry { namespace index { namespace translator { + +template +struct def< boost::shared_ptr< test_object > > +{ + typedef boost::shared_ptr< test_object > value_type; + typedef Indexable const& result_type; + + result_type operator()(value_type const& value) const + { + return value->indexable; + } + + bool equals(value_type const& v1, value_type const& v2) const + { + return v1 == v2; + } +}; + +}}}} + +template +struct generate_value< boost::shared_ptr > > > +{ + typedef bg::model::point P; + typedef test_object

    O; + + static boost::shared_ptr apply(int x, int y) + { + return boost::shared_ptr(new O(P(x, y))); + } +}; + +template +struct generate_value< boost::shared_ptr > > > +{ + typedef bg::model::point P; + typedef test_object

    O; + + static boost::shared_ptr apply(int x, int y, int z) + { + return boost::shared_ptr(new O(P(x, y, z))); + } +}; + +// generate input + template struct generate_input {}; @@ -745,7 +801,7 @@ void test_create_insert(bgi::rtree & tree, std::vector const // rtree removing template -void test_remove(bgi::rtree & tree, Box const& qbox) +void test_remove_clear(bgi::rtree & tree, std::vector const& input, Box const& qbox) { typedef bgi::rtree T; @@ -807,6 +863,21 @@ void test_remove(bgi::rtree & tree, Box const& qbox) BOOST_CHECK( output.size() == tree.size() - values_to_remove.size() ); test_compare_outputs(t, output, expected_output); } + + //clear + { + std::vector expected_output; + tree.spatial_query(bgi::intersects(qbox), std::back_inserter(expected_output)); + size_t s = tree.size(); + tree.clear(); + BOOST_CHECK(tree.empty()); + BOOST_CHECK(tree.size() == 0); + tree.insert(input); + BOOST_CHECK(tree.size() == s); + std::vector output; + tree.spatial_query(bgi::intersects(qbox), std::back_inserter(output)); + test_exactly_the_same_outputs(tree, output, expected_output); + } } // run all tests for a single Algorithm and single rtree @@ -844,7 +915,7 @@ void test_rtree_by_value(Parameters const& parameters) test_copy_assignment_swap_move(tree, qbox); test_create_insert(tree, input, qbox); - test_remove(tree, qbox); + test_remove_clear(tree, input, qbox); // empty tree test @@ -874,6 +945,7 @@ void test_rtree(Parameters const& parameters = Parameters()) typedef std::pair PairP; typedef boost::tuple TupleP; typedef boost::tuple TupleB; + typedef boost::shared_ptr< test_object > SharedPtrP; test_rtree_by_value(parameters); test_rtree_by_value(parameters); @@ -881,6 +953,7 @@ void test_rtree(Parameters const& parameters = Parameters()) test_rtree_by_value(parameters); test_rtree_by_value(parameters); test_rtree_by_value(parameters); + test_rtree_by_value(parameters); } #endif