1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2014 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2014 Bruno Lalande, Paris, France.
5 // Copyright (c) 2014 Mateusz Loskot, London, UK.
6 // Copyright (c) 2014 Adam Wulkiewicz, Lodz, Poland.
8 // Use, modification and distribution is subject to the Boost Software License,
9 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt)
12 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP
13 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP
18 #include <boost/geometry/core/access.hpp>
19 #include <boost/geometry/util/math.hpp>
21 namespace boost { namespace geometry
24 #ifndef DOXYGEN_NO_DETAIL
28 template <typename Box, std::size_t Dimension>
29 struct get_max_size_box
31 static inline typename coordinate_type<Box>::type apply(Box const& box)
33 typename coordinate_type<Box>::type s
34 = geometry::math::abs(geometry::get<1, Dimension>(box) - geometry::get<0, Dimension>(box));
36 return (std::max)(s, get_max_size_box<Box, Dimension - 1>::apply(box));
40 template <typename Box>
41 struct get_max_size_box<Box, 0>
43 static inline typename coordinate_type<Box>::type apply(Box const& box)
45 return geometry::math::abs(geometry::get<1, 0>(box) - geometry::get<0, 0>(box));
49 // This might be implemented later on for other geometries too.
50 // Not dispatched yet.
51 template <typename Box>
52 inline typename coordinate_type<Box>::type get_max_size(Box const& box)
54 return get_max_size_box<Box, dimension<Box>::value - 1>::apply(box);
58 #endif // DOXYGEN_NO_DETAIL
61 }} // namespace boost::geometry
64 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP