From 54f5ead9e81c5420e60f4e91f3dfdc4bb3e3e87e Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Tue, 27 Mar 2018 21:28:13 +0200 Subject: [PATCH 1/6] ticket #13386 - workaround for some gcc compilers complaining about Also move the const according to conventions, in this method. --- .../buffer/buffered_piece_collection.hpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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 1e0bfe192..7030502c1 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -571,8 +571,8 @@ struct buffered_piece_collection const buffer_turn_info_type& turn = *it; if (turn.location == location_ok) { - const buffer_turn_operation_type& op0 = turn.operations[0]; - const buffer_turn_operation_type& op1 = turn.operations[1]; + buffer_turn_operation_type const& op0 = turn.operations[0]; + buffer_turn_operation_type const& op1 = turn.operations[1]; if (! m_pieces[op0.seg_id.piece_index].is_deflated || ! m_pieces[op1.seg_id.piece_index].is_deflated) @@ -585,7 +585,7 @@ struct buffered_piece_collection // It is deflated, update counts for (int i = 0; i < 2; i++) { - const buffer_turn_operation_type& op = turn.operations[i]; + buffer_turn_operation_type const& op = turn.operations[i]; if (op.operation == detail::overlay::operation_union || op.operation == detail::overlay::operation_continue) { @@ -602,15 +602,19 @@ struct buffered_piece_collection if (turn.location == location_ok) { - const buffer_turn_operation_type& op0 = turn.operations[0]; - const buffer_turn_operation_type& op1 = turn.operations[1]; + buffer_turn_operation_type const& op0 = turn.operations[0]; + buffer_turn_operation_type const& op1 = turn.operations[1]; signed_size_type const multi0 = op0.seg_id.multi_index; signed_size_type const multi1 = op1.seg_id.multi_index; if (multi0 == multi1) { - const deflate_properties& prop = properties[multi0]; - if (! prop.has_inflated && prop.count < 3) + deflate_properties const& prop = properties[multi0]; + + // NOTE: Keep brackets around prop.count + // avoid gcc-bug "parse error in template argument list" + // GCC versions 5.4 and 5.5 (and probably more) + if (! prop.has_inflated && (prop.count) < 3) { // Property is not inflated // Not enough points, this might be caused by where From 7bfd8c6ca37ce9bd29ad67c4a484f80a0357ea36 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Tue, 27 Mar 2018 21:46:05 +0200 Subject: [PATCH 2/6] Revert "ticket #13386 - workaround for some gcc compilers complaining about" This reverts commit 54f5ead9e81c5420e60f4e91f3dfdc4bb3e3e87e. --- .../buffer/buffered_piece_collection.hpp | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) 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 7030502c1..1e0bfe192 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -571,8 +571,8 @@ struct buffered_piece_collection const buffer_turn_info_type& turn = *it; if (turn.location == location_ok) { - buffer_turn_operation_type const& op0 = turn.operations[0]; - buffer_turn_operation_type const& op1 = turn.operations[1]; + const buffer_turn_operation_type& op0 = turn.operations[0]; + const buffer_turn_operation_type& op1 = turn.operations[1]; if (! m_pieces[op0.seg_id.piece_index].is_deflated || ! m_pieces[op1.seg_id.piece_index].is_deflated) @@ -585,7 +585,7 @@ struct buffered_piece_collection // It is deflated, update counts for (int i = 0; i < 2; i++) { - buffer_turn_operation_type const& op = turn.operations[i]; + const buffer_turn_operation_type& op = turn.operations[i]; if (op.operation == detail::overlay::operation_union || op.operation == detail::overlay::operation_continue) { @@ -602,19 +602,15 @@ struct buffered_piece_collection if (turn.location == location_ok) { - buffer_turn_operation_type const& op0 = turn.operations[0]; - buffer_turn_operation_type const& op1 = turn.operations[1]; + const buffer_turn_operation_type& op0 = turn.operations[0]; + const buffer_turn_operation_type& op1 = turn.operations[1]; signed_size_type const multi0 = op0.seg_id.multi_index; signed_size_type const multi1 = op1.seg_id.multi_index; if (multi0 == multi1) { - deflate_properties const& prop = properties[multi0]; - - // NOTE: Keep brackets around prop.count - // avoid gcc-bug "parse error in template argument list" - // GCC versions 5.4 and 5.5 (and probably more) - if (! prop.has_inflated && (prop.count) < 3) + const deflate_properties& prop = properties[multi0]; + if (! prop.has_inflated && prop.count < 3) { // Property is not inflated // Not enough points, this might be caused by where From 68296965f55d911d74574ae7bbc065226adca3f0 Mon Sep 17 00:00:00 2001 From: Barend Gehrels Date: Tue, 27 Mar 2018 21:50:18 +0200 Subject: [PATCH 3/6] ticket #13386 - workaround for some gcc compilers --- doc/release_notes.qbk | 1 + .../algorithms/detail/buffer/buffered_piece_collection.hpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/release_notes.qbk b/doc/release_notes.qbk index 3938957c2..1af38d7bc 100644 --- a/doc/release_notes.qbk +++ b/doc/release_notes.qbk @@ -37,6 +37,7 @@ [*Solved issues] +* [@https://svn.boost.org/trac10/ticket/13386 13386] Workaround for some gcc compilers * [@https://svn.boost.org/trac10/ticket/13381 13381] Compile error with matrix_transformer in Visual C++ 2015 * [@https://svn.boost.org/trac10/ticket/13436 13436] Incorrectness in boost::geometry::model::polygon documentation 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 1e0bfe192..ba824243c 100644 --- a/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp +++ b/include/boost/geometry/algorithms/detail/buffer/buffered_piece_collection.hpp @@ -610,7 +610,11 @@ struct buffered_piece_collection if (multi0 == multi1) { const deflate_properties& prop = properties[multi0]; - if (! prop.has_inflated && prop.count < 3) + + // NOTE: Keep brackets around prop.count + // avoid gcc-bug "parse error in template argument list" + // GCC versions 5.4 and 5.5 (and probably more) + if (! prop.has_inflated && (prop.count) < 3) { // Property is not inflated // Not enough points, this might be caused by where From ab2ab3144d86cd17140580b243e632f81c56168e Mon Sep 17 00:00:00 2001 From: Vissarion Fysikopoulos Date: Tue, 27 Mar 2018 13:49:51 +0300 Subject: [PATCH 4/6] [strategies] [tests] Diagonal case fix for box-box distance --- .../distance_cross_track_box_box.hpp | 67 ++++++++++++------- .../distance/distance_geo_box_box.cpp | 22 +++++- 2 files changed, 64 insertions(+), 25 deletions(-) diff --git a/include/boost/geometry/strategies/spherical/distance_cross_track_box_box.hpp b/include/boost/geometry/strategies/spherical/distance_cross_track_box_box.hpp index 4a315c653..efa7a728a 100644 --- a/include/boost/geometry/strategies/spherical/distance_cross_track_box_box.hpp +++ b/include/boost/geometry/strategies/spherical/distance_cross_track_box_box.hpp @@ -44,6 +44,31 @@ class cross_track_box_box_generic { public : + template + ReturnType static inline diagonal_case(Point topA, + Point topB, + Point bottomA, + Point bottomB, + bool north_shortest, + bool non_overlap, + Strategy ps_strategy) + { + if (north_shortest && non_overlap) + { + return ps_strategy.get_distance_strategy().apply(topA, bottomB); + } + if (north_shortest && !non_overlap) + { + return ps_strategy.apply(topA, topB, bottomB); + } + if (!north_shortest && non_overlap) + { + return ps_strategy.get_distance_strategy().apply(bottomA, topB); + } + return ps_strategy.apply(bottomA, topB, bottomB); + } + + template < typename Box1, @@ -162,9 +187,9 @@ public : ReturnType bottom_common = (std::max)(lat_min1, lat_min2); // true if the closest points are on northern hemisphere - bool north_shortest = math::abs(top_common) > math::abs(bottom_common) - || lat_max1 <= lat_min2 - || lat_min1 >= lat_max2; + bool north_shortest = top_common + bottom_common > 0; + // true if box bands do not overlap + bool non_overlap = top_common < bottom_common; if (north_shortest) { @@ -183,44 +208,40 @@ public : #ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX std::cout << "(bottom left)"; #endif - if (north_shortest) - { - return ps_strategy.apply(top_right2, top_left1, bottom_left1); - } - return ps_strategy.apply(bottom_right2, top_left1, bottom_left1); + return diagonal_case(top_right2, top_left1, + bottom_right2, bottom_left1, + north_shortest, non_overlap, + ps_strategy); } if (bottom_max && right_wrap) { #ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX std::cout << "(bottom right)"; #endif - if (north_shortest) - { - return ps_strategy.apply(top_left2, top_right1, bottom_right1); - } - return ps_strategy.apply(bottom_left2, top_right1, bottom_right1); + return diagonal_case(top_left2, top_right1, + bottom_left2, bottom_right1, + north_shortest, non_overlap, + ps_strategy); } if (!bottom_max && !right_wrap) { #ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX std::cout << "(top left)"; #endif - if (north_shortest) - { - return ps_strategy.apply(top_left1, top_right2, bottom_right2); - } - return ps_strategy.apply(bottom_left1, top_right2, bottom_right2); + return diagonal_case(top_left1, top_right2, + bottom_left1, bottom_right2, + north_shortest, non_overlap, + ps_strategy); } if (!bottom_max && right_wrap) { #ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK_BOX_BOX std::cout << "(top right)"; #endif - if (north_shortest) - { - return ps_strategy.apply(top_right1, top_left2, bottom_left2); - } - return ps_strategy.apply(bottom_right1, top_left2, bottom_left2); + return diagonal_case(top_right1, top_left2, + bottom_right1, bottom_left2, + north_shortest, non_overlap, + ps_strategy); } return ReturnType(0); } diff --git a/test/algorithms/distance/distance_geo_box_box.cpp b/test/algorithms/distance/distance_geo_box_box.cpp index c44816e3c..8d656c79e 100644 --- a/test/algorithms/distance/distance_geo_box_box.cpp +++ b/test/algorithms/distance/distance_geo_box_box.cpp @@ -235,14 +235,24 @@ void test_distance_box_box(Strategy_pp const& strategy_pp, strategy_bb); // case 10 - tester::apply("bb10", box1, "BOX(4 18, 8 22)", + tester::apply("bb10a", box1, "BOX(4 18, 8 22)", ps_distance("POINT(10 20)", "SEGMENT(8 18, 8 22)", strategy_ps), strategy_bb); - tester::apply("bb10", box1, "BOX(4 20, 8 22)", + std::string const box1m = "BOX(10 -20,20 -10)"; + tester::apply("bb10am", box1m, "BOX(4 -22, 8 -18)", + ps_distance("POINT(10 20)", "SEGMENT(8 18, 8 22)", strategy_ps), + strategy_bb); + + tester::apply("bb10b", box1, "BOX(4 20, 8 22)", ps_distance("POINT(10 20)", "SEGMENT(8 20, 8 22)", strategy_ps), strategy_bb); + tester::apply("bb10bm", box1m, "BOX(4 -22, 8 -20)", + ps_distance("POINT(10 20)", "SEGMENT(8 22, 8 20)", strategy_ps), + //ps_distance("POINT(10 -20)", "SEGMENT(8 -20, 8 -22)", strategy_ps), + strategy_bb); + // case 11 tester::apply("bb11", box1, "BOX(4 22, 8 24)", pp_distance("POINT(8 22)", "POINT(10 20)", strategy_pp), @@ -299,6 +309,14 @@ void test_distance_box_box(Strategy_pp const& strategy_pp, ps_distance("POINT(20 25)", "SEGMENT(30 -15, 30 30)", strategy_ps), strategy_bb); + tester::apply("bb-eq1b", "BOX(30 -15, 40 30)", "BOX(10 -20, 20 10)", + ps_distance("POINT(30 -15)", "SEGMENT(20 10, 20 -20)", strategy_ps), + strategy_bb); + + tester::apply("bb-eq1bm", "BOX(30 -30, 40 15)", "BOX(10 -10, 20 20)", + ps_distance("POINT(30 15)", "SEGMENT(20 -10, 20 20)", strategy_ps), + strategy_bb); + tester::apply("bb-eq2", "BOX(30 -15, 40 20)", "BOX(10 -20, 20 25)", ps_distance("POINT(30 20)", "SEGMENT(20 -20, 20 25)", strategy_ps), strategy_bb); From df23bb19b83b17749c722edbf29eaf7a50de6b31 Mon Sep 17 00:00:00 2001 From: Vissarion Fysikopoulos Date: Wed, 28 Mar 2018 16:54:08 +0300 Subject: [PATCH 5/6] [strategies] Fix inverse strategy type call from point segment distance computation strategy --- .../geographic/distance_cross_track.hpp | 18 +++++++++--------- .../distance/distance_geo_box_box.cpp | 1 - 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/boost/geometry/strategies/geographic/distance_cross_track.hpp b/include/boost/geometry/strategies/geographic/distance_cross_track.hpp index ba53cd737..be930a3fd 100644 --- a/include/boost/geometry/strategies/geographic/distance_cross_track.hpp +++ b/include/boost/geometry/strategies/geographic/distance_cross_track.hpp @@ -200,8 +200,8 @@ private : CT lon3, CT lat3, //query point p3 Spheroid const& spheroid) { - typedef typename FormulaPolicy::template inverse - inverse_distance_quantities_type; + typedef typename FormulaPolicy::template inverse + inverse_distance_azimuth_quantities_type; typedef typename FormulaPolicy::template inverse inverse_azimuth_type; typedef typename FormulaPolicy::template inverse @@ -419,8 +419,8 @@ private : CT a4 = inverse_azimuth_type::apply(res14.lon2, res14.lat2, lon2, lat2, spheroid).azimuth; - res34 = inverse_distance_quantities_type::apply(res14.lon2, res14.lat2, - lon3, lat3, spheroid); + res34 = inverse_distance_azimuth_quantities_type::apply(res14.lon2, res14.lat2, + lon3, lat3, spheroid); g4 = res34.azimuth - a4; @@ -483,20 +483,20 @@ private : std::cout << "s34(sph) =" << s34_sph << std::endl; std::cout << "s34(geo) =" - << inverse_distance_quantities_type::apply(get<0>(p4), get<1>(p4), lon3, lat3, spheroid).distance + << inverse_distance_azimuth_quantities_type::apply(get<0>(p4), get<1>(p4), lon3, lat3, spheroid).distance << ", p4=(" << get<0>(p4) * math::r2d() << "," << get<1>(p4) * math::r2d() << ")" << std::endl; - CT s31 = inverse_distance_quantities_type::apply(lon3, lat3, lon1, lat1, spheroid).distance; - CT s32 = inverse_distance_quantities_type::apply(lon3, lat3, lon2, lat2, spheroid).distance; + CT s31 = inverse_distance_azimuth_quantities_type::apply(lon3, lat3, lon1, lat1, spheroid).distance; + CT s32 = inverse_distance_azimuth_quantities_type::apply(lon3, lat3, lon2, lat2, spheroid).distance; CT a4 = inverse_azimuth_type::apply(get<0>(p4), get<1>(p4), lon2, lat2, spheroid).azimuth; geometry::formula::result_direct res4 = direct_distance_type::apply(get<0>(p4), get<1>(p4), .04, a4, spheroid); - CT p4_plus = inverse_distance_quantities_type::apply(res4.lon2, res4.lat2, lon3, lat3, spheroid).distance; + CT p4_plus = inverse_distance_azimuth_quantities_type::apply(res4.lon2, res4.lat2, lon3, lat3, spheroid).distance; geometry::formula::result_direct res1 = direct_distance_type::apply(lon1, lat1, s14-.04, a12, spheroid); - CT p4_minus = inverse_distance_quantities_type::apply(res1.lon2, res1.lat2, lon3, lat3, spheroid).distance; + CT p4_minus = inverse_distance_azimuth_quantities_type::apply(res1.lon2, res1.lat2, lon3, lat3, spheroid).distance; std::cout << "s31=" << s31 << "\ns32=" << s32 << "\np4_plus=" << p4_plus << ", p4=(" << res4.lon2 * math::r2d() << "," << res4.lat2 * math::r2d() << ")" diff --git a/test/algorithms/distance/distance_geo_box_box.cpp b/test/algorithms/distance/distance_geo_box_box.cpp index 8d656c79e..9af947d9d 100644 --- a/test/algorithms/distance/distance_geo_box_box.cpp +++ b/test/algorithms/distance/distance_geo_box_box.cpp @@ -250,7 +250,6 @@ void test_distance_box_box(Strategy_pp const& strategy_pp, tester::apply("bb10bm", box1m, "BOX(4 -22, 8 -20)", ps_distance("POINT(10 20)", "SEGMENT(8 22, 8 20)", strategy_ps), - //ps_distance("POINT(10 -20)", "SEGMENT(8 -20, 8 -22)", strategy_ps), strategy_bb); // case 11 From ff6547bc7b0099bfbfe8f3f129605e35e78ac714 Mon Sep 17 00:00:00 2001 From: Vissarion Fysikopoulos Date: Wed, 28 Mar 2018 16:59:03 +0300 Subject: [PATCH 6/6] [formulas] Fix a bug in thomas inverse formula --- include/boost/geometry/formulas/thomas_inverse.hpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/boost/geometry/formulas/thomas_inverse.hpp b/include/boost/geometry/formulas/thomas_inverse.hpp index 6db3285e0..cf69c9df1 100644 --- a/include/boost/geometry/formulas/thomas_inverse.hpp +++ b/include/boost/geometry/formulas/thomas_inverse.hpp @@ -1,7 +1,8 @@ // Boost.Geometry -// Copyright (c) 2015-2017 Oracle and/or its affiliates. +// Copyright (c) 2015-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 // Use, modification and distribution is subject to the Boost Software License, @@ -177,7 +178,7 @@ public: CT const pi = math::pi(); - if (BOOST_GEOMETRY_CONDITION(EnableAzimuth)) + if (BOOST_GEOMETRY_CONDITION(CalcFwdAzimuth)) { CT alpha1 = v + u; if (alpha1 > pi) @@ -188,7 +189,7 @@ public: result.azimuth = alpha1; } - if (BOOST_GEOMETRY_CONDITION(EnableReverseAzimuth)) + if (BOOST_GEOMETRY_CONDITION(CalcRevAzimuth)) { CT alpha2 = pi - (v - u); if (alpha2 > pi)