• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Boost.Geometry Index
2 //
3 // R-tree options, algorithms, parameters
4 //
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
6 //
7 // This file was modified by Oracle on 2019.
8 // Modifications copyright (c) 2019 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
10 //
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
14 
15 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_OPTIONS_HPP
16 #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_OPTIONS_HPP
17 
18 #include <boost/geometry/index/parameters.hpp>
19 
20 namespace boost { namespace geometry { namespace index {
21 
22 namespace detail { namespace rtree {
23 
24 // InsertTag
25 struct insert_default_tag {};
26 struct insert_reinsert_tag {};
27 
28 // ChooseNextNodeTag
29 struct choose_by_content_diff_tag {};
30 struct choose_by_overlap_diff_tag {};
31 
32 // SplitTag
33 struct split_default_tag {};
34 //struct split_kmeans_tag {};
35 
36 // RedistributeTag
37 struct linear_tag {};
38 struct quadratic_tag {};
39 struct rstar_tag {};
40 
41 // NodeTag
42 struct node_variant_dynamic_tag {};
43 struct node_variant_static_tag {};
44 //struct node_weak_dynamic_tag {};
45 //struct node_weak_static_tag {};
46 
47 template <typename Parameters, typename InsertTag, typename ChooseNextNodeTag, typename SplitTag, typename RedistributeTag, typename NodeTag>
48 struct options
49 {
50     typedef Parameters parameters_type;
51     typedef InsertTag insert_tag;
52     typedef ChooseNextNodeTag choose_next_node_tag;
53     typedef SplitTag split_tag;
54     typedef RedistributeTag redistribute_tag;
55     typedef NodeTag node_tag;
56 };
57 
58 template <typename Parameters>
59 struct options_type
60 {
61     // TODO: awulkiew - use static assert
62 };
63 
64 template <size_t MaxElements, size_t MinElements>
65 struct options_type< index::linear<MaxElements, MinElements> >
66 {
67     typedef options<
68         index::linear<MaxElements, MinElements>,
69         insert_default_tag,
70         choose_by_content_diff_tag,
71         split_default_tag,
72         linear_tag,
73         node_variant_static_tag
74     > type;
75 };
76 
77 template <size_t MaxElements, size_t MinElements>
78 struct options_type< index::quadratic<MaxElements, MinElements> >
79 {
80     typedef options<
81         index::quadratic<MaxElements, MinElements>,
82         insert_default_tag,
83         choose_by_content_diff_tag,
84         split_default_tag,
85         quadratic_tag,
86         node_variant_static_tag
87     > type;
88 };
89 
90 template <size_t MaxElements, size_t MinElements, size_t OverlapCostThreshold, size_t ReinsertedElements>
91 struct options_type< index::rstar<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements> >
92 {
93     typedef options<
94         index::rstar<MaxElements, MinElements, OverlapCostThreshold, ReinsertedElements>,
95         insert_reinsert_tag,
96         choose_by_overlap_diff_tag,
97         split_default_tag,
98         rstar_tag,
99         node_variant_static_tag
100     > type;
101 };
102 
103 //template <size_t MaxElements, size_t MinElements>
104 //struct options_type< kmeans<MaxElements, MinElements> >
105 //{
106 //    typedef options<
107 //        kmeans<MaxElements, MinElements>,
108 //        insert_default_tag,
109 //        choose_by_content_diff_tag, // change it?
110 //        split_kmeans_tag,
111 //        int, // dummy tag - not used for now
112 //        node_variant_static_tag
113 //    > type;
114 //};
115 
116 template <>
117 struct options_type< index::dynamic_linear >
118 {
119     typedef options<
120         index::dynamic_linear,
121         insert_default_tag,
122         choose_by_content_diff_tag,
123         split_default_tag,
124         linear_tag,
125         node_variant_dynamic_tag
126     > type;
127 };
128 
129 template <>
130 struct options_type< index::dynamic_quadratic >
131 {
132     typedef options<
133         index::dynamic_quadratic,
134         insert_default_tag,
135         choose_by_content_diff_tag,
136         split_default_tag,
137         quadratic_tag,
138         node_variant_dynamic_tag
139     > type;
140 };
141 
142 template <>
143 struct options_type< index::dynamic_rstar >
144 {
145     typedef options<
146         index::dynamic_rstar,
147         insert_reinsert_tag,
148         choose_by_overlap_diff_tag,
149         split_default_tag,
150         rstar_tag,
151         node_variant_dynamic_tag
152     > type;
153 };
154 
155 template <typename Parameters, typename Strategy>
156 struct options_type< index::parameters<Parameters, Strategy> >
157     : options_type<Parameters>
158 {
159     typedef typename options_type<Parameters>::type opt;
160     typedef options<
161         index::parameters<Parameters, Strategy>,
162         typename opt::insert_tag,
163         typename opt::choose_next_node_tag,
164         typename opt::split_tag,
165         typename opt::redistribute_tag,
166         typename opt::node_tag
167     > type;
168 };
169 
170 }} // namespace detail::rtree
171 
172 }}} // namespace boost::geometry::index
173 
174 #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_OPTIONS_HPP
175