expand_box.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. // Boost.Geometry (aka GGL, Generic Geometry Library)
  2. // Copyright (c) 2007-2015 Barend Gehrels, Amsterdam, the Netherlands.
  3. // Copyright (c) 2008-2015 Bruno Lalande, Paris, France.
  4. // Copyright (c) 2009-2015 Mateusz Loskot, London, UK.
  5. // Copyright (c) 2014-2015 Samuel Debionne, Grenoble, France.
  6. // This file was modified by Oracle on 2015, 2016, 2017, 2018.
  7. // Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
  8. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  9. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  10. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  11. // Distributed under the Boost Software License, Version 1.0.
  12. // (See accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_BOX_HPP
  15. #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_BOX_HPP
  16. #include <cstddef>
  17. #include <algorithm>
  18. #include <boost/geometry/algorithms/detail/envelope/box.hpp>
  19. #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
  20. #include <boost/geometry/strategies/expand.hpp>
  21. #include <boost/geometry/strategies/spherical/envelope_box.hpp>
  22. namespace boost { namespace geometry
  23. {
  24. namespace strategy { namespace expand
  25. {
  26. #ifndef DOXYGEN_NO_DETAIL
  27. namespace detail
  28. {
  29. struct box_on_spheroid
  30. {
  31. template <typename BoxOut, typename BoxIn>
  32. static inline void apply(BoxOut& box_out, BoxIn const& box_in)
  33. {
  34. // normalize both boxes and convert box-in to be of type of box-out
  35. BoxOut mbrs[2];
  36. strategy::envelope::spherical_box::apply(box_in, mbrs[0]);
  37. strategy::envelope::spherical_box::apply(box_out, mbrs[1]);
  38. // compute the envelope of the two boxes
  39. geometry::detail::envelope::envelope_range_of_boxes::apply(mbrs, box_out);
  40. }
  41. };
  42. } // namespace detail
  43. #endif // DOXYGEN_NO_DETAIL
  44. struct spherical_box
  45. : detail::box_on_spheroid
  46. {};
  47. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  48. namespace services
  49. {
  50. template <typename CalculationType>
  51. struct default_strategy<box_tag, spherical_equatorial_tag, CalculationType>
  52. {
  53. typedef spherical_box type;
  54. };
  55. template <typename CalculationType>
  56. struct default_strategy<box_tag, spherical_polar_tag, CalculationType>
  57. {
  58. typedef spherical_box type;
  59. };
  60. template <typename CalculationType>
  61. struct default_strategy<box_tag, geographic_tag, CalculationType>
  62. {
  63. typedef spherical_box type;
  64. };
  65. } // namespace services
  66. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  67. }} // namespace strategy::expand
  68. }} // namespace boost::geometry
  69. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_EXPAND_BOX_HPP