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_BOX_BOX_HPP
0013 #define BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_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/geographic/distance.hpp>
0027 #include <boost/geometry/strategies/geographic/distance_cross_track.hpp>
0028 #include <boost/geometry/strategies/spherical/distance_cross_track.hpp>
0029 #include <boost/geometry/strategies/spherical/distance_cross_track_box_box.hpp>
0030 
0031 #include <boost/geometry/util/math.hpp>
0032 #include <boost/geometry/algorithms/detail/assign_box_corners.hpp>
0033 
0034 
0035 namespace boost { namespace geometry
0036 {
0037 
0038 namespace strategy { namespace distance
0039 {
0040 
0041 
0042 /*!
0043 \brief Strategy functor for distance point to box calculation
0044 \ingroup strategies
0045 \details Class which calculates the distance of a point to a box, for
0046 points and boxes on a sphere or globe
0047 \tparam CalculationType \tparam_calculation
0048 \tparam Strategy underlying point-segment distance strategy, defaults
0049 to cross track
0050 \qbk{
0051 [heading See also]
0052 [link geometry.reference.algorithms.distance.distance_3_with_strategy distance (with strategy)]
0053 }
0054 */
0055 template
0056 <
0057     typename FormulaPolicy = strategy::andoyer,
0058     typename Spheroid = srs::spheroid<double>,
0059     typename CalculationType = void
0060 >
0061 class geographic_cross_track_box_box
0062 {
0063 public:
0064 
0065     // point-point strategy getters
0066     struct distance_pp_strategy
0067     {
0068         typedef geographic<FormulaPolicy, Spheroid, CalculationType> type;
0069     };
0070 
0071     // point-segment strategy getters
0072     struct distance_ps_strategy
0073     {
0074         typedef geographic_cross_track
0075                 <
0076                     FormulaPolicy,
0077                     Spheroid,
0078                     CalculationType
0079                 > type;
0080     };
0081 
0082     template <typename Box1, typename Box2>
0083     struct return_type : services::return_type
0084             <
0085                 typename distance_ps_strategy::type,
0086                 typename point_type<Box1>::type,
0087                 typename point_type<Box2>::type
0088             >
0089     {};
0090 
0091     //constructor
0092 
0093     explicit geographic_cross_track_box_box(Spheroid const& spheroid = Spheroid())
0094              : m_spheroid(spheroid)
0095     {}
0096 
0097     template <typename Box1, typename Box2>
0098     inline typename return_type<Box1, Box2>::type
0099     apply(Box1 const& box1, Box2 const& box2) const
0100     {
0101 /*
0102 #if !defined(BOOST_MSVC)
0103         BOOST_CONCEPT_ASSERT
0104             (
0105                 (concepts::PointSegmentDistanceStrategy
0106                     <
0107                         Strategy,
0108                         typename point_type<Box1>::type,
0109                         typename point_type<Box2>::type
0110                     >)
0111             );
0112 #endif
0113 */
0114         typedef typename return_type<Box1, Box2>::type return_type;
0115         return details::cross_track_box_box_generic
0116                                        <return_type>::apply(box1, box2,
0117                                                             typename distance_pp_strategy::type(m_spheroid),
0118                                                             typename distance_ps_strategy::type(m_spheroid));
0119     }
0120 
0121     Spheroid model() const
0122     {
0123         return m_spheroid;
0124     }
0125 
0126 private :
0127     Spheroid m_spheroid;
0128 };
0129 
0130 
0131 
0132 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0133 namespace services
0134 {
0135 
0136 template <typename Strategy, typename Spheroid, typename CalculationType>
0137 struct tag<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
0138 {
0139     typedef strategy_tag_distance_box_box type;
0140 };
0141 
0142 
0143 template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2>
0144 struct return_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2>
0145     : geographic_cross_track_box_box
0146         <
0147             Strategy, Spheroid, CalculationType
0148         >::template return_type<Box1, Box2>
0149 {};
0150 
0151 template <typename Strategy, typename Spheroid, typename Box1, typename Box2>
0152 struct return_type<geographic_cross_track_box_box<Strategy, Spheroid>, Box1, Box2>
0153     : geographic_cross_track_box_box
0154         <
0155             Strategy, Spheroid
0156         >::template return_type<Box1, Box2>
0157 {};
0158 
0159 template <typename Strategy, typename Box1, typename Box2>
0160 struct return_type<geographic_cross_track_box_box<Strategy>, Box1, Box2>
0161     : geographic_cross_track_box_box
0162         <
0163             Strategy
0164         >::template return_type<Box1, Box2>
0165 {};
0166 
0167 template <typename Strategy, typename Spheroid, typename CalculationType>
0168 struct comparable_type<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
0169 {
0170     typedef geographic_cross_track_box_box
0171         <
0172             typename comparable_type<Strategy>::type, Spheroid, CalculationType
0173         > type;
0174 };
0175 
0176 
0177 template <typename Strategy, typename Spheroid, typename CalculationType>
0178 struct get_comparable<geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> >
0179 {
0180 public:
0181     static inline geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>
0182     apply(geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> const& str)
0183     {
0184         return str;
0185     }
0186 };
0187 
0188 
0189 template <typename Strategy, typename Spheroid, typename CalculationType, typename Box1, typename Box2>
0190 struct result_from_distance
0191     <
0192         geographic_cross_track_box_box<Strategy, Spheroid, CalculationType>, Box1, Box2
0193     >
0194 {
0195 private:
0196     typedef geographic_cross_track_box_box<Strategy, Spheroid, CalculationType> this_strategy;
0197 
0198     typedef typename this_strategy::template return_type
0199         <
0200             Box1, Box2
0201         >::type return_type;
0202 
0203 public:
0204     template <typename T>
0205     static inline return_type apply(this_strategy const& strategy,
0206                                     T const& distance)
0207     {
0208         result_from_distance
0209             <
0210                 Strategy,
0211                 typename point_type<Box1>::type,
0212                 typename point_type<Box2>::type
0213             >::apply(strategy, distance);
0214     }
0215 };
0216 
0217 template <typename Box1, typename Box2>
0218 struct default_strategy
0219     <
0220         box_tag, box_tag, Box1, Box2,
0221         geographic_tag, geographic_tag
0222     >
0223 {
0224     typedef geographic_cross_track_box_box<> type;
0225 };
0226 
0227 
0228 } // namespace services
0229 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0230 
0231 
0232 }} // namespace strategy::distance
0233 
0234 
0235 }} // namespace boost::geometry
0236 
0237 
0238 #endif // BOOST_GEOMETRY_STRATEGIES_GEOGRAPHIC_DISTANCE_CROSS_TRACK_BOX_BOX_HPP