|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r83964 - in trunk/boost/geometry/index: . detail detail/rtree/visitors
From: adam.wulkiewicz_at_[hidden]
Date: 2013-04-19 08:57:13
Author: awulkiew
Date: 2013-04-19 08:57:12 EDT (Fri, 19 Apr 2013)
New Revision: 83964
URL: http://svn.boost.org/trac/boost/changeset/83964
Log:
geometry.index.rtree: Removed distance predicates member unnecessarily stored in nearest visitor.
Text files modified:
trunk/boost/geometry/index/detail/distance_predicates.hpp | 16 +++++++++
trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp | 34 +++++++++++--------
trunk/boost/geometry/index/rtree.hpp | 67 ++++++++++++++++-----------------------
3 files changed, 63 insertions(+), 54 deletions(-)
Modified: trunk/boost/geometry/index/detail/distance_predicates.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/distance_predicates.hpp (original)
+++ trunk/boost/geometry/index/detail/distance_predicates.hpp 2013-04-19 08:57:12 EDT (Fri, 19 Apr 2013)
@@ -29,6 +29,22 @@
namespace boost { namespace geometry { namespace index { namespace detail {
// ------------------------------------------------------------------ //
+// distance_predicates_type
+// ------------------------------------------------------------------ //
+
+template <typename NearestPredicate>
+struct distance_predicates_type
+{
+ typedef void type;
+};
+
+template <typename DistancePredicates>
+struct distance_predicates_type< detail::nearest<DistancePredicates> >
+{
+ typedef DistancePredicates type;
+};
+
+// ------------------------------------------------------------------ //
// relations
// ------------------------------------------------------------------ //
Modified: trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp
==============================================================================
--- trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp (original)
+++ trunk/boost/geometry/index/detail/rtree/visitors/nearest_query.hpp 2013-04-19 08:57:12 EDT (Fri, 19 Apr 2013)
@@ -148,8 +148,8 @@
typename Translator,
typename Box,
typename Allocators,
- typename DistancesPredicates,
typename Predicates,
+ unsigned NearestPredicateIndex,
typename Result
>
class nearest_query
@@ -162,27 +162,35 @@
typedef typename rtree::internal_node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type internal_node;
typedef typename rtree::leaf<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type leaf;
- typedef index::detail::distances_calc<DistancesPredicates, Box, index::detail::bounds_tag> node_distances_calc;
+ typedef index::detail::predicates_element<NearestPredicateIndex, Predicates> nearest_predicate_access;
+ typedef typename index::detail::distance_predicates_type<typename nearest_predicate_access::type>::type distance_predicates_type;
+
+ typedef index::detail::distances_calc<distance_predicates_type, Box, index::detail::bounds_tag> node_distances_calc;
typedef typename node_distances_calc::result_type node_distances_type;
- typedef index::detail::distances_predicates_check<DistancesPredicates, Box, index::detail::bounds_tag> node_distances_predicates_check;
+ typedef index::detail::distances_predicates_check<distance_predicates_type, Box, index::detail::bounds_tag> node_distances_predicates_check;
typedef index::detail::distances_calc<
- DistancesPredicates,
+ distance_predicates_type,
typename indexable_type<Translator>::type,
index::detail::value_tag
> value_distances_calc;
typedef typename value_distances_calc::result_type value_distances_type;
typedef index::detail::distances_predicates_check<
- DistancesPredicates,
+ distance_predicates_type,
typename indexable_type<Translator>::type,
index::detail::value_tag
> value_distances_predicates_check;
+ inline distance_predicates_type const& dist_pred() const
+ {
+ return nearest_predicate_access::get(m_pred).distance_predicates;
+ }
+
static const unsigned predicates_len = index::detail::predicates_length<Predicates>::value;
- inline nearest_query(parameters_type const& parameters, Translator const& translator, DistancesPredicates const& dist_pred, Predicates const& pred, Result & r)
+ inline nearest_query(parameters_type const& parameters, Translator const& translator, Predicates const& pred, Result & r)
: m_parameters(parameters), m_translator(translator)
- , m_dist_pred(dist_pred), m_pred(pred)
+ , m_pred(pred)
, m_result(r)
{}
@@ -210,7 +218,7 @@
if ( index::detail::predicates_check<index::detail::bounds_tag, 0, predicates_len>(m_pred, 0, it->first) )
{
// calculate node's distance(s) for distance predicate
- node_distances_type node_dist_data = node_distances_calc::apply(m_dist_pred, it->first);
+ node_distances_type node_dist_data = node_distances_calc::apply(dist_pred(), it->first);
// TODO: awulkiew - consider at first calculating near distance only,
// comparing it with m_result.comparable_distance if it's valid,
@@ -224,7 +232,7 @@
}
// if current node distance(s) meets distance predicate
- if ( node_distances_predicates_check::apply(m_dist_pred, node_dist_data) )
+ if ( node_distances_predicates_check::apply(dist_pred(), node_dist_data) )
{
// add current node's data into the list
active_branch_list.push_back( std::make_pair(node_dist_data, it->second) );
@@ -265,16 +273,16 @@
if ( index::detail::predicates_check<index::detail::value_tag, 0, predicates_len>(m_pred, *it, m_translator(*it)) )
{
// calculate values distance for distance predicate
- value_distances_type distances = value_distances_calc::apply(m_dist_pred, m_translator(*it));
+ value_distances_type distances = value_distances_calc::apply(dist_pred(), m_translator(*it));
// TODO: awulkiew - consider at first calculating point relation distance only,
// comparing it with m_result.comparable_distance if it's valid,
// after that calculate the rest of distances and check predicates
// if distance meets distance predicate
- if ( value_distances_predicates_check::apply(m_dist_pred, distances) )
+ if ( value_distances_predicates_check::apply(dist_pred(), distances) )
{
- typedef typename index::detail::point_relation<DistancesPredicates>::type point_relation_type;
+ typedef typename index::detail::point_relation<distance_predicates_type>::type point_relation_type;
typedef typename index::detail::relation<point_relation_type>::tag point_relation_tag;
// store value
@@ -325,9 +333,7 @@
parameters_type const& m_parameters;
Translator const& m_translator;
- DistancesPredicates m_dist_pred;
Predicates m_pred;
-
Result & m_result;
};
Modified: trunk/boost/geometry/index/rtree.hpp
==============================================================================
--- trunk/boost/geometry/index/rtree.hpp (original)
+++ trunk/boost/geometry/index/rtree.hpp 2013-04-19 08:57:12 EDT (Fri, 19 Apr 2013)
@@ -1132,10 +1132,34 @@
size_type query_dispatch(Predicates const& predicates, OutIter out_it, boost::mpl::bool_<true> const& /*is_nearest*/) const
{
static const unsigned nearest_index = detail::predicates_find_nearest<Predicates>::value;
- typedef detail::predicates_element<nearest_index, Predicates> element_access;
- typename element_access::type const& nearest_pred = element_access::get(predicates);
+ typedef index::detail::predicates_element<nearest_index, Predicates> nearest_predicate_access;
+ typedef typename index::detail::distance_predicates_type<typename nearest_predicate_access::type >::type distance_predicates_type;
+ typedef typename detail::point_relation<distance_predicates_type>::type point_relation;
+ typedef typename detail::relation<point_relation>::value_type point_type;
+
+ typedef detail::rtree::visitors::nearest_query_result_k<
+ value_type,
+ translator_type,
+ point_type,
+ OutIter
+ > result_type;
+
+ result_type result(nearest_predicate_access::get(predicates).count, out_it);
+
+ detail::rtree::visitors::nearest_query<
+ value_type,
+ options_type,
+ translator_type,
+ box_type,
+ allocators_type,
+ Predicates,
+ nearest_index,
+ result_type
+ > nearest_v(m_members.parameters(), m_members.translator(), predicates, result);
- return raw_nearest_k(nearest_pred.distance_predicates, nearest_pred.count, predicates, out_it);
+ detail::rtree::apply_visitor(nearest_v, *m_members.root);
+
+ return result.finish();
}
#ifdef BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
@@ -1189,43 +1213,6 @@
#endif // BOOST_GEOMETRY_INDEX_DETAIL_EXPERIMENTAL
- /*!
- \brief Find k values meeting distances and spatial predicates.
-
- \par Exception-safety
- strong
- */
- template <typename DistancesPredicates, typename Predicates, typename OutIter>
- inline size_type raw_nearest_k(DistancesPredicates const& dpred, size_t k, Predicates const& pred, OutIter out_it) const
- {
- typedef typename detail::point_relation<DistancesPredicates>::type point_relation;
- typedef typename detail::relation<point_relation>::value_type point_type;
-
- typedef detail::rtree::visitors::nearest_query_result_k<
- value_type,
- translator_type,
- point_type,
- OutIter
- > result_type;
-
- result_type result(k, out_it);
-
- detail::rtree::visitors::nearest_query<
- value_type,
- options_type,
- translator_type,
- box_type,
- allocators_type,
- DistancesPredicates,
- Predicates,
- result_type
- > nearest_v(m_members.parameters(), m_members.translator(), dpred, pred, result);
-
- detail::rtree::apply_visitor(nearest_v, *m_members.root);
-
- return result.finish();
- }
-
struct members_holder
: public translator_type
, public Parameters
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk