Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2017-2021, Oracle and/or its affiliates.
0004 
0005 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0006 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle.
0007 
0008 // Use, modification and distribution is subject to the Boost Software License,
0009 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0010 // http://www.boost.org/LICENSE_1_0.txt)
0011 
0012 #ifndef BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_BOX_HPP
0013 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_BOX_HPP
0014 
0015 #include <boost/config.hpp>
0016 #include <boost/concept_check.hpp>
0017 
0018 #include <boost/geometry/core/access.hpp>
0019 #include <boost/geometry/core/assert.hpp>
0020 #include <boost/geometry/core/point_type.hpp>
0021 #include <boost/geometry/core/radian_access.hpp>
0022 #include <boost/geometry/core/tags.hpp>
0023 
0024 #include <boost/geometry/strategies/distance.hpp>
0025 #include <boost/geometry/strategies/concepts/distance_concept.hpp>
0026 #include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
0027 #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
0028 #include <boost/geometry/strategies/spherical/distance_cross_track_point_box.hpp>
0029 
0030 #include <boost/geometry/util/math.hpp>
0031 #include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
0032 
0033 
0034 namespace boost { namespace geometry
0035 {
0036 
0037 namespace strategy { namespace distance
0038 {
0039 
0040 
0041 /*!
0042 \brief Strategy functor for distance point to box calculation
0043 \ingroup strategies
0044 \details Class which calculates the distance of a point to a box, for
0045 points and boxes on a sphere or globe
0046 \tparam CalculationType \tparam_calculation
0047 \tparam Strategy underlying point-segment distance strategy, defaults
0048 to cross track
0049 \qbk{
0050 [heading See also]
0051 [link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
0052 }
0053 */
0054 template
0055 <
0056     typename FormulaPolicy = strategy::andoyer,
0057     typename Spheroid = srs::spheroid<double>,
0058     typename CalculationType = void
0059 >
0060 class geographic_cross_track_point_box
0061 {
0062 public:
0063     // point-point strategy getters
0064     struct distance_ps_strategy
0065     {
0066         typedef geographic_cross_track<FormulaPolicy, Spheroid, CalculationType> type;
0067     };
0068 
0069     template <typename Point, typename Box>
0070     struct return_type
0071         : services::return_type<typename distance_ps_strategy::type,
0072                                 Point, typename point_type<Box>::type>
0073     {};
0074 
0075     //constructor
0076 
0077     explicit geographic_cross_track_point_box(Spheroid const& spheroid = Spheroid())
0078              : m_spheroid(spheroid)
0079     {}
0080 
0081     template <typename Point, typename Box>
0082     inline typename return_type<Point, Box>::type
0083     apply(Point const& point, Box const& box) const
0084     {
0085 /*
0086 #if !defined(BOOST_MSVC)
0087         BOOST_CONCEPT_ASSERT
0088             (
0089                 (concepts::PointSegmentDistanceStrategy
0090                     <
0091                         Strategy, Point, typename point_type<Box>::type
0092                     >)
0093             );
0094 #endif
0095 */
0096 
0097         typedef typename return_type<Point, Box>::type return_type;
0098 
0099         return details::cross_track_point_box_generic
0100                         <return_type>::apply(point, box,
0101                                              typename distance_ps_strategy::type(m_spheroid));
0102     }
0103 
0104     Spheroid model() const
0105     {
0106         return m_spheroid;
0107     }
0108 
0109 private :
0110     Spheroid m_spheroid;
0111 };
0112 
0113 
0114 
0115 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0116 namespace services
0117 {
0118 
0119 template <typename Strategy, typename Spheroid, typename CalculationType>
0120 struct tag<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
0121 {
0122     typedef strategy_tag_distance_point_box type;
0123 };
0124 
0125 
0126 template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
0127 struct return_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box>
0128     : geographic_cross_track_point_box
0129         <
0130             Strategy, Spheroid, CalculationType
0131         >::template return_type<P, Box>
0132 {};
0133 
0134 template <typename Strategy, typename Spheroid, typename P, typename Box>
0135 struct return_type<geographic_cross_track_point_box<Strategy, Spheroid>, P, Box>
0136     : geographic_cross_track_point_box
0137         <
0138             Strategy, Spheroid
0139         >::template return_type<P, Box>
0140 {};
0141 
0142 template <typename Strategy, typename P, typename Box>
0143 struct return_type<geographic_cross_track_point_box<Strategy>, P, Box>
0144     : geographic_cross_track_point_box
0145         <
0146             Strategy
0147         >::template return_type<P, Box>
0148 {};
0149 
0150 template <typename Strategy, typename Spheroid, typename CalculationType>
0151 struct comparable_type<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
0152 {
0153     typedef geographic_cross_track_point_box
0154         <
0155             Strategy, Spheroid, CalculationType
0156         > type;
0157 };
0158 
0159 
0160 template <typename Strategy, typename Spheroid, typename CalculationType>
0161 struct get_comparable<geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> >
0162 {
0163 public:
0164     static inline geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>
0165     apply(geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> const& str)
0166     {
0167         return str;
0168     }
0169 };
0170 
0171 
0172 template <typename Strategy, typename Spheroid, typename CalculationType, typename P, typename Box>
0173 struct result_from_distance
0174     <
0175         geographic_cross_track_point_box<Strategy, Spheroid, CalculationType>, P, Box
0176     >
0177 {
0178 private:
0179     typedef geographic_cross_track_point_box<Strategy, Spheroid, CalculationType> this_strategy;
0180 
0181     typedef typename this_strategy::template return_type
0182         <
0183             P, Box
0184         >::type return_type;
0185 
0186 public:
0187     template <typename T>
0188     static inline return_type apply(this_strategy const& strategy,
0189                                     T const& distance)
0190     {
0191         result_from_distance
0192             <
0193                 Strategy, P, typename point_type<Box>::type
0194             >::apply(strategy, distance);
0195     }
0196 };
0197 
0198 template <typename Point, typename Box>
0199 struct default_strategy
0200     <
0201         point_tag, box_tag, Point, Box,
0202         geographic_tag, geographic_tag
0203     >
0204 {
0205     typedef geographic_cross_track_point_box<> type;
0206 };
0207 
0208 template <typename Box, typename Point>
0209 struct default_strategy
0210     <
0211         box_tag, point_tag, Box, Point,
0212         geographic_tag, geographic_tag
0213     >
0214 {
0215     typedef typename default_strategy
0216         <
0217             point_tag, box_tag, Point, Box,
0218             geographic_tag, geographic_tag
0219         >::type type;
0220 };
0221 
0222 } // namespace services
0223 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0224 
0225 
0226 }} // namespace strategy::distance
0227 
0228 
0229 }} // namespace boost::geometry
0230 
0231 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_POINT_BOX_HPP