summaryrefslogtreecommitdiff
path: root/boost/geometry/strategies/spherical/distance_cross_track.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:11:01 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2019-12-05 15:11:01 +0900
commit3fdc3e5ee96dca5b11d1694975a65200787eab86 (patch)
tree5c1733853892b8397d67706fa453a9bd978d2102 /boost/geometry/strategies/spherical/distance_cross_track.hpp
parent88e602c57797660ebe0f9e15dbd64c1ff16dead3 (diff)
downloadboost-3fdc3e5ee96dca5b11d1694975a65200787eab86.tar.gz
boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.tar.bz2
boost-3fdc3e5ee96dca5b11d1694975a65200787eab86.zip
Imported Upstream version 1.66.0upstream/1.66.0
Diffstat (limited to 'boost/geometry/strategies/spherical/distance_cross_track.hpp')
-rw-r--r--boost/geometry/strategies/spherical/distance_cross_track.hpp61
1 files changed, 40 insertions, 21 deletions
diff --git a/boost/geometry/strategies/spherical/distance_cross_track.hpp b/boost/geometry/strategies/spherical/distance_cross_track.hpp
index 7daafa4a16..82a2fb3d6f 100644
--- a/boost/geometry/strategies/spherical/distance_cross_track.hpp
+++ b/boost/geometry/strategies/spherical/distance_cross_track.hpp
@@ -2,9 +2,10 @@
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
-// This file was modified by Oracle on 2014.
-// Modifications copyright (c) 2014, Oracle and/or its affiliates.
+// This file was modified by Oracle on 2014-2017.
+// Modifications copyright (c) 2014-2017, Oracle and/or its affiliates.
+// Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
@@ -26,8 +27,6 @@
#include <boost/geometry/core/radian_access.hpp>
#include <boost/geometry/core/tags.hpp>
-#include <boost/geometry/algorithms/detail/course.hpp>
-
#include <boost/geometry/strategies/distance.hpp>
#include <boost/geometry/strategies/concepts/distance_concept.hpp>
#include <boost/geometry/strategies/spherical/distance_haversine.hpp>
@@ -373,19 +372,6 @@ public :
typedef typename return_type<Point, PointOfSegment>::type return_type;
-#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK
- std::cout << "Course " << dsv(sp1) << " to " << dsv(p) << " "
- << crs_AD * geometry::math::r2d<return_type>() << std::endl;
- std::cout << "Course " << dsv(sp1) << " to " << dsv(sp2) << " "
- << crs_AB * geometry::math::r2d<return_type>() << std::endl;
- std::cout << "Course " << dsv(sp2) << " to " << dsv(p) << " "
- << crs_BD * geometry::math::r2d << std::endl;
- std::cout << "Projection AD-AB " << projection1 << " : "
- << d_crs1 * geometry::math::r2d<return_type>() << std::endl;
- std::cout << "Projection BD-BA " << projection2 << " : "
- << d_crs2 * geometry::math::r2d<return_type>() << std::endl;
-#endif
-
// http://williams.best.vwh.net/avform.htm#XTE
return_type d1 = m_strategy.apply(sp1, p);
return_type d3 = m_strategy.apply(sp1, sp2);
@@ -398,10 +384,25 @@ public :
return_type d2 = m_strategy.apply(sp2, p);
- return_type crs_AD = geometry::detail::course<return_type>(sp1, p);
- return_type crs_AB = geometry::detail::course<return_type>(sp1, sp2);
- return_type crs_BA = crs_AB - geometry::math::pi<return_type>();
- return_type crs_BD = geometry::detail::course<return_type>(sp2, p);
+ return_type lon1 = geometry::get_as_radian<0>(sp1);
+ return_type lat1 = geometry::get_as_radian<1>(sp1);
+ return_type lon2 = geometry::get_as_radian<0>(sp2);
+ return_type lat2 = geometry::get_as_radian<1>(sp2);
+ return_type lon = geometry::get_as_radian<0>(p);
+ return_type lat = geometry::get_as_radian<1>(p);
+
+ return_type crs_AD = geometry::formula::spherical_azimuth<return_type, false>
+ (lon1, lat1, lon, lat).azimuth;
+
+ geometry::formula::result_spherical<return_type> result =
+ geometry::formula::spherical_azimuth<return_type, true>
+ (lon1, lat1, lon2, lat2);
+ return_type crs_AB = result.azimuth;
+ return_type crs_BA = result.reverse_azimuth - geometry::math::pi<return_type>();
+
+ return_type crs_BD = geometry::formula::spherical_azimuth<return_type, false>
+ (lon2, lat2, lon, lat).azimuth;
+
return_type d_crs1 = crs_AD - crs_AB;
return_type d_crs2 = crs_BD - crs_BA;
@@ -409,6 +410,24 @@ public :
return_type projection1 = cos( d_crs1 ) * d1 / d3;
return_type projection2 = cos( d_crs2 ) * d2 / d3;
+#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK
+ std::cout << "Course " << dsv(sp1) << " to " << dsv(p) << " "
+ << crs_AD * geometry::math::r2d<return_type>() << std::endl;
+ std::cout << "Course " << dsv(sp1) << " to " << dsv(sp2) << " "
+ << crs_AB * geometry::math::r2d<return_type>() << std::endl;
+ std::cout << "Course " << dsv(sp2) << " to " << dsv(sp1) << " "
+ << crs_BA * geometry::math::r2d<return_type>() << std::endl;
+ std::cout << "Course " << dsv(sp2) << " to " << dsv(p) << " "
+ << crs_BD * geometry::math::r2d<return_type>() << std::endl;
+ std::cout << "Projection AD-AB " << projection1 << " : "
+ << d_crs1 * geometry::math::r2d<return_type>() << std::endl;
+ std::cout << "Projection BD-BA " << projection2 << " : "
+ << d_crs2 * geometry::math::r2d<return_type>() << std::endl;
+ std::cout << " d1: " << (d1 )
+ << " d2: " << (d2 )
+ << std::endl;
+#endif
+
if (projection1 > 0.0 && projection2 > 0.0)
{
#ifdef BOOST_GEOMETRY_DEBUG_CROSS_TRACK