diff --git a/include/boost/geometry/strategies/spherical/closest_points_pt_seg.hpp b/include/boost/geometry/strategies/spherical/closest_points_pt_seg.hpp index aff36314da..5790ead7a5 100644 --- a/include/boost/geometry/strategies/spherical/closest_points_pt_seg.hpp +++ b/include/boost/geometry/strategies/spherical/closest_points_pt_seg.hpp @@ -1,5 +1,7 @@ // Boost.Geometry +// Copyright (c) 2024 Adam Wulkiewicz, Lodz, Poland. + // Copyright (c) 2021, Oracle and/or its affiliates. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle @@ -16,6 +18,8 @@ #include #include +#include + #include #include #include @@ -85,13 +89,21 @@ class cross_track { using CT = typename calculation_type::type; + model::point + < + CT, + dimension::value, + typename coordinate_system::type + > result; + // http://williams.best.vwh.net/avform.htm#XTE CT d3 = m_strategy.apply(sp1, sp2); if (geometry::math::equals(d3, 0.0)) { // "Degenerate" segment, return either d1 or d2 - return sp1; + geometry::detail::conversion::convert_point_to_point(sp1, result); + return result; } CT d1 = m_strategy.apply(sp1, p); @@ -159,24 +171,18 @@ class cross_track false >(lon1, lat1, s14_sph, a12, srs::sphere(earth_radius)); - model::point - < - CT, - dimension::value, - typename coordinate_system::type - > cp; - - geometry::set_from_radian<0>(cp, res_direct.lon2); - geometry::set_from_radian<1>(cp, res_direct.lat2); + geometry::set_from_radian<0>(result, res_direct.lon2); + geometry::set_from_radian<1>(result, res_direct.lat2); - return cp; + return result; } else { #ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK std::cout << "Projection OUTSIDE the segment" << std::endl; #endif - return d1 < d2 ? sp1 : sp2; + geometry::detail::conversion::convert_point_to_point(d1 < d2 ? sp1 : sp2, result); + return result; } }