1 // Boost.Geometry Index
3 // n-dimensional Indexable validity check
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
7 // This file was modified by Oracle on 2020-2021.
8 // Modifications copyright (c) 2020-2021 Oracle and/or its affiliates.
9 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
11 // Use, modification and distribution is subject to the Boost Software License,
12 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
13 // http://www.boost.org/LICENSE_1_0.txt)
15 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_IS_VALID_HPP
16 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_IS_VALID_HPP
20 #include <boost/geometry/core/access.hpp>
21 #include <boost/geometry/core/coordinate_dimension.hpp>
22 #include <boost/geometry/core/static_assert.hpp>
24 namespace boost { namespace geometry { namespace index { namespace detail {
28 template <typename Box,
29 std::size_t Dimension = geometry::dimension<Box>::value>
32 static inline bool apply(Box const& b)
34 return is_valid_box<Box, Dimension - 1>::apply(b) &&
35 ( get<min_corner, Dimension - 1>(b) <= get<max_corner, Dimension - 1>(b) );
39 template <typename Box>
40 struct is_valid_box<Box, 1>
42 static inline bool apply(Box const& b)
44 return get<min_corner, 0>(b) <= get<max_corner, 0>(b);
48 template <typename Indexable,
49 typename Tag = typename geometry::tag<Indexable>::type>
52 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
53 "Not implemented for this Indexable type.",
57 template <typename Indexable>
58 struct is_valid<Indexable, point_tag>
60 static inline bool apply(Indexable const&)
66 template <typename Indexable>
67 struct is_valid<Indexable, box_tag>
69 static inline bool apply(Indexable const& b)
71 return dispatch::is_valid_box<Indexable>::apply(b);
75 template <typename Indexable>
76 struct is_valid<Indexable, segment_tag>
78 static inline bool apply(Indexable const&)
84 } // namespace dispatch
86 template <typename Indexable>
87 inline bool is_valid(Indexable const& b)
89 // CONSIDER: detection of NaNs
90 // e.g. by comparison of b with copy of b
92 return dispatch::is_valid<Indexable>::apply(b);
95 }}}} // namespace boost::geometry::index::detail
97 #endif // BOOST_GEOMETRY_DETAIL_INDEX_ALGORITHMS_IS_VALID_HPP