Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:52

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
0006 // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
0007 
0008 // This file was modified by Oracle on 2015, 2016, 2017, 2018, 2019.
0009 // Modifications copyright (c) 2015-2019, Oracle and/or its affiliates.
0010 
0011 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0012 // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
0013 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0014 
0015 // Distributed under the Boost Software License, Version 1.0.
0016 // (See accompanying file LICENSE_1_0.txt or copy at
0017 // http://www.boost.org/LICENSE_1_0.txt)
0018 
0019 #ifndef BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_BOX_HPP
0020 #define BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_BOX_HPP
0021 
0022 #include <algorithm>
0023 #include <cstddef>
0024 
0025 #include <boost/geometry/core/cs.hpp>
0026 #include <boost/geometry/core/coordinate_dimension.hpp>
0027 #include <boost/geometry/core/coordinate_system.hpp>
0028 #include <boost/geometry/core/tags.hpp>
0029 
0030 #include <boost/geometry/algorithms/convert.hpp>
0031 #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
0032 #include <boost/geometry/algorithms/detail/normalize.hpp>
0033 #include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
0034 #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
0035 #include <boost/geometry/algorithms/dispatch/envelope.hpp>
0036 
0037 #include <boost/geometry/geometries/helper_geometry.hpp>
0038 
0039 #include <boost/geometry/strategy/expand.hpp>
0040 
0041 #include <boost/geometry/views/detail/indexed_point_view.hpp>
0042 
0043 namespace boost { namespace geometry
0044 {
0045 
0046 
0047 #ifndef DOXYGEN_NO_DETAIL
0048 namespace detail { namespace envelope
0049 {
0050 
0051 template
0052 <
0053     std::size_t Index,
0054     std::size_t DimensionCount
0055 >
0056 struct envelope_indexed_box_on_spheroid
0057 {
0058     template <typename BoxIn, typename BoxOut>
0059     static inline void apply(BoxIn const& box_in, BoxOut& mbr)
0060     {
0061         // transform() does not work with boxes of dimension higher
0062         // than 2; to account for such boxes we transform the min/max
0063         // points of the boxes using the indexed_point_view
0064         detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
0065         detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
0066 
0067         // first transform the units
0068         transform_units(box_in_corner, mbr_corner);
0069 
0070         // now transform the remaining coordinates
0071         detail::conversion::point_to_point
0072             <
0073                 detail::indexed_point_view<BoxIn const, Index>,
0074                 detail::indexed_point_view<BoxOut, Index>,
0075                 2,
0076                 DimensionCount
0077             >::apply(box_in_corner, mbr_corner);
0078     }
0079 };
0080 
0081 struct envelope_box_on_spheroid
0082 {
0083     template <typename BoxIn, typename BoxOut>
0084     static inline void apply(BoxIn const& box_in, BoxOut& mbr)
0085     {
0086         // BoxIn can be non-mutable
0087         typename helper_geometry<BoxIn>::type box_in_normalized;
0088         geometry::convert(box_in, box_in_normalized);
0089 
0090         if (! is_inverse_spheroidal_coordinates(box_in))
0091         {
0092             strategy::normalize::spherical_box::apply(box_in, box_in_normalized);
0093         }
0094 
0095         geometry::detail::envelope::envelope_indexed_box_on_spheroid
0096             <
0097                 min_corner, dimension<BoxIn>::value
0098             >::apply(box_in_normalized, mbr);
0099 
0100         geometry::detail::envelope::envelope_indexed_box_on_spheroid
0101             <
0102                 max_corner, dimension<BoxIn>::value
0103             >::apply(box_in_normalized, mbr);
0104     }
0105 };
0106 
0107 }} // namespace detail::envelope
0108 #endif // DOXYGEN_NO_DETAIL
0109 
0110 
0111 namespace strategy { namespace expand
0112 {
0113 
0114 #ifndef DOXYGEN_NO_DETAIL
0115 namespace detail
0116 {
0117 
0118 struct box_on_spheroid
0119 {
0120     template <typename BoxOut, typename BoxIn>
0121     static inline void apply(BoxOut& box_out, BoxIn const& box_in)
0122     {
0123         // normalize both boxes and convert box-in to be of type of box-out
0124         BoxOut mbrs[2];
0125         geometry::detail::envelope::envelope_box_on_spheroid::apply(box_in, mbrs[0]);
0126         geometry::detail::envelope::envelope_box_on_spheroid::apply(box_out, mbrs[1]);
0127 
0128         // compute the envelope of the two boxes
0129         geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box_out);
0130     }
0131 };
0132 
0133 
0134 } // namespace detail
0135 #endif // DOXYGEN_NO_DETAIL
0136 
0137 
0138 struct spherical_box
0139     : detail::box_on_spheroid
0140 {};
0141 
0142 
0143 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0144 
0145 namespace services
0146 {
0147 
0148 template <typename CalculationType>
0149 struct default_strategy<box_tag, spherical_equatorial_tag, CalculationType>
0150 {
0151     typedef spherical_box type;
0152 };
0153 
0154 template <typename CalculationType>
0155 struct default_strategy<box_tag, spherical_polar_tag, CalculationType>
0156 {
0157     typedef spherical_box type;
0158 };
0159 
0160 template <typename CalculationType>
0161 struct default_strategy<box_tag, geographic_tag, CalculationType>
0162 {
0163     typedef spherical_box type;
0164 };
0165 
0166 } // namespace services
0167 
0168 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0169 
0170 
0171 }} // namespace strategy::expand
0172 
0173 }} // namespace boost::geometry
0174 
0175 #endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_BOX_HPP