box.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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.
  7. // Modifications copyright (c) 2015-2017, 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_ALGORITHMS_DETAIL_EXPAND_BOX_HPP
  15. #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_BOX_HPP
  16. #include <cstddef>
  17. #include <algorithm>
  18. #include <boost/mpl/assert.hpp>
  19. #include <boost/type_traits/is_same.hpp>
  20. #include <boost/geometry/core/coordinate_dimension.hpp>
  21. #include <boost/geometry/core/tags.hpp>
  22. #include <boost/geometry/algorithms/detail/envelope/box.hpp>
  23. #include <boost/geometry/algorithms/detail/envelope/range_of_boxes.hpp>
  24. #include <boost/geometry/algorithms/detail/expand/indexed.hpp>
  25. #include <boost/geometry/algorithms/dispatch/expand.hpp>
  26. namespace boost { namespace geometry
  27. {
  28. #ifndef DOXYGEN_NO_DETAIL
  29. namespace detail { namespace expand
  30. {
  31. struct box_on_spheroid
  32. {
  33. template <typename BoxOut, typename BoxIn, typename Strategy>
  34. static inline void apply(BoxOut& box_out,
  35. BoxIn const& box_in,
  36. Strategy const& strategy)
  37. {
  38. // normalize both boxes and convert box-in to be of type of box-out
  39. BoxOut mbrs[2];
  40. detail::envelope::envelope_box_on_spheroid::apply(box_in, mbrs[0], strategy);
  41. detail::envelope::envelope_box_on_spheroid::apply(box_out, mbrs[1], strategy);
  42. // compute the envelope of the two boxes
  43. detail::envelope::envelope_range_of_boxes::apply(mbrs, box_out, strategy);
  44. }
  45. };
  46. }} // namespace detail::expand
  47. #endif // DOXYGEN_NO_DETAIL
  48. #ifndef DOXYGEN_NO_DISPATCH
  49. namespace dispatch
  50. {
  51. // Box + box -> new box containing two input boxes
  52. template
  53. <
  54. typename BoxOut, typename BoxIn,
  55. typename CSTagOut, typename CSTag
  56. >
  57. struct expand
  58. <
  59. BoxOut, BoxIn,
  60. box_tag, box_tag,
  61. CSTagOut, CSTag
  62. >
  63. {
  64. BOOST_MPL_ASSERT_MSG((false),
  65. NOT_IMPLEMENTED_FOR_THESE_COORDINATE_SYSTEMS,
  66. (types<CSTagOut, CSTag>()));
  67. };
  68. template <typename BoxOut, typename BoxIn>
  69. struct expand
  70. <
  71. BoxOut, BoxIn,
  72. box_tag, box_tag,
  73. cartesian_tag, cartesian_tag
  74. > : detail::expand::expand_indexed
  75. <
  76. 0, dimension<BoxIn>::value
  77. >
  78. {};
  79. template <typename BoxOut, typename BoxIn>
  80. struct expand
  81. <
  82. BoxOut, BoxIn,
  83. box_tag, box_tag,
  84. spherical_equatorial_tag, spherical_equatorial_tag
  85. > : detail::expand::box_on_spheroid
  86. {};
  87. template <typename BoxOut, typename BoxIn>
  88. struct expand
  89. <
  90. BoxOut, BoxIn,
  91. box_tag, box_tag,
  92. spherical_polar_tag, spherical_polar_tag
  93. > : detail::expand::box_on_spheroid
  94. {};
  95. template <typename BoxOut, typename BoxIn>
  96. struct expand
  97. <
  98. BoxOut, BoxIn,
  99. box_tag, box_tag,
  100. geographic_tag, geographic_tag
  101. > : detail::expand::box_on_spheroid
  102. {};
  103. } // namespace dispatch
  104. #endif // DOXYGEN_NO_DISPATCH
  105. }} // namespace boost::geometry
  106. #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_EXPAND_INDEXED_HPP