diff --git a/include/boost/geometry/index/detail/varray.hpp b/include/boost/geometry/index/detail/varray.hpp index c08de73da..64bc47bde 100644 --- a/include/boost/geometry/index/detail/varray.hpp +++ b/include/boost/geometry/index/detail/varray.hpp @@ -798,12 +798,12 @@ private: pointer ptr() { - return pointer(m_storage.address()); + return pointer(static_cast(m_storage.address())); } const_pointer ptr() const { - return const_pointer(m_storage.address()); + return const_pointer(static_cast(m_storage.address())); } boost::aligned_storage::value> m_storage; diff --git a/test/rtree/Jamfile.v2 b/test/rtree/Jamfile.v2 index a99fd208d..7880902fd 100644 --- a/test/rtree/Jamfile.v2 +++ b/test/rtree/Jamfile.v2 @@ -13,3 +13,14 @@ 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/rtree_interprocess.cpp b/test/rtree/rtree_interprocess.cpp new file mode 100644 index 000000000..bb8c5d534 --- /dev/null +++ b/test/rtree/rtree_interprocess.cpp @@ -0,0 +1,84 @@ +// 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 + +template +void test_rtree_interprocess(Parameters const& parameters = Parameters()) +{ + namespace bi = boost::interprocess; + struct shm_remove + { + shm_remove() { bi::shared_memory_object::remove("shmem"); } + ~shm_remove(){ bi::shared_memory_object::remove("shmem"); } + } remover; + + bi::managed_shared_memory segment(bi::create_only, "shmem", 65535); + typedef bi::allocator shmem_alloc; + + typedef bgi::rtree, shmem_alloc> Tree; + + Tree * tree = segment.construct("Tree")(parameters, bgi::translator::def(), shmem_alloc(segment.get_segment_manager())); + typedef typename Tree::bounds_type B; + + std::vector input; + B qbox; + + generate_rtree(*tree, input, qbox); + + test_intersects(*tree, input, qbox); + test_disjoint(*tree, input, qbox); + test_covered_by(*tree, input, qbox); + test_overlaps(*tree, input, qbox); + //test_touches(*tree, input, qbox); + test_within(*tree, input, qbox); + + typedef typename bgi::detail::traits::point_type::type P; + P pt; + bg::centroid(qbox, pt); + + test_nearest_query_k(*tree, input, pt, 10); + test_nearest_query_not_found(*tree, generate_outside_point

::apply()); + + segment.destroy_ptr(tree); +} + +int test_main(int, char* []) +{ + typedef bg::model::point P2d; + typedef bg::model::box B2d; + typedef std::pair PB2d; + + 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)); + + typedef bg::model::point P3f; + typedef bg::model::box B3f; + typedef std::pair PB3f; + + 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/test/rtree/test_rtree.hpp b/test/rtree/test_rtree.hpp index f48a5d0a6..5f0129c2d 100644 --- a/test/rtree/test_rtree.hpp +++ b/test/rtree/test_rtree.hpp @@ -480,13 +480,10 @@ generate_value_outside() return generate_value_outside_impl::value>::apply(); } -template -void generate_rtree(bgi::rtree & tree, std::vector & input, Box & qbox) +template +void generate_rtree(Rtree & tree, Elements & input, Box & qbox) { - typedef bgi::rtree T; - typedef typename T::box_type B; - typedef typename T::value_type V; - typedef typename T::indexable_type I; + typedef typename Rtree::indexable_type I; generate_input< bgi::detail::traits::dimension::value @@ -568,8 +565,8 @@ void test_spatial_query(Rtree & rtree, Predicates const& pred, std::vector -void test_intersects(bgi::rtree const& tree, std::vector const& input, Box const& qbox) +template +void test_intersects(bgi::rtree const& tree, std::vector const& input, Box const& qbox) { std::vector expected_output; @@ -592,8 +589,8 @@ void test_intersects(bgi::rtree const& tree, std::vector con test_spatial_query(tree, !bgi::disjoint(qpoly), expected_output);*/ } -template -void test_disjoint(bgi::rtree const& tree, std::vector const& input, Box const& qbox) +template +void test_disjoint(bgi::rtree const& tree, std::vector const& input, Box const& qbox) { std::vector expected_output; @@ -614,8 +611,8 @@ void test_disjoint(bgi::rtree const& tree, std::vector const } -template -void test_covered_by(bgi::rtree const& tree, std::vector const& input, Box const& qbox) +template +void test_covered_by(bgi::rtree const& tree, std::vector const& input, Box const& qbox) { std::vector expected_output; @@ -637,8 +634,8 @@ void test_covered_by(bgi::rtree const& tree, std::vector con template struct test_overlap_impl { - template - static void apply(bgi::rtree const& tree, std::vector const& input, Box const& qbox) + template + static void apply(bgi::rtree const& tree, std::vector const& input, Box const& qbox) { std::vector expected_output; @@ -661,13 +658,13 @@ struct test_overlap_impl template <> struct test_overlap_impl { - template - static void apply(bgi::rtree const& /*tree*/, std::vector const& /*input*/, Box const& /*qbox*/) + template + static void apply(bgi::rtree const& /*tree*/, std::vector const& /*input*/, Box const& /*qbox*/) {} }; -template -void test_overlaps(bgi::rtree const& tree, std::vector const& input, Box const& qbox) +template +void test_overlaps(bgi::rtree const& tree, std::vector const& input, Box const& qbox) { test_overlap_impl< typename bgi::detail::traits::tag< @@ -679,16 +676,16 @@ void test_overlaps(bgi::rtree const& tree, std::vector const //template //struct test_touches_impl //{ -// template -// static void apply(bgi::rtree const& tree, std::vector const& input, Box const& qbox) +// template +// static void apply(bgi::rtree const& tree, std::vector const& input, Box const& qbox) // {} //}; // //template <> //struct test_touches_impl //{ -// template -// static void apply(bgi::rtree const& tree, std::vector const& input, Box const& qbox) +// template +// static void apply(bgi::rtree const& tree, std::vector const& input, Box const& qbox) // { // std::vector expected_output; // @@ -700,21 +697,21 @@ void test_overlaps(bgi::rtree const& tree, std::vector const // } //}; // -//template -//void test_touches(bgi::rtree const& tree, std::vector const& input, Box const& qbox) +//template +//void test_touches(bgi::rtree const& tree, std::vector const& input, Box const& qbox) //{ // test_touches_impl< // bgi::traits::tag< -// typename bgi::rtree::indexable_type +// typename bgi::rtree::indexable_type // >::type, // bgi::traits::dimension< -// typename bgi::rtree::indexable_type +// typename bgi::rtree::indexable_type // >::value // >::apply(tree, input, qbox); //} -template -void test_within(bgi::rtree const& tree, std::vector const& input, Box const& qbox) +template +void test_within(bgi::rtree const& tree, std::vector const& input, Box const& qbox) { std::vector expected_output; @@ -830,7 +827,7 @@ void test_nearest_query_k(Rtree const& rtree, std::vector const& input, P struct AlwaysFalse { template - bool operator()(Value const& v) const { return false; } + bool operator()(Value const& ) const { return false; } }; template