1 // Boost.Geometry Index
3 // n-dimensional Indexable validity check
5 // Copyright (c) 2011-2014 Adam Wulkiewicz, Lodz, Poland.
7 // Use, modification and distribution is subject to the Boost Software License,
8 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
9 // http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_IS_VALID_HPP
12 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_IS_VALID_HPP
15 #include <boost/geometry/core/access.hpp>
17 namespace boost { namespace geometry { namespace index { namespace detail {
21 template <typename Box,
22 std::size_t Dimension = geometry::dimension<Box>::value>
25 static inline bool apply(Box const& b)
27 return is_valid_box<Box, Dimension - 1>::apply(b) &&
28 ( get<min_corner, Dimension - 1>(b) <= get<max_corner, Dimension - 1>(b) );
32 template <typename Box>
33 struct is_valid_box<Box, 1>
35 static inline bool apply(Box const& b)
37 return get<min_corner, 0>(b) <= get<max_corner, 0>(b);
41 template <typename Indexable,
42 typename Tag = typename geometry::tag<Indexable>::type>
47 NOT_IMPLEMENTED_FOR_THIS_INDEXABLE,
51 template <typename Indexable>
52 struct is_valid<Indexable, point_tag>
54 static inline bool apply(Indexable const&)
60 template <typename Indexable>
61 struct is_valid<Indexable, box_tag>
63 static inline bool apply(Indexable const& b)
65 return dispatch::is_valid_box<Indexable>::apply(b);
69 template <typename Indexable>
70 struct is_valid<Indexable, segment_tag>
72 static inline bool apply(Indexable const&)
78 } // namespace dispatch
80 template <typename Indexable>
81 inline bool is_valid(Indexable const& b)
83 // CONSIDER: detection of NaNs
84 // e.g. by comparison of b with copy of b
86 return dispatch::is_valid<Indexable>::apply(b);
89 }}}} // namespace boost::geometry::index::detail
91 #endif // BOOST_GEOMETRY_DETAIL_INDEX_ALGORITHMS_IS_VALID_HPP