diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index 3f4e5a98c9..55a7529423 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -19,6 +19,18 @@ [section:release_notes Release Notes] +[/=================] +[heading Boost 1.84] +[/=================] + +[*Solved issues] + +* [@https://github.com/boostorg/geometry/issues/1138 1138] Fix difference of two polygons +* [@https://github.com/boostorg/geometry/issues/1183 1183] Fix for union_ incomplete result polygon +* [@https://github.com/boostorg/geometry/issues/1184 1184] Fix for intersection +* [@https://github.com/boostorg/geometry/issues/1186 1186] Fix for union_ improper inner ring assignment +* Various fixes of errors and warnings + [/=================] [heading Boost 1.83] [/=================] diff --git a/include/boost/geometry/algorithms/assign.hpp b/include/boost/geometry/algorithms/assign.hpp index dabf1b4a57..5386ac6494 100644 --- a/include/boost/geometry/algorithms/assign.hpp +++ b/include/boost/geometry/algorithms/assign.hpp @@ -216,7 +216,7 @@ template struct assign { static inline void - apply(Geometry1& geometry1, const Geometry2& geometry2) + apply(Geometry1& geometry1, Geometry2 const& geometry2) { concepts::check(); concepts::check(); diff --git a/include/boost/geometry/algorithms/centroid.hpp b/include/boost/geometry/algorithms/centroid.hpp index 9559f06b92..43ac999e51 100644 --- a/include/boost/geometry/algorithms/centroid.hpp +++ b/include/boost/geometry/algorithms/centroid.hpp @@ -82,16 +82,9 @@ class centroid_exception : public geometry::exception { public: - /*! - \brief The default constructor - */ inline centroid_exception() {} - /*! - \brief Returns the explanatory string. - \return Pointer to a null-terminated string with explanatory information. - */ - virtual char const* what() const throw() + char const* what() const noexcept override { return "Boost.Geometry Centroid calculation exception"; } diff --git a/include/boost/geometry/algorithms/correct_closure.hpp b/include/boost/geometry/algorithms/correct_closure.hpp index 38d982c91b..0521c38b81 100644 --- a/include/boost/geometry/algorithms/correct_closure.hpp +++ b/include/boost/geometry/algorithms/correct_closure.hpp @@ -26,6 +26,7 @@ #include #include +#include namespace boost { namespace geometry { diff --git a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp index 8aa9493420..66943b303c 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -698,7 +698,7 @@ struct buffered_piece_collection BOOST_GEOMETRY_ASSERT(pc.offsetted_count >= 0); } - inline void add_piece_point(piece& pc, const point_type& point, bool add_to_original) + inline void add_piece_point(piece& pc, point_type const& point, bool add_to_original) { if (add_to_original && pc.type != strategy::buffer::buffered_concave) { diff --git a/include/boost/geometry/algorithms/detail/buffer/line_line_intersection.hpp b/include/boost/geometry/algorithms/detail/buffer/line_line_intersection.hpp index f1014c9bb4..f217c53b01 100644 --- a/include/boost/geometry/algorithms/detail/buffer/line_line_intersection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/line_line_intersection.hpp @@ -77,7 +77,7 @@ struct line_line_intersection // | pa pa | // | qb qb | auto const denominator_pq = determinant(p, q); - constexpr decltype(denominator_pq) const zero = 0; + static decltype(denominator_pq) const zero = 0; if (equidistant) { diff --git a/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp b/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp index d773d32c36..3861fcbe57 100644 --- a/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp @@ -18,6 +18,7 @@ #include #include +#include #include #include diff --git a/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp b/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp index daa59b618b..12fffc4c4a 100644 --- a/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/turn_in_original_visitor.hpp @@ -16,8 +16,9 @@ #include -#include +#include +#include #include #include #include diff --git a/include/boost/geometry/algorithms/detail/calculate_point_order.hpp b/include/boost/geometry/algorithms/detail/calculate_point_order.hpp index 191f71f3d8..5dc92a0cce 100644 --- a/include/boost/geometry/algorithms/detail/calculate_point_order.hpp +++ b/include/boost/geometry/algorithms/detail/calculate_point_order.hpp @@ -14,6 +14,8 @@ #include +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/detail/closest_feature/point_to_range.hpp b/include/boost/geometry/algorithms/detail/closest_feature/point_to_range.hpp index ed2efd6fce..678502bce6 100644 --- a/include/boost/geometry/algorithms/detail/closest_feature/point_to_range.hpp +++ b/include/boost/geometry/algorithms/detail/closest_feature/point_to_range.hpp @@ -14,7 +14,6 @@ #include #include -#include #include #include diff --git a/include/boost/geometry/algorithms/detail/closest_points/multipoint_to_geometry.hpp b/include/boost/geometry/algorithms/detail/closest_points/multipoint_to_geometry.hpp index f59c85a9b5..2c0f22d5bd 100644 --- a/include/boost/geometry/algorithms/detail/closest_points/multipoint_to_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/closest_points/multipoint_to_geometry.hpp @@ -12,6 +12,8 @@ #include +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp b/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp index 64d81054e8..20fd09bf58 100644 --- a/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp +++ b/include/boost/geometry/algorithms/detail/convex_hull/graham_andrew.hpp @@ -23,6 +23,8 @@ #include #include +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp b/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp index b820cc4bf4..884a9278b3 100644 --- a/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp +++ b/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp @@ -24,6 +24,8 @@ #include +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/detail/disjoint/linear_segment_or_box.hpp b/include/boost/geometry/algorithms/detail/disjoint/linear_segment_or_box.hpp index 4424f144b0..1361811dab 100644 --- a/include/boost/geometry/algorithms/detail/disjoint/linear_segment_or_box.hpp +++ b/include/boost/geometry/algorithms/detail/disjoint/linear_segment_or_box.hpp @@ -22,6 +22,8 @@ #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_DISJOINT_LINEAR_SEGMENT_OR_BOX_HPP +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp b/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp index f230958437..c3d079eb7b 100644 --- a/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp +++ b/include/boost/geometry/algorithms/detail/distance/geometry_collection.hpp @@ -12,6 +12,8 @@ #include +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp b/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp index b908c3e535..40ea1e4245 100644 --- a/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp +++ b/include/boost/geometry/algorithms/detail/equals/collect_vectors.hpp @@ -21,6 +21,7 @@ #include +#include #include #include diff --git a/include/boost/geometry/algorithms/detail/has_self_intersections.hpp b/include/boost/geometry/algorithms/detail/has_self_intersections.hpp index 0b13eb7bda..4074f0d4f0 100644 --- a/include/boost/geometry/algorithms/detail/has_self_intersections.hpp +++ b/include/boost/geometry/algorithms/detail/has_self_intersections.hpp @@ -53,7 +53,7 @@ class overlay_invalid_input_exception : public geometry::exception inline overlay_invalid_input_exception() {} - virtual char const* what() const throw() + char const* what() const noexcept override { return "Boost.Geometry Overlay invalid input exception"; } diff --git a/include/boost/geometry/algorithms/detail/intersection/box_box.hpp b/include/boost/geometry/algorithms/detail/intersection/box_box.hpp index 30c31ff1e5..ff99a2290c 100644 --- a/include/boost/geometry/algorithms/detail/intersection/box_box.hpp +++ b/include/boost/geometry/algorithms/detail/intersection/box_box.hpp @@ -16,7 +16,7 @@ #include -#include +#include namespace boost { namespace geometry diff --git a/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp b/include/boost/geometry/algorithms/detail/intersection/box_box_implementation.hpp similarity index 79% rename from include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp rename to include/boost/geometry/algorithms/detail/intersection/box_box_implementation.hpp index 31db94dd95..86478226c7 100644 --- a/include/boost/geometry/algorithms/detail/overlay/intersection_box_box.hpp +++ b/include/boost/geometry/algorithms/detail/intersection/box_box_implementation.hpp @@ -11,12 +11,11 @@ // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) -#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP -#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_BOX_BOX_IMPLEMENTATION_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_BOX_BOX_IMPLEMENTATION_HPP #include -#include namespace boost { namespace geometry @@ -42,18 +41,16 @@ struct intersection_box_box BoxOut& box_out, Strategy const& strategy) { - typedef typename coordinate_type::type ct; - - ct max1 = get(box1); - ct min2 = get(box2); + auto max1 = get(box1); + auto min2 = get(box2); if (max1 < min2) { return false; } - ct max2 = get(box2); - ct min1 = get(box1); + auto max2 = get(box2); + auto min1 = get(box1); if (max2 < min1) { @@ -93,4 +90,4 @@ struct intersection_box_box }} // namespace boost::geometry -#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_INTERSECTION_BOX_BOX_HPP +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_INTERSECTION_BOX_BOX_IMPLEMENTATION_HPP diff --git a/include/boost/geometry/algorithms/detail/intersection/gc.hpp b/include/boost/geometry/algorithms/detail/intersection/gc.hpp index fa492c0f34..38a10ba328 100644 --- a/include/boost/geometry/algorithms/detail/intersection/gc.hpp +++ b/include/boost/geometry/algorithms/detail/intersection/gc.hpp @@ -12,6 +12,8 @@ #include +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp b/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp index 5af933de85..8b55ee85df 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include diff --git a/include/boost/geometry/algorithms/detail/is_valid/ring.hpp b/include/boost/geometry/algorithms/detail/is_valid/ring.hpp index e34f02f7f6..810b94a453 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/ring.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/ring.hpp @@ -15,6 +15,8 @@ #include +#include + #include #include @@ -38,12 +40,11 @@ #include #include -// TEMP - with UmberllaStrategy this will be not needed +// TEMP - with UmbrellaStrategy this will be not needed #include #include // TODO: use point_order instead of area - #ifdef BOOST_GEOMETRY_TEST_DEBUG #include #endif diff --git a/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp b/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp index a21ee9832b..c52266c190 100644 --- a/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/append_no_dups_or_spikes.hpp @@ -100,7 +100,7 @@ inline void append_no_dups_or_spikes(Range& range, Point const& point, return; } - auto append = [](auto& r, const auto& p) + auto append = [](auto& r, auto const& p) { using point_t = typename boost::range_value::type; point_t rp; @@ -168,56 +168,64 @@ inline void append_no_collinear(Range& range, Point const& point, } } -template -inline void clean_closing_dups_and_spikes(Range& range, - Strategy const& strategy, - RobustPolicy const& robust_policy) +// Should only be called internally, from traverse. +template +inline void remove_spikes_at_closure(Ring& ring, Strategy const& strategy, + RobustPolicy const& robust_policy) { - std::size_t const minsize - = core_detail::closure::minimum_ring_size - < - geometry::closure::value - >::value; - - if (boost::size(range) <= minsize) + // It assumes a closed ring (whatever the closure value) + constexpr std::size_t min_size + = core_detail::closure::minimum_ring_size + < + geometry::closed + >::value; + + if (boost::size(ring) < min_size) { + // Don't act on too small rings. return; } - static bool const closed = geometry::closure::value == geometry::closed; - -// TODO: the following algorithm could be rewritten to first look for spikes -// and then erase some number of points from the beginning of the Range - bool found = false; do { found = false; - auto first = boost::begin(range); - auto second = first + 1; - auto ultimate = boost::end(range) - 1; - if (BOOST_GEOMETRY_CONDITION(closed)) - { - ultimate--; - } + auto const first = boost::begin(ring); + auto const second = first + 1; + auto const penultimate = boost::end(ring) - 2; // Check if closing point is a spike (this is so if the second point is // considered as collinear w.r.t. the last segment) - if (point_is_collinear(*second, *ultimate, *first, + if (point_is_collinear(*second, *penultimate, *first, strategy.side(), // TODO: Pass strategy? robust_policy)) { - range::erase(range, first); - if (BOOST_GEOMETRY_CONDITION(closed)) - { - // Remove closing last point - range::resize(range, boost::size(range) - 1); - // Add new closing point - range::push_back(range, range::front(range)); - } + // Remove first point and last point + range::erase(ring, first); + range::resize(ring, boost::size(ring) - 1); + // Close the ring again + range::push_back(ring, range::front(ring)); + found = true; } - } while(found && boost::size(range) > minsize); + } while (found && boost::size(ring) >= min_size); +} + +template +inline void fix_closure(Ring& ring, Strategy const& strategy) +{ + if (BOOST_GEOMETRY_CONDITION(geometry::closure::value == geometry::open)) + { + if (! boost::empty(ring) + && detail::equals::equals_point_point(range::front(ring), range::back(ring), strategy)) + { + // Correct closure: traversal automatically closes rings. + // Depending on the geometric configuration, + // remove_spikes_at_closure can remove the closing point. + // But it does not always do that. Therefore it is corrected here explicitly. + range::resize(ring, boost::size(ring) - 1); + } + } } diff --git a/include/boost/geometry/algorithms/detail/overlay/approximately_equals.hpp b/include/boost/geometry/algorithms/detail/overlay/approximately_equals.hpp index 1f41085dc1..f41996f1dc 100644 --- a/include/boost/geometry/algorithms/detail/overlay/approximately_equals.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/approximately_equals.hpp @@ -21,6 +21,31 @@ namespace boost { namespace geometry namespace detail { namespace overlay { +// Value for approximately_equals used by get_cluster and sort_by_side +// This is an "epsilon_multiplier" and, therefore, multiplied the epsilon +// belonging to the used floating point type with this value. +template +struct common_approximately_equals_epsilon_multiplier +{ + static T value() + { + // The value is (a bit) arbitrary. For sort_by_side it should be large + // enough to not take a point which is too close by, to calculate the + // side value correctly. For get_cluster it is arbitrary as well, points + // close to each other should form a cluster, which is also important + // for subsequent side calculations. Points too far apart should not be + // clustered. + // + // The value of 100 is currently considered as a sweet spot. + // If the value changes (as of 2023-09-13): + // 10: too small, failing unit test(s): + // - union: issue_1108 + // 50: this would be fine, no tests failing + // 1000: this would be fine, no tests failing + return T(100); + } +}; + template inline bool approximately_equals(Point1 const& a, Point2 const& b, E const& epsilon_multiplier) diff --git a/include/boost/geometry/algorithms/detail/overlay/assign_parents.hpp b/include/boost/geometry/algorithms/detail/overlay/assign_parents.hpp index fb3ee1bef2..578ba090cf 100644 --- a/include/boost/geometry/algorithms/detail/overlay/assign_parents.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/assign_parents.hpp @@ -362,7 +362,7 @@ inline void assign_parents(Geometry1 const& geometry1, } else if (info.parent.source_index >= 0) { - const ring_info_type& parent = ring_map[info.parent]; + ring_info_type const& parent = ring_map[info.parent]; bool const pos = math::larger(info.get_area(), 0); bool const parent_pos = math::larger(parent.area, 0); diff --git a/include/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp b/include/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp index 49d190bd0c..39d107e013 100644 --- a/include/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/backtrack_check_si.hpp @@ -20,7 +20,6 @@ #include #include -#include #include #include #if defined(BOOST_GEOMETRY_DEBUG_INTERSECTION) || defined(BOOST_GEOMETRY_OVERLAY_REPORT_WKT) diff --git a/include/boost/geometry/algorithms/detail/overlay/cluster_exits.hpp b/include/boost/geometry/algorithms/detail/overlay/cluster_exits.hpp index 8c4f4c7f31..b1c7de217d 100644 --- a/include/boost/geometry/algorithms/detail/overlay/cluster_exits.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/cluster_exits.hpp @@ -20,7 +20,6 @@ #include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/detail/overlay/colocate_clusters.hpp b/include/boost/geometry/algorithms/detail/overlay/colocate_clusters.hpp index 06d6e7bd61..6d04f0a098 100644 --- a/include/boost/geometry/algorithms/detail/overlay/colocate_clusters.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/colocate_clusters.hpp @@ -62,14 +62,14 @@ struct cluster_colocator { CoordinateType centroid_0 = 0; CoordinateType centroid_1 = 0; - for (const auto& index : indices) + for (auto const& index : indices) { centroid_0 += geometry::get<0>(turns[index].point); centroid_1 += geometry::get<1>(turns[index].point); } centroid_0 /= indices.size(); centroid_1 /= indices.size(); - for (const auto& index : indices) + for (auto const& index : indices) { geometry::set<0>(turns[index].point, centroid_0); geometry::set<1>(turns[index].point, centroid_1); @@ -86,14 +86,14 @@ inline void colocate_clusters(Clusters const& clusters, Turns& turns) { for (auto const& pair : clusters) { - auto const& indices = pair.second.turn_indices; - if (indices.size() < 2) + auto const& turn_indices = pair.second.turn_indices; + if (turn_indices.size() < 2) { // Defensive check continue; } - using point_t = decltype(turns[*indices.begin()].point); - cluster_colocator::apply(indices, turns); + using point_t = decltype(turns[*turn_indices.begin()].point); + cluster_colocator::apply(turn_indices, turns); } } diff --git a/include/boost/geometry/algorithms/detail/overlay/discard_duplicate_turns.hpp b/include/boost/geometry/algorithms/detail/overlay/discard_duplicate_turns.hpp index 258a815f09..ca537e0815 100644 --- a/include/boost/geometry/algorithms/detail/overlay/discard_duplicate_turns.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/discard_duplicate_turns.hpp @@ -114,7 +114,7 @@ inline void discard_duplicate_start_turns(Turns& turns, { if (turn.method == method_start) { - for (const auto& op : turn.operations) + for (auto const& op : turn.operations) { start_turns_per_segment[adapt_id(op.seg_id)].push_back(index); } @@ -130,7 +130,7 @@ inline void discard_duplicate_start_turns(Turns& turns, // Also avoid comparing "start" with itself. if (turn.method != method_crosses && turn.method != method_start) { - for (const auto& op : turn.operations) + for (auto const& op : turn.operations) { auto it = start_turns_per_segment.find(adapt_id(op.seg_id)); if (it != start_turns_per_segment.end()) diff --git a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp index b94bba6c5a..962c68be69 100644 --- a/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/enrich_intersection_points.hpp @@ -185,7 +185,8 @@ inline void enrich_assign(Operations& operations, Turns& turns, << " nxt=" << op.enriched.next_ip_index << " / " << op.enriched.travels_to_ip_index << " [vx " << op.enriched.travels_to_vertex_index << "]" - << (turns[indexed_op.turn_index].discarded ? " discarded" : "") + << (turns[indexed_op.turn_index].discarded ? " [discarded]" : "") + << (op.enriched.startable ? "" : " [not startable]") << std::endl; } #endif diff --git a/include/boost/geometry/algorithms/detail/overlay/get_clusters.hpp b/include/boost/geometry/algorithms/detail/overlay/get_clusters.hpp index 2747fa68ba..5d6badfd5c 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_clusters.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_clusters.hpp @@ -35,28 +35,24 @@ namespace detail { namespace overlay template struct sweep_equal_policy { -private: - template - static inline T threshold() - { - // Points within some epsilons are considered as equal. - return T(100); - } + public: - // Returns true if point are considered equal (within an epsilon) + // Returns true if point are considered equal template static inline bool equals(P const& p1, P const& p2) { using coor_t = typename coordinate_type

::type; - return approximately_equals(p1, p2, threshold()); + static auto const tolerance + = common_approximately_equals_epsilon_multiplier::value(); + return approximately_equals(p1, p2, tolerance); } template static inline bool exceeds(T value) { - // This threshold is an arbitrary value - // as long as it is bigger than the used value above - T const limit = T(1) / threshold(); + static auto const tolerance + = common_approximately_equals_epsilon_multiplier::value(); + T const limit = T(1) / tolerance; return value > limit; } }; diff --git a/include/boost/geometry/algorithms/detail/overlay/get_distance_measure.hpp b/include/boost/geometry/algorithms/detail/overlay/get_distance_measure.hpp index d462bb524d..81a9418a82 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_distance_measure.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_distance_measure.hpp @@ -78,7 +78,7 @@ struct get_distance_measure static result_type apply(SegmentPoint const& , SegmentPoint const& , Point const& ) { - const result_type result; + result_type const result; return result; } }; @@ -125,7 +125,7 @@ inline auto get_distance_measure(SegmentPoint const& p1, SegmentPoint const& p2, // Verify equality, without using a tolerance // (so don't use equals or equals_point_point) // because it is about very tiny differences. - auto identical = [](const auto& point1, const auto& point2) + auto identical = [](auto const& point1, auto const& point2) { return geometry::get<0>(point1) == geometry::get<0>(point2) && geometry::get<1>(point1) == geometry::get<1>(point2); diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp index 4e10c07bde..0fa6bdbd1b 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turn_info.hpp @@ -1,6 +1,6 @@ -// Boost.Geometry (aka GGL, Generic Geometry Library) +// Boost.Geometry -// Copyright (c) 2007-2021 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2007-2023 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2015-2022. @@ -46,10 +46,7 @@ class turn_info_exception : public geometry::exception message += method; } - virtual ~turn_info_exception() throw() - {} - - virtual char const* what() const throw() + virtual char const* What() const noexcept { return message.c_str(); } @@ -592,7 +589,7 @@ struct touch : public base_turn_handler // >----->P qj is LEFT of P1 and pi is LEFT of Q2 // (the other way round is also possible) - auto has_distance = [&](const auto& r1, const auto& r2) -> bool + auto has_distance = [&](auto const& r1, auto const& r2) -> bool { auto const d1 = get_distance_measure(r1.at(0), r1.at(1), r2.at(1), umbrella_strategy); auto const d2 = get_distance_measure(r2.at(1), r2.at(2), r1.at(0), umbrella_strategy); @@ -855,24 +852,15 @@ struct equal : public base_turn_handler int const side_pk_p = has_pk ? side.pk_wrt_p1() : 0; int const side_qk_p = has_qk ? side.qk_wrt_p1() : 0; - if (BOOST_GEOMETRY_CONDITION(VerifyPolicy::use_side_verification) - && has_pk && has_qk && side_pk_p == side_qk_p) + if (has_pk && has_qk && side_pk_p == side_qk_p) { // They turn to the same side, or continue both collinearly - // Without rescaling, to check for union/intersection, - // try to check side values (without any thresholds) - auto const dm_pk_q2 - = get_distance_measure(range_q.at(1), range_q.at(2), range_p.at(2), - umbrella_strategy); - auto const dm_qk_p2 - = get_distance_measure(range_p.at(1), range_p.at(2), range_q.at(2), - umbrella_strategy); - - if (dm_qk_p2.measure != dm_pk_q2.measure) + // To check for union/intersection, try to check side values + int const side_qk_p2 = side.qk_wrt_p2(); + + if (opposite(side_qk_p2, side_pk_q2)) { - // A (possibly very small) difference is detected, which - // can be used to distinguish between union/intersection - ui_else_iu(dm_qk_p2.measure < dm_pk_q2.measure, ti); + ui_else_iu(side_pk_q2 == 1, ti); return; } } diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp index 76d7faf6de..90e4d0d063 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turn_info_la.hpp @@ -696,7 +696,7 @@ struct get_turn_info_linear_areal namespace ov = overlay; typedef ov::get_turn_info_for_endpoint get_info_e; - const std::size_t ip_count = inters.i_info().count; + std::size_t const ip_count = inters.i_info().count; // no intersection points if (ip_count == 0) { diff --git a/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp b/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp index 326c883b39..b6f8983e31 100644 --- a/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/get_turns.hpp @@ -39,7 +39,6 @@ #include #include -#include #include #include #include @@ -669,10 +668,6 @@ struct get_turns_cs // into account (not in the iterator, nor in the retrieve policy) iterator_type it = boost::begin(view); - //bool first = true; - - //char previous_side[2] = {0, 0}; - signed_size_type index = 0; for (iterator_type prev = it++; @@ -684,64 +679,19 @@ struct get_turns_cs unique_sub_range_from_view_policy view_unique_sub_range(view, *prev, *it, it); - /*if (first) - { - previous_side[0] = get_side<0>(box, *prev); - previous_side[1] = get_side<1>(box, *prev); - } - - char current_side[2]; - current_side[0] = get_side<0>(box, *it); - current_side[1] = get_side<1>(box, *it); - - // There can NOT be intersections if - // 1) EITHER the two points are lying on one side of the box (! 0 && the same) - // 2) OR same in Y-direction - // 3) OR all points are inside the box (0) - if (! ( - (current_side[0] != 0 && current_side[0] == previous_side[0]) - || (current_side[1] != 0 && current_side[1] == previous_side[1]) - || (current_side[0] == 0 - && current_side[1] == 0 - && previous_side[0] == 0 - && previous_side[1] == 0) - ) - )*/ - if (true) - { - get_turns_with_box(seg_id, source_id2, - view_unique_sub_range, - box_points, - intersection_strategy, - robust_policy, - turns, - interrupt_policy); - // Future performance enhancement: - // return if told by the interrupt policy - } + get_turns_with_box(seg_id, source_id2, + view_unique_sub_range, + box_points, + intersection_strategy, + robust_policy, + turns, + interrupt_policy); + // Future performance enhancement: + // return if told by the interrupt policy } } private: - template - static inline int get_side(Box const& box, Point const& point) - { - // Inside -> 0 - // Outside -> -1 (left/below) or 1 (right/above) - // On border -> -2 (left/lower) or 2 (right/upper) - // The only purpose of the value is to not be the same, - // and to denote if it is inside (0) - - typename coordinate_type::type const& c = get(point); - typename coordinate_type::type const& left = get(box); - typename coordinate_type::type const& right = get(box); - - if (geometry::math::equals(c, left)) return -2; - else if (geometry::math::equals(c, right)) return 2; - else if (c < left) return -1; - else if (c > right) return 1; - else return 0; - } template < diff --git a/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp b/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp index aaabb4a4df..b41697477d 100644 --- a/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/handle_colocations.hpp @@ -296,7 +296,7 @@ inline void assign_cluster_ids(Turns& turns, Clusters const& clusters) } for (auto const& kv : clusters) { - for (const auto& index : kv.second.turn_indices) + for (auto const& index : kv.second.turn_indices) { turns[index].cluster_id = kv.first; } diff --git a/include/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp b/include/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp index 435a80c272..3d7ea5eb32 100644 --- a/include/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp @@ -128,7 +128,7 @@ private : template static inline bool is_self_cluster(signed_size_type cluster_id, - const Turns& turns, Clusters const& clusters) + Turns const& turns, Clusters const& clusters) { auto cit = clusters.find(cluster_id); if (cit == clusters.end()) diff --git a/include/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp b/include/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp index 1486f94fbd..4f91c054ad 100644 --- a/include/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/inconsistent_turns_exception.hpp @@ -22,10 +22,7 @@ class inconsistent_turns_exception : public geometry::exception inline inconsistent_turns_exception() {} - virtual ~inconsistent_turns_exception() throw() - {} - - virtual char const* what() const throw() + char const* what() const noexcept override { return "Boost.Geometry Inconsistent Turns exception"; } diff --git a/include/boost/geometry/algorithms/detail/overlay/range_in_geometry.hpp b/include/boost/geometry/algorithms/detail/overlay/range_in_geometry.hpp index e41ee8238c..4fd69411d0 100644 --- a/include/boost/geometry/algorithms/detail/overlay/range_in_geometry.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/range_in_geometry.hpp @@ -13,7 +13,6 @@ #include -#include #include #include diff --git a/include/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp b/include/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp index 20369fa95a..1883e1df21 100644 --- a/include/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/self_turn_points.hpp @@ -24,7 +24,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/detail/overlay/sort_by_side.hpp b/include/boost/geometry/algorithms/detail/overlay/sort_by_side.hpp index 503b36720a..7e31a9fa9d 100644 --- a/include/boost/geometry/algorithms/detail/overlay/sort_by_side.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/sort_by_side.hpp @@ -89,7 +89,7 @@ struct ranked_point struct less_by_turn_index { template - inline bool operator()(const T& first, const T& second) const + inline bool operator()(T const& first, T const& second) const { return first.turn_index == second.turn_index ? first.index < second.index @@ -101,7 +101,7 @@ struct less_by_turn_index struct less_by_index { template - inline bool operator()(const T& first, const T& second) const + inline bool operator()(T const& first, T const& second) const { // Length might be considered too // First order by from/to @@ -123,7 +123,7 @@ struct less_by_index struct less_false { template - inline bool operator()(const T&, const T& ) const + inline bool operator()(T const&, T const& ) const { return false; } @@ -132,14 +132,14 @@ struct less_false template struct less_by_side { - less_by_side(const PointOrigin& p1, const PointTurn& p2, SideStrategy const& strategy) + less_by_side(PointOrigin const& p1, PointTurn const& p2, SideStrategy const& strategy) : m_origin(p1) , m_turn_point(p2) , m_strategy(strategy) {} template - inline bool operator()(const T& first, const T& second) const + inline bool operator()(T const& first, T const& second) const { typedef typename SideStrategy::cs_tag cs_tag; @@ -325,7 +325,8 @@ public : double >::type; - ct_type const tolerance = 1000000000; + static auto const tolerance + = common_approximately_equals_epsilon_multiplier::value(); int offset = 0; while (approximately_equals(point_from, turn.point, tolerance) @@ -417,7 +418,7 @@ public : for (std::size_t i = 0; i < m_ranked_points.size(); i++) { - const rp& ranked = m_ranked_points[i]; + rp const& ranked = m_ranked_points[i]; if (ranked.direction != dir_from) { continue; @@ -439,7 +440,7 @@ public : bool handled[2] = {false, false}; for (std::size_t i = 0; i < m_ranked_points.size(); i++) { - const rp& ranked = m_ranked_points[i]; + rp const& ranked = m_ranked_points[i]; if (ranked.direction != dir_from) { continue; diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp index 22ae1a2de8..82cfb86a83 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal.hpp @@ -26,7 +26,6 @@ #include #include #include -#include #include #include @@ -505,7 +504,7 @@ public : } inline - bool select_operation(const turn_type& turn, + bool select_operation(turn_type const& turn, signed_size_type turn_index, signed_size_type start_turn_index, segment_identifier const& previous_seg_id, @@ -536,7 +535,7 @@ public : return result; } - inline int starting_operation_index(const turn_type& turn) const + inline int starting_operation_index(turn_type const& turn) const { for (int i = 0; i < 2; i++) { @@ -548,7 +547,7 @@ public : return -1; } - inline bool both_finished(const turn_type& turn) const + inline bool both_finished(turn_type const& turn) const { for (int i = 0; i < 2; i++) { diff --git a/include/boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp b/include/boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp index fd3513ff2c..692de7345a 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal_ring_creator.hpp @@ -16,13 +16,13 @@ #include #include +#include #include #include #include #include #include -#include #include #include @@ -140,7 +140,7 @@ struct traversal_ring_creator if (! m_trav.select_turn(start_turn_index, start_op_index, turn_index, op_index, previous_op_index, previous_turn_index, previous_seg_id, - is_start, current_ring.size() > 1)) + is_start, boost::size(current_ring) > 1)) { return is_start ? traverse_error_no_next_ip_at_start @@ -149,8 +149,8 @@ struct traversal_ring_creator { // Check operation (TODO: this might be redundant or should be catched before) - const turn_type& current_turn = m_turns[turn_index]; - const turn_operation_type& op = current_turn.operations[op_index]; + turn_type const& current_turn = m_turns[turn_index]; + turn_operation_type const& op = current_turn.operations[op_index]; if (op.visited.finalized() || m_trav.is_visited(current_turn, op, turn_index, op_index)) { @@ -274,6 +274,9 @@ struct traversal_ring_creator if (traverse_error == traverse_error_none) { + remove_spikes_at_closure(ring, m_strategy, m_robust_policy); + fix_closure(ring, m_strategy); + std::size_t const min_num_points = core_detail::closure::minimum_ring_size < @@ -282,7 +285,6 @@ struct traversal_ring_creator if (geometry::num_points(ring) >= min_num_points) { - clean_closing_dups_and_spikes(ring, m_strategy, m_robust_policy); rings.push_back(ring); m_trav.finalize_visit_info(m_turn_info_map); 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 be0f2bcd87..1858c9ec2a 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traversal_switch_detector.hpp @@ -21,7 +21,11 @@ #include #include #include + +#if defined(BOOST_GEOMETRY_DEBUG_TRAVERSAL_SWITCH_DETECTOR) #include +#endif + #include #include diff --git a/include/boost/geometry/algorithms/detail/overlay/traverse.hpp b/include/boost/geometry/algorithms/detail/overlay/traverse.hpp index 710cea09e9..d56b6b1b2a 100644 --- a/include/boost/geometry/algorithms/detail/overlay/traverse.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/traverse.hpp @@ -11,6 +11,8 @@ #include +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/detail/relate/boundary_checker.hpp b/include/boost/geometry/algorithms/detail/relate/boundary_checker.hpp index 0d95aabac1..91f4dac5b0 100644 --- a/include/boost/geometry/algorithms/detail/relate/boundary_checker.hpp +++ b/include/boost/geometry/algorithms/detail/relate/boundary_checker.hpp @@ -13,6 +13,7 @@ #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_BOUNDARY_CHECKER_HPP #include +#include #include #include diff --git a/include/boost/geometry/algorithms/detail/relate/box_areal.hpp b/include/boost/geometry/algorithms/detail/relate/box_areal.hpp index a9e749fdb2..425e17e25c 100644 --- a/include/boost/geometry/algorithms/detail/relate/box_areal.hpp +++ b/include/boost/geometry/algorithms/detail/relate/box_areal.hpp @@ -51,9 +51,9 @@ struct box_areal } template - static inline void apply(Box const& box, Areal const& areal, - Result& result, - Strategy const& strategy, + static inline void apply(Box const& /* box */, Areal const& /* areal */, + Result& /* result */, + Strategy const& /* strategy */, std::false_type /*is_cartesian*/) { BOOST_GEOMETRY_STATIC_ASSERT_FALSE( diff --git a/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp b/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp index cb1f0f40c9..39d27da01e 100644 --- a/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp +++ b/include/boost/geometry/algorithms/detail/relate/follow_helpers.hpp @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -98,7 +99,7 @@ struct for_each_disjoint_geometry_if { BOOST_GEOMETRY_ASSERT(first != last); - const std::size_t count = boost::size(geometry); + std::size_t const count = boost::size(geometry); // O(I) // gather info about turns generated for contained geometries @@ -229,8 +230,8 @@ class segment_watcher template class exit_watcher { - static const std::size_t op_id = OpId; - static const std::size_t other_op_id = (OpId + 1) % 2; + static std::size_t const op_id = OpId; + static std::size_t const other_op_id = (OpId + 1) % 2; typedef typename TurnInfo::point_type point_type; typedef detail::relate::point_info point_info; diff --git a/include/boost/geometry/algorithms/detail/relate/point_point.hpp b/include/boost/geometry/algorithms/detail/relate/point_point.hpp index c987bb44cb..9e8ccaca23 100644 --- a/include/boost/geometry/algorithms/detail/relate/point_point.hpp +++ b/include/boost/geometry/algorithms/detail/relate/point_point.hpp @@ -19,6 +19,7 @@ #include #include +#include #include #include diff --git a/include/boost/geometry/algorithms/detail/relate/topology_check.hpp b/include/boost/geometry/algorithms/detail/relate/topology_check.hpp index 2fc31ab51b..90f1ebd52f 100644 --- a/include/boost/geometry/algorithms/detail/relate/topology_check.hpp +++ b/include/boost/geometry/algorithms/detail/relate/topology_check.hpp @@ -12,6 +12,7 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_TOPOLOGY_CHECK_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_TOPOLOGY_CHECK_HPP +#include #include #include diff --git a/include/boost/geometry/algorithms/detail/sections/range_by_section.hpp b/include/boost/geometry/algorithms/detail/sections/range_by_section.hpp index f321b40b2a..fd029db1b3 100644 --- a/include/boost/geometry/algorithms/detail/sections/range_by_section.hpp +++ b/include/boost/geometry/algorithms/detail/sections/range_by_section.hpp @@ -21,7 +21,6 @@ #include #include -#include #include #include #include diff --git a/include/boost/geometry/algorithms/discrete_frechet_distance.hpp b/include/boost/geometry/algorithms/discrete_frechet_distance.hpp index 094ae14a3b..c84ec99b40 100644 --- a/include/boost/geometry/algorithms/discrete_frechet_distance.hpp +++ b/include/boost/geometry/algorithms/discrete_frechet_distance.hpp @@ -22,6 +22,8 @@ #include +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/discrete_hausdorff_distance.hpp b/include/boost/geometry/algorithms/discrete_hausdorff_distance.hpp index 115909c06a..9e08c761ae 100644 --- a/include/boost/geometry/algorithms/discrete_hausdorff_distance.hpp +++ b/include/boost/geometry/algorithms/discrete_hausdorff_distance.hpp @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include diff --git a/include/boost/geometry/algorithms/is_convex.hpp b/include/boost/geometry/algorithms/is_convex.hpp index afde6453f5..c5aef2ecbf 100644 --- a/include/boost/geometry/algorithms/is_convex.hpp +++ b/include/boost/geometry/algorithms/is_convex.hpp @@ -16,6 +16,7 @@ #include +#include #include #include diff --git a/include/boost/geometry/arithmetic/infinite_line_functions.hpp b/include/boost/geometry/arithmetic/infinite_line_functions.hpp index 529e83716b..16acb866c5 100644 --- a/include/boost/geometry/arithmetic/infinite_line_functions.hpp +++ b/include/boost/geometry/arithmetic/infinite_line_functions.hpp @@ -97,7 +97,7 @@ side_value(model::infinite_line const& line, Point const& p) } template -inline bool is_degenerate(const model::infinite_line& line) +inline bool is_degenerate(model::infinite_line const& line) { static Type const zero = 0; return math::equals(line.a, zero) && math::equals(line.b, zero); diff --git a/include/boost/geometry/core/exception.hpp b/include/boost/geometry/core/exception.hpp index 72bc598b2a..2dbd298ca4 100644 --- a/include/boost/geometry/core/exception.hpp +++ b/include/boost/geometry/core/exception.hpp @@ -33,7 +33,7 @@ namespace boost { namespace geometry class exception : public std::exception { public: - virtual char const* what() const throw() + char const* what() const noexcept override { return "Boost.Geometry exception"; } @@ -52,7 +52,7 @@ class invalid_input_exception : public geometry::exception inline invalid_input_exception() {} - virtual char const* what() const throw() + char const* what() const noexcept override { return "Boost.Geometry Invalid-Input exception"; } @@ -77,7 +77,7 @@ class empty_input_exception : public geometry::invalid_input_exception inline empty_input_exception() {} - virtual char const* what() const throw() + virtual char const* what() const noexcept { return "Boost.Geometry Empty-Input exception"; } @@ -96,7 +96,7 @@ class invalid_output_exception : public geometry::exception inline invalid_output_exception() {} - virtual char const* what() const throw() + char const* what() const noexcept override { return "Boost.Geometry Invalid-Output exception"; } diff --git a/include/boost/geometry/formulas/karney_inverse.hpp b/include/boost/geometry/formulas/karney_inverse.hpp index 47efc9ff5e..12dd2b2598 100644 --- a/include/boost/geometry/formulas/karney_inverse.hpp +++ b/include/boost/geometry/formulas/karney_inverse.hpp @@ -32,6 +32,7 @@ #define BOOST_GEOMETRY_FORMULAS_KARNEY_INVERSE_HPP +#include #include #include @@ -191,7 +192,7 @@ class karney_inverse if (swap_point < 0) { lon12_sign *= -1; - swap(lat1, lat2); + boost::core::invoke_swap(lat1, lat2); } // Enforce lat1 to be <= 0. @@ -448,9 +449,9 @@ class karney_inverse if (swap_point < 0) { - swap(sin_alpha1, sin_alpha2); - swap(cos_alpha1, cos_alpha2); - swap(result.geodesic_scale, M21); + boost::core::invoke_swap(sin_alpha1, sin_alpha2); + boost::core::invoke_swap(cos_alpha1, cos_alpha2); + boost::core::invoke_swap(result.geodesic_scale, M21); } sin_alpha1 *= swap_point * lon12_sign; diff --git a/include/boost/geometry/formulas/meridian_direct.hpp b/include/boost/geometry/formulas/meridian_direct.hpp index 330af6703f..3699e4c7cb 100644 --- a/include/boost/geometry/formulas/meridian_direct.hpp +++ b/include/boost/geometry/formulas/meridian_direct.hpp @@ -84,8 +84,8 @@ class meridian_direct { result.reverse_azimuth = pi; } - else if (result.lat2 < -half_pi && - result.lat2 > -one_and_a_half_pi) + else if (result.lat2 > -one_and_a_half_pi && + result.lat2 < -half_pi) { result.reverse_azimuth = c0; } diff --git a/include/boost/geometry/index/detail/algorithms/intersection_content.hpp b/include/boost/geometry/index/detail/algorithms/intersection_content.hpp index 1a2cd28bc0..260af9eca5 100644 --- a/include/boost/geometry/index/detail/algorithms/intersection_content.hpp +++ b/include/boost/geometry/index/detail/algorithms/intersection_content.hpp @@ -16,7 +16,7 @@ #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_INTERSECTION_CONTENT_HPP #include -#include +#include #include diff --git a/include/boost/geometry/index/detail/algorithms/path_intersection.hpp b/include/boost/geometry/index/detail/algorithms/path_intersection.hpp index 831efe5046..afa203e1e3 100644 --- a/include/boost/geometry/index/detail/algorithms/path_intersection.hpp +++ b/include/boost/geometry/index/detail/algorithms/path_intersection.hpp @@ -27,6 +27,10 @@ #include #include +#include +#include +#include +#include namespace boost { namespace geometry { namespace index { namespace detail { 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 c545a4160a..ba0fd7c9ac 100644 --- a/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp +++ b/include/boost/geometry/index/detail/rtree/node/variant_dynamic.hpp @@ -16,8 +16,10 @@ #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 @@ -184,7 +186,7 @@ class allocators void swap(allocators & a) { - boost::swap(node_allocator(), a.node_allocator()); + boost::core::invoke_swap(node_allocator(), a.node_allocator()); } bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); } 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 c1612b9853..e0150a7033 100644 --- a/include/boost/geometry/index/detail/rtree/node/variant_static.hpp +++ b/include/boost/geometry/index/detail/rtree/node/variant_static.hpp @@ -15,6 +15,12 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_VARIANT_STATIC_HPP +#include +#include +#include +#include +#include + #include #include @@ -146,7 +152,7 @@ class allocators void swap(allocators & a) { - boost::swap(node_allocator(), a.node_allocator()); + boost::core::invoke_swap(node_allocator(), a.node_allocator()); } bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); } 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 8c2ec41475..6db7161ee9 100644 --- a/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp +++ b/include/boost/geometry/index/detail/rtree/node/weak_dynamic.hpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include @@ -228,8 +228,8 @@ class allocators void swap(allocators & a) { - boost::swap(internal_node_allocator(), a.internal_node_allocator()); - boost::swap(leaf_allocator(), a.leaf_allocator()); + boost::core::invoke_swap(internal_node_allocator(), a.internal_node_allocator()); + boost::core::invoke_swap(leaf_allocator(), a.leaf_allocator()); } bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); } 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 a1a5988643..9569afc56c 100644 --- a/include/boost/geometry/index/detail/rtree/node/weak_static.hpp +++ b/include/boost/geometry/index/detail/rtree/node/weak_static.hpp @@ -15,6 +15,10 @@ #ifndef BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_RTREE_NODE_WEAK_STATIC_HPP +#include +#include +#include + #include #include @@ -155,8 +159,8 @@ class allocators void swap(allocators & a) { - boost::swap(internal_node_allocator(), a.internal_node_allocator()); - boost::swap(leaf_allocator(), a.leaf_allocator()); + boost::core::invoke_swap(internal_node_allocator(), a.internal_node_allocator()); + boost::core::invoke_swap(leaf_allocator(), a.leaf_allocator()); } bool operator==(allocators const& a) const { return leaf_allocator() == a.leaf_allocator(); } diff --git a/include/boost/geometry/index/detail/utilities.hpp b/include/boost/geometry/index/detail/utilities.hpp index 9060071b33..afe122904b 100644 --- a/include/boost/geometry/index/detail/utilities.hpp +++ b/include/boost/geometry/index/detail/utilities.hpp @@ -12,7 +12,7 @@ #include -#include +#include #ifndef BOOST_GEOMETRY_INDEX_DETAIL_UTILITIES_HPP #define BOOST_GEOMETRY_INDEX_DETAIL_UTILITIES_HPP @@ -40,7 +40,7 @@ static inline void move_cond(T &, T &, std::false_type) {} template inline void swap_cond(T & l, T & r, std::true_type) { - ::boost::swap(l, r); + ::boost::core::invoke_swap(l, r); } template inline diff --git a/include/boost/geometry/index/detail/varray.hpp b/include/boost/geometry/index/detail/varray.hpp index 9911520bbb..4d010cb828 100644 --- a/include/boost/geometry/index/detail/varray.hpp +++ b/include/boost/geometry/index/detail/varray.hpp @@ -21,7 +21,6 @@ #include #include #include -#include #include // TODO - use std::reverse_iterator and std::iterator_traits @@ -1566,7 +1565,6 @@ class varray { //std::iter_swap(first_sm, first_la); //std::swap(*first_sm, *first_la); // may throw - //boost::swap(*first_sm, *first_la); value_type temp(std::move(*first_sm)); // may throw *first_sm = std::move(*first_la); // may throw *first_la = std::move(temp); // may throw diff --git a/include/boost/geometry/index/rtree.hpp b/include/boost/geometry/index/rtree.hpp index 425dae965a..584a77624b 100644 --- a/include/boost/geometry/index/rtree.hpp +++ b/include/boost/geometry/index/rtree.hpp @@ -24,6 +24,7 @@ // Boost #include #include +#include // Boost.Geometry #include @@ -657,9 +658,9 @@ class rtree src.m_members.parameters(), std::move(src.m_members.allocators())) { - boost::swap(m_members.values_count, src.m_members.values_count); - boost::swap(m_members.leafs_level, src.m_members.leafs_level); - boost::swap(m_members.root, src.m_members.root); + boost::core::invoke_swap(m_members.values_count, src.m_members.values_count); + boost::core::invoke_swap(m_members.leafs_level, src.m_members.leafs_level); + boost::core::invoke_swap(m_members.root, src.m_members.root); } /*! @@ -683,9 +684,9 @@ class rtree { if ( src.m_members.allocators() == allocator ) { - boost::swap(m_members.values_count, src.m_members.values_count); - boost::swap(m_members.leafs_level, src.m_members.leafs_level); - boost::swap(m_members.root, src.m_members.root); + boost::core::invoke_swap(m_members.values_count, src.m_members.values_count); + boost::core::invoke_swap(m_members.leafs_level, src.m_members.leafs_level); + boost::core::invoke_swap(m_members.root, src.m_members.root); } else { @@ -758,9 +759,9 @@ class rtree m_members.equal_to() = src.m_members.equal_to(); m_members.parameters() = src.m_members.parameters(); - boost::swap(m_members.values_count, src.m_members.values_count); - boost::swap(m_members.leafs_level, src.m_members.leafs_level); - boost::swap(m_members.root, src.m_members.root); + boost::core::invoke_swap(m_members.values_count, src.m_members.values_count); + boost::core::invoke_swap(m_members.leafs_level, src.m_members.leafs_level); + boost::core::invoke_swap(m_members.root, src.m_members.root); // NOTE: if propagate is true for std allocators on darwin 4.2.1, glibc++ // (allocators stored as base classes of members_holder) @@ -795,9 +796,9 @@ class rtree */ void swap(rtree & other) { - boost::swap(m_members.indexable_getter(), other.m_members.indexable_getter()); - boost::swap(m_members.equal_to(), other.m_members.equal_to()); - boost::swap(m_members.parameters(), other.m_members.parameters()); + boost::core::invoke_swap(m_members.indexable_getter(), other.m_members.indexable_getter()); + boost::core::invoke_swap(m_members.equal_to(), other.m_members.equal_to()); + boost::core::invoke_swap(m_members.parameters(), other.m_members.parameters()); // NOTE: if propagate is true for std allocators on darwin 4.2.1, glibc++ // (allocators stored as base classes of members_holder) @@ -808,9 +809,9 @@ class rtree > propagate; detail::swap_cond(m_members.allocators(), other.m_members.allocators(), propagate()); - boost::swap(m_members.values_count, other.m_members.values_count); - boost::swap(m_members.leafs_level, other.m_members.leafs_level); - boost::swap(m_members.root, other.m_members.root); + boost::core::invoke_swap(m_members.values_count, other.m_members.values_count); + boost::core::invoke_swap(m_members.leafs_level, other.m_members.leafs_level); + boost::core::invoke_swap(m_members.root, other.m_members.root); } /*! diff --git a/include/boost/geometry/io/dsv/write.hpp b/include/boost/geometry/io/dsv/write.hpp index 5870d21c58..e8b257a93a 100644 --- a/include/boost/geometry/io/dsv/write.hpp +++ b/include/boost/geometry/io/dsv/write.hpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include diff --git a/include/boost/geometry/io/svg/svg_mapper.hpp b/include/boost/geometry/io/svg/svg_mapper.hpp index 76be933c08..06ac64c3c2 100644 --- a/include/boost/geometry/io/svg/svg_mapper.hpp +++ b/include/boost/geometry/io/svg/svg_mapper.hpp @@ -456,7 +456,7 @@ public : << " x=\"" << get<0>(map_point) + offset_x << "\"" << " y=\"" << get<1>(map_point) + offset_y << "\"" << ">"; - if (s.find("\n") == std::string::npos) + if (s.find('\n') == std::string::npos) { m_stream << s; } diff --git a/include/boost/geometry/io/wkt/read.hpp b/include/boost/geometry/io/wkt/read.hpp index a8d0f6a484..5bbfd235c2 100644 --- a/include/boost/geometry/io/wkt/read.hpp +++ b/include/boost/geometry/io/wkt/read.hpp @@ -96,9 +96,7 @@ struct read_wkt_exception : public geometry::exception complete = message + "' in (" + wkt.substr(0, 100) + ")"; } - virtual ~read_wkt_exception() throw() {} - - virtual const char* what() const throw() + const char* what() const noexcept override { return complete.c_str(); } diff --git a/include/boost/geometry/policies/robustness/rescale_policy.hpp b/include/boost/geometry/policies/robustness/rescale_policy.hpp index 9394f8d9d4..7d6ad7e9fa 100644 --- a/include/boost/geometry/policies/robustness/rescale_policy.hpp +++ b/include/boost/geometry/policies/robustness/rescale_policy.hpp @@ -5,9 +5,10 @@ // Copyright (c) 2014-2015 Mateusz Loskot, London, UK. // Copyright (c) 2014-2015 Adam Wulkiewicz, Lodz, Poland. -// This file was modified by Oracle on 2015, 2018. -// Modifications copyright (c) 2015-2018, Oracle and/or its affiliates. +// This file was modified by Oracle on 2015, 2023. +// Modifications copyright (c) 2015-2023, 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, @@ -19,6 +20,7 @@ #include +#include #include #include diff --git a/include/boost/geometry/policies/robustness/segment_ratio.hpp b/include/boost/geometry/policies/robustness/segment_ratio.hpp index 9a3914a756..5a75fad014 100644 --- a/include/boost/geometry/policies/robustness/segment_ratio.hpp +++ b/include/boost/geometry/policies/robustness/segment_ratio.hpp @@ -153,7 +153,7 @@ class segment_ratio , m_approximation(0) {} - inline segment_ratio(const Type& numerator, const Type& denominator) + inline segment_ratio(Type const& numerator, Type const& denominator) : m_numerator(numerator) , m_denominator(denominator) { @@ -207,7 +207,7 @@ class segment_ratio inline Type const& numerator() const { return m_numerator; } inline Type const& denominator() const { return m_denominator; } - inline void assign(const Type& numerator, const Type& denominator) + inline void assign(Type const& numerator, Type const& denominator) { m_numerator = numerator; m_denominator = denominator; diff --git a/include/boost/geometry/srs/projection.hpp b/include/boost/geometry/srs/projection.hpp index 9025952c0d..00e4523f79 100644 --- a/include/boost/geometry/srs/projection.hpp +++ b/include/boost/geometry/srs/projection.hpp @@ -19,6 +19,7 @@ #include #include +#include #include #include diff --git a/include/boost/geometry/srs/projections/exception.hpp b/include/boost/geometry/srs/projections/exception.hpp index c96ee005a5..f565cb70e1 100644 --- a/include/boost/geometry/srs/projections/exception.hpp +++ b/include/boost/geometry/srs/projections/exception.hpp @@ -43,7 +43,7 @@ class projection_exception : public geometry::exception , m_msg(msg) {} - virtual char const* what() const throw() + char const* what() const noexcept override { //return "Boost.Geometry Projection exception"; return m_msg.what(); diff --git a/include/boost/geometry/srs/projections/str_cast.hpp b/include/boost/geometry/srs/projections/str_cast.hpp index e3729e2be5..70c6b6d1f7 100644 --- a/include/boost/geometry/srs/projections/str_cast.hpp +++ b/include/boost/geometry/srs/projections/str_cast.hpp @@ -21,7 +21,7 @@ namespace boost { namespace geometry class bad_str_cast : public geometry::exception { - virtual char const* what() const throw() + char const* what() const noexcept override { return "Unable to convert from string."; } diff --git a/include/boost/geometry/srs/transformation.hpp b/include/boost/geometry/srs/transformation.hpp index d3c9b09c53..b327e11218 100644 --- a/include/boost/geometry/srs/transformation.hpp +++ b/include/boost/geometry/srs/transformation.hpp @@ -14,6 +14,7 @@ #include #include +#include #include #include diff --git a/include/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp b/include/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp index 35aae192a3..02e72cf051 100644 --- a/include/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp +++ b/include/boost/geometry/strategies/agnostic/point_in_poly_oriented_winding.hpp @@ -2,6 +2,10 @@ // Copyright (c) 2011-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2023, Oracle and/or its affiliates. + +// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle + // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. @@ -13,6 +17,7 @@ #define BOOST_GEOMETRY_STRATEGY_AGNOSTIC_POINT_IN_POLY_ORIENTED_WINDING_HPP +#include #include #include #include diff --git a/include/boost/geometry/strategies/cartesian/centroid_average.hpp b/include/boost/geometry/strategies/cartesian/centroid_average.hpp index 103a1d8ab3..a382a2fbd4 100644 --- a/include/boost/geometry/strategies/cartesian/centroid_average.hpp +++ b/include/boost/geometry/strategies/cartesian/centroid_average.hpp @@ -3,7 +3,7 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2017-2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2015-2021. // Modifications copyright (c) 2015-2021 Oracle and/or its affiliates. @@ -89,7 +89,8 @@ public : centroid = state.centroid; if ( state.count > 0 ) { - divide_value(centroid, state.count); + using coord_t = typename coordinate_type::type; + divide_value(centroid, static_cast(state.count)); return true; } return false; diff --git a/include/boost/geometry/strategies/cartesian/side_rounded_input.hpp b/include/boost/geometry/strategies/cartesian/side_rounded_input.hpp index fc1543008f..9283a2b845 100644 --- a/include/boost/geometry/strategies/cartesian/side_rounded_input.hpp +++ b/include/boost/geometry/strategies/cartesian/side_rounded_input.hpp @@ -47,7 +47,7 @@ struct side_rounded_input coor_t const p_x = geometry::get<0>(p); coor_t const p_y = geometry::get<1>(p); - constexpr coor_t eps = std::numeric_limits::epsilon() / 2; + static coor_t const eps = std::numeric_limits::epsilon() / 2; coor_t const det = (p1_x - p_x) * (p2_y - p_y) - (p1_y - p_y) * (p2_x - p_x); coor_t const err_bound = (Coeff1 * eps + Coeff2 * eps * eps) * ( (geometry::math::abs(p1_x) + geometry::math::abs(p_x)) diff --git a/include/boost/geometry/strategy/spherical/envelope_range.hpp b/include/boost/geometry/strategy/spherical/envelope_range.hpp index 8833bd8ea3..e9f5ba2188 100644 --- a/include/boost/geometry/strategy/spherical/envelope_range.hpp +++ b/include/boost/geometry/strategy/spherical/envelope_range.hpp @@ -10,6 +10,8 @@ #ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_RANGE_HPP #define BOOST_GEOMETRY_STRATEGY_SPHERICAL_ENVELOPE_RANGE_HPP +#include + #include #include #include diff --git a/include/boost/geometry/util/math.hpp b/include/boost/geometry/util/math.hpp index c88572ed53..edd0f412c2 100644 --- a/include/boost/geometry/util/math.hpp +++ b/include/boost/geometry/util/math.hpp @@ -450,7 +450,7 @@ struct define_half_pi template struct relaxed_epsilon { - static inline T apply(const T& factor) + static inline T apply(T const& factor) { return factor * std::numeric_limits::epsilon(); } diff --git a/include/boost/geometry/util/rational.hpp b/include/boost/geometry/util/rational.hpp index 805c85eb46..2e8b751ad9 100644 --- a/include/boost/geometry/util/rational.hpp +++ b/include/boost/geometry/util/rational.hpp @@ -60,10 +60,10 @@ struct coordinate_cast > // Note: decimal comma is not (yet) supported, it does (and should) not // occur in a WKT, where points are comma separated. - std::string::size_type p = source.find("."); + std::string::size_type p = source.find('.'); if (p == std::string::npos) { - p = source.find("/"); + p = source.find('/'); if (p == std::string::npos) { return rational(atol(source.c_str())); diff --git a/include/boost/geometry/util/series_expansion.hpp b/include/boost/geometry/util/series_expansion.hpp index bdc4d7c6eb..55c8b8f2fc 100644 --- a/include/boost/geometry/util/series_expansion.hpp +++ b/include/boost/geometry/util/series_expansion.hpp @@ -30,6 +30,7 @@ #ifndef BOOST_GEOMETRY_UTIL_SERIES_EXPANSION_HPP #define BOOST_GEOMETRY_UTIL_SERIES_EXPANSION_HPP +#include #include #include diff --git a/include/boost/geometry/views/detail/boundary_view/implementation.hpp b/include/boost/geometry/views/detail/boundary_view/implementation.hpp index 8a17b760ce..df9842d1f8 100644 --- a/include/boost/geometry/views/detail/boundary_view/implementation.hpp +++ b/include/boost/geometry/views/detail/boundary_view/implementation.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include diff --git a/index/test/algorithms/path_intersection.cpp b/index/test/algorithms/path_intersection.cpp index 66c76c4e1e..2c7e4df15c 100644 --- a/index/test/algorithms/path_intersection.cpp +++ b/index/test/algorithms/path_intersection.cpp @@ -17,7 +17,7 @@ #include #include -//#include +#include template void test_path_intersection(Box const& box, Linestring const& path, diff --git a/index/test/rtree/exceptions/test_throwing.hpp b/index/test/rtree/exceptions/test_throwing.hpp index c88a5f56e3..69306159d3 100644 --- a/index/test/rtree/exceptions/test_throwing.hpp +++ b/index/test/rtree/exceptions/test_throwing.hpp @@ -15,7 +15,7 @@ struct throwing_value_copy_exception : public std::exception { - const char * what() const throw() { return "value copy failed."; } + const char * what() const noexcept { return "value copy failed."; } }; struct throwing_value @@ -79,7 +79,7 @@ struct value< std::pair, throwing_value> > struct throwing_varray_exception : public std::exception { - const char * what() const throw() { return "static vector exception."; } + const char * what() const noexcept { return "static vector exception."; } }; struct throwing_varray_settings diff --git a/index/test/rtree/exceptions/test_throwing_node.hpp b/index/test/rtree/exceptions/test_throwing_node.hpp index e245d79642..5c258b6696 100644 --- a/index/test/rtree/exceptions/test_throwing_node.hpp +++ b/index/test/rtree/exceptions/test_throwing_node.hpp @@ -13,6 +13,13 @@ #define BOOST_GEOMETRY_INDEX_TEST_RTREE_THROWING_NODE_HPP #include +#include +#include +#include +#include +#include +#include +#include struct throwing_nodes_stats { @@ -235,7 +242,7 @@ class allocators void swap(allocators & a) { - boost::swap(node_allocator(), a.node_allocator()); + boost::core::invoke_swap(node_allocator(), a.node_allocator()); } bool operator==(allocators const& a) const { return node_allocator() == a.node_allocator(); } @@ -250,7 +257,7 @@ class allocators struct node_bad_alloc : public std::exception { - const char * what() const throw() { return "internal node creation failed."; } + const char * what() const noexcept { return "internal node creation failed."; } }; struct throwing_node_settings diff --git a/test/algorithms/buffer/buffer_linestring_geo.cpp b/test/algorithms/buffer/buffer_linestring_geo.cpp index 68fe9f2c07..eae4357309 100644 --- a/test/algorithms/buffer/buffer_linestring_geo.cpp +++ b/test/algorithms/buffer/buffer_linestring_geo.cpp @@ -71,7 +71,7 @@ void test_linestring() } settings.test_area = false; - auto const n = sizeof(testcases_aimes) / sizeof(testcases_aimes[0]); + int const n = sizeof(testcases_aimes) / sizeof(testcases_aimes[0]); // Cases (ouf of 197) where the guessed area estimations are not met. // If this needs to be changed, be sure to diff --git a/test/algorithms/buffer/buffer_multi_polygon.cpp b/test/algorithms/buffer/buffer_multi_polygon.cpp index 64f8691a0b..4b87a53788 100644 --- a/test/algorithms/buffer/buffer_multi_polygon.cpp +++ b/test/algorithms/buffer/buffer_multi_polygon.cpp @@ -548,7 +548,10 @@ void test_all() test_one("rt_p15", rt_p15, join_miter, end_flat, 23.6569, 1.0); test_one("rt_p16", rt_p16, join_miter, end_flat, 23.4853, 1.0); +#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES) + // Fails with rescaling after correcting the tolerance in sort_by_side test_one("rt_p17", rt_p17, join_miter, end_flat, 25.3137, 1.0); +#endif test_one("rt_p18", rt_p18, join_miter, end_flat, 23.3137, 1.0); test_one("rt_p19", rt_p19, join_miter, end_flat, 25.5637, 1.0); test_one("rt_p20", rt_p20, join_miter, end_flat, 25.4853, 1.0); @@ -597,9 +600,12 @@ void test_all() test_one("rt_u11_50", rt_u11, join_miter, end_flat, 0.04289, -0.50); test_one("rt_u11_25", rt_u11, join_miter, end_flat, 10.1449, -0.25); +#if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES) + // Fails with rescaling after correcting the tolerance in sort_by_side test_one("rt_u12", rt_u12, join_miter, end_flat, 142.1348, 1.0); +#endif #if ! defined(BOOST_GEOMETRY_USE_RESCALING) || defined(BOOST_GEOMETRY_TEST_FAILURES) - // Fails if rescaling is used in combination with get_clusters + // Fails with rescaling in combination with get_clusters test_one("rt_u13", rt_u13, join_miter, end_flat, 115.4853, 1.0); #endif diff --git a/test/algorithms/buffer/buffer_piece_border.cpp b/test/algorithms/buffer/buffer_piece_border.cpp index 0baeb773f4..b3ce0a2789 100644 --- a/test/algorithms/buffer/buffer_piece_border.cpp +++ b/test/algorithms/buffer/buffer_piece_border.cpp @@ -161,10 +161,10 @@ void test_point(std::string const& wkt, bool expected_outside, Point point; bg::read_wkt(wkt, point); border.point_on_piece(point, false, false, state); - BOOST_CHECK(expected_outside == state.count > 0); - BOOST_CHECK(expected_on_offsetted == state.count_on_offsetted > 0); - BOOST_CHECK(expected_on_edge == state.count_on_edge > 0); - BOOST_CHECK(expected_on_origin == state.count_on_origin > 0); + BOOST_CHECK(expected_outside == (state.count > 0)); + BOOST_CHECK(expected_on_offsetted == (state.count_on_offsetted > 0)); + BOOST_CHECK(expected_on_edge == (state.count_on_edge > 0)); + BOOST_CHECK(expected_on_origin == (state.count_on_origin > 0)); #ifdef TEST_WITH_SVG std::string style = "fill:" + color + ";stroke:rgb(0,0,0);stroke-width:1"; diff --git a/test/algorithms/envelope_expand/test_envelope.hpp b/test/algorithms/envelope_expand/test_envelope.hpp index 0873d81ba5..9ecd9eafb4 100644 --- a/test/algorithms/envelope_expand/test_envelope.hpp +++ b/test/algorithms/envelope_expand/test_envelope.hpp @@ -42,8 +42,8 @@ struct check_result ctype >; - static void apply(Box const& b, const type& x1, const type& y1, const type& /*z1*/, - const type& x2, const type& y2, const type& /*z2*/) + static void apply(Box const& b, type const& x1, type const& y1, type const& /*z1*/, + type const& x2, type const& y2, type const& /*z2*/) { BOOST_CHECK_CLOSE((bg::get(b)), x1, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), y1, 0.001); @@ -64,8 +64,8 @@ struct check_result ctype >; - static void apply(Box const& b, const type& x1, const type& y1, const type& z1, - const type& x2, const type& y2, const type& z2) + static void apply(Box const& b, type const& x1, type const& y1, type const& z1, + type const& x2, type const& y2, type const& z2) { BOOST_CHECK_CLOSE((bg::get(b)), x1, 0.001); BOOST_CHECK_CLOSE((bg::get(b)), y1, 0.001); @@ -80,9 +80,9 @@ struct check_result template void test_envelope(std::string const& wkt, - const T& x1, const T& x2, - const T& y1, const T& y2, - const T& z1 = 0, const T& z2 = 0) + T const& x1, T const& x2, + T const& y1, T const& y2, + T const& z1 = 0, T const& z2 = 0) { typedef bg::model::box::type > box_type; box_type b; diff --git a/test/algorithms/overlay/Jamfile b/test/algorithms/overlay/Jamfile index a3a5be23b5..22995f954a 100644 --- a/test/algorithms/overlay/Jamfile +++ b/test/algorithms/overlay/Jamfile @@ -18,6 +18,7 @@ test-suite boost-geometry-algorithms-overlay [ run assemble.cpp : : : : algorithms_assemble ] [ run copy_segment_point.cpp : : : : algorithms_copy_segment_point ] [ run get_clusters.cpp : : : : algorithms_get_clusters ] + [ run get_distance_measure.cpp : : : : algorithms_get_distance_measure ] [ run get_ring.cpp : : : : algorithms_get_ring ] [ run get_turn_info.cpp : : : : algorithms_get_turn_info ] [ run get_turns.cpp : : : : algorithms_get_turns ] diff --git a/test/algorithms/overlay/get_distance_measure.cpp b/test/algorithms/overlay/get_distance_measure.cpp new file mode 100644 index 0000000000..df0322b35e --- /dev/null +++ b/test/algorithms/overlay/get_distance_measure.cpp @@ -0,0 +1,129 @@ +// Boost.Geometry +// Unit Test + +// Copyright (c) 2023 Barend Gehrels, Amsterdam, the Netherlands. + +// 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) + +#include + +#include +#include +#include +#include +#include + +// #define BOOST_GEOMETRY_TEST_WITH_COUT +// #define BOOST_GEOMETRY_TEST_FAILURES + +template +void do_test(std::string const& case_id, + Point const& s1, + Point const& s2, + Point const& p, + int expected_side, + bool ignore_failure = false) +{ + using coor_t = typename bg::coordinate_type::type; + typename bg::strategies::relate::services::default_strategy + < + Point, Point + >::type strategy; + + auto const dm = bg::detail::get_distance_measure(s1, s2, p, strategy); + auto const dm_side = dm.measure < 0.0 ? -1 : dm.measure > 0.0 ? 1 : 0; + auto const tr_side = strategy.side().apply(s1, s2, p); + auto const rob_side = bg::strategy::side::side_robust::apply(s1, s2, p); + + #if defined(BOOST_GEOMETRY_TEST_WITH_COUT) + std::cout << " " << case_id << " " << string_from_type::name() + << std::setprecision(20) + << " " << dm.measure << " " << dm_side << " " << tr_side << " " << rob_side + << (dm_side != rob_side ? " [*** DM WRONG]" : "") + << (tr_side != rob_side ? " [*** TR WRONG]" : "") + << std::endl; + #endif + + BOOST_CHECK_MESSAGE(expected_side == -9 || expected_side == dm_side, + "Case: " << case_id + << " ctype: " << string_from_type::name() + << " expected: " << expected_side + << " detected: " << dm_side); + + // This is often wrong for float, and sometimes for double + BOOST_CHECK_MESSAGE(ignore_failure || tr_side == dm_side, + "Case: " << case_id + << " ctype: " << string_from_type::name() + << " tr_side: " << tr_side + << " dm_side: " << dm_side); + + // This is always guaranteed for the tested values + BOOST_CHECK_MESSAGE(tr_side == rob_side, + "Case: " << case_id + << " ctype: " << string_from_type::name() + << " tr_side: " << tr_side + << " rob_side: " << rob_side); +} + +template +void test_get_distance_measure() +{ + using coor_t = typename bg::coordinate_type::type; + + do_test("simplex_coll", {1.0, 0.0}, {1.0, 1.0}, {1.0, 0.5}, 0); + do_test("simplex_left", {1.0, 0.0}, {1.0, 1.0}, {0.9, 0.5}, 1); + do_test("simplex_right", {1.0, 0.0}, {1.0, 1.0}, {1.1, 0.5}, -1); + + bool const is_float = std::is_same::value; + bool const is_double = std::is_same::value; + + // The issue 1183 where get_distance_measure failed for these coordinates. + std::string const case_id = "issue_1183_"; + Point const p1{38902.349206128216, 6721371.1493254723}; + Point const p2{38937.993505971914, 6721407.9151819283}; + Point const q1 = p1; + Point const q2{38960.647313876834, 6721431.2817974398}; + { + do_test(case_id + "p", p1, p2, q2, 1, is_float); + do_test(case_id + "q", q1, q2, p1, 0); + } + + double const test_epsilon = 1.0e-9; + + // Walk along x axis to get the switch from left to right (between 2 and 3) + for (int i = -5; i <= 15; i++) + { +#if defined(BOOST_GEOMETRY_TEST_FAILURES) + bool const ignore_failure = false; +#else + bool const ignore_failure = is_float || (is_double && i >= 3 && i <= 12); +#endif + double const v = i / 10.0; + Point q2a = q2; + bg::set<0>(q2a, bg::get<0>(q2) + v * test_epsilon); + do_test(case_id + std::to_string(i), p1, p2, q2a, -9, ignore_failure); + } + // Focus on the switch from left to right (between 0.251 and 0.252) + for (int i = 250; i <= 260; i++) + { + double const v = i / 1000.0; + Point q2a = q2; + bg::set<0>(q2a, bg::get<0>(q2) + v * test_epsilon); + do_test(case_id + std::to_string(i), p1, p2, q2, -9, is_float || is_double); + } +} + +int test_main(int, char* []) +{ + using fp = bg::model::point; + using dp = bg::model::point; + using ep = bg::model::point; + + test_get_distance_measure(); + test_get_distance_measure(); + test_get_distance_measure(); + + return 0; +} diff --git a/test/algorithms/overlay/overlay_cases.hpp b/test/algorithms/overlay/overlay_cases.hpp index 2936a06dd4..48ebfcde11 100644 --- a/test/algorithms/overlay/overlay_cases.hpp +++ b/test/algorithms/overlay/overlay_cases.hpp @@ -1113,6 +1113,69 @@ static std::string issue_1108[2] = "POLYGON((22 1,22 0,14 0,18 -1.2696790939262529996,12 0,22 1))" }; +static std::string issue_1138[2] = +{ + "POLYGON((2000.0 0.0, 2000.0 1500.0, 2041.0688999999999851 1500.0, 2041.0688999999999851 1471.3408999999999196, 2101.0889000000001943 1471.3408999999999196, 2101.0889000000001943 1500.0 2333.7840000000001055 1500.0 2333.7840000000001055 1471.9327000000000680, 2334.3757000000000517 1471.3409999999998945, 2335.2123000000001412 1471.3409999999998945, 2335.8040000000000873 1471.9327000000000680, 2335.8040000000000873 1500.0 2589.9909999999999854 1500.0 2589.9909999999999854 1471.9327000000000680, 2590.3476000000000568 1471.5760999999999967, 2533.8917000000001281 1471.5760999999999967, 2533.8917000000001281 1242.4249999999999545, 2326.7667000000001281 1242.4249999999999545, 2326.7667000000001281 1245.8577000000000226, 2325.5118999999999687 1246.1938999999999851, 2324.6006999999999607 1247.1051999999999680, 2324.2644000000000233 1248.3599999999999000, 2323.7667000000001281 1248.3599999999999000, 2323.7667000000001281 1269.3599999999999000, 2288.7467000000001462 1269.3599999999999000, 2288.7467000000001462 1248.3599999999999000, 2286.7489999999997963 1248.3599999999999000, 2286.4798000000000684 1247.3551999999999680, 2285.7514999999998508 1246.6268999999999778, 2284.7467000000001462 1246.3577000000000226, 2284.7467000000001462 1242.4249999999999545, 2099.4816999999998188 1242.4249999999999545, 2099.4816999999998188 0.0 2000.0 0.0000000000000000))", + "POLYGON((3000.0 0.0,2099.4817 0,2099.4817 1242.425,2316.6867 1242.425,2316.6867 1471.576,2334.1407 1471.576,2333.784 1471.9327,2333.784 1500.0,3000.0 1500.0,3000.0 0.0))" +}; + +static std::string issue_1183[2] = +{ + "POLYGON((\ +-38880.685990792437 6721344.0451435195,\ +-38902.349206128216 6721371.1493254723,\ +-38937.993505971914 6721407.9151819283,\ +-38925.264019448201 6721389.3887558663,\ +-38925.240186032526 6721389.3524003429,\ +-38903.891993208345 6721355.1907963008,\ +-38909.181455691403 6721352.2237809654,\ +-38926.953387540903 6721388.3157829558,\ +-38940.906008282145 6721408.6223519640,\ +-38961.796165266409 6721432.5740491701,\ +-38961.819650679929 6721432.6019898951,\ +-38977.627018370375 6721452.1204930553,\ +-38977.724235665897 6721452.2645238554,\ +-38997.157657657241 6721487.2743892670,\ +-38997.156729985494 6721487.2749042027,\ +-38997.205159411656 6721487.3621566473,\ +-38995.456469315024 6721488.3327662209,\ +-38976.018586129794 6721453.3126770724,\ +-38959.181300235970 6721432.6429256191,\ +-38900.879954713615 6721372.5071140006,\ +-38900.816775977277 6721372.4353842726,\ +-38879.096795985606 6721345.2601805655,\ +-38879.046005852288 6721345.1907021403,\ +-38880.685990792437 6721344.0451435195,\ +))", + "POLYGON((\ +-38880.685990792437 6721344.0451435195,\ +-38902.349206128216 6721371.1493254723,\ +-38960.647313876834 6721431.2817974398,\ +-38960.704662809898 6721431.3463021647,\ +-38977.625225408119 6721452.1182855805,\ +-38977.724248525541 6721452.2645470239,\ +-38997.205159411656 6721487.3621566473,\ +-38995.456469315024 6721488.3327662209,\ +-38976.018586130762 6721453.3126770733,\ +-38959.181300235970 6721432.6429256191,\ +-38900.879954713615 6721372.5071140006,\ +-38879.046005852288 6721345.1907021403,\ +-38880.685990792437 6721344.0451435195,\ +))" +}; + +static std::string issue_1184[2] = +{ + "POLYGON((1169 177,2004 177,2004 1977,1262 1977,1169 177))", + "POLYGON((1179 371,1175 287,1179 287,1179 371))" +}; + +static std::string issue_1186[2] = +{ + "POLYGON((-13848.1446527556 6710443.1496919869,-13847.6993747924 6710443.1496919869,-13847.8106942832 6710440.1096301023,-13848.2559722463 6710440.2884572418,-13848.1446527556 6710443.1496919869))", + "POLYGON((-13848.1446527556 6710443.1496919869,-13848.2559722463 6710440.2884572418,-13847.8106942832 6710440.1096301023,-13847.6993747924 6710443.1496919869,-13847.3654163201 6710442.9708647905,-13846.0295824308 6710442.9708647905,-13846.4748603939 6710435.1024718173,-13847.8106942832 6710435.1024718173,-13848.1446527556 6710435.1024718173,-13849.8144451172 6710443.1496919869,-13848.1446527556 6710443.1496919869),(-13847.4767358109 6710440.1096301023,-13847.8106942832 6710440.1096301023,-13847.9220137740 6710439.9308029665,-13847.5880553017 6710439.7519758362,-13847.4767358109 6710440.1096301023))" +}; + static std::string ggl_list_20120229_volker[3] = { "POLYGON((1716 1554,2076 2250,2436 2352,2796 1248,3156 2484,3516 2688,3516 2688,3156 2484,2796 1248,2436 2352,2076 2250, 1716 1554))", diff --git a/test/algorithms/set_operations/difference/difference.cpp b/test/algorithms/set_operations/difference/difference.cpp index fb38427199..1c36b8f650 100644 --- a/test/algorithms/set_operations/difference/difference.cpp +++ b/test/algorithms/set_operations/difference/difference.cpp @@ -583,6 +583,8 @@ void test_all() #endif TEST_DIFFERENCE(issue_876b, 1, 6114.18234, 1, 4754.29449, count_set(1, 2)); + TEST_DIFFERENCE(issue_1138, 1, 203161.751, 2, 1237551.0171, 1); + TEST_DIFFERENCE(mysql_21977775, 2, 160.856568913, 2, 92.3565689126, 4); TEST_DIFFERENCE(mysql_21965285, 1, 92.0, 1, 14.0, 1); TEST_DIFFERENCE(mysql_23023665_1, 1, 92.0, 1, 142.5, 2); diff --git a/test/algorithms/set_operations/difference/test_difference.hpp b/test/algorithms/set_operations/difference/test_difference.hpp index fb6dfe9a79..d9e13a210d 100644 --- a/test/algorithms/set_operations/difference/test_difference.hpp +++ b/test/algorithms/set_operations/difference/test_difference.hpp @@ -159,7 +159,7 @@ void difference_output(std::string const& caseid, G1 const& g1, G2 const& g2, Ou template std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g2, - const count_set& expected_count, + count_set const& expected_count, int expected_rings_count, int expected_point_count, expectation_limits const& expected_area, difference_type dtype, @@ -305,7 +305,7 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g template std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g2, - const count_set& expected_count, int expected_point_count, + count_set const& expected_count, int expected_point_count, expectation_limits const& expected_area, difference_type dtype, ut_settings const& settings) @@ -323,15 +323,15 @@ static int counter = 0; template std::string test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, - const count_set& expected_count1, + count_set const& expected_count1, int expected_rings_count1, int expected_point_count1, expectation_limits const& expected_area1, - const count_set& expected_count2, + count_set const& expected_count2, int expected_rings_count2, int expected_point_count2, expectation_limits const& expected_area2, - const count_set& expected_count_s, + count_set const& expected_count_s, int expected_rings_count_s, int expected_point_count_s, expectation_limits const& expected_area_s, @@ -382,11 +382,11 @@ std::string test_one(std::string const& caseid, template std::string test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, - const count_set& expected_count1, + count_set const& expected_count1, int expected_rings_count1, int expected_point_count1, expectation_limits const& expected_area1, - const count_set& expected_count2, + count_set const& expected_count2, int expected_rings_count2, int expected_point_count2, expectation_limits const& expected_area2, @@ -407,13 +407,13 @@ std::string test_one(std::string const& caseid, template std::string test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, - const count_set& expected_count1, + count_set const& expected_count1, int expected_point_count1, expectation_limits const& expected_area1, - const count_set& expected_count2, + count_set const& expected_count2, int expected_point_count2, expectation_limits const& expected_area2, - const count_set& expected_count_s, + count_set const& expected_count_s, int expected_point_count_s, expectation_limits const& expected_area_s, ut_settings const& settings = ut_settings()) @@ -429,13 +429,13 @@ std::string test_one(std::string const& caseid, template std::string test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, - const count_set& expected_count1, + count_set const& expected_count1, int expected_point_count1, expectation_limits const& expected_area1, - const count_set& expected_count2, + count_set const& expected_count2, int expected_point_count2, expectation_limits const& expected_area2, - const count_set& expected_count_s, + count_set const& expected_count_s, ut_settings const& settings = ut_settings()) { return test_one(caseid, wkt1, wkt2, @@ -452,10 +452,10 @@ std::string test_one(std::string const& caseid, template std::string test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, - const count_set& expected_count1, + count_set const& expected_count1, int expected_point_count1, expectation_limits const& expected_area1, - const count_set& expected_count2, + count_set const& expected_count2, int expected_point_count2, expectation_limits const& expected_area2, ut_settings const& settings = ut_settings()) diff --git a/test/algorithms/set_operations/intersection/Jamfile b/test/algorithms/set_operations/intersection/Jamfile index ec4a9684c2..c65ebc6732 100644 --- a/test/algorithms/set_operations/intersection/Jamfile +++ b/test/algorithms/set_operations/intersection/Jamfile @@ -29,4 +29,5 @@ test-suite boost-geometry-algorithms-intersection [ run intersection_pl_l.cpp : : : : algorithms_intersection_pl_l ] [ run intersection_pl_pl.cpp : : : : algorithms_intersection_pl_pl ] [ run intersection_tupled.cpp : : : : algorithms_intersection_tupled ] + [ run intersection_integer.cpp : : : : algorithms_intersection_integer ] ; diff --git a/test/algorithms/set_operations/intersection/intersection.cpp b/test/algorithms/set_operations/intersection/intersection.cpp index c37f1d5bff..4ce0127604 100644 --- a/test/algorithms/set_operations/intersection/intersection.cpp +++ b/test/algorithms/set_operations/intersection/intersection.cpp @@ -826,33 +826,6 @@ void test_rational() 1, 7, 5.47363293); } -template -void test_ticket_10868(std::string const& wkt_out) -{ - typedef bg::model::point point_type; - typedef bg::model::polygon - < - point_type, /*ClockWise*/false, /*Closed*/false - > polygon_type; - typedef bg::model::multi_polygon multipolygon_type; - - polygon_type polygon1; - bg::read_wkt(ticket_10868[0], polygon1); - polygon_type polygon2; - bg::read_wkt(ticket_10868[1], polygon2); - - multipolygon_type multipolygon_out; - bg::intersection(polygon1, polygon2, multipolygon_out); - std::stringstream stream; - stream << bg::wkt(multipolygon_out); - - BOOST_CHECK_EQUAL(stream.str(), wkt_out); - - test_one("ticket_10868", - ticket_10868[0], ticket_10868[1], - 1, 7, 20266195244586.0); -} - int test_main(int, char* []) { BoostGeometryWriteTestConfiguration(); @@ -869,21 +842,6 @@ int test_main(int, char* []) test_rational > >(); #endif -#if defined(BOOST_GEOMETRY_TEST_FAILURES) - // ticket #10868 still fails for 32-bit integers - test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); - -#if !defined(BOOST_NO_INT64_T) || defined(BOOST_HAS_MS_INT64) - test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); -#endif - - if (BOOST_GEOMETRY_CONDITION(sizeof(long) * CHAR_BIT >= 64)) - { - test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); - } - - test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); -#endif #endif #if defined(BOOST_GEOMETRY_TEST_FAILURES) diff --git a/test/algorithms/set_operations/intersection/intersection_integer.cpp b/test/algorithms/set_operations/intersection/intersection_integer.cpp new file mode 100644 index 0000000000..9bd948e3f4 --- /dev/null +++ b/test/algorithms/set_operations/intersection/intersection_integer.cpp @@ -0,0 +1,122 @@ +// Boost.Geometry +// Unit Test + +// Copyright (c) 2007-2023 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2015-2022. +// Modifications copyright (c) 2015-2022, Oracle and/or its affiliates. +// Contributed and/or modified by Menelaos Karavelas, 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) + +#include "test_intersection.hpp" +#include + +#include + +#define TEST_INTERSECTION(caseid, clips, points, area) \ + (test_one) \ + ( #caseid, caseid[0], caseid[1], clips, points, area, settings) + +namespace +{ + std::string rectangles[2] = + { + "POLYGON((1000 1000,2000 1000,2000 2000,1000 2000))", + "POLYGON((500 500,1500 500,1500 1500,500 1500))" + }; + + std::string start_within[2] = + { + "POLYGON((1000 1000,2000 1000,2000 2000,1000 2000))", + "POLYGON((1250 1250,1500 750,1750 1250,1750 1750))" + }; +} + + +template +void test_areal() +{ + static bool is_open = bg::closure::value == bg::open; + + ut_settings settings; + settings.test_point_count = true; + + TEST_INTERSECTION(rectangles, 1, is_open ? 4 : 5, 250000.0); + TEST_INTERSECTION(start_within, 1, is_open ? 5 : 6, 218750.0); + TEST_INTERSECTION(issue_1184, 1, is_open ? 3 : 4, 156.0); +} + +template +void test_all() +{ + using polygon = bg::model::polygon

; + using polygon_ccw = bg::model::polygon; + using polygon_open = bg::model::polygon; + using polygon_ccw_open = bg::model::polygon; + test_areal(); + test_areal(); + test_areal(); + test_areal(); +} + +template +void test_ticket_10868(/*std::string const& wkt_out*/) +{ + using point_type = bg::model::point; + using polygon_type = bg::model::polygon + < + point_type, /*ClockWise*/false, /*Closed*/false + >; + using multipolygon_type = bg::model::multi_polygon; + + polygon_type polygon1; + polygon_type polygon2; + bg::read_wkt(ticket_10868[0], polygon1); + bg::read_wkt(ticket_10868[1], polygon2); + + multipolygon_type multipolygon_out; + bg::intersection(polygon1, polygon2, multipolygon_out); + std::stringstream stream; + stream << bg::wkt(multipolygon_out); + + // BOOST_CHECK_EQUAL(stream.str(), wkt_out); + + test_one("ticket_10868", + ticket_10868[0], ticket_10868[1], + 1, 7, 20266195244586.0); +} + + + +int test_main(int, char* []) +{ + BoostGeometryWriteTestConfiguration(); + + test_all >(); + + +#if defined(BOOST_GEOMETRY_TEST_FAILURES) + // ticket #10868 still fails for 32-bit integers + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); + + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); +#endif + + #if defined(BOOST_GEOMETRY_TEST_FAILURES) + // Ticket #10868 was normally not run for other types + // It results in a different area (might be fine) + // and it reports self intersections. + if (BOOST_GEOMETRY_CONDITION(sizeof(long) * CHAR_BIT >= 64)) + { + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); + } + + test_ticket_10868("MULTIPOLYGON(((33520458 6878575,33480192 14931538,31446819 18947953,30772384 19615678,30101303 19612322,30114725 16928001,33520458 6878575)))"); + #endif + + return 0; +} diff --git a/test/algorithms/set_operations/intersection/test_intersection.hpp b/test/algorithms/set_operations/intersection/test_intersection.hpp index 4baa6f8fbd..1712670ac6 100644 --- a/test/algorithms/set_operations/intersection/test_intersection.hpp +++ b/test/algorithms/set_operations/intersection/test_intersection.hpp @@ -50,12 +50,15 @@ struct ut_settings : ut_base_settings { double percentage; - bool debug; + bool debug{false}; + bool test_point_count{false}; + + bool debug_wkt{false}; + bool debug_dsv{false}; explicit ut_settings(double p = 0.0001, bool tv = true) : ut_base_settings(tv) , percentage(p) - , debug(false) {} }; @@ -64,7 +67,7 @@ template void check_result(IntersectionOutput const& intersection_output, std::string const& caseid, G1 const& g1, G2 const& g2, - const count_set& expected_count, const count_set& expected_hole_count, + count_set const& expected_count, count_set const& expected_hole_count, int expected_point_count, expectation_limits const& expected_length_or_area, ut_settings const& settings) { @@ -82,7 +85,7 @@ void check_result(IntersectionOutput const& intersection_output, { // here n should rather be of type std::size_t, but expected_point_count // is set to -1 in some test cases so type int was left for now - n += static_cast(bg::num_points(*it, true)); + n += static_cast(bg::num_points(*it, false)); } if (! expected_hole_count.empty()) @@ -95,10 +98,15 @@ void check_result(IntersectionOutput const& intersection_output, ? bg::length(*it) : bg::area(*it); - if (settings.debug) + if (settings.debug_wkt) { std::cout << std::setprecision(20) << bg::wkt(*it) << std::endl; } + if (settings.debug_dsv) + { + // Write as DSV (which, by default, does not add a closing point) + std::cout << std::setprecision(20) << bg::dsv(*it) << std::endl; + } } if (settings.test_validity()) @@ -112,21 +120,17 @@ void check_result(IntersectionOutput const& intersection_output, << " type: " << (type_for_assert_message())); } - boost::ignore_unused(n); - #if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST) -#if defined(BOOST_GEOMETRY_USE_RESCALING) - // Without rescaling, point count might easily differ (which is no problem) - if (expected_point_count > 0) + // Only test if explicitly mentioned + if (settings.test_point_count) { - BOOST_CHECK_MESSAGE(bg::math::abs(n - expected_point_count) < 3, + BOOST_CHECK_MESSAGE(n == expected_point_count, "intersection: " << caseid << " #points expected: " << expected_point_count << " detected: " << n << " type: " << (type_for_assert_message()) ); } -#endif if (! expected_count.empty()) { @@ -161,14 +165,27 @@ void check_result(IntersectionOutput const& intersection_output, template typename bg::default_area_result::type test_intersection(std::string const& caseid, G1 const& g1, G2 const& g2, - const count_set& expected_count = count_set(), - const count_set& expected_hole_count = count_set(), + count_set const& expected_count = count_set(), + count_set const& expected_hole_count = count_set(), int expected_point_count = 0, expectation_limits const& expected_length_or_area = 0, ut_settings const& settings = ut_settings()) { + using coordinate_type = typename bg::coordinate_type::type; + constexpr bool is_ccw = + bg::point_order::value == bg::counterclockwise + || bg::point_order::value == bg::counterclockwise; + constexpr bool is_open = + bg::closure::value == bg::open + || bg::closure::value == bg::open; + if (settings.debug) { - std::cout << std::endl << "case " << caseid << std::endl; + + std::cout << std::endl << "case " << caseid + << " " << string_from_type::name() + << (is_ccw ? " ccw" : "") + << (is_open ? " open" : "") + << std::endl; } typedef typename setop_output_type::type result_type; @@ -179,13 +196,12 @@ typename bg::default_area_result::type test_intersection(std::string const& #if ! defined(BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE) if (! settings.debug) { - // Check _inserter behaviour with stratey - typedef typename bg::strategy::intersection::services::default_strategy - < - typename bg::cs_tag::type - >::type strategy_type; + // Check inserter behaviour with stratey + using strategy_type + = typename bg::strategies::relate::services::default_strategy::type; result_type clip; - bg::detail::intersection::intersection_insert(g1, g2, std::back_inserter(clip), strategy_type()); + bg::detail::intersection::intersection_insert(g1, g2, + std::back_inserter(clip), strategy_type()); } #endif @@ -226,22 +242,14 @@ typename bg::default_area_result::type test_intersection(std::string const& #if defined(TEST_WITH_SVG) { bool const is_line = bg::geometry_id::type::value == 2; - typedef typename bg::coordinate_type::type coordinate_type; - - bool const ccw = - bg::point_order::value == bg::counterclockwise - || bg::point_order::value == bg::counterclockwise; - bool const open = - bg::closure::value == bg::open - || bg::closure::value == bg::open; std::ostringstream filename; filename << "intersection_" << caseid << "_" << string_from_type::name() << string_from_type::name() - << (ccw ? "_ccw" : "") - << (open ? "_open" : "") + << (is_ccw ? "_ccw" : "") + << (is_open ? "_open" : "") #if defined(BOOST_GEOMETRY_USE_RESCALING) << "_rescaled" #endif @@ -281,7 +289,7 @@ typename bg::default_area_result::type test_intersection(std::string const& template typename bg::default_area_result::type test_intersection(std::string const& caseid, G1 const& g1, G2 const& g2, - const count_set& expected_count = count_set(), int expected_point_count = 0, + count_set const& expected_count = count_set(), int expected_point_count = 0, expectation_limits const& expected_length_or_area = 0, ut_settings const& settings = ut_settings()) { @@ -295,8 +303,8 @@ typename bg::default_area_result::type test_intersection(std::string const& template typename bg::default_area_result::type test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, - const count_set& expected_count, - const count_set& expected_hole_count, + count_set const& expected_count, + count_set const& expected_hole_count, int expected_point_count, expectation_limits const& expected_length_or_area, ut_settings const& settings = ut_settings()) @@ -320,7 +328,7 @@ typename bg::default_area_result::type test_one(std::string const& caseid, template typename bg::default_area_result::type test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, - const count_set& expected_count, + count_set const& expected_count, int expected_point_count, expectation_limits const& expected_length_or_area, ut_settings const& settings = ut_settings()) @@ -334,7 +342,7 @@ typename bg::default_area_result::type test_one(std::string const& caseid, template void test_one_lp(std::string const& caseid, std::string const& wkt_areal, std::string const& wkt_linear, - const count_set& expected_count = count_set(), int expected_point_count = 0, + count_set const& expected_count = count_set(), int expected_point_count = 0, expectation_limits const& expected_length = 0, ut_settings const& settings = ut_settings()) { diff --git a/test/algorithms/set_operations/union/Jamfile b/test/algorithms/set_operations/union/Jamfile index d3f54ac923..6cd0159c03 100644 --- a/test/algorithms/set_operations/union/Jamfile +++ b/test/algorithms/set_operations/union/Jamfile @@ -25,6 +25,7 @@ test-suite boost-geometry-algorithms-union [ run union_gc.cpp : : : : algorithms_union_gc ] [ run union_linear_linear.cpp : : : : algorithms_union_linear_linear ] [ run union_pl_pl.cpp : : : : algorithms_union_pl_pl ] + [ run union_issues.cpp : : : : algorithms_union_issues ] [ run union_tupled.cpp : : : : algorithms_union_tupled ] [ run union_other_types.cpp : : : BOOST_GEOMETRY_TEST_ONLY_ONE_TYPE : algorithms_union_other_types ] ; diff --git a/test/algorithms/set_operations/union/test_union.hpp b/test/algorithms/set_operations/union/test_union.hpp index 1946e3df76..2f6957bee1 100644 --- a/test/algorithms/set_operations/union/test_union.hpp +++ b/test/algorithms/set_operations/union/test_union.hpp @@ -28,6 +28,7 @@ #include #include #include +#include #include @@ -68,7 +69,7 @@ inline std::size_t num_points(Range const& rng, bool add_for_open = false) template void test_union(std::string const& caseid, G1 const& g1, G2 const& g2, - const count_set& expected_count, const count_set& expected_hole_count, + count_set const& expected_count, count_set const& expected_hole_count, int expected_point_count, expectation_limits const& expected_area, ut_settings const& settings) { @@ -240,7 +241,7 @@ void test_union(std::string const& caseid, G1 const& g1, G2 const& g2, template void test_one(std::string const& caseid, std::string const& wkt1, std::string const& wkt2, - const count_set& expected_count, const count_set& expected_hole_count, + count_set const& expected_count, count_set const& expected_hole_count, int expected_point_count, expectation_limits const& expected_area, ut_settings const& settings = ut_settings()) { diff --git a/test/algorithms/set_operations/union/union.cpp b/test/algorithms/set_operations/union/union.cpp index 4a77ac3efc..a009911cc1 100644 --- a/test/algorithms/set_operations/union/union.cpp +++ b/test/algorithms/set_operations/union/union.cpp @@ -465,6 +465,12 @@ void test_areal() TEST_UNION(issue_1108, 1, 0, -1, 12.1742); TEST_UNION_REV(issue_1108, 1, 0, -1, 12.1742); + TEST_UNION(issue_1183, 1, 0, -1, 607.6507); + TEST_UNION_REV(issue_1183, 1, 0, -1, 607.6507); + + TEST_UNION(issue_1186, 1, 1, -1, 21.6189); + TEST_UNION_REV(issue_1186, 1, 1, -1, 21.6189); + { // Rescaling produces an invalid result ut_settings settings; diff --git a/test/algorithms/set_operations/union/union_issues.cpp b/test/algorithms/set_operations/union/union_issues.cpp new file mode 100644 index 0000000000..2346c1fcbe --- /dev/null +++ b/test/algorithms/set_operations/union/union_issues.cpp @@ -0,0 +1,56 @@ +// Boost.Geometry + +// Unit Test + +// Copyright (c) 2023 Barend Gehrels, Amsterdam, the Netherlands. + +// 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) + +// This unit test is verifying some issues which do not use WKT, +// or are not expressable as WKT (for example by the use of an epsilon) + +#include + +#include +#include +#include + +#include + +template +void issue_1103() +{ + using point_t = bg::model::d2::point_xy; + using polygon_t = bg::model::polygon; + + polygon_t poly1; + bg::append(poly1, point_t(1, 1)); + bg::append(poly1, point_t(1, std::numeric_limits::epsilon())); + bg::append(poly1, point_t(0, std::numeric_limits::epsilon())); + bg::append(poly1, point_t(0, 1)); + bg::append(poly1, point_t(1, 1)); + + polygon_t poly2; + bg::append(poly2, point_t(1, 0)); + bg::append(poly2, point_t(1, -1)); + bg::append(poly2, point_t(0, -1)); + bg::append(poly2, point_t(0, 0)); + bg::append(poly2, point_t(1, 0)); + + bg::model::multi_polygon result; + bg::union_(poly1, poly2, result); + + // Verify result. Before commit b1bebca the result was empty. + BOOST_CHECK_EQUAL(1, static_cast(boost::size(result))); + BOOST_CHECK_CLOSE(2.0, bg::area(result), 0.0001); +} + +int test_main(int, char* []) +{ + issue_1103(); + issue_1103(); + + return 0; +} diff --git a/test/concepts/function_asserting_a_point.hpp b/test/concepts/function_asserting_a_point.hpp index 802d198527..3e67b89e0b 100644 --- a/test/concepts/function_asserting_a_point.hpp +++ b/test/concepts/function_asserting_a_point.hpp @@ -18,7 +18,7 @@ namespace bg = boost::geometry; namespace test { template - void function_asserting_a_point(P& p1, const CP& p2) + void function_asserting_a_point(P& p1, CP const& p2) { BOOST_CONCEPT_ASSERT((bg::concepts::Point

)); BOOST_CONCEPT_ASSERT((bg::concepts::ConstPoint

)); diff --git a/test/concepts/function_requiring_a_point.hpp b/test/concepts/function_requiring_a_point.hpp index d8628e940e..6af0991bb5 100644 --- a/test/concepts/function_requiring_a_point.hpp +++ b/test/concepts/function_requiring_a_point.hpp @@ -17,7 +17,7 @@ namespace bg = boost::geometry; namespace test { template - inline void function_requiring_a_point(P& p1, const C& p2) + inline void function_requiring_a_point(P& p1, C const& p2) { BOOST_CONCEPT_ASSERT((bg::concepts::Point

)); BOOST_CONCEPT_ASSERT((bg::concepts::ConstPoint)); diff --git a/test/core/assert.cpp b/test/core/assert.cpp index 59d90dee1e..2393c25163 100644 --- a/test/core/assert.cpp +++ b/test/core/assert.cpp @@ -20,7 +20,7 @@ struct assert_failure_exception : std::exception { - const char * what() const throw() + const char * what() const noexcept { return "assertion failure"; } diff --git a/test/count_set.hpp b/test/count_set.hpp index 3ac900616c..83e985a4be 100644 --- a/test/count_set.hpp +++ b/test/count_set.hpp @@ -49,7 +49,7 @@ struct count_set return m_values.count(value) > 0; } - friend std::ostream &operator<<(std::ostream &os, const count_set& s) + friend std::ostream &operator<<(std::ostream &os, count_set const& s) { os << "{"; for (std::size_t const& value : s.m_values) @@ -60,7 +60,7 @@ struct count_set return os; } - count_set operator+(const count_set& a) const + count_set operator+(count_set const& a) const { count_set result; result.m_values = combine(this->m_values, a.m_values); @@ -71,7 +71,7 @@ private : typedef std::set set_type; set_type m_values; - set_type combine(const set_type& a, const set_type& b) const + set_type combine(const set_type& a, set_type const& b) const { set_type result; if (a.size() == 1 && b.size() == 1) diff --git a/test/expectation_limits.hpp b/test/expectation_limits.hpp index ba7585803d..bbb5c1462e 100644 --- a/test/expectation_limits.hpp +++ b/test/expectation_limits.hpp @@ -42,7 +42,7 @@ struct expectation_limits bool has_two_limits() const { return m_lower_limit < m_upper_limit; } template - bool contains_logarithmic(const T& value, double tolerance) const + bool contains_logarithmic(T const& value, double tolerance) const { using std::abs; using std::log; @@ -50,7 +50,7 @@ struct expectation_limits } template - bool contains(const T& value, double percentage, bool logarithmic = false) const + bool contains(T const& value, double percentage, bool logarithmic = false) const { if (m_upper_limit < 1.0e-8) { @@ -80,7 +80,7 @@ struct expectation_limits : expectation_limits(this->m_lower_limit + a.m_lower_limit); } - friend std::ostream &operator<<(std::ostream &os, const expectation_limits& lim) + friend std::ostream &operator<<(std::ostream &os, expectation_limits const& lim) { if (lim.has_two_limits()) { diff --git a/test/geometries/custom_non_copiable/helper_functions.hpp b/test/geometries/custom_non_copiable/helper_functions.hpp index 489e5c45f0..563baf2b52 100644 --- a/test/geometries/custom_non_copiable/helper_functions.hpp +++ b/test/geometries/custom_non_copiable/helper_functions.hpp @@ -17,7 +17,7 @@ #include template -void fill(Ring& ring, const std::vector::type>& v) +void fill(Ring& ring, std::vector::type> const& v) { ring.custom_clear(); for(auto const& p : v) diff --git a/test/test_common/test_point.hpp b/test/test_common/test_point.hpp index 3f888a2f55..42a0f11b40 100644 --- a/test/test_common/test_point.hpp +++ b/test/test_common/test_point.hpp @@ -74,7 +74,7 @@ template<> struct access return p.c1; } - static inline void set(test::test_point& p, const float& value) + static inline void set(test::test_point& p, float const& value) { p.c1 = value; } @@ -87,7 +87,7 @@ template<> struct access return p.c2; } - static inline void set(test::test_point& p, const float& value) + static inline void set(test::test_point& p, float const& value) { p.c2 = value; } @@ -100,7 +100,7 @@ template<> struct access return p.c3; } - static inline void set(test::test_point& p, const float& value) + static inline void set(test::test_point& p, float const& value) { p.c3 = value; }