-// Copyright (c) 2011-2017 Adam Wulkiewicz, Lodz, Poland.
+// Copyright (c) 2011-2019 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
//
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
#include <boost/geometry/algorithms/expand.hpp>
#include <boost/geometry/index/detail/algorithms/content.hpp>
#include <boost/geometry/algorithms/expand.hpp>
#include <boost/geometry/index/detail/algorithms/content.hpp>
parameters_type const& parameters,
size_t node_relative_level)
{
parameters_type const& parameters,
size_t node_relative_level)
{
- return choose_by_minimum_overlap_cost(children, indexable, parameters.get_overlap_cost_threshold());
+ return choose_by_minimum_overlap_cost(children, indexable,
+ parameters.get_overlap_cost_threshold(),
+ index::detail::get_strategy(parameters));
- return choose_by_minimum_content_cost(children, indexable);
+ {
+ return choose_by_minimum_content_cost(children, indexable,
+ index::detail::get_strategy(parameters));
+ }
- template <typename Indexable>
+ struct child_contents
+ {
+ content_type content_diff;
+ content_type content;
+ size_t i;
+
+ void set(size_t i_, content_type const& content_, content_type const& content_diff_)
+ {
+ i = i_;
+ content = content_;
+ content_diff = content_diff_;
+ }
+ };
+
+ template <typename Indexable, typename Strategy>
static inline size_t choose_by_minimum_overlap_cost(children_type const& children,
Indexable const& indexable,
static inline size_t choose_by_minimum_overlap_cost(children_type const& children,
Indexable const& indexable,
size_t choosen_index = 0;
// create container of children sorted by content enlargement needed to include the new value
size_t choosen_index = 0;
// create container of children sorted by content enlargement needed to include the new value
- typedef boost::tuple<size_t, content_type, content_type> child_contents;
-
- typename rtree::container_from_elements_type<children_type, child_contents>::type children_contents;
- children_contents.resize(children_count);
+ typename rtree::container_from_elements_type<children_type, child_contents>::type
+ children_contents(children_count);
// areas difference
content_type content = index::detail::content(box_exp);
content_type content_diff = content - index::detail::content(ch_i.first);
// areas difference
content_type content = index::detail::content(box_exp);
content_type content_diff = content - index::detail::content(ch_i.first);
if ( content_diff < min_content_diff ||
(content_diff == min_content_diff && content < min_content) )
if ( content_diff < min_content_diff ||
(content_diff == min_content_diff && content < min_content) )
- choosen_index = choose_by_minimum_overlap_cost_first_n(children, indexable, first_n_children_count, children_count, children_contents);
+ choosen_index = choose_by_minimum_overlap_cost_first_n(children, indexable,
+ first_n_children_count,
+ children_count,
+ children_contents,
+ strategy);
- static inline bool content_diff_less(boost::tuple<size_t, content_type, content_type> const& p1, boost::tuple<size_t, content_type, content_type> const& p2)
+ static inline bool content_diff_less(child_contents const& p1, child_contents const& p2)
- return boost::get<1>(p1) < boost::get<1>(p2) ||
- (boost::get<1>(p1) == boost::get<1>(p2) && boost::get<2>(p1) < boost::get<2>(p2));
+ return p1.content_diff < p2.content_diff
+ || (p1.content_diff == p2.content_diff && (p1.content) < (p2.content));
static inline size_t choose_by_minimum_overlap_cost_first_n(children_type const& children,
Indexable const& indexable,
size_t const first_n_children_count,
size_t const children_count,
static inline size_t choose_by_minimum_overlap_cost_first_n(children_type const& children,
Indexable const& indexable,
size_t const first_n_children_count,
size_t const children_count,
{
BOOST_GEOMETRY_INDEX_ASSERT(first_n_children_count <= children_count, "unexpected value");
BOOST_GEOMETRY_INDEX_ASSERT(children_contents.size() == children_count, "unexpected number of elements");
{
BOOST_GEOMETRY_INDEX_ASSERT(first_n_children_count <= children_count, "unexpected value");
BOOST_GEOMETRY_INDEX_ASSERT(children_contents.size() == children_count, "unexpected number of elements");
// update result
if ( overlap_diff < smallest_overlap_diff ||
( overlap_diff == smallest_overlap_diff && ( content_diff < smallest_content_diff ||
// update result
if ( overlap_diff < smallest_overlap_diff ||
( overlap_diff == smallest_overlap_diff && ( content_diff < smallest_content_diff ||
- template <typename Indexable>
- static inline size_t choose_by_minimum_content_cost(children_type const& children, Indexable const& indexable)
+ template <typename Indexable, typename Strategy>
+ static inline size_t choose_by_minimum_content_cost(children_type const& children,
+ Indexable const& indexable,
+ Strategy const& strategy)