//
// Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland.
//
+// This file was modified by Oracle on 2019.
+// Modifications copyright (c) 2019 Oracle and/or its affiliates.
+// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
+//
// 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)
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_RSTAR_INSERT_HPP
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_RSTAR_INSERT_HPP
+#include <boost/core/ignore_unused.hpp>
+
#include <boost/geometry/index/detail/algorithms/content.hpp>
namespace boost { namespace geometry { namespace index {
namespace rstar {
+// Utility to distinguish between default and non-default index strategy
+template <typename Point1, typename Point2, typename Strategy>
+struct comparable_distance_point_point
+{
+ typedef typename Strategy::comparable_distance_point_point_strategy_type strategy_type;
+ typedef typename geometry::comparable_distance_result
+ <
+ Point1, Point2, strategy_type
+ >::type result_type;
+
+ static inline strategy_type get_strategy(Strategy const& strategy)
+ {
+ return strategy.get_comparable_distance_point_point_strategy();
+ }
+};
+
+template <typename Point1, typename Point2>
+struct comparable_distance_point_point<Point1, Point2, default_strategy>
+{
+ typedef default_strategy strategy_type;
+ typedef typename geometry::default_comparable_distance_result
+ <
+ Point1, Point2
+ >::type result_type;
+
+ static inline strategy_type get_strategy(default_strategy const& )
+ {
+ return strategy_type();
+ }
+};
+
template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
class remove_elements_to_reinsert
{
typedef typename rtree::elements_type<Node>::type elements_type;
typedef typename elements_type::value_type element_type;
typedef typename geometry::point_type<Box>::type point_type;
+ typedef typename index::detail::strategy_type<parameters_type>::type strategy_type;
// TODO: awulkiew - change second point_type to the point type of the Indexable?
- typedef typename
- geometry::default_comparable_distance_result<point_type>::type
- comparable_distance_type;
+ typedef rstar::comparable_distance_point_point
+ <
+ point_type, point_type, strategy_type
+ > comparable_distance_pp;
+ typedef typename comparable_distance_pp::result_type comparable_distance_type;
elements_type & elements = rtree::elements(n);
// If constructor is used instead of resize() MS implementation leaks here
sorted_elements.reserve(elements_count); // MAY THROW, STRONG (V, E: alloc, copy)
+ typename comparable_distance_pp::strategy_type
+ cdist_strategy = comparable_distance_pp::get_strategy(index::detail::get_strategy(parameters));
+
for ( typename elements_type::const_iterator it = elements.begin() ;
it != elements.end() ; ++it )
{
point_type element_center;
geometry::centroid( rtree::element_indexable(*it, translator), element_center);
sorted_elements.push_back(std::make_pair(
- geometry::comparable_distance(node_center, element_center),
+ geometry::comparable_distance(node_center, element_center, cdist_strategy),
*it)); // MAY THROW (V, E: copy)
}
}
BOOST_CATCH_END
- ::boost::ignore_unused_variable_warning(parameters);
+ ::boost::ignore_unused(parameters);
}
private:
inline void recalculate_aabb(Node const& n) const
{
base::m_traverse_data.current_element().first =
- elements_box<Box>(rtree::elements(n).begin(), rtree::elements(n).end(), base::m_translator);
+ elements_box<Box>(rtree::elements(n).begin(), rtree::elements(n).end(),
+ base::m_translator,
+ index::detail::get_strategy(base::m_parameters));
}
inline void recalculate_aabb(leaf const& n) const
{
base::m_traverse_data.current_element().first =
- values_box<Box>(rtree::elements(n).begin(), rtree::elements(n).end(), base::m_translator);
+ values_box<Box>(rtree::elements(n).begin(), rtree::elements(n).end(),
+ base::m_translator,
+ index::detail::get_strategy(base::m_parameters));
}
size_type result_relative_level;