Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-18 08:42:56

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2015-2024.
0006 // Modifications copyright (c) 2015-2024, Oracle and/or its affiliates.
0007 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0008 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0009 
0010 // Use, modification and distribution is subject to the Boost Software License,
0011 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0012 // http://www.boost.org/LICENSE_1_0.txt)
0013 
0014 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_FUNCTIONS_HPP
0015 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_FUNCTIONS_HPP
0016 
0017 #include <boost/geometry/core/access.hpp>
0018 #include <boost/geometry/core/coordinate_type.hpp>
0019 #include <boost/geometry/core/tag_cast.hpp>
0020 
0021 // For spherical/geographic longitudes covered_by point/box
0022 #include <boost/geometry/strategies/cartesian/point_in_box.hpp>
0023 
0024 #include <boost/geometry/util/select_coordinate_type.hpp>
0025 
0026 
0027 namespace boost { namespace geometry
0028 {
0029 
0030 #ifndef DOXYGEN_NO_DETAIL
0031 namespace detail { namespace section
0032 {
0033 
0034 // TODO: This code is CS-specific, should be moved to strategies
0035 
0036 template
0037 <
0038     std::size_t Dimension,
0039     typename Geometry,
0040     typename CastedCSTag = tag_cast_t<cs_tag_t<Geometry>, spherical_tag>
0041 >
0042 struct preceding_check
0043 {
0044     template <typename Point, typename Box>
0045     static inline bool apply(int dir, Point const& point, Box const& /*point_box*/, Box const& other_box)
0046     {
0047         return (dir == 1  && get<Dimension>(point) < get<min_corner, Dimension>(other_box))
0048             || (dir == -1 && get<Dimension>(point) > get<max_corner, Dimension>(other_box));
0049     }
0050 };
0051 
0052 template <typename Geometry>
0053 struct preceding_check<0, Geometry, spherical_tag>
0054 {
0055     template <typename Point, typename Box>
0056     static inline bool apply(int dir, Point const& point, Box const& point_box, Box const& other_box)
0057     {
0058         using calc_t = typename select_coordinate_type<Point, Box>::type;
0059         using units_t = detail::coordinate_system_units_t<Point>;
0060 
0061         calc_t const c0 = 0;
0062 
0063         calc_t const value = get<0>(point);
0064         calc_t const other_min = get<min_corner, 0>(other_box);
0065         calc_t const other_max = get<max_corner, 0>(other_box);
0066 
0067         bool const pt_covered = strategy::within::detail::covered_by_range
0068                                     <
0069                                         Point, 0, spherical_tag
0070                                     >::apply(value,
0071                                              other_min,
0072                                              other_max);
0073 
0074         if (pt_covered)
0075         {
0076             return false;
0077         }
0078 
0079         if (dir == 1)
0080         {
0081             calc_t const diff_min = math::longitude_distance_signed
0082                                         <
0083                                             units_t, calc_t
0084                                         >(other_min, value);
0085 
0086             calc_t const diff_min_min = math::longitude_distance_signed
0087                                         <
0088                                             units_t, calc_t
0089                                         >(other_min, get<min_corner, 0>(point_box));
0090 
0091             return diff_min < c0 && diff_min_min <= c0 && diff_min_min <= diff_min;
0092         }
0093         else if (dir == -1)
0094         {
0095             calc_t const diff_max = math::longitude_distance_signed
0096                                         <
0097                                             units_t, calc_t
0098                                         >(other_max, value);
0099 
0100             calc_t const diff_max_max = math::longitude_distance_signed
0101                                         <
0102                                             units_t, calc_t
0103                                         >(other_max, get<max_corner, 0>(point_box));
0104 
0105             return diff_max > c0 && diff_max_max >= c0 && diff_max <= diff_max_max;
0106         }
0107 
0108         return false;
0109     }
0110 };
0111 
0112 
0113 template
0114 <
0115     std::size_t Dimension,
0116     typename Point,
0117     typename Box
0118 >
0119 inline bool preceding(int dir,
0120                       Point const& point,
0121                       Box const& point_box,
0122                       Box const& other_box)
0123 {
0124     return preceding_check<Dimension, Box>::apply(dir, point, point_box, other_box);
0125 }
0126 
0127 template
0128 <
0129     std::size_t Dimension,
0130     typename Point,
0131     typename Box
0132 >
0133 inline bool exceeding(int dir,
0134                       Point const& point,
0135                       Box const& point_box,
0136                       Box const& other_box)
0137 {
0138     return preceding<Dimension>(-dir, point, point_box, other_box);
0139 }
0140 
0141 
0142 }} // namespace detail::section
0143 #endif
0144 
0145 
0146 }} // namespace boost::geometry
0147 
0148 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_SECTIONS_FUNCTIONS_HPP