1 // Boost.Geometry (aka GGL, Generic Geometry Library)
3 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
4 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
5 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
7 // This file was modified by Oracle on 2015, 2016, 2017.
8 // Modifications copyright (c) 2015-2017, Oracle and/or its affiliates.
10 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
11 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
12 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
14 // Distributed under the Boost Software License, Version 1.0.
15 // (See accompanying file LICENSE_1_0.txt or copy at
16 // http://www.boost.org/LICENSE_1_0.txt)
18 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_BOX_HPP
19 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_BOX_HPP
23 #include <boost/geometry/core/cs.hpp>
24 #include <boost/geometry/core/coordinate_dimension.hpp>
25 #include <boost/geometry/core/coordinate_system.hpp>
26 #include <boost/geometry/core/tags.hpp>
28 #include <boost/geometry/views/detail/indexed_point_view.hpp>
30 #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
31 #include <boost/geometry/algorithms/detail/normalize.hpp>
32 #include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
34 #include <boost/geometry/algorithms/dispatch/envelope.hpp>
37 namespace boost { namespace geometry
40 #ifndef DOXYGEN_NO_DETAIL
41 namespace detail { namespace envelope
48 std::size_t Dimension,
49 std::size_t DimensionCount
51 struct envelope_indexed_box
53 template <typename BoxIn, typename BoxOut>
54 static inline void apply(BoxIn const& box_in, BoxOut& mbr)
56 detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
57 detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
59 detail::conversion::point_to_point
61 detail::indexed_point_view<BoxIn const, Index>,
62 detail::indexed_point_view<BoxOut, Index>,
65 >::apply(box_in_corner, mbr_corner);
72 std::size_t DimensionCount
74 struct envelope_indexed_box_on_spheroid
76 template <typename BoxIn, typename BoxOut>
77 static inline void apply(BoxIn const& box_in, BoxOut& mbr)
79 // transform() does not work with boxes of dimension higher
80 // than 2; to account for such boxes we transform the min/max
81 // points of the boxes using the indexed_point_view
82 detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
83 detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
85 // first transform the units
86 transform_units(box_in_corner, mbr_corner);
88 // now transform the remaining coordinates
89 detail::conversion::point_to_point
91 detail::indexed_point_view<BoxIn const, Index>,
92 detail::indexed_point_view<BoxOut, Index>,
95 >::apply(box_in_corner, mbr_corner);
102 template<typename BoxIn, typename BoxOut, typename Strategy>
103 static inline void apply(BoxIn const& box_in,
109 min_corner, 0, dimension<BoxIn>::value
110 >::apply(box_in, mbr);
114 max_corner, 0, dimension<BoxIn>::value
115 >::apply(box_in, mbr);
120 struct envelope_box_on_spheroid
122 template <typename BoxIn, typename BoxOut, typename Strategy>
123 static inline void apply(BoxIn const& box_in,
127 BoxIn box_in_normalized = detail::return_normalized<BoxIn>(box_in);
129 envelope_indexed_box_on_spheroid
131 min_corner, dimension<BoxIn>::value
132 >::apply(box_in_normalized, mbr);
134 envelope_indexed_box_on_spheroid
136 max_corner, dimension<BoxIn>::value
137 >::apply(box_in_normalized, mbr);
142 }} // namespace detail::envelope
143 #endif // DOXYGEN_NO_DETAIL
145 #ifndef DOXYGEN_NO_DISPATCH
150 template <typename Box>
151 struct envelope<Box, box_tag, cartesian_tag>
152 : detail::envelope::envelope_box
156 template <typename Box>
157 struct envelope<Box, box_tag, spherical_polar_tag>
158 : detail::envelope::envelope_box_on_spheroid
162 template <typename Box>
163 struct envelope<Box, box_tag, spherical_equatorial_tag>
164 : detail::envelope::envelope_box_on_spheroid
168 template <typename Box>
169 struct envelope<Box, box_tag, geographic_tag>
170 : detail::envelope::envelope_box_on_spheroid
174 } // namespace dispatch
175 #endif // DOXYGEN_NO_DISPATCH
177 }} // namespace boost::geometry
179 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ENVELOPE_BOX_HPP