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 // This file was modified by Oracle on 2018.
9 // Modifications copyright (c) 2018, Oracle and/or its affiliates.
11 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
13 // Use, modification and distribution is subject to the Boost Software License,
14 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
15 // http://www.boost.org/LICENSE_1_0.txt)
17 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP
18 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP
22 #include <boost/geometry/core/access.hpp>
23 #include <boost/geometry/core/coordinate_dimension.hpp>
24 #include <boost/geometry/util/math.hpp>
26 namespace boost { namespace geometry
29 #ifndef DOXYGEN_NO_DETAIL
33 template <typename Box, std::size_t Dimension>
34 struct get_max_size_box
36 static inline typename coordinate_type<Box>::type apply(Box const& box)
38 typename coordinate_type<Box>::type s
39 = geometry::math::abs(geometry::get<1, Dimension>(box) - geometry::get<0, Dimension>(box));
41 return (std::max)(s, get_max_size_box<Box, Dimension - 1>::apply(box));
45 template <typename Box>
46 struct get_max_size_box<Box, 0>
48 static inline typename coordinate_type<Box>::type apply(Box const& box)
50 return geometry::math::abs(geometry::get<1, 0>(box) - geometry::get<0, 0>(box));
54 // This might be implemented later on for other geometries too.
55 // Not dispatched yet.
56 template <typename Box>
57 inline typename coordinate_type<Box>::type get_max_size(Box const& box)
59 return get_max_size_box<Box, dimension<Box>::value - 1>::apply(box);
63 #endif // DOXYGEN_NO_DETAIL
66 }} // namespace boost::geometry
69 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_GET_MAX_SIZE_HPP