diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index 8f225c79d..1f3bcbf9c 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -19,6 +19,33 @@ [section:release_notes Release Notes] +[/=================] +[heading Boost 1.77] +[/=================] + +[*Improvements] + +* [@https://github.com/boostorg/geometry/pull/812 812] Umbrella strategies for distance and comparable_distance (undocumented for now). +* [@https://github.com/boostorg/geometry/pull/840 840] Umbrella strategies for various algorithms (undocumented for now). +* [@https://github.com/boostorg/geometry/pull/850 850] Introduced DynamicGeometry and GeometryCollection concepts and support in some algorithms (undocumented for now). +* [@https://github.com/boostorg/geometry/pull/855 855] Various improvements related to strategies. Default strategies are now included with algorithms. + +[*Solved issues] + +* [@https://github.com/boostorg/geometry/issues/865 865] Exception thrown in rtree serialization. +* [@https://github.com/boostorg/geometry/issues/439 439] Invalid box spherical area computation. +* [@https://github.com/boostorg/geometry/issues/838 838] Invalid result of union_(). +* [@https://github.com/boostorg/geometry/issues/851 851] Invalid geographic disjoint segment/box result. +* [@https://github.com/boostorg/geometry/issues/861 861] Invalid result of intersection(). + +[*Bugfixes] + +* [@https://github.com/boostorg/geometry/pull/832 832] Fixed box spherical and geographic area computation. +* [@https://github.com/boostorg/geometry/pull/853 853] Fixed geographic disjoint segment/box. +* [@https://github.com/boostorg/geometry/pull/866 866] Fixed serialization of rtree containing lesser number of elements in root node than minimum. +* [@https://github.com/boostorg/geometry/pull/886 886] Fixed knn rtree query bug causing it to be slow for big k. +* Various fixes in set operations and buffer. + [/=================] [heading Boost 1.76] [/=================] diff --git a/doc/src/examples/algorithms/is_valid_failure.cpp b/doc/src/examples/algorithms/is_valid_failure.cpp index f566e23a2..9569ba6ad 100644 --- a/doc/src/examples/algorithms/is_valid_failure.cpp +++ b/doc/src/examples/algorithms/is_valid_failure.cpp @@ -32,7 +32,7 @@ int main() // if the invalidity is only due to lack of closing points and/or wrongly oriented rings, then bg::correct can fix it bool could_be_fixed = (failure == boost::geometry::failure_not_closed - || boost::geometry::failure_wrong_orientation); + || failure == boost::geometry::failure_wrong_orientation); std::cout << "is valid? " << (valid ? "yes" : "no") << std::endl; if (! valid) { diff --git a/include/boost/geometry/algorithms/azimuth.hpp b/include/boost/geometry/algorithms/azimuth.hpp index 28e5491e7..26c9a5530 100644 --- a/include/boost/geometry/algorithms/azimuth.hpp +++ b/include/boost/geometry/algorithms/azimuth.hpp @@ -23,6 +23,8 @@ #include #include +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/detail/disjoint/box_box.hpp b/include/boost/geometry/algorithms/detail/disjoint/box_box.hpp index 8092ae4f8..02585b6f0 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/box_box.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/box_box.hpp @@ -5,9 +5,8 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2013-2020. -// Modifications copyright (c) 2013-2020, Oracle and/or its affiliates. - +// This file was modified by Oracle on 2013-2021. +// Modifications copyright (c) 2013-2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -25,9 +24,7 @@ #include -// For backward compatibility -#include -#include +#include namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/detail/disjoint/point_box.hpp b/include/boost/geometry/algorithms/detail/disjoint/point_box.hpp index 99cdda9ed..186f48feb 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/point_box.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/point_box.hpp @@ -5,9 +5,8 @@ // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland -// This file was modified by Oracle on 2013-2020. -// Modifications copyright (c) 2013-2020, Oracle and/or its affiliates. - +// This file was modified by Oracle on 2013-2021. +// Modifications copyright (c) 2013-2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -23,12 +22,13 @@ #include +#include + #include #include #include -#include -#include +#include namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/detail/overlay/is_self_turn.hpp b/include/boost/geometry/algorithms/detail/overlay/is_self_turn.hpp index 448c04404..1606c31e9 100644 --- a/include/boost/geometry/algorithms/detail/overlay/is_self_turn.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/is_self_turn.hpp @@ -26,8 +26,7 @@ struct is_self_turn_check template static inline bool apply(Turn const& turn) { - return turn.operations[0].seg_id.source_index - == turn.operations[1].seg_id.source_index; + return turn.is_self(); } }; diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp index a0149789c..b65f00424 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp @@ -621,31 +621,32 @@ public : return m_turns[rp.turn_index].operations[rp.operation_index]; } - inline sort_by_side::rank_type select_rank(sbs_type const& sbs, - bool skip_isolated) const + inline sort_by_side::rank_type select_rank(sbs_type const& sbs) const { + static bool const is_intersection + = target_operation == operation_intersection; + // Take the first outgoing rank corresponding to incoming region, // or take another region if it is not isolated - turn_operation_type const& incoming_op - = operation_from_rank(sbs.m_ranked_points.front()); + auto const& in_op = operation_from_rank(sbs.m_ranked_points.front()); for (std::size_t i = 0; i < sbs.m_ranked_points.size(); i++) { - typename sbs_type::rp const& rp = sbs.m_ranked_points[i]; + auto const& rp = sbs.m_ranked_points[i]; if (rp.rank == 0 || rp.direction == sort_by_side::dir_from) { continue; } - turn_operation_type const& op = operation_from_rank(rp); + auto const& out_op = operation_from_rank(rp); - if (op.operation != target_operation - && op.operation != operation_continue) + if (out_op.operation != target_operation + && out_op.operation != operation_continue) { continue; } - if (op.enriched.region_id == incoming_op.enriched.region_id - || (skip_isolated && ! op.enriched.isolated)) + if (in_op.enriched.region_id == out_op.enriched.region_id + || (is_intersection && ! out_op.enriched.isolated)) { // Region corresponds to incoming region, or (for intersection) // there is a non-isolated other region which should be taken @@ -660,7 +661,7 @@ public : int& op_index, sbs_type const& sbs, signed_size_type start_turn_index, int start_op_index) const { - sort_by_side::rank_type const selected_rank = select_rank(sbs, false); + sort_by_side::rank_type const selected_rank = select_rank(sbs); int current_priority = 0; for (std::size_t i = 1; i < sbs.m_ranked_points.size(); i++) @@ -688,49 +689,59 @@ public : inline bool analyze_cluster_intersection(signed_size_type& turn_index, int& op_index, sbs_type const& sbs) const { - sort_by_side::rank_type const selected_rank = select_rank(sbs, true); + // Select the rank based on regions and isolation + sort_by_side::rank_type const selected_rank = select_rank(sbs); - if (selected_rank > 0) + if (selected_rank <= 0) { - typename turn_operation_type::comparable_distance_type - min_remaining_distance = 0; + return false; + } - std::size_t selected_index = sbs.m_ranked_points.size(); - for (std::size_t i = 0; i < sbs.m_ranked_points.size(); i++) + // From these ranks, select the index: the first, or the one with + // the smallest remaining distance + typename turn_operation_type::comparable_distance_type + min_remaining_distance = 0; + + std::size_t selected_index = sbs.m_ranked_points.size(); + for (std::size_t i = 0; i < sbs.m_ranked_points.size(); i++) + { + auto const& ranked_point = sbs.m_ranked_points[i]; + + if (ranked_point.rank > selected_rank) { - typename sbs_type::rp const& ranked_point = sbs.m_ranked_points[i]; - - if (ranked_point.rank == selected_rank) - { - turn_operation_type const& op = operation_from_rank(ranked_point); - - if (op.visited.finalized()) - { - // This direction is already traveled before, the same - // cannot be traveled again - continue; - } - - // Take turn with the smallest remaining distance - if (selected_index == sbs.m_ranked_points.size() - || op.remaining_distance < min_remaining_distance) - { - selected_index = i; - min_remaining_distance = op.remaining_distance; - } - } + break; } - - if (selected_index < sbs.m_ranked_points.size()) + else if (ranked_point.rank == selected_rank) { - typename sbs_type::rp const& ranked_point = sbs.m_ranked_points[selected_index]; - turn_index = ranked_point.turn_index; - op_index = ranked_point.operation_index; - return true; + auto const& op = operation_from_rank(ranked_point); + + if (op.visited.finalized()) + { + // This direction is already traveled, + // it cannot be traveled again + continue; + } + + if (selected_index == sbs.m_ranked_points.size() + || op.remaining_distance < min_remaining_distance) + { + // It was unassigned or it is better + selected_index = i; + min_remaining_distance = op.remaining_distance; + } } } - return false; + if (selected_index == sbs.m_ranked_points.size()) + { + // Should not happen, there must be points with the selected rank + return false; + } + + auto const& ranked_point = sbs.m_ranked_points[selected_index]; + turn_index = ranked_point.turn_index; + op_index = ranked_point.operation_index; + return true; } inline bool fill_sbs(sbs_type& sbs, @@ -819,6 +830,7 @@ public : return result; } + // Analyzes a non-clustered "ii" intersection, as if it is clustered. inline bool analyze_ii_intersection(signed_size_type& turn_index, int& op_index, turn_type const& current_turn, segment_identifier const& previous_seg_id) diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp index ad248826d..be0f2bcd8 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp @@ -89,7 +89,6 @@ struct traversal_switch_detector enum isolation_type { - isolation_unknown = -1, isolation_no = 0, isolation_yes = 1, isolation_multiple = 2 @@ -121,7 +120,7 @@ struct traversal_switch_detector struct region_properties { signed_size_type region_id = -1; - isolation_type isolated = isolation_unknown; + isolation_type isolated = isolation_no; set_type unique_turn_ids; connection_map connected_region_counts; }; @@ -374,7 +373,7 @@ struct traversal_switch_detector { region_properties& properties = key_val.second; - if (properties.isolated == isolation_unknown + if (properties.isolated == isolation_no && has_only_isolated_children(properties)) { properties.isolated = isolation_yes; @@ -388,13 +387,36 @@ struct traversal_switch_detector { for (turn_type& turn : m_turns) { + // For difference, for the input walked through in reverse, + // the meaning is reversed: what is isolated is actually not, + // and vice versa. + bool const reverseMeaningInTurn + = (Reverse1 || Reverse2) + && ! turn.is_self() + && ! turn.is_clustered() + && uu_or_ii(turn) + && turn.operations[0].enriched.region_id + != turn.operations[1].enriched.region_id; + for (auto& op : turn.operations) { auto mit = m_connected_regions.find(op.enriched.region_id); if (mit != m_connected_regions.end()) { + bool const reverseMeaningInOp + = reverseMeaningInTurn + && ((op.seg_id.source_index == 0 && Reverse1) + || (op.seg_id.source_index == 1 && Reverse2)); + + // It is assigned to isolated if it's property is "Yes", + // (one connected interior, or chained). + // "Multiple" doesn't count for isolation, + // neither for intersection, neither for difference. region_properties const& prop = mit->second; - op.enriched.isolated = prop.isolated == isolation_yes; + op.enriched.isolated + = reverseMeaningInOp + ? false + : prop.isolated == isolation_yes; } } } @@ -478,8 +500,12 @@ struct traversal_switch_detector // Discarded turns don't connect rings to the same region // Also xx are not relevant // (otherwise discarded colocated uu turn could make a connection) - return ! turn.discarded - && ! turn.both(operation_blocked); + return ! turn.discarded && ! turn.both(operation_blocked); + } + + inline bool uu_or_ii(turn_type const& turn) const + { + return turn.both(operation_union) || turn.both(operation_intersection); } inline bool connects_same_region(turn_type const& turn) const @@ -492,7 +518,7 @@ struct traversal_switch_detector if (! turn.is_clustered()) { // If it is a uu/ii-turn (non clustered), it is never same region - return ! (turn.both(operation_union) || turn.both(operation_intersection)); + return ! uu_or_ii(turn); } if (BOOST_GEOMETRY_CONDITION(target_operation == operation_union)) @@ -565,10 +591,83 @@ struct traversal_switch_detector } } +#if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR) + void debug_show_results() + { + auto isolation_to_string = [](isolation_type const& iso) -> std::string + { + switch(iso) + { + case isolation_no : return "no"; + case isolation_yes : return "yes"; + case isolation_multiple : return "multiple"; + } + return "error"; + }; + auto set_to_string = [](auto const& s) -> std::string + { + std::ostringstream result; + for (auto item : s) { result << " " << item; } + return result.str(); + }; + + for (auto const& kv : m_connected_regions) + { + auto const& prop = kv.second; + + std::ostringstream sub; + sub << "[turns" << set_to_string(prop.unique_turn_ids) + << "] regions"; + for (auto const& kvs : prop.connected_region_counts) + { + sub << " { " << kvs.first + << " : via [" << set_to_string(kvs.second.unique_turn_ids) + << " ] }"; + } + + std::cout << "REGION " << prop.region_id + << " " << isolation_to_string(prop.isolated) + << " " << sub.str() + << std::endl; + } + + for (std::size_t turn_index = 0; turn_index < m_turns.size(); ++turn_index) + { + turn_type const& turn = m_turns[turn_index]; + + if (uu_or_ii(turn) && ! turn.is_clustered()) + { + std::cout << (turn.both(operation_union) ? "UU" : "II") + << " " << turn_index + << " (" << geometry::get<0>(turn.point) + << ", " << geometry::get<1>(turn.point) << ")" + << " -> " << std::boolalpha + << " [" << turn.operations[0].seg_id.source_index + << "/" << turn.operations[1].seg_id.source_index << "] " + << "(" << turn.operations[0].enriched.region_id + << " " << turn.operations[0].enriched.isolated + << ") / (" << turn.operations[1].enriched.region_id + << " " << turn.operations[1].enriched.isolated << ")" + << std::endl; + } + } + + for (auto const& key_val : m_clusters) + { + cluster_info const& cinfo = key_val.second; + std::cout << "CL RESULT " << key_val.first + << " -> " << cinfo.open_count << std::endl; + } + } +#endif + void iterate() { #if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR) - std::cout << "BEGIN SWITCH DETECTOR (region_ids and isolation)" << std::endl; + std::cout << "BEGIN SWITCH DETECTOR (region_ids and isolation)" + << (Reverse1 ? " REVERSE_1" : "") + << (Reverse2 ? " REVERSE_2" : "") + << std::endl; #endif // Collect turns per ring @@ -608,33 +707,7 @@ struct traversal_switch_detector #if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR) std::cout << "END SWITCH DETECTOR" << std::endl; - - for (std::size_t turn_index = 0; turn_index < m_turns.size(); ++turn_index) - { - turn_type const& turn = m_turns[turn_index]; - - if ((turn.both(operation_union) || turn.both(operation_intersection)) - && ! turn.is_clustered()) - { - std::cout << (turn.both(operation_union) ? "UU" : "II") - << " " << turn_index - << " (" << geometry::get<0>(turn.point) - << ", " << geometry::get<1>(turn.point) << ")" - << " -> " << std::boolalpha - << "(" << turn.operations[0].enriched.region_id - << " " << turn.operations[0].enriched.isolated - << ") / (" << turn.operations[1].enriched.region_id - << " " << turn.operations[1].enriched.isolated << ")" - << std::endl; - } - } - - for (auto const& key_val : m_clusters) - { - cluster_info const& cinfo = key_val.second; - std::cout << "CL RESULT " << key_val.first - << " -> " << cinfo.open_count << std::endl; - } + debug_show_results(); #endif } diff --git a/include/boost/geometry/algorithms/detail/overlay/turn_info.hpp b/include/boost/geometry/algorithms/detail/overlay/turn_info.hpp index 7dcbf4c8e..08cb516cf 100644 --- a/include/boost/geometry/algorithms/detail/overlay/turn_info.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/turn_info.hpp @@ -138,6 +138,11 @@ struct turn_info { return cluster_id > 0; } + inline bool is_self() const + { + return operations[0].seg_id.source_index + == operations[1].seg_id.source_index; + } private : inline bool has12(operation_type type1, operation_type type2) const diff --git a/include/boost/geometry/algorithms/detail/sections/section_functions.hpp b/include/boost/geometry/algorithms/detail/sections/section_functions.hpp index 44fb4665b..abc6de409 100644 --- a/include/boost/geometry/algorithms/detail/sections/section_functions.hpp +++ b/include/boost/geometry/algorithms/detail/sections/section_functions.hpp @@ -2,9 +2,8 @@ // Copyright (c) 2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2015, 2017, 2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. - +// This file was modified by Oracle on 2015-2021. +// Modifications copyright (c) 2015-2021, 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, @@ -132,9 +131,11 @@ static inline bool preceding(int dir, RobustPolicy const& robust_policy) { typename geometry::robust_point_type::type robust_point; - assert_coordinate_type_equal(robust_point, point_box); geometry::recalculate(robust_point, point, robust_policy); + // After recalculate() to prevent warning: 'robust_point' may be used uninitialized + assert_coordinate_type_equal(robust_point, point_box); + return preceding_check::apply(dir, robust_point, point_box, other_box); diff --git a/include/boost/geometry/algorithms/detail/visit.hpp b/include/boost/geometry/algorithms/detail/visit.hpp index 60958f4b4..bbc2f4e86 100644 --- a/include/boost/geometry/algorithms/detail/visit.hpp +++ b/include/boost/geometry/algorithms/detail/visit.hpp @@ -217,7 +217,8 @@ struct visit_breadth_first bool result = true; traits::iter_visit>::apply([&](auto && g) { - result = visit_or_enqueue(function, std::forward(g), queue, it); + result = visit_breadth_first::visit_or_enqueue( + function, std::forward(g), queue, it); }, it); if (! result) @@ -235,7 +236,7 @@ struct visit_breadth_first // so this call can be avoided. traits::iter_visit>::apply([&](auto && g) { - set_iterators(std::forward(g), it, end); + visit_breadth_first::set_iterators(std::forward(g), it, end); }, queue.front()); queue.pop_front(); } diff --git a/include/boost/geometry/algorithms/difference.hpp b/include/boost/geometry/algorithms/difference.hpp index 64df80e77..2155b9e54 100644 --- a/include/boost/geometry/algorithms/difference.hpp +++ b/include/boost/geometry/algorithms/difference.hpp @@ -161,10 +161,10 @@ struct call_intersection_insert typename Strategy > static inline OutputIterator apply(Geometry1 const& geometry1, - Geometry2 const& geometry2, - RobustPolicy const& robust_policy, + Geometry2 const& , + RobustPolicy const& , OutputIterator out, - Strategy const& strategy) + Strategy const& ) { base_t::access::get(out) = geometry::detail::convert_to_output < diff --git a/include/boost/geometry/algorithms/line_interpolate.hpp b/include/boost/geometry/algorithms/line_interpolate.hpp index 05a55a7c2..a3b4b2ba8 100644 --- a/include/boost/geometry/algorithms/line_interpolate.hpp +++ b/include/boost/geometry/algorithms/line_interpolate.hpp @@ -1,7 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2018-2021 Oracle and/or its affiliates. - // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -19,6 +18,8 @@ #include #include #include +#include +#include #include #include diff --git a/include/boost/geometry/core/config.hpp b/include/boost/geometry/core/config.hpp index 1c6fab8e0..3066586c4 100644 --- a/include/boost/geometry/core/config.hpp +++ b/include/boost/geometry/core/config.hpp @@ -1,6 +1,6 @@ // Boost.Geometry -// Copyright (c) 2019 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2019-2021 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2018-2020 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -23,10 +23,6 @@ #define BOOST_GEOMETRY_CXX11_TUPLE #endif -// Defining this selects Kramer rule for segment-intersection -// That is default behaviour. -#define BOOST_GEOMETRY_USE_KRAMER_RULE - // Rescaling is turned on, unless NO_ROBUSTNESS is defined // In future versions of Boost.Geometry, it will be turned off by default #if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS) diff --git a/include/boost/geometry/formulas/interpolate_point_spherical.hpp b/include/boost/geometry/formulas/interpolate_point_spherical.hpp index 7141a5a9f..2e712d44c 100644 --- a/include/boost/geometry/formulas/interpolate_point_spherical.hpp +++ b/include/boost/geometry/formulas/interpolate_point_spherical.hpp @@ -1,6 +1,6 @@ // Boost.Geometry -// Copyright (c) 2019 Oracle and/or its affiliates. +// Copyright (c) 2019-2021 Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -12,6 +12,9 @@ #ifndef BOOST_GEOMETRY_FORMULAS_INTERPOLATE_POINT_SPHERICAL_HPP #define BOOST_GEOMETRY_FORMULAS_INTERPOLATE_POINT_SPHERICAL_HPP +#include +#include + namespace boost { namespace geometry { namespace formula { diff --git a/include/boost/geometry/formulas/karney_inverse.hpp b/include/boost/geometry/formulas/karney_inverse.hpp index b6b17a8e8..936fbe22c 100644 --- a/include/boost/geometry/formulas/karney_inverse.hpp +++ b/include/boost/geometry/formulas/karney_inverse.hpp @@ -36,6 +36,7 @@ #include #include +#include #include #include @@ -51,16 +52,20 @@ namespace boost { namespace geometry { namespace math { template inline T difference_angle(T const& x, T const& y, T& e) { - T t, d = math::sum_error(std::remainder(-x, T(360)), std::remainder(y, T(360)), t); + auto res1 = boost::geometry::detail::precise_math::two_sum( + std::remainder(-x, T(360)), std::remainder(y, T(360))); - normalize_azimuth(d); + normalize_azimuth(res1[0]); // Here y - x = d + t (mod 360), exactly, where d is in (-180,180] and // abs(t) <= eps (eps = 2^-45 for doubles). The only case where the // addition of t takes the result outside the range (-180,180] is d = 180 // and t > 0. The case, d = -180 + eps, t = -eps, can't happen, since // sum_error would have returned the exact result in such a case (i.e., given t = 0). - return math::sum_error(d == 180 && t > 0 ? -180 : d, t, e); + auto res2 = boost::geometry::detail::precise_math::two_sum( + res1[0] == 180 && res1[1] > 0 ? -180 : res1[0], res1[1]); + e = res2[1]; + return res2[0]; } }}} // namespace boost::geometry::math diff --git a/include/boost/geometry/index/detail/algorithms/bounds.hpp b/include/boost/geometry/index/detail/algorithms/bounds.hpp index 1828a2467..999246d9c 100644 --- a/include/boost/geometry/index/detail/algorithms/bounds.hpp +++ b/include/boost/geometry/index/detail/algorithms/bounds.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -15,6 +15,11 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP +#include +#include +#include +#include + #include namespace boost { namespace geometry { namespace index { namespace detail diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp index c4e44cae1..6afe03eec 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_centroid.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,6 +15,9 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_CENTROID_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_CENTROID_HPP +#include +#include + #include #include diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp index 214fbf6aa..102ac545e 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_far.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,6 +15,9 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_FAR_HPP +#include +#include + #include #include diff --git a/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp b/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp index 15368a7d2..4f2905f3a 100644 --- a/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp +++ b/include/boost/geometry/index/detail/algorithms/comparable_distance_near.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,6 +15,9 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_NEAR_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_COMPARABLE_DISTANCE_NEAR_HPP +#include +#include + #include namespace boost { namespace geometry { namespace index { namespace detail { diff --git a/include/boost/geometry/index/detail/algorithms/content.hpp b/include/boost/geometry/index/detail/algorithms/content.hpp index 7833ae377..d698a3208 100644 --- a/include/boost/geometry/index/detail/algorithms/content.hpp +++ b/include/boost/geometry/index/detail/algorithms/content.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2020. -// Modifications copyright (c) 2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2020-2021. +// Modifications copyright (c) 2020-2021 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, @@ -15,7 +15,12 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_CONTENT_HPP +#include +#include #include +#include +#include +#include namespace boost { namespace geometry { namespace index { namespace detail { diff --git a/include/boost/geometry/index/detail/algorithms/intersection_content.hpp b/include/boost/geometry/index/detail/algorithms/intersection_content.hpp index 880540bc0..1a2cd28bc 100644 --- a/include/boost/geometry/index/detail/algorithms/intersection_content.hpp +++ b/include/boost/geometry/index/detail/algorithms/intersection_content.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -20,6 +20,9 @@ #include +#include +#include + namespace boost { namespace geometry { namespace index { namespace detail { // Util to distinguish between default and non-default index strategy diff --git a/include/boost/geometry/index/detail/algorithms/is_valid.hpp b/include/boost/geometry/index/detail/algorithms/is_valid.hpp index 0d57ed57e..5cd241c29 100644 --- a/include/boost/geometry/index/detail/algorithms/is_valid.hpp +++ b/include/boost/geometry/index/detail/algorithms/is_valid.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2020. -// Modifications copyright (c) 2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2020-2021. +// Modifications copyright (c) 2020-2021 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, @@ -18,6 +18,7 @@ #include #include +#include #include namespace boost { namespace geometry { namespace index { namespace detail { diff --git a/include/boost/geometry/index/detail/algorithms/margin.hpp b/include/boost/geometry/index/detail/algorithms/margin.hpp index 2033f4a53..5a05d3c02 100644 --- a/include/boost/geometry/index/detail/algorithms/margin.hpp +++ b/include/boost/geometry/index/detail/algorithms/margin.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2020. -// Modifications copyright (c) 2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2020-2021. +// Modifications copyright (c) 2020-2021 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, @@ -15,7 +15,12 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_MARGIN_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_MARGIN_HPP +#include +#include #include +#include +#include +#include // WARNING! comparable_margin() will work only if the same Geometries are compared // so it shouldn't be used in the case of Variants! diff --git a/include/boost/geometry/index/detail/algorithms/path_intersection.hpp b/include/boost/geometry/index/detail/algorithms/path_intersection.hpp index 4803f5914..ab0860349 100644 --- a/include/boost/geometry/index/detail/algorithms/path_intersection.hpp +++ b/include/boost/geometry/index/detail/algorithms/path_intersection.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2017 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2020. -// Modifications copyright (c) 2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2020-2021. +// Modifications copyright (c) 2020-2021 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, @@ -20,6 +20,7 @@ #include +#include #include diff --git a/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp b/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp index a2717d26e..674d9f5f8 100644 --- a/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp +++ b/include/boost/geometry/index/detail/algorithms/segment_intersection.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2020. -// Modifications copyright (c) 2020, Oracle and/or its affiliates. +// This file was modified by Oracle on 2020-2021. +// Modifications copyright (c) 2020-2021, 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, @@ -15,9 +15,14 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_SEGMENT_INTERSECTION_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_SEGMENT_INTERSECTION_HPP +#include #include +#include +#include #include +#include +#include namespace boost { namespace geometry { namespace index { namespace detail { diff --git a/include/boost/geometry/index/detail/distance_predicates.hpp b/include/boost/geometry/index/detail/distance_predicates.hpp index dcd8d1243..69ce45633 100644 --- a/include/boost/geometry/index/detail/distance_predicates.hpp +++ b/include/boost/geometry/index/detail/distance_predicates.hpp @@ -5,8 +5,8 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -22,7 +22,7 @@ #include #include #include - +#include #include namespace boost { namespace geometry { namespace index { namespace detail { diff --git a/include/boost/geometry/index/detail/predicates.hpp b/include/boost/geometry/index/detail/predicates.hpp index 08bc18e15..c1a8b73c4 100644 --- a/include/boost/geometry/index/detail/predicates.hpp +++ b/include/boost/geometry/index/detail/predicates.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -20,9 +20,13 @@ //#include #include +#include +#include #include +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace predicates { @@ -31,10 +35,10 @@ namespace predicates { // predicates // ------------------------------------------------------------------ // -template +template ::value> struct satisfies_impl { - satisfies_impl() : fun(NULL) {} + satisfies_impl() : fun(nullptr) {} satisfies_impl(Fun f) : fun(f) {} Fun * fun; }; @@ -42,20 +46,19 @@ struct satisfies_impl template struct satisfies_impl { - satisfies_impl() {} + satisfies_impl() = default; satisfies_impl(Fun const& f) : fun(f) {} Fun fun; }; template -struct satisfies - : satisfies_impl::value> +struct satisfies : satisfies_impl { - typedef satisfies_impl::value> base; + using base_t = satisfies_impl; - satisfies() {} - satisfies(Fun const& f) : base(f) {} - satisfies(base const& b) : base(b) {} + satisfies() = default; + satisfies(Fun const& f) : base_t(f) {} + satisfies(base_t const& b) : base_t(b) {} }; // ------------------------------------------------------------------ // @@ -91,12 +94,12 @@ struct nearest nearest() // : count(0) {} - nearest(PointOrRelation const& por, unsigned k) + nearest(PointOrRelation const& por, std::size_t k) : point_or_relation(por) , count(k) {} PointOrRelation point_or_relation; - unsigned count; + std::size_t count; }; template @@ -105,12 +108,12 @@ struct path path() // : count(0) {} - path(SegmentOrLinestring const& g, unsigned k) + path(SegmentOrLinestring const& g, std::size_t k) : geometry(g) , count(k) {} SegmentOrLinestring geometry; - unsigned count; + std::size_t count; }; } // namespace predicates @@ -520,31 +523,31 @@ struct predicate_check, bounds_tag> template struct predicates_length { - static const unsigned value = 1; + static const std::size_t value = 1; }; template struct predicates_length> { - static const unsigned value = std::tuple_size>::value; + static const std::size_t value = std::tuple_size>::value; }; // ------------------------------------------------------------------ // // predicates_element // ------------------------------------------------------------------ // -template +template struct predicates_element { BOOST_GEOMETRY_STATIC_ASSERT((I < 1), "Invalid I index.", - std::integral_constant); + std::integral_constant); typedef T type; static type const& get(T const& p) { return p; } }; -template +template struct predicates_element> { typedef std::tuple predicate_type; @@ -557,7 +560,7 @@ struct predicates_element> // predicates_check // ------------------------------------------------------------------ // -template +template struct predicates_check_tuple { template @@ -572,7 +575,7 @@ struct predicates_check_tuple } }; -template +template struct predicates_check_tuple { template @@ -582,13 +585,13 @@ struct predicates_check_tuple } }; -template +template struct predicates_check_impl { static const bool check = First < 1 && Last <= 1 && First <= Last; BOOST_GEOMETRY_STATIC_ASSERT((check), "Invalid First or Last index.", - std::integer_sequence); + std::integer_sequence); template static inline bool apply(Predicate const& p, Value const& v, Indexable const& i, Strategy const& s) @@ -597,16 +600,16 @@ struct predicates_check_impl } }; -template +template struct predicates_check_impl, Tag, First, Last> { typedef std::tuple predicates_type; - static const unsigned pred_len = std::tuple_size::value; + static const std::size_t pred_len = std::tuple_size::value; static const bool check = First < pred_len && Last <= pred_len && First <= Last; BOOST_GEOMETRY_STATIC_ASSERT((check), "Invalid First or Last index.", - std::integer_sequence); + std::integer_sequence); template static inline bool apply(predicates_type const& p, Value const& v, Indexable const& i, Strategy const& s) @@ -619,7 +622,7 @@ struct predicates_check_impl, Tag, First, Last> } }; -template +template inline bool predicates_check(Predicates const& p, Value const& v, Indexable const& i, Strategy const& s) { return detail::predicates_check_impl @@ -635,19 +638,19 @@ inline bool predicates_check(Predicates const& p, Value const& v, Indexable cons template struct predicates_is_distance { - static const unsigned value = 0; + static const std::size_t value = 0; }; template struct predicates_is_distance< predicates::nearest > { - static const unsigned value = 1; + static const std::size_t value = 1; }; template struct predicates_is_distance< predicates::path > { - static const unsigned value = 1; + static const std::size_t value = 1; }; // predicates_count_nearest @@ -655,13 +658,13 @@ struct predicates_is_distance< predicates::path > template struct predicates_count_distance { - static const unsigned value = predicates_is_distance::value; + static const std::size_t value = predicates_is_distance::value; }; -template +template struct predicates_count_distance_tuple { - static const unsigned value = + static const std::size_t value = predicates_is_distance::type>::value + predicates_count_distance_tuple::value; }; @@ -669,14 +672,14 @@ struct predicates_count_distance_tuple template struct predicates_count_distance_tuple { - static const unsigned value = + static const std::size_t value = predicates_is_distance::type>::value; }; template struct predicates_count_distance> { - static const unsigned value = predicates_count_distance_tuple< + static const std::size_t value = predicates_count_distance_tuple< std::tuple, std::tuple_size>::value >::value; @@ -687,16 +690,16 @@ struct predicates_count_distance> template struct predicates_find_distance { - static const unsigned value = predicates_is_distance::value ? 0 : 1; + static const std::size_t value = predicates_is_distance::value ? 0 : 1; }; -template +template struct predicates_find_distance_tuple { static const bool is_found = predicates_find_distance_tuple::is_found || predicates_is_distance::type>::value; - static const unsigned value = predicates_find_distance_tuple::is_found ? + static const std::size_t value = predicates_find_distance_tuple::is_found ? predicates_find_distance_tuple::value : (predicates_is_distance::type>::value ? N-1 : std::tuple_size::value); @@ -706,13 +709,13 @@ template struct predicates_find_distance_tuple { static const bool is_found = predicates_is_distance::type>::value; - static const unsigned value = is_found ? 0 : std::tuple_size::value; + static const std::size_t value = is_found ? 0 : std::tuple_size::value; }; template struct predicates_find_distance> { - static const unsigned value = predicates_find_distance_tuple< + static const std::size_t value = predicates_find_distance_tuple< std::tuple, std::tuple_size>::value >::value; diff --git a/include/boost/geometry/index/detail/rtree/adaptors.hpp b/include/boost/geometry/index/detail/rtree/adaptors.hpp index 4e0eb9ba0..4da3d7b94 100644 --- a/include/boost/geometry/index/detail/rtree/adaptors.hpp +++ b/include/boost/geometry/index/detail/rtree/adaptors.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,13 +15,13 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ADAPTORS_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ADAPTORS_HPP -#include -#include +#include #include namespace boost { namespace geometry { namespace index { +// Forward declaration template class rtree; diff --git a/include/boost/geometry/index/detail/rtree/iterators.hpp b/include/boost/geometry/index/detail/rtree/iterators.hpp index a47dd7ea4..1d5cd1a23 100644 --- a/include/boost/geometry/index/detail/rtree/iterators.hpp +++ b/include/boost/geometry/index/detail/rtree/iterators.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,6 +15,10 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ITERATORS_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_ITERATORS_HPP +#include + +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace iterators { template diff --git a/include/boost/geometry/index/detail/rtree/kmeans/kmeans.hpp b/include/boost/geometry/index/detail/rtree/kmeans/kmeans.hpp index 3f61482b2..34edcfa7c 100644 --- a/include/boost/geometry/index/detail/rtree/kmeans/kmeans.hpp +++ b/include/boost/geometry/index/detail/rtree/kmeans/kmeans.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,6 +15,6 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_KMEANS_KMEANS_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_KMEANS_KMEANS_HPP -#include +#include #endif // BOOST_GEOMETRY_INDEX_DETAIL_RTREE_KMEANS_KMEANS_HPP diff --git a/include/boost/geometry/index/detail/rtree/kmeans/split.hpp b/include/boost/geometry/index/detail/rtree/kmeans/split.hpp index f19654972..aa9dfbba4 100644 --- a/include/boost/geometry/index/detail/rtree/kmeans/split.hpp +++ b/include/boost/geometry/index/detail/rtree/kmeans/split.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,13 +15,17 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_KMEANS_SPLIT_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_KMEANS_SPLIT_HPP -#include -#include +#include +#include namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { +// TODO: This should be defined in options.hpp +// For now it's defined here to satisfy Boost header policy +struct split_kmeans_tag {}; + namespace kmeans { // some details @@ -56,25 +64,34 @@ namespace kmeans { // 4. Pamietac o parametryzacji kontenera z nadmiarowymi elementami // PS. Z R* reinsertami moze byc masakra -template -class split +template +class split { protected: - typedef typename rtree::node::type node; - typedef typename rtree::internal_node::type internal_node; - typedef typename rtree::leaf::type leaf; + typedef typename MembersHolder::parameters_type parameters_type; + typedef typename MembersHolder::box_type box_type; + typedef typename MembersHolder::translator_type translator_type; + typedef typename MembersHolder::allocators_type allocators_type; + typedef typename MembersHolder::size_type size_type; - typedef typename Options::parameters_type parameters_type; + typedef typename MembersHolder::node node; + typedef typename MembersHolder::internal_node internal_node; + typedef typename MembersHolder::leaf leaf; public: + typedef index::detail::varray + < + typename rtree::elements_type::type::value_type, + 1 + > nodes_container_type; + template - static inline void apply(node* & root_node, - size_t & leafs_level, + static inline void apply(nodes_container_type & additional_nodes, Node & n, - internal_node *parent_node, - size_t current_child_index, - Translator const& tr, - Allocators & allocators) + box_type & n_box, + parameters_type const& parameters, + translator_type const& translator, + allocators_type & allocators) { } diff --git a/include/boost/geometry/index/detail/rtree/node/node_elements.hpp b/include/boost/geometry/index/detail/rtree/node/node_elements.hpp index 0e5848987..ca034a8d7 100644 --- a/include/boost/geometry/index/detail/rtree/node/node_elements.hpp +++ b/include/boost/geometry/index/detail/rtree/node/node_elements.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -15,6 +19,7 @@ #include #include #include +#include namespace boost { namespace geometry { namespace index { diff --git a/include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp b/include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp index 0062402d4..a63aad884 100644 --- a/include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp +++ b/include/boost/geometry/index/detail/rtree/node/scoped_deallocator.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,6 +15,8 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_SCOPED_DEALLOCATOR_HPP +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { diff --git a/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp b/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp index 52b253ccf..e871e6f19 100644 --- a/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp +++ b/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,7 +15,15 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_DYNAMIC_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_DYNAMIC_HPP +#include +#include #include +#include +#include + +#include +#include +#include namespace boost { namespace geometry { namespace index { diff --git a/include/boost/geometry/index/detail/rtree/node/variant_static.hpp b/include/boost/geometry/index/detail/rtree/node/variant_static.hpp index c30998d68..624ce472e 100644 --- a/include/boost/geometry/index/detail/rtree/node/variant_static.hpp +++ b/include/boost/geometry/index/detail/rtree/node/variant_static.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,6 +15,9 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP +#include +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { diff --git a/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp b/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp index eadda62a9..9a3220183 100644 --- a/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp +++ b/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,10 +15,24 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_DYNAMIC_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_DYNAMIC_HPP +#include +#include +#include + +#include +#include +#include +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { +// TODO: This should be defined in options.hpp +// For now it's defined here to satisfy Boost header policy +struct node_weak_dynamic_tag {}; +struct node_weak_static_tag {}; + template struct weak_internal_node : public weak_node @@ -87,7 +105,7 @@ struct visitor struct internal_node_alloc { - typedef typename internal_nod + typedef typename internal_node < Value, Parameters, Box, allocators, @@ -116,6 +134,22 @@ struct leaf_alloc >::template rebind_alloc type; }; +template +struct node_alloc +{ + typedef typename weak_node + < + Value, Parameters, Box, + allocators, + Tag + >::type node_type; + + typedef typename ::boost::container::allocator_traits + < + Allocator + >::template rebind_alloc type; +}; + template class allocators : public internal_node_alloc::type diff --git a/include/boost/geometry/index/detail/rtree/node/weak_static.hpp b/include/boost/geometry/index/detail/rtree/node/weak_static.hpp index ac9e69cec..65b80266d 100644 --- a/include/boost/geometry/index/detail/rtree/node/weak_static.hpp +++ b/include/boost/geometry/index/detail/rtree/node/weak_static.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,6 +15,9 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP +#include +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { diff --git a/include/boost/geometry/index/detail/rtree/node/weak_visitor.hpp b/include/boost/geometry/index/detail/rtree/node/weak_visitor.hpp index 08d84778e..a6beaf090 100644 --- a/include/boost/geometry/index/detail/rtree/node/weak_visitor.hpp +++ b/include/boost/geometry/index/detail/rtree/node/weak_visitor.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,6 +15,8 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_VISITOR_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_VISITOR_HPP +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { diff --git a/include/boost/geometry/index/detail/rtree/pack_create.hpp b/include/boost/geometry/index/detail/rtree/pack_create.hpp index 4cfd39669..6a8ffe6aa 100644 --- a/include/boost/geometry/index/detail/rtree/pack_create.hpp +++ b/include/boost/geometry/index/detail/rtree/pack_create.hpp @@ -5,8 +5,8 @@ // Copyright (c) 2011-2017 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2020 Caian Benedicto, Campinas, Brazil. // -// This file was modified by Oracle on 2019. -// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -18,12 +18,15 @@ #include +#include #include + +#include #include #include +#include #include - -#include +#include namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { diff --git a/include/boost/geometry/index/detail/rtree/query_iterators.hpp b/include/boost/geometry/index/detail/rtree/query_iterators.hpp index 8822bcf04..3ca0bafdf 100644 --- a/include/boost/geometry/index/detail/rtree/query_iterators.hpp +++ b/include/boost/geometry/index/detail/rtree/query_iterators.hpp @@ -4,8 +4,8 @@ // // 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. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -17,6 +17,10 @@ #include +#include +#include +#include + //#define BOOST_GEOMETRY_INDEX_DETAIL_QUERY_ITERATORS_USE_MOVE namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace iterators { diff --git a/include/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp b/include/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp index 7ba5f0f99..4ea9060f8 100644 --- a/include/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp +++ b/include/boost/geometry/index/detail/rtree/rstar/choose_next_node.hpp @@ -4,8 +4,8 @@ // // 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. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -27,6 +27,8 @@ #include #include +#include +#include #include namespace boost { namespace geometry { namespace index { diff --git a/include/boost/geometry/index/detail/rtree/rstar/insert.hpp b/include/boost/geometry/index/detail/rtree/rstar/insert.hpp index 8517b7f1b..ce830007a 100644 --- a/include/boost/geometry/index/detail/rtree/rstar/insert.hpp +++ b/include/boost/geometry/index/detail/rtree/rstar/insert.hpp @@ -19,7 +19,12 @@ #include +#include + #include +#include +#include +#include namespace boost { namespace geometry { namespace index { diff --git a/include/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp b/include/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp index bdabebf22..44933dac4 100644 --- a/include/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp +++ b/include/boost/geometry/index/detail/rtree/utilities/gl_draw.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -15,7 +15,16 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_GL_DRAW_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_UTILITIES_GL_DRAW_HPP +#include + +#include +#include +#include #include +#include +#include + +#include namespace boost { namespace geometry { namespace index { namespace detail { diff --git a/include/boost/geometry/index/detail/rtree/utilities/print.hpp b/include/boost/geometry/index/detail/rtree/utilities/print.hpp index 2ed71a6b8..15d618eb6 100644 --- a/include/boost/geometry/index/detail/rtree/utilities/print.hpp +++ b/include/boost/geometry/index/detail/rtree/utilities/print.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -17,7 +17,11 @@ #include +#include +#include #include +#include +#include namespace boost { namespace geometry { namespace index { namespace detail { diff --git a/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp b/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp index edf47f90b..ede7b346e 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/distance_query.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019. -// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -15,10 +15,38 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_DISTANCE_QUERY_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_DISTANCE_QUERY_HPP +#include +#include +#include +#include +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { + +struct pair_first_less +{ + template + inline bool operator()(std::pair const& p1, + std::pair const& p2) const + { + return p1.first < p2.first; + } +}; + +struct pair_first_greater +{ + template + inline bool operator()(std::pair const& p1, + std::pair const& p2) const + { + return p1.first > p2.first; + } +}; + + template class distance_query_result { @@ -40,16 +68,16 @@ public: m_neighbors.push_back(std::make_pair(curr_comp_dist, val)); if ( m_neighbors.size() == m_count ) - std::make_heap(m_neighbors.begin(), m_neighbors.end(), neighbors_less); + std::make_heap(m_neighbors.begin(), m_neighbors.end(), pair_first_less()); } else { if ( curr_comp_dist < m_neighbors.front().first ) { - std::pop_heap(m_neighbors.begin(), m_neighbors.end(), neighbors_less); + std::pop_heap(m_neighbors.begin(), m_neighbors.end(), pair_first_less()); m_neighbors.back().first = curr_comp_dist; m_neighbors.back().second = val; - std::push_heap(m_neighbors.begin(), m_neighbors.end(), neighbors_less); + std::push_heap(m_neighbors.begin(), m_neighbors.end(), pair_first_less()); } } } @@ -80,13 +108,6 @@ public: } private: - inline static bool neighbors_less( - std::pair const& p1, - std::pair const& p2) - { - return p1.first < p2.first; - } - size_t m_count; OutIt m_out_it; @@ -97,7 +118,7 @@ template < typename MembersHolder, typename Predicates, - unsigned DistancePredicateIndex, + std::size_t DistancePredicateIndex, typename OutIter > class distance_query @@ -125,7 +146,7 @@ public: typedef typename calculate_value_distance::result_type value_distance_type; typedef typename calculate_node_distance::result_type node_distance_type; - static const unsigned predicates_len = index::detail::predicates_length::value; + static const std::size_t predicates_len = index::detail::predicates_length::value; inline distance_query(parameters_type const& parameters, translator_type const& translator, Predicates const& pred, OutIter out_it) : m_parameters(parameters), m_translator(translator) @@ -186,7 +207,7 @@ public: return; // sort array - std::sort(active_branch_list.begin(), active_branch_list.end(), abl_less); + std::sort(active_branch_list.begin(), active_branch_list.end(), pair_first_less()); // recursively visit nodes for ( typename active_branch_list_type::const_iterator it = active_branch_list.begin(); @@ -209,7 +230,7 @@ public: // from the copying of the whole containers on resize of the ABLs container //// make a heap - //std::make_heap(active_branch_list.begin(), active_branch_list.end(), abl_greater); + //std::make_heap(active_branch_list.begin(), active_branch_list.end(), pair_first_greater()); //// recursively visit nodes //while ( !active_branch_list.empty() ) @@ -223,7 +244,7 @@ public: // rtree::apply_visitor(*this, *(active_branch_list.front().second)); - // std::pop_heap(active_branch_list.begin(), active_branch_list.end(), abl_greater); + // std::pop_heap(active_branch_list.begin(), active_branch_list.end(), pair_first_greater()); // active_branch_list.pop_back(); //} } @@ -262,20 +283,6 @@ public: } private: - static inline bool abl_less( - std::pair const& p1, - std::pair const& p2) - { - return p1.first < p2.first; - } - - //static inline bool abl_greater( - // std::pair const& p1, - // std::pair const& p2) - //{ - // return p1.first > p2.first; - //} - template static inline bool is_node_prunable(Distance const& greatest_dist, node_distance_type const& d) { @@ -299,7 +306,7 @@ private: template < typename MembersHolder, typename Predicates, - unsigned DistancePredicateIndex + std::size_t DistancePredicateIndex > class distance_query_incremental : public MembersHolder::visitor_const @@ -330,38 +337,19 @@ public: typedef typename allocators_type::const_reference const_reference; typedef typename allocators_type::node_pointer node_pointer; - static const unsigned predicates_len = index::detail::predicates_length::value; + static const std::size_t predicates_len = index::detail::predicates_length::value; typedef typename rtree::elements_type::type internal_elements; typedef typename internal_elements::const_iterator internal_iterator; typedef typename rtree::elements_type::type leaf_elements; typedef std::pair branch_data; - typedef typename index::detail::rtree::container_from_elements_type< - internal_elements, branch_data - >::type active_branch_list_type; - struct internal_stack_element - { - internal_stack_element() : current_branch(0) {} -#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES - // Required in c++03 for containers using Boost.Move - internal_stack_element & operator=(internal_stack_element const& o) - { - branches = o.branches; - current_branch = o.current_branch; - return *this; - } -#endif - active_branch_list_type branches; - typename active_branch_list_type::size_type current_branch; - }; - typedef std::vector internal_stack_type; + typedef std::vector internal_heap_type; inline distance_query_incremental() : m_translator(NULL) // , m_pred() , current_neighbor((std::numeric_limits::max)()) -// , next_closest_node_distance((std::numeric_limits::max)()) // , m_strategy_type() {} @@ -369,7 +357,6 @@ public: : m_translator(::boost::addressof(translator)) , m_pred(pred) , current_neighbor((std::numeric_limits::max)()) - , next_closest_node_distance((std::numeric_limits::max)()) , m_strategy(index::detail::get_strategy(params)) { BOOST_GEOMETRY_INDEX_ASSERT(0 < max_count(), "k must be greather than 0"); @@ -392,7 +379,7 @@ public: { size_type new_neighbor = current_neighbor == (std::numeric_limits::max)() ? 0 : current_neighbor + 1; - if ( internal_stack.empty() ) + if ( internal_heap.empty() ) { if ( new_neighbor < neighbors.size() ) current_neighbor = new_neighbor; @@ -407,41 +394,33 @@ public: } else { - active_branch_list_type & branches = internal_stack.back().branches; - typename active_branch_list_type::size_type & current_branch = internal_stack.back().current_branch; - - if ( branches.size() <= current_branch ) - { - internal_stack.pop_back(); - continue; - } + branch_data const& closest_branch = internal_heap.front(); + node_distance_type const& closest_distance = closest_branch.first; // if there are no nodes which can have closer values, set new value if ( new_neighbor < neighbors.size() && - // here must be < because otherwise neighbours may be sorted in different order - // if there is another value with equal distance - neighbors[new_neighbor].first < next_closest_node_distance ) + // NOTE: In order to use <= current neighbor can't be sorted again + neighbors[new_neighbor].first <= closest_distance ) { current_neighbor = new_neighbor; return; } - // if node is further than the furthest neighbour, following nodes also will be further - BOOST_GEOMETRY_INDEX_ASSERT(neighbors.size() <= max_count(), "unexpected neighbours count"); + // if node is further than the furthest neighbor, following nodes will also be further + BOOST_GEOMETRY_INDEX_ASSERT(neighbors.size() <= max_count(), "unexpected neighbors count"); if ( max_count() <= neighbors.size() && - is_node_prunable(neighbors.back().first, branches[current_branch].first) ) + neighbors.back().first <= closest_distance ) { - // stop traversing current level - internal_stack.pop_back(); + internal_heap.clear(); continue; } else { - // new level - must increment current_branch before traversing of another level (mem reallocation) - ++current_branch; - rtree::apply_visitor(*this, *(branches[current_branch - 1].second)); + node_pointer ptr = closest_branch.second; + std::pop_heap(internal_heap.begin(), internal_heap.end(), pair_first_greater()); + internal_heap.pop_back(); - next_closest_node_distance = calc_closest_node_distance(internal_stack.begin(), internal_stack.end()); + rtree::apply_visitor(*this, *ptr); } } } @@ -470,9 +449,6 @@ public: typedef typename rtree::elements_type::type elements_type; elements_type const& elements = rtree::elements(n); - // add new element - internal_stack.resize(internal_stack.size()+1); - // fill active branch list array of nodes meeting predicates for ( typename elements_type::const_iterator it = elements.begin() ; it != elements.end() ; ++it ) { @@ -494,21 +470,16 @@ public: // if current node is further than found neighbors - don't analyze it if ( max_count() <= neighbors.size() && - is_node_prunable(neighbors.back().first, node_distance) ) + neighbors.back().first <= node_distance ) { continue; } - // add current node's data into the list - internal_stack.back().branches.push_back( std::make_pair(node_distance, it->second) ); + // add current node's data into the queue + internal_heap.push_back(std::make_pair(node_distance, it->second)); + std::push_heap(internal_heap.begin(), internal_heap.end(), pair_first_greater()); } } - - if ( internal_stack.back().branches.empty() ) - internal_stack.pop_back(); - else - // sort array - std::sort(internal_stack.back().branches.begin(), internal_stack.back().branches.end(), abl_less); } // Put values into the list of neighbours if those values meets predicates @@ -547,50 +518,22 @@ public: } } + // TODO: sort is probably suboptimal. + // An alternative would be std::set, but it'd probably add constant cost. + // Ideally replace this with double-ended priority queue, e.g. min-max heap. + // NOTE: A condition in increment() relies on the fact that current neighbor doesn't + // participate in sorting anymore. + // sort array - std::sort(neighbors.begin(), neighbors.end(), neighbors_less); + size_type sort_first = current_neighbor == (std::numeric_limits::max)() ? 0 : current_neighbor + 1; + std::sort(neighbors.begin() + sort_first, neighbors.end(), pair_first_less()); // remove furthest values if ( max_count() < neighbors.size() ) neighbors.resize(max_count()); } private: - static inline bool abl_less(std::pair const& p1, - std::pair const& p2) - { - return p1.first < p2.first; - } - - static inline bool neighbors_less(std::pair const& p1, - std::pair const& p2) - { - return p1.first < p2.first; - } - - node_distance_type - calc_closest_node_distance(typename internal_stack_type::const_iterator first, - typename internal_stack_type::const_iterator last) - { - node_distance_type result = (std::numeric_limits::max)(); - for ( ; first != last ; ++first ) - { - if ( first->branches.size() <= first->current_branch ) - continue; - - node_distance_type curr_dist = first->branches[first->current_branch].first; - if ( curr_dist < result ) - result = curr_dist; - } - return result; - } - - template - static inline bool is_node_prunable(Distance const& greatest_dist, node_distance_type const& d) - { - return greatest_dist <= d; - } - - inline unsigned max_count() const + inline std::size_t max_count() const { return nearest_predicate_access::get(m_pred).count; } @@ -604,10 +547,9 @@ private: Predicates m_pred; - internal_stack_type internal_stack; + internal_heap_type internal_heap; std::vector< std::pair > neighbors; size_type current_neighbor; - node_distance_type next_closest_node_distance; strategy_type m_strategy; }; diff --git a/include/boost/geometry/index/detail/rtree/visitors/insert.hpp b/include/boost/geometry/index/detail/rtree/visitors/insert.hpp index 8b32c8176..5d158bc7d 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/insert.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/insert.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -21,12 +21,14 @@ #include #include -#include #include #include - +#include #include +#include + +#include namespace boost { namespace geometry { namespace index { diff --git a/include/boost/geometry/index/detail/rtree/visitors/iterator.hpp b/include/boost/geometry/index/detail/rtree/visitors/iterator.hpp index 621231ae9..71127dcbe 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/iterator.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/iterator.hpp @@ -4,6 +4,10 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -11,6 +15,9 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ITERATOR_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_ITERATOR_HPP +#include +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { diff --git a/include/boost/geometry/index/detail/rtree/visitors/remove.hpp b/include/boost/geometry/index/detail/rtree/visitors/remove.hpp index 59f486163..7cdbb0344 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/remove.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/remove.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2017 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019. -// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -15,11 +15,13 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_REMOVE_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_REMOVE_HPP +#include + +#include +#include #include #include -#include - namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { diff --git a/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp b/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp index cdef103b3..5f2c07ea2 100644 --- a/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp +++ b/include/boost/geometry/index/detail/rtree/visitors/spatial_query.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019. -// Modifications copyright (c) 2019 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -15,6 +15,10 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_SPATIAL_QUERY_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_VISITORS_SPATIAL_QUERY_HPP +#include +#include +#include + namespace boost { namespace geometry { namespace index { namespace detail { namespace rtree { namespace visitors { @@ -35,7 +39,7 @@ struct spatial_query typedef typename allocators_type::size_type size_type; - static const unsigned predicates_len = index::detail::predicates_length::value; + static const std::size_t predicates_len = index::detail::predicates_length::value; inline spatial_query(parameters_type const& par, translator_type const& t, Predicates const& p, OutIter out_it) : tr(t), pred(p), out_iter(out_it), found_count(0), strategy(index::detail::get_strategy(par)) @@ -119,7 +123,7 @@ public: typedef typename rtree::elements_type::type leaf_elements; typedef typename rtree::elements_type::type::const_iterator leaf_iterator; - static const unsigned predicates_len = index::detail::predicates_length::value; + static const std::size_t predicates_len = index::detail::predicates_length::value; inline spatial_query_incremental() : m_translator(NULL) diff --git a/include/boost/geometry/index/detail/serialization.hpp b/include/boost/geometry/index/detail/serialization.hpp index 71902d19f..909c38e3c 100644 --- a/include/boost/geometry/index/detail/serialization.hpp +++ b/include/boost/geometry/index/detail/serialization.hpp @@ -2,6 +2,10 @@ // // Copyright (c) 2011-2015 Adam Wulkiewicz, Lodz, Poland. // +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021 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) @@ -9,11 +13,21 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_SERIALIZATION_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_SERIALIZATION_HPP +#include +#include + //#include #include #include //#include +#include +#include + +#include +#include +#include + // TODO // how about using the unsigned type capable of storing Max in compile-time versions? @@ -26,7 +40,13 @@ // each geometry save without this info // TODO - move to index/detail/serialization.hpp -namespace boost { namespace geometry { namespace index { namespace detail { +namespace boost { namespace geometry { namespace index { + +// Forward declaration +template +class rtree; + +namespace detail { // TODO - use boost::move? template diff --git a/include/boost/geometry/index/detail/translator.hpp b/include/boost/geometry/index/detail/translator.hpp index 34960d226..900be6e73 100644 --- a/include/boost/geometry/index/detail/translator.hpp +++ b/include/boost/geometry/index/detail/translator.hpp @@ -2,8 +2,8 @@ // // Copyright (c) 2011-2013 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -15,6 +15,8 @@ #include +#include + namespace boost { namespace geometry { namespace index { namespace detail { diff --git a/include/boost/geometry/index/parameters.hpp b/include/boost/geometry/index/parameters.hpp index fdaef9284..477518866 100644 --- a/include/boost/geometry/index/parameters.hpp +++ b/include/boost/geometry/index/parameters.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2017 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -15,13 +15,13 @@ #ifndef BOOST_GEOMETRY_INDEX_PARAMETERS_HPP #define BOOST_GEOMETRY_INDEX_PARAMETERS_HPP - #include #include #include +#include namespace boost { namespace geometry { namespace index { diff --git a/include/boost/geometry/index/predicates.hpp b/include/boost/geometry/index/predicates.hpp index 09faaaf20..6da0d0ec5 100644 --- a/include/boost/geometry/index/predicates.hpp +++ b/include/boost/geometry/index/predicates.hpp @@ -4,8 +4,8 @@ // // Copyright (c) 2011-2018 Adam Wulkiewicz, Lodz, Poland. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -338,7 +338,7 @@ Only one \c nearest() predicate may be used in a query. */ template inline detail::predicates::nearest -nearest(Geometry const& geometry, unsigned k) +nearest(Geometry const& geometry, std::size_t k) { return detail::predicates::nearest(geometry, k); } @@ -368,7 +368,7 @@ Only one distance predicate (\c nearest() or \c path()) may be used in a query. */ template inline detail::predicates::path -path(SegmentOrLinestring const& linestring, unsigned k) +path(SegmentOrLinestring const& linestring, std::size_t k) { return detail::predicates::path(linestring, k); } diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index 1f54afac1..2b7e3811d 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -6,8 +6,8 @@ // Copyright (c) 2011-2019 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2020 Caian Benedicto, Campinas, Brazil. // -// This file was modified by Oracle on 2019-2020. -// Modifications copyright (c) 2019-2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2019-2021. +// Modifications copyright (c) 2019-2021 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, @@ -1082,7 +1082,7 @@ public: if ( !m_members.root ) return 0; - static const unsigned distance_predicates_count = detail::predicates_count_distance::value; + static const std::size_t distance_predicates_count = detail::predicates_count_distance::value; static const bool is_distance_predicate = 0 < distance_predicates_count; BOOST_GEOMETRY_STATIC_ASSERT((distance_predicates_count <= 1), "Only one distance predicate can be passed.", @@ -1252,7 +1252,7 @@ private: > qbegin_(Predicates const& predicates) const { - static const unsigned distance_predicates_count = detail::predicates_count_distance::value; + static const std::size_t distance_predicates_count = detail::predicates_count_distance::value; BOOST_GEOMETRY_STATIC_ASSERT((distance_predicates_count <= 1), "Only one distance predicate can be passed.", Predicates); @@ -1319,7 +1319,7 @@ private: > qend_(Predicates const& predicates) const { - static const unsigned distance_predicates_count = detail::predicates_count_distance::value; + static const std::size_t distance_predicates_count = detail::predicates_count_distance::value; BOOST_GEOMETRY_STATIC_ASSERT((distance_predicates_count <= 1), "Only one distance predicate can be passed.", Predicates); @@ -1916,7 +1916,7 @@ private: { BOOST_GEOMETRY_INDEX_ASSERT(m_members.root, "The root must exist"); - static const unsigned distance_predicate_index = detail::predicates_find_distance::value; + static const std::size_t distance_predicate_index = detail::predicates_find_distance::value; detail::rtree::visitors::distance_query< members_holder, Predicates, diff --git a/include/boost/geometry/io/wkt/write.hpp b/include/boost/geometry/io/wkt/write.hpp index aa52d072f..73b374c9e 100644 --- a/include/boost/geometry/io/wkt/write.hpp +++ b/include/boost/geometry/io/wkt/write.hpp @@ -478,9 +478,10 @@ struct wkt static inline void apply(OutputStream& os, Geometry const& geometry, bool force_closure) { - output_or_recursive_call(os, geometry, force_closure); + wkt::output_or_recursive_call(os, geometry, force_closure); } +private: template < typename OutputStream, typename Geom, @@ -501,7 +502,7 @@ struct wkt traits::iter_visit::apply([&](auto const& g) { - output_or_recursive_call(os, g, force_closure); + wkt::output_or_recursive_call(os, g, force_closure); }, it); } diff --git a/include/boost/geometry/iterators/concatenate_iterator.hpp b/include/boost/geometry/iterators/concatenate_iterator.hpp index d3266e975..42145ec25 100644 --- a/include/boost/geometry/iterators/concatenate_iterator.hpp +++ b/include/boost/geometry/iterators/concatenate_iterator.hpp @@ -86,6 +86,10 @@ public: , m_it2(other.m_it2) {} + concatenate_iterator(concatenate_iterator const& other) = default; + + concatenate_iterator& operator=(concatenate_iterator const& other) = default; + private: friend class boost::iterator_core_access; diff --git a/include/boost/geometry/iterators/flatten_iterator.hpp b/include/boost/geometry/iterators/flatten_iterator.hpp index 9b45d2efe..cfe232b4e 100644 --- a/include/boost/geometry/iterators/flatten_iterator.hpp +++ b/include/boost/geometry/iterators/flatten_iterator.hpp @@ -100,6 +100,8 @@ public: m_inner_it(other.m_inner_it) {} + flatten_iterator(flatten_iterator const& other) = default; + flatten_iterator& operator=(flatten_iterator const& other) { m_outer_it = other.m_outer_it; diff --git a/include/boost/geometry/srs/projections/factory.hpp b/include/boost/geometry/srs/projections/factory.hpp index 0fddb0a27..156fece80 100644 --- a/include/boost/geometry/srs/projections/factory.hpp +++ b/include/boost/geometry/srs/projections/factory.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017-2020. -// Modifications copyright (c) 2017-2020, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017-2021. +// Modifications copyright (c) 2017-2021, 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, @@ -145,7 +145,7 @@ struct factory_key { return par.id.name; } - static const char* get(const char* name, srs::dpar::value_proj id) + static const char* get(const char* name, srs::dpar::value_proj ) { return name; } @@ -160,7 +160,7 @@ struct factory_key > { return par.id.id; } - static srs::dpar::value_proj get(const char* name, srs::dpar::value_proj id) + static srs::dpar::value_proj get(const char* , srs::dpar::value_proj id) { return id; } diff --git a/include/boost/geometry/srs/projections/proj/igh.hpp b/include/boost/geometry/srs/projections/proj/igh.hpp index 385ac3031..8e01151c8 100644 --- a/include/boost/geometry/srs/projections/proj/igh.hpp +++ b/include/boost/geometry/srs/projections/proj/igh.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2017, 2018, 2019. -// Modifications copyright (c) 2017-2019, Oracle and/or its affiliates. +// This file was modified by Oracle on 2017-2021. +// Modifications copyright (c) 2017-2021, 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, @@ -287,7 +287,7 @@ namespace projections // Interrupted Goode Homolosine template - inline void setup_igh(Params const& params, Parameters& par, par_igh& proj_parm) + inline void setup_igh(Params const& , Parameters& par, par_igh& proj_parm) { static const T d0 = 0; static const T d4044118 = igh::d4044118(); diff --git a/include/boost/geometry/strategies/distance/comparable.hpp b/include/boost/geometry/strategies/distance/comparable.hpp index 34a828cfe..3a6d8300b 100644 --- a/include/boost/geometry/strategies/distance/comparable.hpp +++ b/include/boost/geometry/strategies/distance/comparable.hpp @@ -14,6 +14,8 @@ #include #include +#include + namespace boost { namespace geometry { diff --git a/include/boost/geometry/strategies/distance/services.hpp b/include/boost/geometry/strategies/distance/services.hpp index 4ac35c6dd..5ce3cd98b 100644 --- a/include/boost/geometry/strategies/distance/services.hpp +++ b/include/boost/geometry/strategies/distance/services.hpp @@ -14,6 +14,8 @@ #include #include +#include + namespace boost { namespace geometry { diff --git a/include/boost/geometry/strategies/geographic/buffer_point_circle.hpp b/include/boost/geometry/strategies/geographic/buffer_point_circle.hpp index 8d6643d73..d9efba917 100644 --- a/include/boost/geometry/strategies/geographic/buffer_point_circle.hpp +++ b/include/boost/geometry/strategies/geographic/buffer_point_circle.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2018-2019 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2020. -// Modifications copyright (c) 2020 Oracle and/or its affiliates. +// This file was modified by Oracle on 2020-2021. +// Modifications copyright (c) 2020-2021 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, @@ -17,12 +17,12 @@ #include +#include +#include +#include #include #include -#include - - namespace boost { namespace geometry { diff --git a/include/boost/geometry/strategies/intersection_result.hpp b/include/boost/geometry/strategies/intersection_result.hpp index 4b5aa1c46..94aae51d8 100644 --- a/include/boost/geometry/strategies/intersection_result.hpp +++ b/include/boost/geometry/strategies/intersection_result.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2015, 2016. -// Modifications copyright (c) 2015-2016 Oracle and/or its affiliates. +// This file was modified by Oracle on 2015-2021. +// Modifications copyright (c) 2015-2021 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, @@ -15,9 +15,9 @@ #include +#include #include - namespace boost { namespace geometry { diff --git a/include/boost/geometry/strategies/line_interpolate/geographic.hpp b/include/boost/geometry/strategies/line_interpolate/geographic.hpp index 5d57ea378..048f81c2c 100644 --- a/include/boost/geometry/strategies/line_interpolate/geographic.hpp +++ b/include/boost/geometry/strategies/line_interpolate/geographic.hpp @@ -1,7 +1,6 @@ // Boost.Geometry // Copyright (c) 2021, Oracle and/or its affiliates. - // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Licensed under the Boost Software License version 1.0. @@ -13,6 +12,8 @@ #include +#include + #include #include diff --git a/include/boost/geometry/strategies/relate/geographic.hpp b/include/boost/geometry/strategies/relate/geographic.hpp index 60c6b9e58..4f556e953 100644 --- a/include/boost/geometry/strategies/relate/geographic.hpp +++ b/include/boost/geometry/strategies/relate/geographic.hpp @@ -13,6 +13,7 @@ // TEMP - move to strategy #include +#include #include #include #include diff --git a/include/boost/geometry/strategies/simplify/spherical.hpp b/include/boost/geometry/strategies/simplify/spherical.hpp index 0858087f3..4ff51b38c 100644 --- a/include/boost/geometry/strategies/simplify/spherical.hpp +++ b/include/boost/geometry/strategies/simplify/spherical.hpp @@ -12,6 +12,7 @@ #include +#include #include #include diff --git a/include/boost/geometry/strategy/cartesian/side_robust.hpp b/include/boost/geometry/strategy/cartesian/side_robust.hpp index 4ee4a1726..5362ed068 100644 --- a/include/boost/geometry/strategy/cartesian/side_robust.hpp +++ b/include/boost/geometry/strategy/cartesian/side_robust.hpp @@ -5,6 +5,11 @@ // Contributed and/or modified by Tinko Bartels, // as part of Google Summer of Code 2019 program. +// This file was modified by Oracle on 2021. +// Modifications copyright (c) 2021, Oracle and/or its affiliates. +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle +// 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) @@ -49,10 +54,16 @@ public: static inline PromotedType side_value(P1 const& p1, P2 const& p2, P const& p) { - typedef ::boost::geometry::detail::precise_math::vec2d vec2d; - vec2d pa { get<0>(p1), get<1>(p1) }; - vec2d pb { get<0>(p2), get<1>(p2) }; - vec2d pc { get<0>(p), get<1>(p) }; + using vec2d = ::boost::geometry::detail::precise_math::vec2d; + vec2d pa; + pa.x = get<0>(p1); + pa.y = get<1>(p1); + vec2d pb; + pb.x = get<0>(p2); + pb.y = get<1>(p2); + vec2d pc; + pc.x = get<0>(p); + pc.y = get<1>(p); return ::boost::geometry::detail::precise_math::orient2d (pa, pb, pc); } diff --git a/include/boost/geometry/util/math.hpp b/include/boost/geometry/util/math.hpp index 60cbf2cf3..fc9d7a3be 100644 --- a/include/boost/geometry/util/math.hpp +++ b/include/boost/geometry/util/math.hpp @@ -4,12 +4,13 @@ // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. -// This file was modified by Oracle on 2014-2020. -// Modifications copyright (c) 2014-2020, Oracle and/or its affiliates. +// This file was modified by Oracle on 2014-2021. +// Modifications copyright (c) 2014-2021, Oracle and/or its affiliates. +// Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle -// Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -847,24 +848,6 @@ inline T round_angle(T const& x) { return x < 0 ? -y : y; } - -/*! -\brief The error-free sum of two numbers. -*/ -template -inline T sum_error(T const& u, T const& v, T& t) -{ - volatile T s = u + v; - volatile T up = s - v; - volatile T vpp = s - up; - - up -= u; - vpp -= v; - t = -(up + vpp); - - return s; -} - /*! \brief Evaluate the polynomial in x using Horner's method. */ diff --git a/include/boost/geometry/util/sequence.hpp b/include/boost/geometry/util/sequence.hpp index 5bb1a5e25..2f8e7b51b 100644 --- a/include/boost/geometry/util/sequence.hpp +++ b/include/boost/geometry/util/sequence.hpp @@ -62,13 +62,13 @@ struct sequence_element {}; template struct sequence_element> { - typedef typename sequence_element>::type type; + using type = typename sequence_element>::type; }; template struct sequence_element<0, type_sequence> { - typedef T type; + using type = T; }; template @@ -125,6 +125,7 @@ struct sequence_empty {}; +// Defines type member for the first type in sequence that satisfies UnaryPred. template < typename Sequence, @@ -151,13 +152,13 @@ template