diff --git a/include/boost/geometry/formulas/karney_direct.hpp b/include/boost/geometry/formulas/karney_direct.hpp index 463697e4b..bccdb371e 100644 --- a/include/boost/geometry/formulas/karney_direct.hpp +++ b/include/boost/geometry/formulas/karney_direct.hpp @@ -82,10 +82,10 @@ public: { result_type result; - CT lon1 = lo1; - CT const lat1 = la1; + CT lon1 = lo1 * math::r2d(); + CT const lat1 = la1 * math::r2d(); - Azi azi12 = azimuth12; + Azi azi12 = azimuth12 * math::r2d(); math::normalize_azimuth(azi12); CT const c0 = 0; @@ -169,9 +169,6 @@ public: CT const cos_alpha2 = cos_alpha0 * cos_sigma2; result.reverse_azimuth = atan2(sin_alpha2, cos_alpha2); - - // Convert the angle to radians. - result.reverse_azimuth /= math::d2r(); } if (BOOST_GEOMETRY_CONDITION(CalcCoordinates)) @@ -182,9 +179,6 @@ public: result.lat2 = atan2(sin_beta2, one_minus_f * cos_beta2); - // Convert the coordinate to radians. - result.lat2 /= math::d2r(); - // Find the longitude at the second point. CT const sin_omega2 = sin_alpha0 * sin_sigma2; CT const cos_omega2 = cos_sigma2; @@ -224,6 +218,8 @@ public: // otherwise differential quantities are calculated incorrectly. // But here it's ok since result.lon2 is not used after this point. math::normalize_longitude(result.lon2); + + result.lon2 *= math::d2r(); } if (BOOST_GEOMETRY_CONDITION(CalcQuantities)) diff --git a/test/formulas/direct.cpp b/test/formulas/direct.cpp index 97fb170f4..112a096ed 100644 --- a/test/formulas/direct.cpp +++ b/test/formulas/direct.cpp @@ -48,9 +48,12 @@ inline expected_results symmetric_wrt_origin(expected_results r) } template -void check_direct(Result const& result, expected_result const& expected, expected_result const& reference, +void check_direct(Result& result, expected_result const& expected, expected_result const& reference, double reference_error, bool check_reference_only = false) { + result.lon2 *= r2d; + result.lat2 *= r2d; + result.reverse_azimuth *= r2d; check_direct_sph(result, expected, reference, reference_error, check_reference_only); check_one(result.reduced_length, expected.reduced_length, reference.reduced_length, reference_error); check_one(result.geodesic_scale, expected.geodesic_scale, reference.geodesic_scale, reference_error); @@ -75,10 +78,6 @@ void test_all(expected_results const& results) double distance = results.distance; double azi12r = results.azimuth12 * d2r; - double lon1d = results.p1.lon; - double lat1d = results.p1.lat; - double azi12d = results.azimuth12; - // WGS84 bg::srs::spheroid spheroid(6378137.0, 6356752.3142451793); bg::srs::sphere const sphere; @@ -87,23 +86,14 @@ void test_all(expected_results const& results) typedef bg::formula::vincenty_direct vi_t; result = vi_t::apply(lon1r, lat1r, distance, azi12r, spheroid); - result.lon2 *= r2d; - result.lat2 *= r2d; - result.reverse_azimuth *= r2d; check_direct(result, results.vincenty, results.karney, 0.00000001); typedef bg::formula::thomas_direct th_t; result = th_t::apply(lon1r, lat1r, distance, azi12r, spheroid); - result.lon2 *= r2d; - result.lat2 *= r2d; - result.reverse_azimuth *= r2d; check_direct(result, results.thomas, results.karney, 0.0000001); typedef bg::formula::thomas_direct th_t1st; result = th_t1st::apply(lon1r, lat1r, distance, azi12r, spheroid); - result.lon2 *= r2d; - result.lat2 *= r2d; - result.reverse_azimuth *= r2d; check_direct(result, results.thomas1st, results.karney, 0.0000001); /* typedef bg::formula::series_expansion_direct series; @@ -115,13 +105,10 @@ void test_all(expected_results const& results) */ result = bg::formula::spherical_direct(lon1r, lat1r, distance, azi12r, sphere); - result.lon2 *= r2d; - result.lat2 *= r2d; - result.reverse_azimuth *= r2d; check_direct_sph(result, results.spherical, results.karney, 0.1); typedef bg::formula::karney_direct ka_t; - result = ka_t::apply(lon1d, lat1d, distance, azi12d, spheroid); + result = ka_t::apply(lon1r, lat1r, distance, azi12r, spheroid); check_direct(result, results.karney, results.karney, 0.0000001); #ifdef BOOST_GEOEMTRY_TEST_WITH_GEOGRAPHICLIB @@ -140,10 +127,11 @@ void test_all(expected_results const& results) void test_karney_antipodal(expected_results_antipodal const& results) { - double lon1d = results.p1.lon; - double lat1d = results.p1.lat; + double const r2d = bg::math::r2d(); + double lon1r = results.p1.lon * bg::math::d2r(); + double lat1r = results.p1.lat * bg::math::d2r(); double distance = results.distance; - double azi12d = results.azimuth12; + double azi12r = results.azimuth12 * bg::math::d2r(); // WGS84 bg::srs::spheroid spheroid(6378137.0, 6356752.3142451793); @@ -151,7 +139,7 @@ void test_karney_antipodal(expected_results_antipodal const& results) bg::formula::result_direct result; typedef bg::formula::karney_direct ka_t; - result = ka_t::apply(lon1d, lat1d, distance, azi12d, spheroid); + result = ka_t::apply(lon1r, lat1r, distance, azi12r, spheroid); check_direct(result, results.karney, results.karney, 0.0000001, true); }