Merged from index_dev

Fixed rtree::clear() mem leak.
Added test for clear() and boost::shared_ptr as Values.
Each linear algo test file divided into 2 files.
Added reference in docs->rtree introduction.

[SVN r81778]
This commit is contained in:
Adam Wulkiewicz
2012-12-07 22:52:53 +00:00
parent 640ae6ced6
commit f4f0094c3a
39 changed files with 496 additions and 43 deletions

View File

@@ -31,7 +31,7 @@
by Antonin Guttman in 1984 <a href="#ftn.geometry_index.r_tree.introduction.f0" class="footnote"><sup class="footnote"><a name="geometry_index.r_tree.introduction.f0"></a>[1]</sup></a> 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 <a href="#ftn.geometry_index.r_tree.introduction.f1" class="footnote"><sup class="footnote"><a name="geometry_index.r_tree.introduction.f1"></a>[2]</sup></a>.
</p>
<p>
The R-tree structure is presented on the image below. Each R-tree's node
@@ -51,7 +51,7 @@
</p>
<p>
The R-tree is a self-balanced data structure. The key part of balancing algorithm
is node splitting algorithm <a href="#ftn.geometry_index.r_tree.introduction.f1" class="footnote"><sup class="footnote"><a name="geometry_index.r_tree.introduction.f1"></a>[2]</sup></a> <a href="#ftn.geometry_index.r_tree.introduction.f2" class="footnote"><sup class="footnote"><a name="geometry_index.r_tree.introduction.f2"></a>[3]</sup></a>. Each algorithm produces different splits so the internal structure
is node splitting algorithm <a href="#ftn.geometry_index.r_tree.introduction.f2" class="footnote"><sup class="footnote"><a name="geometry_index.r_tree.introduction.f2"></a>[3]</sup></a> <a href="#ftn.geometry_index.r_tree.introduction.f3" class="footnote"><sup class="footnote"><a name="geometry_index.r_tree.introduction.f3"></a>[4]</sup></a>. 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,
</li>
<li class="listitem">
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.
</li>
</ul></div>
<div class="footnotes">
@@ -203,10 +204,14 @@
Searching</em></span>
</p></div>
<div id="ftn.geometry_index.r_tree.introduction.f1" class="footnote"><p><a href="#geometry_index.r_tree.introduction.f1" class="para"><sup class="para">[2] </sup></a>
Cheung, K.; Fu, A. (1998). <span class="emphasis"><em>Enhanced Nearest Neighbour Search
on the R-tree</em></span>
</p></div>
<div id="ftn.geometry_index.r_tree.introduction.f2" class="footnote"><p><a href="#geometry_index.r_tree.introduction.f2" class="para"><sup class="para">[3] </sup></a>
Greene, D. (1989). <span class="emphasis"><em>An implementation and performance analysis
of spatial data access methods</em></span>
</p></div>
<div id="ftn.geometry_index.r_tree.introduction.f2" class="footnote"><p><a href="#geometry_index.r_tree.introduction.f2" class="para"><sup class="para">[3] </sup></a>
<div id="ftn.geometry_index.r_tree.introduction.f3" class="footnote"><p><a href="#geometry_index.r_tree.introduction.f3" class="para"><sup class="para">[4] </sup></a>
Beckmann, N.; Kriegel, H. P.; Schneider, R.; Seeger, B. (1990). <span class="emphasis"><em>The
R*-tree: an efficient and robust access method for points and rectangles</em></span>
</p></div>

View File

@@ -56,7 +56,7 @@
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"><p><small>Last revised: November 26, 2012 at 22:11:47 GMT</small></p></td>
<td align="left"><p><small>Last revised: November 27, 2012 at 12:09:04 GMT</small></p></td>
<td align="right"><div class="copyright-footer"></div></td>
</tr></table>
<hr>

View File

@@ -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]

View File

@@ -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 <typename Container>

View File

@@ -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<value_type, options_type, translator_type, box_type, allocators_type> del_v(t.m_root, t.m_allocators);
detail::rtree::apply_visitor(del_v, *t.m_root);
}
else
{
detail::rtree::clear_node<value_type, options_type, translator_type, box_type, allocators_type>::apply(*t.m_root, t.m_allocators);
}
detail::rtree::visitors::destroy<value_type, options_type, translator_type, box_type, allocators_type> del_v(t.m_root, t.m_allocators);
detail::rtree::apply_visitor(del_v, *t.m_root);
t.m_root = 0;
}

View File

@@ -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 ]

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
test_rtree<P2dc, bgi::linear<4, 2> >();
test_rtree<P2dc>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
test_rtree<P2dc>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
test_rtree<P2fc, bgi::linear<4, 2> >();
test_rtree<P2fc>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
test_rtree<P2fc>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
test_rtree<P2ic, bgi::linear<4, 2> >();
test_rtree<P2ic>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
test_rtree<P2ic>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -20,7 +20,6 @@ int test_main(int, char* [])
typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
test_rtree<P2ttmc, bgi::linear<4, 2> >();
test_rtree<P2ttmc>(bgi::runtime::linear(4, 2));
#endif

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
#ifdef HAVE_TTMATH
typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
test_rtree<P2ttmc>(bgi::runtime::linear(4, 2));
#endif
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
test_rtree<P2dc, bgi::quadratic<4, 2> >();
test_rtree<P2dc>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<double, 2, bg::cs::cartesian> P2dc;
test_rtree<P2dc>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
test_rtree<P2fc, bgi::quadratic<4, 2> >();
test_rtree<P2fc>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<float, 2, bg::cs::cartesian> P2fc;
test_rtree<P2fc>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
test_rtree<P2ic, bgi::quadratic<4, 2> >();
test_rtree<P2ic>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<int, 2, bg::cs::cartesian> P2ic;
test_rtree<P2ic>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -20,7 +20,6 @@ int test_main(int, char* [])
typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
test_rtree<P2ttmc, bgi::quadratic<4, 2> >();
test_rtree<P2ttmc>(bgi::runtime::quadratic(4, 2));
#endif
return 0;

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
#ifdef HAVE_TTMATH
typedef bg::model::point<ttmath_big, 2, bg::cs::cartesian> P2ttmc;
test_rtree<P2ttmc>(bgi::runtime::quadratic(4, 2));
#endif
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
test_rtree<P3dc, bgi::linear<4, 2> >();
test_rtree<P3dc>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
test_rtree<P3dc>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
test_rtree<P3fc, bgi::linear<4, 2> >();
test_rtree<P3fc>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
test_rtree<P3fc>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
test_rtree<P3ic, bgi::linear<4, 2> >();
test_rtree<P3ic>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
test_rtree<P3ic>(bgi::runtime::linear(4, 2));
return 0;
}

View File

@@ -20,7 +20,6 @@ int test_main(int, char* [])
typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
test_rtree<P3ttmc, bgi::linear<4, 2> >();
test_rtree<P3ttmc>(bgi::runtime::linear(4, 2));
#endif
return 0;

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
#ifdef HAVE_TTMATH
typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
test_rtree<P3ttmc>(bgi::runtime::linear(4, 2));
#endif
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
test_rtree<P3dc, bgi::quadratic<4, 2> >();
test_rtree<P3dc>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<double, 3, bg::cs::cartesian> P3dc;
test_rtree<P3dc>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
test_rtree<P3fc, bgi::quadratic<4, 2> >();
test_rtree<P3fc>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<float, 3, bg::cs::cartesian> P3fc;
test_rtree<P3fc>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -18,7 +18,6 @@ int test_main(int, char* [])
typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
test_rtree<P3ic, bgi::quadratic<4, 2> >();
test_rtree<P3ic>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
typedef bg::model::point<int, 3, bg::cs::cartesian> P3ic;
test_rtree<P3ic>(bgi::runtime::quadratic(4, 2));
return 0;
}

View File

@@ -20,7 +20,6 @@ int test_main(int, char* [])
typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
test_rtree<P3ttmc, bgi::quadratic<4, 2> >();
test_rtree<P3ttmc>(bgi::runtime::quadratic(4, 2));
#endif
return 0;

View File

@@ -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 <rtree/test_rtree.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/point.hpp>
#include <boost/geometry/geometries/box.hpp>
int test_main(int, char* [])
{
#ifdef HAVE_TTMATH
typedef bg::model::point<ttmath_big, 3, bg::cs::cartesian> P3ttmc;
test_rtree<P3ttmc>(bgi::runtime::quadratic(4, 2));
#endif
return 0;
}

View File

@@ -187,6 +187,62 @@ struct generate_value< boost::tuple<bg::model::box< bg::model::point<T, 3, C> >,
}
};
// shared_ptr value
template <typename Indexable>
struct test_object
{
test_object(Indexable const& indexable_) : indexable(indexable_) {}
Indexable indexable;
};
namespace boost { namespace geometry { namespace index { namespace translator {
template <typename Indexable>
struct def< boost::shared_ptr< test_object<Indexable> > >
{
typedef boost::shared_ptr< test_object<Indexable> > 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 <typename T, typename C>
struct generate_value< boost::shared_ptr<test_object<bg::model::point<T, 2, C> > > >
{
typedef bg::model::point<T, 2, C> P;
typedef test_object<P> O;
static boost::shared_ptr<O> apply(int x, int y)
{
return boost::shared_ptr<O>(new O(P(x, y)));
}
};
template <typename T, typename C>
struct generate_value< boost::shared_ptr<test_object<bg::model::point<T, 3, C> > > >
{
typedef bg::model::point<T, 3, C> P;
typedef test_object<P> O;
static boost::shared_ptr<O> apply(int x, int y, int z)
{
return boost::shared_ptr<O>(new O(P(x, y, z)));
}
};
// generate input
template <size_t Dimension>
struct generate_input
{};
@@ -745,7 +801,7 @@ void test_create_insert(bgi::rtree<Value, Algo> & tree, std::vector<Value> const
// rtree removing
template <typename Value, typename Algo, typename Box>
void test_remove(bgi::rtree<Value, Algo> & tree, Box const& qbox)
void test_remove_clear(bgi::rtree<Value, Algo> & tree, std::vector<Value> const& input, Box const& qbox)
{
typedef bgi::rtree<Value, Algo> T;
@@ -807,6 +863,21 @@ void test_remove(bgi::rtree<Value, Algo> & tree, Box const& qbox)
BOOST_CHECK( output.size() == tree.size() - values_to_remove.size() );
test_compare_outputs(t, output, expected_output);
}
//clear
{
std::vector<Value> 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<Value> 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<Point, int> PairP;
typedef boost::tuple<Point, int, int> TupleP;
typedef boost::tuple<Box, int, int> TupleB;
typedef boost::shared_ptr< test_object<Point> > SharedPtrP;
test_rtree_by_value<Point, Parameters>(parameters);
test_rtree_by_value<Box, Parameters>(parameters);
@@ -881,6 +953,7 @@ void test_rtree(Parameters const& parameters = Parameters())
test_rtree_by_value<PairP, Parameters>(parameters);
test_rtree_by_value<TupleP, Parameters>(parameters);
test_rtree_by_value<TupleB, Parameters>(parameters);
test_rtree_by_value<SharedPtrP, Parameters>(parameters);
}
#endif