]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // Boost.Geometry Index |
2 | // | |
3 | // Sum values calculated for indexable's dimensions, used e.g. in R-tree k nearest neighbors query | |
4 | // | |
5 | // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. | |
6 | // | |
7 | // Use, modification and distribution is subject to the Boost Software License, | |
8 | // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at | |
9 | // http://www.boost.org/LICENSE_1_0.txt) | |
10 | ||
11 | #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_SUM_FOR_INDEXABLE_HPP | |
12 | #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_SUM_FOR_INDEXABLE_HPP | |
13 | ||
14 | namespace boost { namespace geometry { namespace index { namespace detail { | |
15 | ||
16 | template < | |
17 | typename Geometry, | |
18 | typename Indexable, | |
19 | typename IndexableTag, | |
20 | typename AlgoTag, | |
21 | size_t DimensionIndex> | |
22 | struct sum_for_indexable_dimension | |
23 | { | |
24 | BOOST_MPL_ASSERT_MSG( | |
25 | (false), | |
26 | NOT_IMPLEMENTED_FOR_THIS_INDEXABLE_TAG_TYPE, | |
27 | (sum_for_indexable_dimension)); | |
28 | }; | |
29 | ||
30 | template < | |
31 | typename Geometry, | |
32 | typename Indexable, | |
33 | typename IndexableTag, | |
34 | typename AlgoTag, | |
35 | size_t N> | |
36 | struct sum_for_indexable | |
37 | { | |
38 | typedef typename sum_for_indexable_dimension< | |
39 | Geometry, Indexable, IndexableTag, AlgoTag, N - 1 | |
40 | >::result_type result_type; | |
41 | ||
42 | inline static result_type apply(Geometry const& g, Indexable const& i) | |
43 | { | |
44 | return | |
45 | sum_for_indexable< | |
46 | Geometry, Indexable, IndexableTag, AlgoTag, N - 1 | |
47 | >::apply(g, i) + | |
48 | sum_for_indexable_dimension< | |
49 | Geometry, Indexable, IndexableTag, AlgoTag, N - 1 | |
50 | >::apply(g, i); | |
51 | } | |
52 | }; | |
53 | ||
54 | template < | |
55 | typename Geometry, | |
56 | typename Indexable, | |
57 | typename IndexableTag, | |
58 | typename AlgoTag> | |
59 | struct sum_for_indexable<Geometry, Indexable, IndexableTag, AlgoTag, 1> | |
60 | { | |
61 | typedef typename sum_for_indexable_dimension< | |
62 | Geometry, Indexable, IndexableTag, AlgoTag, 0 | |
63 | >::result_type result_type; | |
64 | ||
65 | inline static result_type apply(Geometry const& g, Indexable const& i) | |
66 | { | |
67 | return | |
68 | sum_for_indexable_dimension< | |
69 | Geometry, Indexable, IndexableTag, AlgoTag, 0 | |
70 | >::apply(g, i); | |
71 | } | |
72 | }; | |
73 | ||
74 | }}}} // namespace boost::geometry::index::detail | |
75 | ||
76 | #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_SUM_FOR_INDEXABLE_HPP |