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.
6 // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
8 // This file was modified by Oracle on 2015, 2016, 2017, 2018, 2019.
9 // Modifications copyright (c) 2015-2019, Oracle and/or its affiliates.
11 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
12 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
13 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
15 // Distributed under the Boost Software License, Version 1.0.
16 // (See accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
19 #ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_BOX_HPP
20 #define BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_BOX_HPP
25 #include <boost/geometry/core/cs.hpp>
26 #include <boost/geometry/core/coordinate_dimension.hpp>
27 #include <boost/geometry/core/coordinate_system.hpp>
28 #include <boost/geometry/core/tags.hpp>
30 #include <boost/geometry/algorithms/convert.hpp>
31 #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
32 #include <boost/geometry/algorithms/detail/normalize.hpp>
33 #include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
34 #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
35 #include <boost/geometry/algorithms/dispatch/envelope.hpp>
37 #include <boost/geometry/geometries/helper_geometry.hpp>
39 #include <boost/geometry/strategy/expand.hpp>
41 #include <boost/geometry/views/detail/indexed_point_view.hpp>
43 namespace boost { namespace geometry
47 #ifndef DOXYGEN_NO_DETAIL
48 namespace detail { namespace envelope
54 std::size_t DimensionCount
56 struct envelope_indexed_box_on_spheroid
58 template <typename BoxIn, typename BoxOut>
59 static inline void apply(BoxIn const& box_in, BoxOut& mbr)
61 // transform() does not work with boxes of dimension higher
62 // than 2; to account for such boxes we transform the min/max
63 // points of the boxes using the indexed_point_view
64 detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
65 detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
67 // first transform the units
68 transform_units(box_in_corner, mbr_corner);
70 // now transform the remaining coordinates
71 detail::conversion::point_to_point
73 detail::indexed_point_view<BoxIn const, Index>,
74 detail::indexed_point_view<BoxOut, Index>,
77 >::apply(box_in_corner, mbr_corner);
81 struct envelope_box_on_spheroid
83 template <typename BoxIn, typename BoxOut>
84 static inline void apply(BoxIn const& box_in, BoxOut& mbr)
86 // BoxIn can be non-mutable
87 typename helper_geometry<BoxIn>::type box_in_normalized;
88 geometry::convert(box_in, box_in_normalized);
90 if (! is_inverse_spheroidal_coordinates(box_in))
92 strategy::normalize::spherical_box::apply(box_in, box_in_normalized);
95 geometry::detail::envelope::envelope_indexed_box_on_spheroid
97 min_corner, dimension<BoxIn>::value
98 >::apply(box_in_normalized, mbr);
100 geometry::detail::envelope::envelope_indexed_box_on_spheroid
102 max_corner, dimension<BoxIn>::value
103 >::apply(box_in_normalized, mbr);
107 }} // namespace detail::envelope
108 #endif // DOXYGEN_NO_DETAIL
111 namespace strategy { namespace expand
114 #ifndef DOXYGEN_NO_DETAIL
118 struct box_on_spheroid
120 template <typename BoxOut, typename BoxIn>
121 static inline void apply(BoxOut& box_out, BoxIn const& box_in)
123 // normalize both boxes and convert box-in to be of type of box-out
125 geometry::detail::envelope::envelope_box_on_spheroid::apply(box_in, mbrs[0]);
126 geometry::detail::envelope::envelope_box_on_spheroid::apply(box_out, mbrs[1]);
128 // compute the envelope of the two boxes
129 geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box_out);
134 } // namespace detail
135 #endif // DOXYGEN_NO_DETAIL
139 : detail::box_on_spheroid
143 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
148 template <typename CalculationType>
149 struct default_strategy<box_tag, spherical_equatorial_tag, CalculationType>
151 typedef spherical_box type;
154 template <typename CalculationType>
155 struct default_strategy<box_tag, spherical_polar_tag, CalculationType>
157 typedef spherical_box type;
160 template <typename CalculationType>
161 struct default_strategy<box_tag, geographic_tag, CalculationType>
163 typedef spherical_box type;
166 } // namespace services
168 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
171 }} // namespace strategy::expand
173 }} // namespace boost::geometry
175 #endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_BOX_HPP