Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
0006 // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
0007 
0008 // This file was modified by Oracle on 2013-2018.
0009 // Modifications copyright (c) 2013-2018, Oracle and/or its affiliates.
0010 
0011 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0012 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0013 
0014 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0015 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0016 
0017 // Use, modification and distribution is subject to the Boost Software License,
0018 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0019 // http://www.boost.org/LICENSE_1_0.txt)
0020 
0021 #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_BOX_BOX_HPP
0022 #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_BOX_BOX_HPP
0023 
0024 #include <cstddef>
0025 
0026 #include <boost/geometry/core/cs.hpp>
0027 
0028 #include <boost/geometry/strategies/cartesian/disjoint_box_box.hpp>
0029 #include <boost/geometry/strategies/disjoint.hpp>
0030 
0031 #include <boost/geometry/util/normalize_spheroidal_coordinates.hpp>
0032 #include <boost/geometry/util/select_most_precise.hpp>
0033 
0034 
0035 namespace boost { namespace geometry { namespace strategy { namespace disjoint
0036 {
0037 
0038 #ifndef DOXYGEN_NO_DETAIL
0039 namespace detail
0040 {
0041 
0042 struct box_box_on_spheroid
0043 {
0044     template <typename Box1, typename Box2>
0045     static inline bool apply(Box1 const& box1, Box2 const& box2)
0046     {
0047         typedef typename geometry::select_most_precise
0048             <
0049                 typename coordinate_type<Box1>::type,
0050                 typename coordinate_type<Box2>::type
0051             >::type calc_t;
0052         typedef typename geometry::detail::cs_angular_units<Box1>::type units_t;
0053         typedef math::detail::constants_on_spheroid<calc_t, units_t> constants;
0054 
0055         calc_t const b1_min = get<min_corner, 0>(box1);
0056         calc_t const b1_max = get<max_corner, 0>(box1);
0057         calc_t const b2_min = get<min_corner, 0>(box2);
0058         calc_t const b2_max = get<max_corner, 0>(box2);
0059 
0060         // min <= max <=> diff >= 0
0061         calc_t const diff1 = b1_max - b1_min;
0062         calc_t const diff2 = b2_max - b2_min;
0063 
0064         // check the intersection if neither box cover the whole globe
0065         if (diff1 < constants::period() && diff2 < constants::period())
0066         {
0067             // calculate positive longitude translation with b1_min as origin
0068             calc_t const diff_min = math::longitude_distance_unsigned<units_t>(b1_min, b2_min);
0069             calc_t const b2_min_transl = b1_min + diff_min; // always right of b1_min
0070             calc_t b2_max_transl = b2_min_transl - constants::period() + diff2;
0071 
0072             // if the translation is too close then use the original point
0073             // note that math::abs(b2_max_transl - b2_max) takes values very
0074             // close to k*2*constants::period() for k=0,1,2,...
0075             if (math::abs(b2_max_transl - b2_max) < constants::period() / 2)
0076             {
0077                 b2_max_transl = b2_max;
0078             }
0079 
0080             if (b2_min_transl > b1_max  // b2_min right of b1_max
0081              && b2_max_transl < b1_min) // b2_max left of b1_min
0082             {
0083                 return true;
0084             }
0085         }
0086 
0087         return box_box
0088             <
0089                 Box1, Box2, 1
0090             >::apply(box1, box2);
0091     }
0092 };
0093 
0094 } // namespace detail
0095 #endif // DOXYGEN_NO_DETAIL
0096 
0097 
0098 struct spherical_box_box
0099 {
0100     template <typename Box1, typename Box2>
0101     static inline bool apply(Box1 const& box1, Box2 const& box2)
0102     {
0103         return detail::box_box_on_spheroid::apply(box1, box2);
0104     }
0105 };
0106 
0107 
0108 namespace services
0109 {
0110 
0111 template <typename Box1, typename Box2, int TopDim1, int TopDim2>
0112 struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, spherical_equatorial_tag, spherical_equatorial_tag>
0113 {
0114     typedef disjoint::spherical_box_box type;
0115 };
0116 
0117 template <typename Box1, typename Box2, int TopDim1, int TopDim2>
0118 struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, spherical_polar_tag, spherical_polar_tag>
0119 {
0120     typedef disjoint::spherical_box_box type;
0121 };
0122 
0123 template <typename Box1, typename Box2, int TopDim1, int TopDim2>
0124 struct default_strategy<Box1, Box2, box_tag, box_tag, TopDim1, TopDim2, geographic_tag, geographic_tag>
0125 {
0126     typedef disjoint::spherical_box_box type;
0127 };
0128 
0129 } // namespace services
0130 
0131 }}}} // namespace boost::geometry::strategy::disjoint
0132 
0133 
0134 #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_DISJOINT_BOX_BOX_HPP