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.
8 // Modifications copyright (c) 2020 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/static_assert.hpp>
23 namespace boost { namespace geometry { namespace index { namespace detail {
27 template <typename Box,
28 std::size_t Dimension = geometry::dimension<Box>::value>
31 static inline bool apply(Box const& b)
33 return is_valid_box<Box, Dimension - 1>::apply(b) &&
34 ( get<min_corner, Dimension - 1>(b) <= get<max_corner, Dimension - 1>(b) );
38 template <typename Box>
39 struct is_valid_box<Box, 1>
41 static inline bool apply(Box const& b)
43 return get<min_corner, 0>(b) <= get<max_corner, 0>(b);
47 template <typename Indexable,
48 typename Tag = typename geometry::tag<Indexable>::type>
51 BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
52 "Not implemented for this Indexable type.",
56 template <typename Indexable>
57 struct is_valid<Indexable, point_tag>
59 static inline bool apply(Indexable const&)
65 template <typename Indexable>
66 struct is_valid<Indexable, box_tag>
68 static inline bool apply(Indexable const& b)
70 return dispatch::is_valid_box<Indexable>::apply(b);
74 template <typename Indexable>
75 struct is_valid<Indexable, segment_tag>
77 static inline bool apply(Indexable const&)
83 } // namespace dispatch
85 template <typename Indexable>
86 inline bool is_valid(Indexable const& b)
88 // CONSIDER: detection of NaNs
89 // e.g. by comparison of b with copy of b
91 return dispatch::is_valid<Indexable>::apply(b);
94 }}}} // namespace boost::geometry::index::detail
96 #endif // BOOST_GEOMETRY_DETAIL_INDEX_ALGORITHMS_IS_VALID_HPP