update boost
This commit is contained in:
@@ -3,7 +3,11 @@
|
||||
// R-tree linear split algorithm implementation
|
||||
//
|
||||
// Copyright (c) 2008 Federico J. Fernandez.
|
||||
// Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
|
||||
// Copyright (c) 2011-2022 Adam Wulkiewicz, Lodz, Poland.
|
||||
//
|
||||
// This file was modified by Oracle on 2019-2020.
|
||||
// Modifications copyright (c) 2019-2020 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
|
||||
@@ -12,9 +16,13 @@
|
||||
#ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_LINEAR_REDISTRIBUTE_ELEMENTS_HPP
|
||||
#define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_LINEAR_REDISTRIBUTE_ELEMENTS_HPP
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
#include <boost/type_traits/is_unsigned.hpp>
|
||||
#include <type_traits>
|
||||
|
||||
#include <boost/core/ignore_unused.hpp>
|
||||
|
||||
#include <boost/geometry/core/static_assert.hpp>
|
||||
|
||||
#include <boost/geometry/index/detail/algorithms/bounds.hpp>
|
||||
#include <boost/geometry/index/detail/algorithms/content.hpp>
|
||||
#include <boost/geometry/index/detail/bounded_view.hpp>
|
||||
|
||||
@@ -29,13 +37,13 @@ namespace detail { namespace rtree {
|
||||
namespace linear {
|
||||
|
||||
template <typename R, typename T>
|
||||
inline R difference_dispatch(T const& from, T const& to, ::boost::mpl::bool_<false> const& /*is_unsigned*/)
|
||||
inline R difference_dispatch(T const& from, T const& to, std::false_type /*is_unsigned*/)
|
||||
{
|
||||
return to - from;
|
||||
}
|
||||
|
||||
template <typename R, typename T>
|
||||
inline R difference_dispatch(T const& from, T const& to, ::boost::mpl::bool_<true> const& /*is_unsigned*/)
|
||||
inline R difference_dispatch(T const& from, T const& to, std::true_type /*is_unsigned*/)
|
||||
{
|
||||
return from <= to ? R(to - from) : -R(from - to);
|
||||
}
|
||||
@@ -43,13 +51,11 @@ inline R difference_dispatch(T const& from, T const& to, ::boost::mpl::bool_<tru
|
||||
template <typename R, typename T>
|
||||
inline R difference(T const& from, T const& to)
|
||||
{
|
||||
BOOST_MPL_ASSERT_MSG(!boost::is_unsigned<R>::value, RESULT_CANT_BE_UNSIGNED, (R));
|
||||
BOOST_GEOMETRY_STATIC_ASSERT((! std::is_unsigned<R>::value),
|
||||
"Result can not be an unsigned type.",
|
||||
R);
|
||||
|
||||
typedef ::boost::mpl::bool_<
|
||||
boost::is_unsigned<T>::value
|
||||
> is_unsigned;
|
||||
|
||||
return difference_dispatch<R>(from, to, is_unsigned());
|
||||
return difference_dispatch<R>(from, to, std::is_unsigned<T>());
|
||||
}
|
||||
|
||||
// TODO: awulkiew
|
||||
@@ -82,15 +88,20 @@ struct find_greatest_normalized_separation
|
||||
typedef typename rtree::element_indexable_type<element_type, Translator>::type indexable_type;
|
||||
typedef typename coordinate_type<indexable_type>::type coordinate_type;
|
||||
|
||||
typedef typename boost::mpl::if_c<
|
||||
boost::is_integral<coordinate_type>::value,
|
||||
double,
|
||||
coordinate_type
|
||||
>::type separation_type;
|
||||
typedef std::conditional_t
|
||||
<
|
||||
std::is_integral<coordinate_type>::value,
|
||||
double,
|
||||
coordinate_type
|
||||
> separation_type;
|
||||
|
||||
typedef typename geometry::point_type<indexable_type>::type point_type;
|
||||
typedef geometry::model::box<point_type> bounds_type;
|
||||
typedef index::detail::bounded_view<indexable_type, bounds_type> bounded_view_type;
|
||||
typedef index::detail::bounded_view
|
||||
<
|
||||
indexable_type, bounds_type,
|
||||
typename index::detail::strategy_type<Parameters>::type
|
||||
> bounded_view_type;
|
||||
|
||||
static inline void apply(Elements const& elements,
|
||||
Parameters const& parameters,
|
||||
@@ -103,43 +114,52 @@ struct find_greatest_normalized_separation
|
||||
BOOST_GEOMETRY_INDEX_ASSERT(elements.size() == elements_count, "unexpected number of elements");
|
||||
BOOST_GEOMETRY_INDEX_ASSERT(2 <= elements_count, "unexpected number of elements");
|
||||
|
||||
auto const& strategy = index::detail::get_strategy(parameters);
|
||||
|
||||
// find the lowest low, highest high
|
||||
bounded_view_type bounded_indexable_0(rtree::element_indexable(elements[0], translator));
|
||||
indexable_type const& indexable_0 = rtree::element_indexable(elements[0], translator);
|
||||
bounded_view_type const bounded_indexable_0(indexable_0, strategy);
|
||||
coordinate_type lowest_low = geometry::get<min_corner, DimensionIndex>(bounded_indexable_0);
|
||||
coordinate_type highest_high = geometry::get<max_corner, DimensionIndex>(bounded_indexable_0);
|
||||
|
||||
// and the lowest high
|
||||
coordinate_type lowest_high = highest_high;
|
||||
size_t lowest_high_index = 0;
|
||||
for ( size_t i = 1 ; i < elements_count ; ++i )
|
||||
for (size_t i = 1 ; i < elements_count ; ++i)
|
||||
{
|
||||
bounded_view_type bounded_indexable(rtree::element_indexable(elements[i], translator));
|
||||
indexable_type const& indexable_i = rtree::element_indexable(elements[i], translator);
|
||||
bounded_view_type const bounded_indexable(indexable_i, strategy);
|
||||
coordinate_type min_coord = geometry::get<min_corner, DimensionIndex>(bounded_indexable);
|
||||
coordinate_type max_coord = geometry::get<max_corner, DimensionIndex>(bounded_indexable);
|
||||
|
||||
if ( max_coord < lowest_high )
|
||||
if (max_coord < lowest_high)
|
||||
{
|
||||
lowest_high = max_coord;
|
||||
lowest_high_index = i;
|
||||
}
|
||||
|
||||
if ( min_coord < lowest_low )
|
||||
if (min_coord < lowest_low)
|
||||
{
|
||||
lowest_low = min_coord;
|
||||
}
|
||||
|
||||
if ( highest_high < max_coord )
|
||||
if (highest_high < max_coord)
|
||||
{
|
||||
highest_high = max_coord;
|
||||
}
|
||||
}
|
||||
|
||||
// find the highest low
|
||||
size_t highest_low_index = lowest_high_index == 0 ? 1 : 0;
|
||||
bounded_view_type bounded_indexable_hl(rtree::element_indexable(elements[highest_low_index], translator));
|
||||
indexable_type const& indexable_hl = rtree::element_indexable(elements[highest_low_index], translator);
|
||||
bounded_view_type const bounded_indexable_hl(indexable_hl, strategy);
|
||||
coordinate_type highest_low = geometry::get<min_corner, DimensionIndex>(bounded_indexable_hl);
|
||||
for ( size_t i = highest_low_index ; i < elements_count ; ++i )
|
||||
for (size_t i = highest_low_index ; i < elements_count ; ++i)
|
||||
{
|
||||
bounded_view_type bounded_indexable(rtree::element_indexable(elements[i], translator));
|
||||
indexable_type const& indexable = rtree::element_indexable(elements[i], translator);
|
||||
bounded_view_type const bounded_indexable(indexable, strategy);
|
||||
coordinate_type min_coord = geometry::get<min_corner, DimensionIndex>(bounded_indexable);
|
||||
if ( highest_low < min_coord &&
|
||||
i != lowest_high_index )
|
||||
if (highest_low < min_coord && i != lowest_high_index)
|
||||
{
|
||||
highest_low = min_coord;
|
||||
highest_low_index = i;
|
||||
@@ -147,12 +167,14 @@ struct find_greatest_normalized_separation
|
||||
}
|
||||
|
||||
coordinate_type const width = highest_high - lowest_low;
|
||||
|
||||
|
||||
// highest_low - lowest_high
|
||||
separation = difference<separation_type>(lowest_high, highest_low);
|
||||
// BOOST_GEOMETRY_INDEX_ASSERT(0 <= width);
|
||||
if ( std::numeric_limits<coordinate_type>::epsilon() < width )
|
||||
if (std::numeric_limits<coordinate_type>::epsilon() < width)
|
||||
{
|
||||
separation /= width;
|
||||
}
|
||||
|
||||
seed1 = highest_low_index;
|
||||
seed2 = lowest_high_index;
|
||||
@@ -306,28 +328,34 @@ inline void pick_seeds(Elements const& elements,
|
||||
|
||||
// from void split_node(node_pointer const& n, node_pointer& n1, node_pointer& n2) const
|
||||
|
||||
template <typename Value, typename Options, typename Translator, typename Box, typename Allocators>
|
||||
struct redistribute_elements<Value, Options, Translator, Box, Allocators, linear_tag>
|
||||
template <typename MembersHolder>
|
||||
struct redistribute_elements<MembersHolder, linear_tag>
|
||||
{
|
||||
typedef typename Options::parameters_type parameters_type;
|
||||
typedef typename MembersHolder::box_type box_type;
|
||||
typedef typename MembersHolder::parameters_type parameters_type;
|
||||
typedef typename MembersHolder::translator_type translator_type;
|
||||
typedef typename MembersHolder::allocators_type allocators_type;
|
||||
|
||||
typedef typename rtree::node<Value, parameters_type, Box, Allocators, typename Options::node_tag>::type node;
|
||||
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 typename MembersHolder::node node;
|
||||
typedef typename MembersHolder::internal_node internal_node;
|
||||
typedef typename MembersHolder::leaf leaf;
|
||||
|
||||
template <typename Node>
|
||||
static inline void apply(Node & n,
|
||||
Node & second_node,
|
||||
Box & box1,
|
||||
Box & box2,
|
||||
box_type & box1,
|
||||
box_type & box2,
|
||||
parameters_type const& parameters,
|
||||
Translator const& translator,
|
||||
Allocators & allocators)
|
||||
translator_type const& translator,
|
||||
allocators_type & allocators)
|
||||
{
|
||||
typedef typename rtree::elements_type<Node>::type elements_type;
|
||||
typedef typename elements_type::value_type element_type;
|
||||
typedef typename rtree::element_indexable_type<element_type, Translator>::type indexable_type;
|
||||
typedef typename index::detail::default_content_result<Box>::type content_type;
|
||||
typedef typename rtree::element_indexable_type<element_type, translator_type>::type indexable_type;
|
||||
typedef typename index::detail::default_content_result<box_type>::type content_type;
|
||||
|
||||
typename index::detail::strategy_type<parameters_type>::type const&
|
||||
strategy = index::detail::get_strategy(parameters);
|
||||
|
||||
elements_type & elements1 = rtree::elements(n);
|
||||
elements_type & elements2 = rtree::elements(second_node);
|
||||
@@ -357,8 +385,10 @@ struct redistribute_elements<Value, Options, Translator, Box, Allocators, linear
|
||||
elements2.push_back(elements_copy[seed2]); // MAY THROW, STRONG (alloc, copy)
|
||||
|
||||
// calculate boxes
|
||||
detail::bounds(rtree::element_indexable(elements_copy[seed1], translator), box1);
|
||||
detail::bounds(rtree::element_indexable(elements_copy[seed2], translator), box2);
|
||||
detail::bounds(rtree::element_indexable(elements_copy[seed1], translator),
|
||||
box1, strategy);
|
||||
detail::bounds(rtree::element_indexable(elements_copy[seed2], translator),
|
||||
box2, strategy);
|
||||
|
||||
// initialize areas
|
||||
content_type content1 = index::detail::content(box1);
|
||||
@@ -380,23 +410,23 @@ struct redistribute_elements<Value, Options, Translator, Box, Allocators, linear
|
||||
if ( elements1.size() + remaining <= parameters.get_min_elements() )
|
||||
{
|
||||
elements1.push_back(elem); // MAY THROW, STRONG (copy)
|
||||
geometry::expand(box1, indexable);
|
||||
index::detail::expand(box1, indexable, strategy);
|
||||
content1 = index::detail::content(box1);
|
||||
}
|
||||
else if ( elements2.size() + remaining <= parameters.get_min_elements() )
|
||||
{
|
||||
elements2.push_back(elem); // MAY THROW, STRONG (alloc, copy)
|
||||
geometry::expand(box2, indexable);
|
||||
index::detail::expand(box2, indexable, strategy);
|
||||
content2 = index::detail::content(box2);
|
||||
}
|
||||
// choose better node and insert element
|
||||
else
|
||||
{
|
||||
// calculate enlarged boxes and areas
|
||||
Box enlarged_box1(box1);
|
||||
Box enlarged_box2(box2);
|
||||
geometry::expand(enlarged_box1, indexable);
|
||||
geometry::expand(enlarged_box2, indexable);
|
||||
box_type enlarged_box1(box1);
|
||||
box_type enlarged_box2(box2);
|
||||
index::detail::expand(enlarged_box1, indexable, strategy);
|
||||
index::detail::expand(enlarged_box2, indexable, strategy);
|
||||
content_type enlarged_content1 = index::detail::content(enlarged_box1);
|
||||
content_type enlarged_content2 = index::detail::content(enlarged_box2);
|
||||
|
||||
@@ -420,7 +450,7 @@ struct redistribute_elements<Value, Options, Translator, Box, Allocators, linear
|
||||
content2 = enlarged_content2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BOOST_GEOMETRY_INDEX_ASSERT(0 < remaining, "unexpected value");
|
||||
--remaining;
|
||||
}
|
||||
@@ -431,7 +461,7 @@ struct redistribute_elements<Value, Options, Translator, Box, Allocators, linear
|
||||
elements1.clear();
|
||||
elements2.clear();
|
||||
|
||||
rtree::destroy_elements<Value, Options, Translator, Box, Allocators>::apply(elements_copy, allocators);
|
||||
rtree::destroy_elements<MembersHolder>::apply(elements_copy, allocators);
|
||||
//elements_copy.clear();
|
||||
|
||||
BOOST_RETHROW // RETHROW, BASIC
|
||||
|
||||
Reference in New Issue
Block a user