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 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) 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/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..9af947d9d 100644 --- a/test/algorithms/distance/distance_geo_box_box.cpp +++ b/test/algorithms/distance/distance_geo_box_box.cpp @@ -235,14 +235,23 @@ 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), + 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 +308,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);