]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/boost/geometry/strategies/cartesian/box_in_box.hpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / boost / geometry / strategies / cartesian / box_in_box.hpp
index 4641aafcb18a89eac8fdf3bf703608b663c8e07e..fef054cdb8da82e146242f3fb650f51caa92ed15 100644 (file)
@@ -5,8 +5,8 @@
 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
 // Copyright (c) 2013-2015 Adam Wulkiewicz, Lodz, Poland.
 
-// This file was modified by Oracle on 2015, 2016, 2017.
-// Modifications copyright (c) 2016-2017, Oracle and/or its affiliates.
+// This file was modified by Oracle on 2015, 2016, 2017, 2019.
+// Modifications copyright (c) 2016-2019, Oracle and/or its affiliates.
 
 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
 
@@ -36,6 +36,11 @@ namespace within
 {
 
 
+#ifndef DOXYGEN_NO_DETAIL
+namespace detail
+{
+
+
 struct box_within_coord
 {
     template <typename BoxContainedValue, typename BoxContainingValue>
@@ -63,18 +68,6 @@ struct box_covered_by_coord
 };
 
 
-template <typename Geometry, std::size_t Dimension, typename CSTag>
-struct box_within_range
-    : box_within_coord
-{};
-
-
-template <typename Geometry, std::size_t Dimension, typename CSTag>
-struct box_covered_by_range
-    : box_covered_by_coord
-{};
-
-
 struct box_within_longitude_diff
 {
     template <typename CalcT>
@@ -109,7 +102,7 @@ struct box_longitude_range
                 BoxContainedValue,
                 BoxContainingValue
             >::type calc_t;
-        typedef typename coordinate_system<Geometry>::type::units units_t;
+        typedef typename geometry::detail::cs_angular_units<Geometry>::type units_t;
         typedef math::detail::constants_on_spheroid<calc_t, units_t> constants;
 
         if (CoordCheck::apply(bed_min, bed_max, bing_min, bing_max))
@@ -144,35 +137,21 @@ struct box_longitude_range
 };
 
 
-// spherical_equatorial_tag, spherical_polar_tag and geographic_cat are casted to spherical_tag
-template <typename Geometry>
-struct box_within_range<Geometry, 0, spherical_tag>
-    : box_longitude_range<Geometry, box_within_coord, box_within_longitude_diff>
-{};
-
-
-template <typename Geometry>
-struct box_covered_by_range<Geometry, 0, spherical_tag>
-    : box_longitude_range<Geometry, box_covered_by_coord, box_covered_by_longitude_diff>
-{};
-
-
 template
 <
     template <typename, std::size_t, typename> class SubStrategy,
-    typename Box1,
-    typename Box2,
+    typename CSTag,
     std::size_t Dimension,
     std::size_t DimensionCount
 >
 struct relate_box_box_loop
 {
+    template <typename Box1, typename Box2>
     static inline bool apply(Box1 const& b_contained, Box2 const& b_containing)
     {
         assert_dimension_equal<Box1, Box2>();
-        typedef typename tag_cast<typename cs_tag<Box1>::type, spherical_tag>::type cs_tag_t;
-
-        if (! SubStrategy<Box1, Dimension, cs_tag_t>::apply(
+        
+        if (! SubStrategy<Box1, Dimension, CSTag>::apply(
                     get<min_corner, Dimension>(b_contained),
                     get<max_corner, Dimension>(b_contained),
                     get<min_corner, Dimension>(b_containing),
@@ -183,10 +162,9 @@ struct relate_box_box_loop
             return false;
         }
 
-        return relate_box_box_loop
+        return within::detail::relate_box_box_loop
             <
-                SubStrategy,
-                Box1, Box2,
+                SubStrategy, CSTag,
                 Dimension + 1, DimensionCount
             >::apply(b_contained, b_containing);
     }
@@ -195,32 +173,110 @@ struct relate_box_box_loop
 template
 <
     template <typename, std::size_t, typename> class SubStrategy,
-    typename Box1,
-    typename Box2,
+    typename CSTag,
     std::size_t DimensionCount
 >
-struct relate_box_box_loop<SubStrategy, Box1, Box2, DimensionCount, DimensionCount>
+struct relate_box_box_loop<SubStrategy, CSTag, DimensionCount, DimensionCount>
 {
+    template <typename Box1, typename Box2>
     static inline bool apply(Box1 const& , Box2 const& )
     {
         return true;
     }
 };
 
+
+} // namespace detail
+#endif // DOXYGEN_NO_DETAIL
+
+
+// for backward compatibility
+template <typename Geometry, std::size_t Dimension, typename CSTag>
+struct box_within_range
+    : within::detail::box_within_coord
+{};
+
+
+template <typename Geometry, std::size_t Dimension, typename CSTag>
+struct box_covered_by_range
+    : within::detail::box_covered_by_coord
+{};
+
+
+// spherical_equatorial_tag, spherical_polar_tag and geographic_cat are casted to spherical_tag
+template <typename Geometry>
+struct box_within_range<Geometry, 0, spherical_tag>
+    : within::detail::box_longitude_range
+        <
+            Geometry,
+            within::detail::box_within_coord,
+            within::detail::box_within_longitude_diff
+        >
+{};
+
+
+template <typename Geometry>
+struct box_covered_by_range<Geometry, 0, spherical_tag>
+    : within::detail::box_longitude_range
+        <
+            Geometry,
+            within::detail::box_covered_by_coord,
+            within::detail::box_covered_by_longitude_diff
+        >
+{};
+
+
+// for backward compatibility
 template
 <
-    typename Box1,
-    typename Box2,
+    typename B1,
+    typename B2,
     template <typename, std::size_t, typename> class SubStrategy = box_within_range
 >
 struct box_in_box
 {
+    template <typename Box1, typename Box2>
+    static inline bool apply(Box1 const& box1, Box2 const& box2)
+    {
+        typedef typename tag_cast
+            <
+                typename geometry::cs_tag<Box1>::type,
+                spherical_tag
+            >::type cs_tag;
+
+        return within::detail::relate_box_box_loop
+            <
+                SubStrategy, cs_tag,
+                0, dimension<Box1>::type::value
+            >::apply(box1, box2);
+    }
+};
+
+
+struct cartesian_box_box
+{
+    template <typename Box1, typename Box2>
+    static inline bool apply(Box1 const& box1, Box2 const& box2)
+    {
+        return within::detail::relate_box_box_loop
+            <
+                box_within_range,
+                cartesian_tag,
+                0, dimension<Box1>::type::value
+            >::apply(box1, box2);
+    }
+};
+
+struct spherical_box_box
+{
+    template <typename Box1, typename Box2>
     static inline bool apply(Box1 const& box1, Box2 const& box2)
     {
-        return relate_box_box_loop
+        return within::detail::relate_box_box_loop
             <
-                SubStrategy,
-                Box1, Box2, 0, dimension<Box1>::type::value
+                box_within_range,
+                spherical_tag,
+                0, dimension<Box1>::type::value
             >::apply(box1, box2);
     }
 };
@@ -229,6 +285,42 @@ struct box_in_box
 } // namespace within
 
 
+namespace covered_by
+{
+
+
+struct cartesian_box_box
+{
+    template <typename Box1, typename Box2>
+    static inline bool apply(Box1 const& box1, Box2 const& box2)
+    {
+        return within::detail::relate_box_box_loop
+            <
+                strategy::within::box_covered_by_range,
+                cartesian_tag,
+                0, dimension<Box1>::type::value
+            >::apply(box1, box2);
+    }
+};
+
+struct spherical_box_box
+{
+    template <typename Box1, typename Box2>
+    static inline bool apply(Box1 const& box1, Box2 const& box2)
+    {
+        return within::detail::relate_box_box_loop
+            <
+                strategy::within::box_covered_by_range,
+                spherical_tag,
+                0, dimension<Box1>::type::value
+            >::apply(box1, box2);
+    }
+};
+
+
+}
+
+
 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
 
 
@@ -244,7 +336,7 @@ struct default_strategy
         cartesian_tag, cartesian_tag
     >
 {
-    typedef within::box_in_box<BoxContained, BoxContaining> type;
+    typedef cartesian_box_box type;
 };
 
 // spherical_equatorial_tag, spherical_polar_tag and geographic_cat are casted to spherical_tag
@@ -257,7 +349,7 @@ struct default_strategy
         spherical_tag, spherical_tag
     >
 {
-    typedef within::box_in_box<BoxContained, BoxContaining> type;
+    typedef spherical_box_box type;
 };
 
 
@@ -275,11 +367,7 @@ struct default_strategy
         cartesian_tag, cartesian_tag
     >
 {
-    typedef within::box_in_box
-                <
-                    BoxContained, BoxContaining,
-                    within::box_covered_by_range
-                > type;
+    typedef cartesian_box_box type;
 };
 
 // spherical_equatorial_tag, spherical_polar_tag and geographic_cat are casted to spherical_tag
@@ -292,11 +380,7 @@ struct default_strategy
         spherical_tag, spherical_tag
     >
 {
-    typedef within::box_in_box
-                <
-                    BoxContained, BoxContaining,
-                    within::box_covered_by_range
-                > type;
+    typedef spherical_box_box type;
 };