From a222ecd55d8147cf4b016981f803cd9834905f5a Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Thu, 1 Jun 2023 12:13:56 +0200 Subject: [PATCH 1/3] [algorithms] Check const Ring concept in calculate_point_order --- .../geometry/algorithms/detail/calculate_point_order.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/calculate_point_order.hpp b/include/boost/geometry/algorithms/detail/calculate_point_order.hpp index 3c76786d4..191f71f3d 100644 --- a/include/boost/geometry/algorithms/detail/calculate_point_order.hpp +++ b/include/boost/geometry/algorithms/detail/calculate_point_order.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2019-2021, Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2019-2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Licensed under the Boost Software License version 1.0. @@ -334,7 +335,7 @@ namespace detail template inline geometry::order_selector calculate_point_order(Ring const& ring, Strategy const& strategy) { - concepts::check(); + concepts::check(); return dispatch::calculate_point_order::apply(ring, strategy); } @@ -347,7 +348,7 @@ inline geometry::order_selector calculate_point_order(Ring const& ring) typename geometry::cs_tag::type >::type strategy_type; - concepts::check(); + concepts::check(); return dispatch::calculate_point_order::apply(ring, strategy_type()); } From fa4ff35d6af2995c0d5bc76ad96840f950bf783c Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 7 Jun 2023 21:18:33 +0200 Subject: [PATCH 2/3] Fix Visual Studio warnings - C4100 Unreferenced formal parameter - C4127 Conditional expression is constant - C4456 Declaration hides previous local declaration - C4701 Potentially uninitialized local variable used - C4702 Unreachable code --- .../algorithms/detail/buffer/piece_border.hpp | 2 +- .../detail/convex_hull/interface.hpp | 3 +- .../detail/overlay/handle_self_turns.hpp | 6 ++-- .../detail/overlay/pointlike_pointlike.hpp | 9 ++++-- .../detail/relate/implementation_gc.hpp | 31 +++++++++---------- .../algorithms/detail/relate/linear_areal.hpp | 4 +-- .../geometry/algorithms/detail/sweep.hpp | 7 +++-- .../algorithms/detail/within/multi_point.hpp | 5 ++- .../boost/geometry/algorithms/simplify.hpp | 5 +-- .../boost/geometry/formulas/area_formulas.hpp | 5 +-- .../formulas/differential_quantities.hpp | 15 ++++----- .../formulas/gnomonic_intersection.hpp | 5 +-- .../geometry/formulas/karney_inverse.hpp | 7 +++-- .../geometry/formulas/meridian_direct.hpp | 11 ++++--- .../geometry/formulas/meridian_inverse.hpp | 13 ++++---- .../formulas/sjoberg_intersection.hpp | 11 ++++--- .../geometry/srs/projections/impl/pj_init.hpp | 6 ++-- .../srs/projections/impl/pj_transform.hpp | 13 +++++--- .../geometry/srs/projections/proj/tmerc.hpp | 10 +++--- .../cartesian/buffer_join_round.hpp | 2 ++ .../strategies/cartesian/intersection.hpp | 8 ++--- .../cartesian/turn_in_ring_winding.hpp | 12 +++---- .../geographic/buffer_join_round.hpp | 3 +- .../geographic/distance_cross_track.hpp | 2 +- include/boost/geometry/util/precise_math.hpp | 6 ++-- .../boost/geometry/util/series_expansion.hpp | 9 +++--- .../difference/test_difference.hpp | 3 +- .../intersection/test_intersection.hpp | 5 +++ .../test_intersection_linear_linear.hpp | 6 ++-- test/geometries/boost_polygon.cpp | 18 ++++++----- .../custom_non_copiable/helper_functions.hpp | 2 ++ test/iterators/test_iterator_common.hpp | 8 +++-- test/strategies/buffer_join_geo.cpp | 3 ++ test/util/select_most_precise.cpp | 4 ++- 34 files changed, 152 insertions(+), 107 deletions(-) diff --git a/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp b/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp index 16cb89ed3..d773d32c3 100644 --- a/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/piece_border.hpp @@ -353,7 +353,7 @@ private : TiRStrategy const& strategy, geometry::strategy::buffer::place_on_ring_type place_on_ring, State& state) const { - return strategy.apply(point, p1, p2, place_on_ring, m_is_convex, state, get_full_ring()); + return strategy.apply(point, p1, p2, place_on_ring, m_is_convex, state); } template diff --git a/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp b/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp index ed10d68de..b820cc4bf 100644 --- a/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp +++ b/include/boost/geometry/algorithms/detail/convex_hull/interface.hpp @@ -3,6 +3,7 @@ // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2014-2021. // Modifications copyright (c) 2014-2021 Oracle and/or its affiliates. @@ -224,7 +225,7 @@ struct convex_hull template static inline void apply(Box const& box, OutputGeometry& out, - Strategy const& strategy) + Strategy const& ) { static bool const Close = geometry::closure::value == closed; 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 3ee49dec8..435a80c27 100644 --- a/include/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/handle_self_turns.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2017 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2017-2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2019-2022. // Modifications copyright (c) 2019-2022 Oracle and/or its affiliates. @@ -165,8 +165,8 @@ private : if (! cinfo.turn_indices.empty() && is_self_cluster(cluster_id, turns, clusters)) { - signed_size_type const index = *cinfo.turn_indices.begin(); - if (! check_within::apply(turns[index], + signed_size_type const first_index = *cinfo.turn_indices.begin(); + if (! check_within::apply(turns[first_index], geometry0, geometry1, strategy)) { diff --git a/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp b/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp index e59f8011e..cc3364edd 100644 --- a/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp +++ b/include/boost/geometry/algorithms/detail/overlay/pointlike_pointlike.hpp @@ -1,7 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2020, Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2014-2020, 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 @@ -33,6 +34,8 @@ #include +#include + namespace boost { namespace geometry { @@ -256,8 +259,8 @@ struct multipoint_multipoint_point { typedef geometry::less less_type; - if ( OverlayType != overlay_difference - && boost::size(multipoint1) > boost::size(multipoint2) ) + if (BOOST_GEOMETRY_CONDITION(OverlayType != overlay_difference) + && boost::size(multipoint1) > boost::size(multipoint2)) { return multipoint_multipoint_point < diff --git a/include/boost/geometry/algorithms/detail/relate/implementation_gc.hpp b/include/boost/geometry/algorithms/detail/relate/implementation_gc.hpp index 359aca954..f0fa11d2a 100644 --- a/include/boost/geometry/algorithms/detail/relate/implementation_gc.hpp +++ b/include/boost/geometry/algorithms/detail/relate/implementation_gc.hpp @@ -1,9 +1,8 @@ // Boost.Geometry -// Copyright (c) 2022 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2022-2023 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2022 Oracle and/or its affiliates. - // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -25,6 +24,7 @@ #include #include #include +#include #include @@ -49,18 +49,17 @@ struct aa_handler_wrapper explicit aa_handler_wrapper(Handler& handler) : m_handler(handler) - { - m_overwrite_ii = ! handler.template may_update(); - m_overwrite_ie = ! handler.template may_update(); - m_overwrite_ei = ! handler.template may_update(); - } + , m_overwrite_ii(! handler.template may_update()) + , m_overwrite_ie(! handler.template may_update()) + , m_overwrite_ei(! handler.template may_update()) + {} template inline bool may_update() const { - if ((F1 == interior && F2 == interior && m_overwrite_ii) - || (F1 == interior && F2 == exterior && m_overwrite_ie) - || (F1 == exterior && F2 == interior && m_overwrite_ei)) + if ((BOOST_GEOMETRY_CONDITION(F1 == interior && F2 == interior) && m_overwrite_ii) + || (BOOST_GEOMETRY_CONDITION(F1 == interior && F2 == exterior) && m_overwrite_ie) + || (BOOST_GEOMETRY_CONDITION(F1 == exterior && F2 == interior) && m_overwrite_ei)) { char const c = m_handler.template get(); return D > c || c > '9'; @@ -74,9 +73,9 @@ struct aa_handler_wrapper template inline void update() { - if ((F1 == interior && F2 == interior && m_overwrite_ii) - || (F1 == interior && F2 == exterior && m_overwrite_ie) - || (F1 == exterior && F2 == interior && m_overwrite_ei)) + if ((BOOST_GEOMETRY_CONDITION(F1 == interior && F2 == interior) && m_overwrite_ii) + || (BOOST_GEOMETRY_CONDITION(F1 == interior && F2 == exterior) && m_overwrite_ie) + || (BOOST_GEOMETRY_CONDITION(F1 == exterior && F2 == interior) && m_overwrite_ei)) { // NOTE: Other handlers first check for potential interruption // and only after that checks update condition. @@ -97,9 +96,9 @@ struct aa_handler_wrapper private: Handler & m_handler; - bool m_overwrite_ii = false; - bool m_overwrite_ie = false; - bool m_overwrite_ei = false; + bool const m_overwrite_ii; + bool const m_overwrite_ie; + bool const m_overwrite_ei; }; diff --git a/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp b/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp index a91397df9..1e35e64fc 100644 --- a/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp +++ b/include/boost/geometry/algorithms/detail/relate/linear_areal.hpp @@ -1,10 +1,10 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2013-2022. // Modifications copyright (c) 2013-2022 Oracle and/or its affiliates. - // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -234,7 +234,7 @@ template typename Strategy > inline bool calculate_from_inside_sides(Pi const& pi, Pj const& pj, Pk const& pk, - Qi const& qi, Qj const& qj, Qk const& qk, + Qi const& , Qj const& qj, Qk const& qk, Strategy const& strategy) { auto const side_strategy = strategy.side(); diff --git a/include/boost/geometry/algorithms/detail/sweep.hpp b/include/boost/geometry/algorithms/detail/sweep.hpp index 3dc78261f..a8c7f9a91 100644 --- a/include/boost/geometry/algorithms/detail/sweep.hpp +++ b/include/boost/geometry/algorithms/detail/sweep.hpp @@ -1,7 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2015, Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Licensed under the Boost Software License version 1.0. @@ -10,6 +11,8 @@ #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SWEEP_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SWEEP_HPP +#include + #include @@ -56,7 +59,7 @@ inline void sweep(Range const& range, PriorityQueue& queue, event_type event = queue.top(); queue.pop(); event_visitor.apply(event, queue); - if (interrupt_policy.enabled && interrupt_policy.apply(event)) + if (BOOST_GEOMETRY_CONDITION(interrupt_policy.enabled) && interrupt_policy.apply(event)) { break; } diff --git a/include/boost/geometry/algorithms/detail/within/multi_point.hpp b/include/boost/geometry/algorithms/detail/within/multi_point.hpp index 6a7274869..b9e1e096a 100644 --- a/include/boost/geometry/algorithms/detail/within/multi_point.hpp +++ b/include/boost/geometry/algorithms/detail/within/multi_point.hpp @@ -1,5 +1,7 @@ // Boost.Geometry +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. + // Copyright (c) 2017-2020, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -38,6 +40,7 @@ #include #include +#include #include @@ -234,7 +237,7 @@ struct multi_point_multi_geometry if (boundaries > 0) { - if (is_linear && boundaries % 2 == 0) + if (BOOST_GEOMETRY_CONDITION(is_linear) && boundaries % 2 == 0) { found_interior = true; } diff --git a/include/boost/geometry/algorithms/simplify.hpp b/include/boost/geometry/algorithms/simplify.hpp index 2e83666f1..312de9636 100644 --- a/include/boost/geometry/algorithms/simplify.hpp +++ b/include/boost/geometry/algorithms/simplify.hpp @@ -3,6 +3,7 @@ // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2018-2022. // Modifications copyright (c) 2018-2022 Oracle and/or its affiliates. @@ -482,7 +483,7 @@ public : // Do not duplicate the closing point auto rot_end = boost::end(ring); std::size_t rot_index = index; - if (is_closed_in && size > 1) + if (BOOST_GEOMETRY_CONDITION(is_closed_in) && size > 1) { --rot_end; if (rot_index == size - 1) { rot_index = 0; } @@ -497,7 +498,7 @@ public : simplify_range<0>::apply(rotated, out, max_distance, impl, strategies); // Open output if needed - if (! is_closed_out && boost::size(out) > 1) + if (BOOST_GEOMETRY_CONDITION(! is_closed_out) && boost::size(out) > 1) { range::pop_back(out); } diff --git a/include/boost/geometry/formulas/area_formulas.hpp b/include/boost/geometry/formulas/area_formulas.hpp index 36bdd1342..b8da8a672 100644 --- a/include/boost/geometry/formulas/area_formulas.hpp +++ b/include/boost/geometry/formulas/area_formulas.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2015-2022 Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2015-2022 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 @@ -380,7 +381,7 @@ public: return pi; } - if (LongSegment && lat1r != lat2r) // not for segments parallel to equator + if (BOOST_GEOMETRY_CONDITION(LongSegment) && lat1r != lat2r) // not for segments parallel to equator { CT const cbet1 = cos(lat1r); CT const sbet1 = sin(lat1r); diff --git a/include/boost/geometry/formulas/differential_quantities.hpp b/include/boost/geometry/formulas/differential_quantities.hpp index 77b8de183..1df9adb8e 100644 --- a/include/boost/geometry/formulas/differential_quantities.hpp +++ b/include/boost/geometry/formulas/differential_quantities.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2016-2019 Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2016-2019 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -162,7 +163,7 @@ private: CT const& sin_sig2, CT const& cos_sig2, CT const& cos_alp0_sqr, CT const& f) { - if (Order == 0) + if (BOOST_GEOMETRY_CONDITION(Order == 0)) { return 0; } @@ -176,7 +177,7 @@ private: CT const sin_2sig_12 = sin_2sig2 - sin_2sig1; CT const L1 = sig_12 - sin_2sig_12 / c2; - if (Order == 1) + if (BOOST_GEOMETRY_CONDITION(Order == 1)) { return cos_alp0_sqr * f * L1; } @@ -195,7 +196,7 @@ private: + (c12 * cos_alp0_sqr - c24) * sig_12) / c16; - if (Order == 2) + if (BOOST_GEOMETRY_CONDITION(Order == 2)) { return cos_alp0_sqr * f * (L1 + f * L2); } @@ -241,7 +242,7 @@ private: CT const& sin_sig2, CT const& cos_sig2, CT const& cos_alp0_sqr, CT const& ep_sqr) { - if (Order == 0) + if (BOOST_GEOMETRY_CONDITION(Order == 0)) { return 0; } @@ -259,7 +260,7 @@ private: CT const L1 = (c2 * sig_12 - sin_2sig_12) / c4; - if (Order == 1) + if (BOOST_GEOMETRY_CONDITION(Order == 1)) { return c2a0ep2 * L1; } @@ -273,7 +274,7 @@ private: CT const L2 = (sin_4sig_12 - c8 * sin_2sig_12 + 12 * sig_12) / c64; - if (Order == 2) + if (BOOST_GEOMETRY_CONDITION(Order == 2)) { return c2a0ep2 * (L1 + c2a0ep2 * L2); } diff --git a/include/boost/geometry/formulas/gnomonic_intersection.hpp b/include/boost/geometry/formulas/gnomonic_intersection.hpp index 33c2fe62b..64795f762 100644 --- a/include/boost/geometry/formulas/gnomonic_intersection.hpp +++ b/include/boost/geometry/formulas/gnomonic_intersection.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2016 Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2016 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -80,7 +81,7 @@ public: CT xa1, ya1, xa2, ya2; CT xb1, yb1, xb2, yb2; CT x, y; - double lat1, lon1; + CT lon1, lat1; bool ok = gnom_t::forward(lon, lat, lona1, lata1, xa1, ya1, spheroid) && gnom_t::forward(lon, lat, lona2, lata2, xa2, ya2, spheroid) diff --git a/include/boost/geometry/formulas/karney_inverse.hpp b/include/boost/geometry/formulas/karney_inverse.hpp index e1a5de0a3..47efc9ff5 100644 --- a/include/boost/geometry/formulas/karney_inverse.hpp +++ b/include/boost/geometry/formulas/karney_inverse.hpp @@ -1,6 +1,7 @@ // Boost.Geometry // Copyright (c) 2018 Adeel Ahmad, Islamabad, Pakistan. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program. @@ -267,8 +268,8 @@ public: CT sin_sigma2 = sin_beta2; CT cos_sigma2 = cos_alpha2 * cos_beta2; - CT sigma12 = std::atan2((std::max)(c0, cos_sigma1 * sin_sigma2 - sin_sigma1 * cos_sigma2), - cos_sigma1 * cos_sigma2 + sin_sigma1 * sin_sigma2); + sigma12 = std::atan2((std::max)(c0, cos_sigma1 * sin_sigma2 - sin_sigma1 * cos_sigma2), + cos_sigma1 * cos_sigma2 + sin_sigma1 * sin_sigma2); CT dummy; meridian_length(n, ep2, sigma12, sin_sigma1, cos_sigma1, dn1, @@ -281,7 +282,7 @@ public: { if (sigma12 < c3 * tiny) { - sigma12 = m12x = s12x = c0; + sigma12 = m12x = s12x = c0; } m12x *= b; diff --git a/include/boost/geometry/formulas/meridian_direct.hpp b/include/boost/geometry/formulas/meridian_direct.hpp index f8e73f57c..330af6703 100644 --- a/include/boost/geometry/formulas/meridian_direct.hpp +++ b/include/boost/geometry/formulas/meridian_direct.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2018 Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2018 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 @@ -127,14 +128,14 @@ public: CT mp = formula::quarter_meridian(spheroid); CT mu = geometry::math::pi()/CT(2) * m / mp; - if (Order == 0) + if (BOOST_GEOMETRY_CONDITION(Order == 0)) { return mu; } CT H2 = 1.5 * n; - if (Order == 1) + if (BOOST_GEOMETRY_CONDITION(Order == 1)) { return mu + H2 * sin(2*mu); } @@ -142,7 +143,7 @@ public: CT n2 = n * n; CT H4 = 1.3125 * n2; - if (Order == 2) + if (BOOST_GEOMETRY_CONDITION(Order == 2)) { return mu + H2 * sin(2*mu) + H4 * sin(4*mu); } @@ -151,7 +152,7 @@ public: H2 -= 0.84375 * n3; CT H6 = 1.572916667 * n3; - if (Order == 3) + if (BOOST_GEOMETRY_CONDITION(Order == 3)) { return mu + H2 * sin(2*mu) + H4 * sin(4*mu) + H6 * sin(6*mu); } diff --git a/include/boost/geometry/formulas/meridian_inverse.hpp b/include/boost/geometry/formulas/meridian_inverse.hpp index 43bec1997..c21196f5c 100644 --- a/include/boost/geometry/formulas/meridian_inverse.hpp +++ b/include/boost/geometry/formulas/meridian_inverse.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2017-2018 Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2017-2018 Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -118,14 +119,14 @@ public : CT M = a/(1+n); CT C0 = 1; - if (Order == 0) + if (BOOST_GEOMETRY_CONDITION(Order == 0)) { return M * C0 * lat; } CT C2 = -1.5 * n; - if (Order == 1) + if (BOOST_GEOMETRY_CONDITION(Order == 1)) { return M * (C0 * lat + C2 * sin(2*lat)); } @@ -134,7 +135,7 @@ public : C0 += .25 * n2; CT C4 = 0.9375 * n2; - if (Order == 2) + if (BOOST_GEOMETRY_CONDITION(Order == 2)) { return M * (C0 * lat + C2 * sin(2*lat) + C4 * sin(4*lat)); } @@ -143,7 +144,7 @@ public : C2 += 0.1875 * n3; CT C6 = -0.729166667 * n3; - if (Order == 3) + if (BOOST_GEOMETRY_CONDITION(Order == 3)) { return M * (C0 * lat + C2 * sin(2*lat) + C4 * sin(4*lat) + C6 * sin(6*lat)); @@ -153,7 +154,7 @@ public : C4 -= 0.234375 * n4; CT C8 = 0.615234375 * n4; - if (Order == 4) + if (BOOST_GEOMETRY_CONDITION(Order == 4)) { return M * (C0 * lat + C2 * sin(2*lat) + C4 * sin(4*lat) + C6 * sin(6*lat) + C8 * sin(8*lat)); diff --git a/include/boost/geometry/formulas/sjoberg_intersection.hpp b/include/boost/geometry/formulas/sjoberg_intersection.hpp index 7c9222e0c..af56f285f 100644 --- a/include/boost/geometry/formulas/sjoberg_intersection.hpp +++ b/include/boost/geometry/formulas/sjoberg_intersection.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2016-2019 Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2016-2019 Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Use, modification and distribution is subject to the Boost Software License, @@ -206,7 +207,7 @@ inline CT sjoberg_d_lambda_e_sqr(CT const& sin_betaj, CT const& sin_beta, { using math::detail::bounded; - if (Order == 0) + if (BOOST_GEOMETRY_CONDITION(Order == 0)) { return 0; } @@ -218,7 +219,7 @@ inline CT sjoberg_d_lambda_e_sqr(CT const& sin_betaj, CT const& sin_beta, CT const asin_Bj = asin(sin_betaj / sqrt_1_Cj_sqr); CT const L0 = (asin_B - asin_Bj) / c2; - if (Order == 1) + if (BOOST_GEOMETRY_CONDITION(Order == 1)) { return -Cj * e_sqr * L0; } @@ -237,7 +238,7 @@ inline CT sjoberg_d_lambda_e_sqr(CT const& sin_betaj, CT const& sin_beta, CT const sqrt_Yj = math::sqrt(-Xj_sqr + one_minus_Cj_sqr); CT const L1 = (Cj_sqr_plus_one * (asin_B - asin_Bj) + X * sqrt_Y - Xj * sqrt_Yj) / c16; - if (Order == 2) + if (BOOST_GEOMETRY_CONDITION(Order == 2)) { return -Cj * e_sqr * (L0 + e_sqr * L1); } @@ -251,7 +252,7 @@ inline CT sjoberg_d_lambda_e_sqr(CT const& sin_betaj, CT const& sin_beta, CT const Fj = Xj * (-c2 * Xj_sqr + c3 * Cj_sqr + c5); CT const L2 = (E * (asin_B - asin_Bj) + F * sqrt_Y - Fj * sqrt_Yj) / c128; - if (Order == 3) + if (BOOST_GEOMETRY_CONDITION(Order == 3)) { return -Cj * e_sqr * (L0 + e_sqr * (L1 + e_sqr * L2)); } diff --git a/include/boost/geometry/srs/projections/impl/pj_init.hpp b/include/boost/geometry/srs/projections/impl/pj_init.hpp index 3c8660e07..66aa7ba0d 100644 --- a/include/boost/geometry/srs/projections/impl/pj_init.hpp +++ b/include/boost/geometry/srs/projections/impl/pj_init.hpp @@ -58,8 +58,8 @@ #include #include -#include #include +#include namespace boost { namespace geometry { namespace projections @@ -479,14 +479,14 @@ inline void pj_init_axis(Params const& params, parameters & projdef) // TODO: implement axis support for other types of parameters template -inline void pj_init_axis(srs::dpar::parameters const& params, parameters & projdef) +inline void pj_init_axis(srs::dpar::parameters const& , parameters & ) {} template struct pj_init_axis_static { template - static void apply(Params const& , parameters & projdef) + static void apply(Params const& , parameters & ) {} }; diff --git a/include/boost/geometry/srs/projections/impl/pj_transform.hpp b/include/boost/geometry/srs/projections/impl/pj_transform.hpp index edf664f67..b4f14c80b 100644 --- a/include/boost/geometry/srs/projections/impl/pj_transform.hpp +++ b/include/boost/geometry/srs/projections/impl/pj_transform.hpp @@ -1,6 +1,8 @@ // Boost.Geometry // This file is manually converted from PROJ4 +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. + // This file was modified by Oracle on 2017, 2018. // Modifications copyright (c) 2017-2018, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -49,6 +51,7 @@ #include #include +#include #include #include @@ -249,7 +252,7 @@ inline bool pj_transform(SrcPrj const& srcprj, Par const& srcdefn, /* -------------------------------------------------------------------- */ /* Transform Z to meters if it isn't already. */ /* -------------------------------------------------------------------- */ - if( srcdefn.vto_meter != 1.0 && dimension > 2 ) + if( BOOST_GEOMETRY_CONDITION(srcdefn.vto_meter != 1.0 && dimension > 2) ) { for( std::size_t i = 0; i < point_count; i++ ) { @@ -261,10 +264,10 @@ inline bool pj_transform(SrcPrj const& srcprj, Par const& srcdefn, /* -------------------------------------------------------------------- */ /* Transform geocentric source coordinates to lat/long. */ /* -------------------------------------------------------------------- */ - if( srcdefn.is_geocent ) + if( BOOST_GEOMETRY_CONDITION(srcdefn.is_geocent) ) { // Point should be cartesian 3D (ECEF) - if (dimension < 3) + if ( BOOST_GEOMETRY_CONDITION(dimension < 3) ) BOOST_THROW_EXCEPTION( projection_exception(error_geocentric) ); //return PJD_ERR_GEOCENTRIC; @@ -454,10 +457,10 @@ inline bool pj_transform(SrcPrj const& srcprj, Par const& srcdefn, /* -------------------------------------------------------------------- */ /* Transform destination latlong to geocentric if required. */ /* -------------------------------------------------------------------- */ - if( dstdefn.is_geocent ) + if( BOOST_GEOMETRY_CONDITION(dstdefn.is_geocent) ) { // Point should be cartesian 3D (ECEF) - if (dimension < 3) + if ( BOOST_GEOMETRY_CONDITION(dimension < 3) ) BOOST_THROW_EXCEPTION( projection_exception(error_geocentric) ); //return PJD_ERR_GEOCENTRIC; diff --git a/include/boost/geometry/srs/projections/proj/tmerc.hpp b/include/boost/geometry/srs/projections/proj/tmerc.hpp index 1c4d822d5..6d645ec12 100644 --- a/include/boost/geometry/srs/projections/proj/tmerc.hpp +++ b/include/boost/geometry/srs/projections/proj/tmerc.hpp @@ -1,6 +1,7 @@ // Boost.Geometry - gis-projections (based on PROJ4) // Copyright (c) 2008-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2017, 2018, 2019, 2022. // Modifications copyright (c) 2017-2022, Oracle and/or its affiliates. @@ -41,8 +42,6 @@ #ifndef BOOST_GEOMETRY_PROJECTIONS_TMERC_HPP #define BOOST_GEOMETRY_PROJECTIONS_TMERC_HPP -#include - #include #include #include @@ -50,6 +49,9 @@ #include #include +#include +#include + namespace boost { namespace geometry { @@ -291,7 +293,7 @@ namespace projections /* Ellipsoidal, forward */ //static PJ_XY exact_e_fwd (PJ_LP lp, PJ *P) - inline void fwd(Parameters const& par, + inline void fwd(Parameters const& /*par*/, T const& lp_lon, T const& lp_lat, T& xy_x, T& xy_y) const @@ -382,7 +384,7 @@ namespace projections /* Ellipsoidal, inverse */ - inline void inv(Parameters const& par, + inline void inv(Parameters const& /*par*/, T const& xy_x, T const& xy_y, T& lp_lon, diff --git a/include/boost/geometry/strategies/cartesian/buffer_join_round.hpp b/include/boost/geometry/strategies/cartesian/buffer_join_round.hpp index c5918300b..95553685c 100644 --- a/include/boost/geometry/strategies/cartesian/buffer_join_round.hpp +++ b/include/boost/geometry/strategies/cartesian/buffer_join_round.hpp @@ -1,6 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2012-2015 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2015. // Modifications copyright (c) 2015, Oracle and/or its affiliates. @@ -143,6 +144,7 @@ public : geometry::equal_to equals; if (equals(perp1, perp2)) { + boost::ignore_unused(ip); #ifdef BOOST_GEOMETRY_DEBUG_BUFFER_WARN std::cout << "Corner for equal points " << geometry::wkt(ip) << " " << geometry::wkt(perp1) << std::endl; #endif diff --git a/include/boost/geometry/strategies/cartesian/intersection.hpp b/include/boost/geometry/strategies/cartesian/intersection.hpp index ba853af58..94d33401c 100644 --- a/include/boost/geometry/strategies/cartesian/intersection.hpp +++ b/include/boost/geometry/strategies/cartesian/intersection.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2013-2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2013-2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2014-2021. // Modifications copyright (c) 2014-2021, Oracle and/or its affiliates. @@ -249,10 +249,7 @@ struct cartesian_segments assign_b(point, a, b); } -#if defined(BOOST_GEOMETRY_USE_RESCALING) - return; -#endif - +#ifndef BOOST_GEOMETRY_USE_RESCALING // Verify nearly collinear cases (the threshold is arbitrary // but influences performance). If the intersection is located // outside the segments, then it should be moved. @@ -267,6 +264,7 @@ struct cartesian_segments assign_if_exceeds(point, a); assign_if_exceeds(point, b); } +#endif } CoordinateType dx_a, dy_a; diff --git a/include/boost/geometry/strategies/cartesian/turn_in_ring_winding.hpp b/include/boost/geometry/strategies/cartesian/turn_in_ring_winding.hpp index 3c65ec88c..a029535d5 100644 --- a/include/boost/geometry/strategies/cartesian/turn_in_ring_winding.hpp +++ b/include/boost/geometry/strategies/cartesian/turn_in_ring_winding.hpp @@ -1,6 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2020 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -107,13 +108,12 @@ public: return s1y < s2y ? (py >= s1y && py <= s2y) : (py >= s2y && py <= s1y); } - template + template static inline void apply_on_boundary(Point const& point, PointOfSegment const& s1, PointOfSegment const& s2, place_on_ring_type place_on_ring, - counter& the_state, - Ring const& full_ring) + counter& the_state) { if (place_on_ring == place_on_ring_offsetted) { @@ -149,13 +149,13 @@ public: } } - template + template static inline bool apply(Point const& point, PointOfSegment const& s1, PointOfSegment const& s2, place_on_ring_type place_on_ring, bool is_convex, - counter& the_state, Ring const& full_ring) + counter& the_state) { int const side = strategy::side::side_rounded_input::apply(s1, s2, point); @@ -179,7 +179,7 @@ public: { if (side == 0) { - apply_on_boundary(point, s1, s2, place_on_ring, the_state, full_ring); + apply_on_boundary(point, s1, s2, place_on_ring, the_state); } #if defined(BOOST_GEOMETRY_USE_RESCALING) else if (side == -1) diff --git a/include/boost/geometry/strategies/geographic/buffer_join_round.hpp b/include/boost/geometry/strategies/geographic/buffer_join_round.hpp index 3f5a1a887..4f891d057 100644 --- a/include/boost/geometry/strategies/geographic/buffer_join_round.hpp +++ b/include/boost/geometry/strategies/geographic/buffer_join_round.hpp @@ -1,6 +1,7 @@ // Boost.Geometry // Copyright (c) 2022 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -55,7 +56,7 @@ public : #ifndef DOXYGEN_SHOULD_SKIP_THIS //! Fills output_range with a rounded shape around a vertex template - inline bool apply(Point const& ip, Point const& vertex, + inline bool apply(Point const& /*ip*/, Point const& vertex, Point const& perp1, Point const& perp2, DistanceType const& buffer_distance, RangeOut& range_out) const diff --git a/include/boost/geometry/strategies/geographic/distance_cross_track.hpp b/include/boost/geometry/strategies/geographic/distance_cross_track.hpp index 900822793..db5e46b9c 100644 --- a/include/boost/geometry/strategies/geographic/distance_cross_track.hpp +++ b/include/boost/geometry/strategies/geographic/distance_cross_track.hpp @@ -465,7 +465,7 @@ private: template - static inline auto non_iterative_case(CT const& lon1, CT const& lat1, //p1 + static inline auto non_iterative_case(CT const& , CT const& , //p1 CT const& lon2, CT const& lat2, //p2 CT const& distance) { diff --git a/include/boost/geometry/util/precise_math.hpp b/include/boost/geometry/util/precise_math.hpp index e14c20fbb..fb1b07845 100644 --- a/include/boost/geometry/util/precise_math.hpp +++ b/include/boost/geometry/util/precise_math.hpp @@ -1,6 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2019 Tinko Bartels, Berlin, Germany. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // Contributed and/or modified by Tinko Bartels, // as part of Google Summer of Code 2019 program. @@ -22,6 +23,7 @@ #include #include +#include // The following code is based on "Adaptive Precision Floating-Point Arithmetic // and Fast Robust Geometric Predicates" by Richard Shewchuk, @@ -294,7 +296,7 @@ inline RealNumber orient2dtail(vec2d const& p1, t6_01[1] = two_product_tail(t3[0], t4[0], t6_01[0]); std::array tA_03 = two_two_expansion_diff(t5_01, t6_01); RealNumber det = std::accumulate(tA_03.begin(), tA_03.end(), static_cast(0)); - if (Robustness == 1) + if (BOOST_GEOMETRY_CONDITION(Robustness == 1)) { return det; } @@ -381,7 +383,7 @@ inline RealNumber orient2d(vec2d const& p1, t6_01[0] = t3[0] * t4[0]; RealNumber det = t5_01[0] - t6_01[0]; - if (Robustness == 0) + if (BOOST_GEOMETRY_CONDITION(Robustness == 0)) { return det; } diff --git a/include/boost/geometry/util/series_expansion.hpp b/include/boost/geometry/util/series_expansion.hpp index 1a5c6472a..bdc4d7c6e 100644 --- a/include/boost/geometry/util/series_expansion.hpp +++ b/include/boost/geometry/util/series_expansion.hpp @@ -1,6 +1,7 @@ // Boost.Geometry // Copyright (c) 2018 Adeel Ahmad, Islamabad, Pakistan. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // Contributed and/or modified by Adeel Ahmad, as part of Google Summer of Code 2018 program. @@ -60,9 +61,9 @@ namespace boost { namespace geometry { namespace series_expansion { s/case\sCT(/case /g; s/):/:/g; s/epsCT(2)/eps2/g;' */ template - inline CT evaluate_A1(CT eps) + inline CT evaluate_A1(CT const& eps) { - CT eps2 = math::sqr(eps); + CT const eps2 = math::sqr(eps); CT t; switch (SeriesOrder/2) { @@ -78,7 +79,7 @@ namespace boost { namespace geometry { namespace series_expansion { case 3: t = eps2*(eps2*(eps2+CT(4))+CT(64))/CT(256); break; - case 4: + default: t = eps2*(eps2*(eps2*(CT(25)*eps2+CT(64))+CT(256))+CT(4096))/CT(16384); break; } @@ -224,7 +225,7 @@ namespace boost { namespace geometry { namespace series_expansion { template inline void evaluate_coeffs_C1(Coeffs &c, CT const& eps) { - CT eps2 = math::sqr(eps); + CT const eps2 = math::sqr(eps); CT d = eps; switch (int(Coeffs::static_size) - 1) { diff --git a/test/algorithms/set_operations/difference/test_difference.hpp b/test/algorithms/set_operations/difference/test_difference.hpp index 8717235cc..fb6dfe9a7 100644 --- a/test/algorithms/set_operations/difference/test_difference.hpp +++ b/test/algorithms/set_operations/difference/test_difference.hpp @@ -2,7 +2,7 @@ // Unit Test // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2017-2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2016-2020. // Modifications copyright (c) 2016-2020, Oracle and/or its affiliates. @@ -167,6 +167,7 @@ std::string test_difference(std::string const& caseid, G1 const& g1, G2 const& g { typedef typename bg::coordinate_type::type coordinate_type; boost::ignore_unused(); + boost::ignore_unused(expected_point_count); bg::model::multi_polygon result; diff --git a/test/algorithms/set_operations/intersection/test_intersection.hpp b/test/algorithms/set_operations/intersection/test_intersection.hpp index 5951325b6..4baa6f8fb 100644 --- a/test/algorithms/set_operations/intersection/test_intersection.hpp +++ b/test/algorithms/set_operations/intersection/test_intersection.hpp @@ -1,6 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Unit Test +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. + // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands. // This file was modified by Oracle on 2016-2021. @@ -17,6 +19,7 @@ #include #include +#include #include #include @@ -65,6 +68,8 @@ void check_result(IntersectionOutput const& intersection_output, int expected_point_count, expectation_limits const& expected_length_or_area, ut_settings const& settings) { + boost::ignore_unused(expected_point_count); + typedef typename boost::range_value::type OutputType; bool const is_line = bg::geometry_id::type::value == 2; diff --git a/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp b/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp index 414a350d6..0e7f733af 100644 --- a/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp +++ b/test/algorithms/set_operations/intersection/test_intersection_linear_linear.hpp @@ -1,5 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. + // Copyright (c) 2014-2021, 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 @@ -55,8 +57,8 @@ struct ut_settings template -inline void check_result(Geometry1 const& geometry1, - Geometry2 const& geometry2, +inline void check_result(Geometry1 const& , + Geometry2 const& , MultiLineString const& mls_output, MultiLineString const& mls_int1, MultiLineString const& mls_int2, diff --git a/test/geometries/boost_polygon.cpp b/test/geometries/boost_polygon.cpp index c535b22d1..dd562066e 100644 --- a/test/geometries/boost_polygon.cpp +++ b/test/geometries/boost_polygon.cpp @@ -2,6 +2,7 @@ // Unit Test // Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -34,14 +35,15 @@ template void fill_polygon_with_two_holes(boost::polygon::polygon_with_holes_data& boost_polygon_polygon) { - std::vector > point_vector; - point_vector.push_back(boost::polygon::point_data(0, 0)); - point_vector.push_back(boost::polygon::point_data(0, 10)); - point_vector.push_back(boost::polygon::point_data(10, 10)); - point_vector.push_back(boost::polygon::point_data(10, 0)); - point_vector.push_back(boost::polygon::point_data(0, 0)); - boost_polygon_polygon.set(point_vector.begin(), point_vector.end()); - + { + std::vector > point_vector; + point_vector.push_back(boost::polygon::point_data(0, 0)); + point_vector.push_back(boost::polygon::point_data(0, 10)); + point_vector.push_back(boost::polygon::point_data(10, 10)); + point_vector.push_back(boost::polygon::point_data(10, 0)); + point_vector.push_back(boost::polygon::point_data(0, 0)); + boost_polygon_polygon.set(point_vector.begin(), point_vector.end()); + } std::vector > holes; holes.resize(2); diff --git a/test/geometries/custom_non_copiable/helper_functions.hpp b/test/geometries/custom_non_copiable/helper_functions.hpp index 5d35e9d02..489e5c45f 100644 --- a/test/geometries/custom_non_copiable/helper_functions.hpp +++ b/test/geometries/custom_non_copiable/helper_functions.hpp @@ -1,6 +1,7 @@ // Boost.Geometry // Copyright (c) 2023 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -127,6 +128,7 @@ void create_svg(std::ostream& stream, Geometry1 const& a, Geometry2 const& b, Ge void write_svg(std::ostringstream& svg, std::string const& filename) { + boost::ignore_unused(svg, filename); #if defined(TEST_WITH_SVG_FILE) std::ofstream tmp("/tmp/" + filename); if (tmp.good()) diff --git a/test/iterators/test_iterator_common.hpp b/test/iterators/test_iterator_common.hpp index 05b84a463..29b5ec653 100644 --- a/test/iterators/test_iterator_common.hpp +++ b/test/iterators/test_iterator_common.hpp @@ -114,10 +114,12 @@ inline void test_equality(CombinedIterator first, CombinedIterator beyond, { typedef typename CombinedContainer::const_iterator iterator; - iterator it = combined.begin(); - for (CombinedIterator cit = first; cit != beyond; ++cit, ++it) { - BOOST_CHECK( *cit == *it ); + iterator it = combined.begin(); + for (CombinedIterator cit = first; cit != beyond; ++cit, ++it) + { + BOOST_CHECK( *cit == *it ); + } } if ( combined.begin() != combined.end() ) diff --git a/test/strategies/buffer_join_geo.cpp b/test/strategies/buffer_join_geo.cpp index e2fed8927..f22860b5b 100644 --- a/test/strategies/buffer_join_geo.cpp +++ b/test/strategies/buffer_join_geo.cpp @@ -2,6 +2,7 @@ // Unit Test // Copyright (c) 2022 Barend Gehrels, Amsterdam, the Netherlands. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -44,6 +45,8 @@ void test_join(std::string const& case_id, JoinStrategy const& join, P const& ve T const& buffer_distance, T const& angle1, T const& angle2, std::size_t expected_size) { + boost::ignore_unused(case_id); + // Use a deque to be able to use push_front bg::model::ring output_ring; diff --git a/test/util/select_most_precise.cpp b/test/util/select_most_precise.cpp index c4146089c..0c53e71ce 100644 --- a/test/util/select_most_precise.cpp +++ b/test/util/select_most_precise.cpp @@ -4,6 +4,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) 2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2021. // Modifications copyright (c) 2021, Oracle and/or its affiliates. @@ -19,6 +20,7 @@ #include +#include #include @@ -60,7 +62,7 @@ int test_main(int, char* []) test(); test(); - if ( sizeof(long double) > sizeof(double) ) + if (BOOST_GEOMETRY_CONDITION(sizeof(long double) > sizeof(double))) { // This cannot be done for MSVC because double/long double is the same // This is also true for Android From 96845810c99dd00b18d2cf158ce4c23f9fe6f1b2 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Sat, 1 Jul 2023 20:51:46 +0200 Subject: [PATCH 3/3] Add if constexpr macro and replace condition macro. --- include/boost/geometry/algorithms/densify.hpp | 9 ++--- .../detail/buffer/buffer_inserter.hpp | 34 ++++++++++--------- .../algorithms/detail/is_valid/linear.hpp | 13 ++++--- .../detail/is_valid/multipolygon.hpp | 13 ++++--- .../algorithms/detail/is_valid/polygon.hpp | 7 ++-- include/boost/geometry/io/wkt/write.hpp | 20 ++++++----- .../is_valid/failing_reason_policy.hpp | 30 ++++++++++------ include/boost/geometry/util/constexpr.hpp | 27 +++++++++++++++ 8 files changed, 99 insertions(+), 54 deletions(-) create mode 100644 include/boost/geometry/util/constexpr.hpp diff --git a/include/boost/geometry/algorithms/densify.hpp b/include/boost/geometry/algorithms/densify.hpp index fa8d5b1e5..b8069053a 100644 --- a/include/boost/geometry/algorithms/densify.hpp +++ b/include/boost/geometry/algorithms/densify.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2017-2021, Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2017-2021, Oracle and/or its affiliates. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Licensed under the Boost Software License version 1.0. @@ -33,7 +34,7 @@ #include #include #include -#include +#include #include @@ -102,7 +103,7 @@ struct densify_range strategy.apply(p0, p1, policy, len); } - if (BOOST_GEOMETRY_CONDITION(AppendLastPoint)) + if BOOST_GEOMETRY_CONSTEXPR (AppendLastPoint) { convert_and_push_back(rng_out, *prev); // back(rng) } @@ -130,7 +131,7 @@ struct densify_ring strategy.apply(p0, p1, policy, len); - if (BOOST_GEOMETRY_CONDITION(IsClosed2)) + if BOOST_GEOMETRY_CONSTEXPR (IsClosed2) { convert_and_push_back(ring_out, p1); } diff --git a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp index 51ba1abfe..5e8635c3d 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffer_inserter.hpp @@ -1,7 +1,7 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) // Copyright (c) 2012-2020 Barend Gehrels, Amsterdam, the Netherlands. -// Copyright (c) 2022 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2022-2023 Adam Wulkiewicz, Lodz, Poland. // This file was modified by Oracle on 2017-2022. // Modifications copyright (c) 2017-2022 Oracle and/or its affiliates. @@ -44,7 +44,7 @@ #include #include -#include +#include #include #include @@ -942,17 +942,17 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator { boost::ignore_unused(visit_pieces_policy); - typedef detail::buffer::buffered_piece_collection - < - typename geometry::ring_type::type, - Strategies, - DistanceStrategy, - RobustPolicy - > collection_type; + using collection_type = detail::buffer::buffered_piece_collection + < + typename geometry::ring_type::type, + Strategies, + DistanceStrategy, + RobustPolicy + >; collection_type collection(strategies, distance_strategy, robust_policy); collection_type const& const_collection = collection; - bool const areal = util::is_areal::value; + static constexpr bool areal = util::is_areal::value; dispatch::buffer_inserter < @@ -969,7 +969,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator robust_policy, strategies); collection.get_turns(); - if (BOOST_GEOMETRY_CONDITION(areal)) + if BOOST_GEOMETRY_CONSTEXPR (areal) { collection.check_turn_in_original(); } @@ -989,7 +989,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator // phase 1: turns (after enrichment/clustering) visit_pieces_policy.apply(const_collection, 1); - if (BOOST_GEOMETRY_CONDITION(areal)) + if BOOST_GEOMETRY_CONSTEXPR (areal) { collection.deflate_check_turns(); } @@ -1001,8 +1001,7 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator // - the output is counter clockwise // and avoid reversing twice bool reverse = distance_strategy.negative() && areal; - if (BOOST_GEOMETRY_CONDITION( - geometry::point_order::value == counterclockwise)) + if BOOST_GEOMETRY_CONSTEXPR (geometry::point_order::value == counterclockwise) { reverse = ! reverse; } @@ -1011,9 +1010,12 @@ inline void buffer_inserter(GeometryInput const& geometry_input, OutputIterator collection.reverse(); } - if (BOOST_GEOMETRY_CONDITION(distance_strategy.negative() && areal)) + if BOOST_GEOMETRY_CONSTEXPR (areal) { - collection.discard_nonintersecting_deflated_rings(); + if (distance_strategy.negative()) + { + collection.discard_nonintersecting_deflated_rings(); + } } collection.template assign(out); diff --git a/include/boost/geometry/algorithms/detail/is_valid/linear.hpp b/include/boost/geometry/algorithms/detail/is_valid/linear.hpp index 946cbf101..3753c87a4 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/linear.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/linear.hpp @@ -1,7 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2021, Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -31,7 +32,7 @@ #include #include -#include +#include namespace boost { namespace geometry @@ -158,10 +159,12 @@ public: VisitPolicy& visitor, Strategy const& strategy) { - if (BOOST_GEOMETRY_CONDITION( - AllowEmptyMultiGeometries && boost::empty(multilinestring))) + if BOOST_GEOMETRY_CONSTEXPR (AllowEmptyMultiGeometries) { - return visitor.template apply(); + if (boost::empty(multilinestring)) + { + return visitor.template apply(); + } } using per_ls = per_linestring; diff --git a/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp b/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp index a464bd6c6..5af933de8 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/multipolygon.hpp @@ -1,7 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014-2021, Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2014-2021, Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -27,7 +28,7 @@ #include #include -#include +#include #include #include @@ -282,10 +283,12 @@ public: { using debug_phase = debug_validity_phase; - if (BOOST_GEOMETRY_CONDITION(AllowEmptyMultiGeometries) - && boost::empty(multipolygon)) + if BOOST_GEOMETRY_CONSTEXPR (AllowEmptyMultiGeometries) { - return visitor.template apply(); + if (boost::empty(multipolygon)) + { + return visitor.template apply(); + } } // check validity of all polygons ring diff --git a/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp b/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp index 747ee54ef..6d6090d10 100644 --- a/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp +++ b/include/boost/geometry/algorithms/detail/is_valid/polygon.hpp @@ -1,9 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2017 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2017-2023 Adam Wulkiewicz, Lodz, Poland. // Copyright (c) 2014-2021, Oracle and/or its affiliates. - // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle @@ -35,7 +34,7 @@ #include #include -#include +#include #include #include @@ -447,7 +446,7 @@ public: return false; } - if (BOOST_GEOMETRY_CONDITION(CheckRingValidityOnly)) + if BOOST_GEOMETRY_CONSTEXPR (CheckRingValidityOnly) { return true; } diff --git a/include/boost/geometry/io/wkt/write.hpp b/include/boost/geometry/io/wkt/write.hpp index ee93041e7..90f69a54a 100644 --- a/include/boost/geometry/io/wkt/write.hpp +++ b/include/boost/geometry/io/wkt/write.hpp @@ -50,7 +50,7 @@ #include #include -#include +#include #include @@ -129,7 +129,7 @@ struct wkt_range if (boost::size(range) > 0) { - if (WriteDoubleBrackets) + if BOOST_GEOMETRY_CONSTEXPR (WriteDoubleBrackets) { os << "("; } @@ -143,15 +143,17 @@ struct wkt_range } // optionally, close range to ring by repeating the first point - if (BOOST_GEOMETRY_CONDITION(ForceClosurePossible) - && force_closure - && boost::size(range) > 1 - && wkt_range::disjoint(*begin, *(end - 1))) + if BOOST_GEOMETRY_CONSTEXPR (ForceClosurePossible) { - os << ","; - stream_type::apply(os, *begin); + if (force_closure + && boost::size(range) > 1 + && wkt_range::disjoint(*begin, *(end - 1))) + { + os << ","; + stream_type::apply(os, *begin); + } } - if (WriteDoubleBrackets) + if BOOST_GEOMETRY_CONSTEXPR (WriteDoubleBrackets) { os << ")"; } diff --git a/include/boost/geometry/policies/is_valid/failing_reason_policy.hpp b/include/boost/geometry/policies/is_valid/failing_reason_policy.hpp index bb28091d9..701e72c2d 100644 --- a/include/boost/geometry/policies/is_valid/failing_reason_policy.hpp +++ b/include/boost/geometry/policies/is_valid/failing_reason_policy.hpp @@ -1,7 +1,8 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2015, Oracle and/or its affiliates. +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. +// Copyright (c) 2015, 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 @@ -14,7 +15,7 @@ #include #include -#include +#include #include #include #include @@ -69,10 +70,12 @@ private: static inline validity_failure_type transform_failure_type(validity_failure_type failure) { - if (BOOST_GEOMETRY_CONDITION( - AllowDuplicates && failure == failure_duplicate_points)) + if BOOST_GEOMETRY_CONSTEXPR (AllowDuplicates) { - return no_failure; + if (failure == failure_duplicate_points) + { + return no_failure; + } } return failure; } @@ -81,10 +84,12 @@ private: validity_failure_type transform_failure_type(validity_failure_type failure, bool is_linear) { - if (BOOST_GEOMETRY_CONDITION( - is_linear && AllowSpikes && failure == failure_spikes)) + if BOOST_GEOMETRY_CONSTEXPR (AllowSpikes) { - return no_failure; + if (is_linear && failure == failure_spikes) + { + return no_failure; + } } return transform_failure_type(failure); } @@ -123,9 +128,12 @@ private: bool is_linear, SpikePoint const& spike_point) { - if (BOOST_GEOMETRY_CONDITION(is_linear && AllowSpikes)) + if BOOST_GEOMETRY_CONSTEXPR (AllowSpikes) { - return; + if (is_linear) + { + return; + } } oss << ". A spike point was found with apex at " @@ -173,7 +181,7 @@ private: static inline void apply(std::ostringstream& oss, Point const& point) { - if (BOOST_GEOMETRY_CONDITION(AllowDuplicates)) + if BOOST_GEOMETRY_CONSTEXPR (AllowDuplicates) { return; } diff --git a/include/boost/geometry/util/constexpr.hpp b/include/boost/geometry/util/constexpr.hpp new file mode 100644 index 000000000..72d141145 --- /dev/null +++ b/include/boost/geometry/util/constexpr.hpp @@ -0,0 +1,27 @@ +// Boost.Geometry + +// Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#ifndef BOOST_GEOMETRY_UTIL_CONSTEXPR_HPP +#define BOOST_GEOMETRY_UTIL_CONSTEXPR_HPP + + +#include + + +#ifndef BOOST_NO_CXX17_IF_CONSTEXPR + +#define BOOST_GEOMETRY_CONSTEXPR(CONDITION) constexpr (CONDITION) + +#else + +#define BOOST_GEOMETRY_CONSTEXPR(CONDITION) (BOOST_GEOMETRY_CONDITION(CONDITION)) + +#endif + + +#endif // BOOST_GEOMETRY_UTIL_CONSTEXPR_HPP