Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:45

0001 // Boost.Geometry
0002 
0003 // Copyright (c) 2023 Adam Wulkiewicz, Lodz, Poland.
0004 
0005 // Copyright (c) 2021, Oracle and/or its affiliates.
0006 
0007 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0008 
0009 // Licensed under the Boost Software License version 1.0.
0010 // http://www.boost.org/users/license.html
0011 
0012 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_CLOSEST_POINTS_CROSS_TRACK_HPP
0013 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_CLOSEST_POINTS_CROSS_TRACK_HPP
0014 
0015 #include <boost/geometry/core/coordinate_dimension.hpp>
0016 #include <boost/geometry/core/coordinate_promotion.hpp>
0017 #include <boost/geometry/core/coordinate_system.hpp>
0018 #include <boost/geometry/core/radian_access.hpp>
0019 #include <boost/geometry/geometries/point.hpp>
0020 #include <boost/geometry/srs/spheroid.hpp>
0021 #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
0022 #include <boost/geometry/util/select_calculation_type.hpp>
0023 
0024 namespace boost { namespace geometry
0025 {
0026 
0027 namespace strategy { namespace closest_points
0028 {
0029 
0030 template
0031 <
0032     typename FormulaPolicy = geometry::strategy::andoyer,
0033     typename Spheroid = srs::spheroid<double>,
0034     typename CalculationType = void
0035 >
0036 class geographic_cross_track
0037     : public distance::detail::geographic_cross_track
0038         <
0039             FormulaPolicy,
0040             Spheroid,
0041             CalculationType,
0042             false,
0043             true
0044         >
0045 {
0046     using base_t = distance::detail::geographic_cross_track
0047         <
0048             FormulaPolicy,
0049             Spheroid,
0050             CalculationType,
0051             false,
0052             true
0053         >;
0054 
0055     template <typename Point, typename PointOfSegment>
0056     struct calculation_type
0057         : promote_floating_point
0058           <
0059               typename select_calculation_type
0060                   <
0061                       Point,
0062                       PointOfSegment,
0063                       CalculationType
0064                   >::type
0065           >
0066     {};
0067 
0068 public :
0069     explicit geographic_cross_track(Spheroid const& spheroid = Spheroid())
0070         : base_t(spheroid)
0071         {}
0072 
0073         template <typename Point, typename PointOfSegment>
0074         auto apply(Point const& p,
0075                    PointOfSegment const& sp1,
0076                    PointOfSegment const& sp2) const
0077         {
0078             auto result = base_t::apply(get_as_radian<0>(sp1), get_as_radian<1>(sp1),
0079                                         get_as_radian<0>(sp2), get_as_radian<1>(sp2),
0080                                         get_as_radian<0>(p), get_as_radian<1>(p),
0081                                         base_t::m_spheroid);
0082 
0083             model::point
0084                 <
0085                     typename calculation_type<Point, PointOfSegment>::type,
0086                     dimension<PointOfSegment>::value,
0087                     typename coordinate_system<PointOfSegment>::type
0088                 > cp;
0089 
0090             geometry::set_from_radian<0>(cp, result.lon);
0091             geometry::set_from_radian<1>(cp, result.lat);
0092 
0093             return cp;
0094         }
0095 };
0096 
0097 }} // namespace strategy::closest_points
0098 
0099 }} // namespace boost::geometry
0100 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_CLOSEST_POINTS_CROSS_TRACK_HPP