diff --git a/include/boost/geometry/strategies/geographic/distance_cross_track.hpp b/include/boost/geometry/strategies/geographic/distance_cross_track.hpp index ff6eea211..bbef7d9f0 100644 --- a/include/boost/geometry/strategies/geographic/distance_cross_track.hpp +++ b/include/boost/geometry/strategies/geographic/distance_cross_track.hpp @@ -333,13 +333,6 @@ private : CT a312 = a13 - a12; -#ifdef BOOST_GEOMETRY_DEBUG_GEOGRAPHIC_CROSS_TRACK - std::cout << "a1=" << a12 * math::r2d() << std::endl; - std::cout << "a13=" << a13 * math::r2d() << std::endl; - std::cout << "a312=" << a312 * math::r2d() << std::endl; - std::cout << "cos(a312)=" << cos(a312) << std::endl; -#endif - // TODO: meridian case optimization if (geometry::math::equals(a312, c0) && meridian_not_crossing_pole) { @@ -356,6 +349,14 @@ private : CT projection1 = cos( a312 ) * d1 / d3; +#ifdef BOOST_GEOMETRY_DEBUG_GEOGRAPHIC_CROSS_TRACK + std::cout << "a1=" << a12 * math::r2d() << std::endl; + std::cout << "a13=" << a13 * math::r2d() << std::endl; + std::cout << "a312=" << a312 * math::r2d() << std::endl; + std::cout << "cos(a312)=" << cos(a312) << std::endl; + std::cout << "projection 1=" << projection1 << std::endl; +#endif + if (projection1 < c0) { #ifdef BOOST_GEOMETRY_DEBUG_GEOGRAPHIC_CROSS_TRACK @@ -371,13 +372,15 @@ private : CT a321 = a23 - a21; + CT projection2 = cos( a321 ) * d2 / d3; + #ifdef BOOST_GEOMETRY_DEBUG_GEOGRAPHIC_CROSS_TRACK std::cout << "a21=" << a21 * math::r2d() << std::endl; std::cout << "a23=" << a23 * math::r2d() << std::endl; std::cout << "a321=" << a321 * math::r2d() << std::endl; std::cout << "cos(a321)=" << cos(a321) << std::endl; + std::cout << "projection 2=" << projection2 << std::endl; #endif - CT projection2 = cos( a321 ) * d2 / d3; if (projection2 < c0) { diff --git a/test/algorithms/distance/distance_geo_pl_l.cpp b/test/algorithms/distance/distance_geo_pl_l.cpp index 572626694..a6408f7dd 100644 --- a/test/algorithms/distance/distance_geo_pl_l.cpp +++ b/test/algorithms/distance/distance_geo_pl_l.cpp @@ -338,6 +338,32 @@ void test_distance_point_segment(Strategy_pp const& strategy_pp, "SEGMENT(0 0,180 0)", 0, strategy_ps, true, true); + + tester::apply("p-s-20", + "POINT(80 89)", + "SEGMENT(0 0,180 0)", + pp_distance("POINT(80 89)", "POINT(0 89.82633489283377)", strategy_pp), + strategy_ps, true, true); + + tester::apply("p-s-21", + "POINT(80 89)", + "SEGMENT(0 -1,180 1)", + pp_distance("POINT(80 89)", "POINT(0 89.82633489283377)", strategy_pp), + strategy_ps, true, true); + + // meridian special case + tester::apply("p-s-mer2", + "POINT(2.5 3)", + "SEGMENT(2 2,2 4)", + pp_distance("POINT(2.5 3)", "POINT(2 3.000114792872075)", strategy_pp), + strategy_ps, true, true); + tester::apply("p-s-mer4", + "POINT(1 80)", + "SEGMENT(0 0,0 90)", + pp_distance("POINT(1 80)", "POINT(0 80.00149225834545)", strategy_pp), + strategy_ps, true, true); + + } template @@ -352,37 +378,13 @@ void test_distance_point_segment_no_thomas(Strategy_pp const& strategy_pp, typedef test_distance_of_geometries tester; // thomas strategy is failing for those test cases + // this is because of inaccurate results for points close to poles - // meridian special case - tester::apply("p-s-mer2", - "POINT(2.5 3)", - "SEGMENT(2 2,2 4)", - pp_distance("POINT(2.5 3)", "POINT(2 3.000114792872075)", strategy_pp), - strategy_ps, true, true); - tester::apply("p-s-mer4", - "POINT(1 80)", - "SEGMENT(0 0,0 90)", - pp_distance("POINT(1 80)", "POINT(0 80.00149225834545)", strategy_pp), - strategy_ps, true, true); - - // Half meridian segment passing through pole tester::apply("p-s-19", "POINT(90 89)", "SEGMENT(0 0,180 0)", pp_distance("POINT(90 89)", "POINT(90 90)", strategy_pp), strategy_ps, true, true); - - tester::apply("p-s-20", - "POINT(80 89)", - "SEGMENT(0 0,180 0)", - pp_distance("POINT(80 89)", "POINT(0 89.82633489283377)", strategy_pp), - strategy_ps, true, true); - - tester::apply("p-s-21", - "POINT(80 89)", - "SEGMENT(0 -1,180 1)", - pp_distance("POINT(80 89)", "POINT(0 89.82633489283377)", strategy_pp), - strategy_ps, true, true); } //=========================================================================== @@ -677,9 +679,8 @@ BOOST_AUTO_TEST_CASE( test_all_point_segment ) test_distance_point_segment(thomas_pp(), thomas_strategy()); test_distance_point_segment(andoyer_pp(), andoyer_strategy()); - test_distance_point_segment_no_thomas(vincenty_pp(), vincenty_strategy()); - ///test_distance_point_segment_no_thomas(thomas_pp(), thomas_strategy()); + //test_distance_point_segment_no_thomas(thomas_pp(), thomas_strategy()); test_distance_point_segment_no_thomas(andoyer_pp(), andoyer_strategy()); test_distance_point_linestring(vincenty_pp(), vincenty_strategy());