1 // Boost.Geometry Index
3 // n-dimensional bounds
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_BOUNDS_HPP
12 #define BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP
14 #include <boost/geometry/index/detail/bounded_view.hpp>
16 namespace boost { namespace geometry { namespace index { namespace detail {
20 template <typename Geometry,
22 typename TagGeometry = typename geometry::tag<Geometry>::type,
23 typename TagBounds = typename geometry::tag<Bounds>::type>
26 static inline void apply(Geometry const& g, Bounds & b)
28 geometry::convert(g, b);
32 template <typename Geometry, typename Bounds>
33 struct bounds<Geometry, Bounds, segment_tag, box_tag>
35 static inline void apply(Geometry const& g, Bounds & b)
37 index::detail::bounded_view<Geometry, Bounds> v(g);
38 geometry::convert(v, b);
42 } // namespace dispatch
44 template <typename Geometry, typename Bounds>
45 inline void bounds(Geometry const& g, Bounds & b)
47 concepts::check_concepts_and_equal_dimensions<Geometry const, Bounds>();
48 dispatch::bounds<Geometry, Bounds>::apply(g, b);
53 template <typename Geometry,
54 typename TagGeometry = typename geometry::tag<Geometry>::type>
55 struct return_ref_or_bounds
57 typedef Geometry const& result_type;
59 static inline result_type apply(Geometry const& g)
65 template <typename Geometry>
66 struct return_ref_or_bounds<Geometry, segment_tag>
68 typedef typename point_type<Geometry>::type point_type;
69 typedef geometry::model::box<point_type> bounds_type;
70 typedef index::detail::bounded_view<Geometry, bounds_type> result_type;
72 static inline result_type apply(Geometry const& g)
74 return result_type(g);
78 } // namespace dispatch
80 template <typename Geometry>
82 typename dispatch::return_ref_or_bounds<Geometry>::result_type
83 return_ref_or_bounds(Geometry const& g)
85 return dispatch::return_ref_or_bounds<Geometry>::apply(g);
88 }}}} // namespace boost::geometry::index::detail
90 #endif // BOOST_GEOMETRY_INDEX_DETAIL_ALGORITHMS_BOUNDS_HPP