Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-01 08:16:32

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/util/is_inverse_spheroidal_coordinates.hpp>
0042 
0043 #include <boost/geometry/views/detail/indexed_point_view.hpp>
0044 
0045 namespace boost { namespace geometry
0046 {
0047 
0048 
0049 #ifndef DOXYGEN_NO_DETAIL
0050 namespace detail { namespace envelope
0051 {
0052 
0053 template
0054 <
0055     std::size_t Index,
0056     std::size_t DimensionCount
0057 >
0058 struct envelope_indexed_box_on_spheroid
0059 {
0060     template <typename BoxIn, typename BoxOut>
0061     static inline void apply(BoxIn const& box_in, BoxOut& mbr)
0062     {
0063         // transform() does not work with boxes of dimension higher
0064         // than 2; to account for such boxes we transform the min/max
0065         // points of the boxes using the indexed_point_view
0066         detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
0067         detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
0068 
0069         // first transform the units
0070         transform_units(box_in_corner, mbr_corner);
0071 
0072         // now transform the remaining coordinates
0073         detail::conversion::point_to_point
0074             <
0075                 detail::indexed_point_view<BoxIn const, Index>,
0076                 detail::indexed_point_view<BoxOut, Index>,
0077                 2,
0078                 DimensionCount
0079             >::apply(box_in_corner, mbr_corner);
0080     }
0081 };
0082 
0083 struct envelope_box_on_spheroid
0084 {
0085     template <typename BoxIn, typename BoxOut>
0086     static inline void apply(BoxIn const& box_in, BoxOut& mbr)
0087     {
0088         // BoxIn can be non-mutable
0089         typename helper_geometry<BoxIn>::type box_in_normalized;
0090         geometry::convert(box_in, box_in_normalized);
0091 
0092         if (! is_inverse_spheroidal_coordinates(box_in))
0093         {
0094             strategy::normalize::spherical_box::apply(box_in, box_in_normalized);
0095         }
0096 
0097         geometry::detail::envelope::envelope_indexed_box_on_spheroid
0098             <
0099                 min_corner, dimension<BoxIn>::value
0100             >::apply(box_in_normalized, mbr);
0101 
0102         geometry::detail::envelope::envelope_indexed_box_on_spheroid
0103             <
0104                 max_corner, dimension<BoxIn>::value
0105             >::apply(box_in_normalized, mbr);
0106     }
0107 };
0108 
0109 }} // namespace detail::envelope
0110 #endif // DOXYGEN_NO_DETAIL
0111 
0112 
0113 namespace strategy { namespace expand
0114 {
0115 
0116 #ifndef DOXYGEN_NO_DETAIL
0117 namespace detail
0118 {
0119 
0120 struct box_on_spheroid
0121 {
0122     template <typename BoxOut, typename BoxIn>
0123     static inline void apply(BoxOut& box_out, BoxIn const& box_in)
0124     {
0125         // normalize both boxes and convert box-in to be of type of box-out
0126         BoxOut mbrs[2];
0127         geometry::detail::envelope::envelope_box_on_spheroid::apply(box_in, mbrs[0]);
0128         geometry::detail::envelope::envelope_box_on_spheroid::apply(box_out, mbrs[1]);
0129 
0130         // compute the envelope of the two boxes
0131         geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box_out);
0132     }
0133 };
0134 
0135 
0136 } // namespace detail
0137 #endif // DOXYGEN_NO_DETAIL
0138 
0139 
0140 struct spherical_box
0141     : detail::box_on_spheroid
0142 {};
0143 
0144 
0145 #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0146 
0147 namespace services
0148 {
0149 
0150 template <typename CalculationType>
0151 struct default_strategy<box_tag, spherical_equatorial_tag, CalculationType>
0152 {
0153     typedef spherical_box type;
0154 };
0155 
0156 template <typename CalculationType>
0157 struct default_strategy<box_tag, spherical_polar_tag, CalculationType>
0158 {
0159     typedef spherical_box type;
0160 };
0161 
0162 template <typename CalculationType>
0163 struct default_strategy<box_tag, geographic_tag, CalculationType>
0164 {
0165     typedef spherical_box type;
0166 };
0167 
0168 } // namespace services
0169 
0170 #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
0171 
0172 
0173 }} // namespace strategy::expand
0174 
0175 }} // namespace boost::geometry
0176 
0177 #endif // BOOST_GEOMETRY_STRATEGY_SPHERICAL_EXPAND_BOX_HPP