• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry
2 
3 // Copyright (c) 2019, Oracle and/or its affiliates.
4 
5 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
6 
7 // Licensed under the Boost Software License version 1.0.
8 // http://www.boost.org/users/license.html
9 
10 #include "common.hpp"
11 
12 // These includes are required for the following code to compile.
13 // This is probably wrong.
14 #include <boost/geometry/algorithms/covered_by.hpp>
15 #include <boost/geometry/algorithms/disjoint.hpp>
16 #include <boost/geometry/algorithms/equals.hpp>
17 #include <boost/geometry/algorithms/intersects.hpp>
18 
19 #include <boost/geometry/index/rtree.hpp>
20 
21 #include <vector>
22 
23 namespace bgi = boost::geometry::index;
24 
25 template
26 <
27     typename VG, typename QG,
28     typename VTag = typename bg::tag<VG>::type,
29     typename QTag = typename bg::tag<QG>::type
30 >
31 struct call_query
32 {
33     template <typename Rtree, typename Res>
applycall_query34     static inline void apply(Rtree const& , Res const& )
35     {}
36 };
37 
38 template <typename VG, typename QG>
39 struct call_query<VG, QG, bg::box_tag, bg::point_tag>
40 {
41     template <typename Rtree>
applycall_query42     static inline void apply(Rtree const& rtree, QG const& qg)
43     {
44         std::vector<VG> res;
45         rtree.query(bgi::intersects(qg), std::back_inserter(res));
46     }
47 };
48 
49 template <typename G, typename P>
rtree_test(G const & g,P const & p)50 inline void rtree_test(G const& g, P const& p)
51 {
52     {
53         bgi::rtree<G, P> rtree;
54     }
55 
56     std::vector<G> de2(100, g);
57 
58     bgi::rtree<G, P> rtree(de2, p);
59     rtree.insert(g);
60     rtree.remove(g);
61     rtree.count(g);
62 
63     call_query<G, geom::point>::apply(rtree, geom::point(0, 0));
64 }
65 
test_main(int,char * [])66 int test_main(int, char*[])
67 {
68     geom g;
69 
70     rtree_test(g.pt, bgi::parameters<bgi::linear<4>, bg::strategy::index::cartesian<> >());
71     rtree_test(g.pt, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::cartesian<> >());
72     rtree_test(g.pt, bgi::parameters<bgi::rstar<4>, bg::strategy::index::cartesian<> >());
73     rtree_test(g.b, bgi::parameters<bgi::linear<4>, bg::strategy::index::cartesian<> >());
74     rtree_test(g.b, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::cartesian<> >());
75     rtree_test(g.b, bgi::parameters<bgi::rstar<4>, bg::strategy::index::cartesian<> >());
76     rtree_test(g.s, bgi::parameters<bgi::linear<4>, bg::strategy::index::cartesian<> >());
77     rtree_test(g.s, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::cartesian<> >());
78     rtree_test(g.s, bgi::parameters<bgi::rstar<4>, bg::strategy::index::cartesian<> >());
79 
80     rtree_test(g.pt, bgi::parameters<bgi::linear<4>, bg::strategy::index::spherical<> >());
81     rtree_test(g.pt, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::spherical<> >());
82     rtree_test(g.pt, bgi::parameters<bgi::rstar<4>, bg::strategy::index::spherical<> >());
83     rtree_test(g.b, bgi::parameters<bgi::linear<4>, bg::strategy::index::spherical<> >());
84     rtree_test(g.b, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::spherical<> >());
85     rtree_test(g.b, bgi::parameters<bgi::rstar<4>, bg::strategy::index::spherical<> >());
86     rtree_test(g.s, bgi::parameters<bgi::linear<4>, bg::strategy::index::spherical<> >());
87     rtree_test(g.s, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::spherical<> >());
88     rtree_test(g.s, bgi::parameters<bgi::rstar<4>, bg::strategy::index::spherical<> >());
89 
90     rtree_test(g.pt, bgi::parameters<bgi::linear<4>, bg::strategy::index::geographic<> >());
91     rtree_test(g.pt, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::geographic<> >());
92     rtree_test(g.pt, bgi::parameters<bgi::rstar<4>, bg::strategy::index::geographic<> >());
93     rtree_test(g.b, bgi::parameters<bgi::linear<4>, bg::strategy::index::geographic<> >());
94     rtree_test(g.b, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::geographic<> >());
95     rtree_test(g.b, bgi::parameters<bgi::rstar<4>, bg::strategy::index::geographic<> >());
96     rtree_test(g.s, bgi::parameters<bgi::linear<4>, bg::strategy::index::geographic<> >());
97     rtree_test(g.s, bgi::parameters<bgi::quadratic<4>, bg::strategy::index::geographic<> >());
98     rtree_test(g.s, bgi::parameters<bgi::rstar<4>, bg::strategy::index::geographic<> >());
99 
100     return 0;
101 }
102