envelope_box.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. // This file was modified by Oracle on 2015-2018.
  6. // Modifications copyright (c) 2015-2018, Oracle and/or its affiliates.
  7. // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
  8. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
  9. // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
  10. // Distributed under the Boost Software License, Version 1.0.
  11. // (See accompanying file LICENSE_1_0.txt or copy at
  12. // http://www.boost.org/LICENSE_1_0.txt)
  13. #ifndef BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_BOX_HPP
  14. #define BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_BOX_HPP
  15. #include <cstddef>
  16. #include <boost/geometry/core/cs.hpp>
  17. #include <boost/geometry/core/coordinate_dimension.hpp>
  18. #include <boost/geometry/core/coordinate_system.hpp>
  19. #include <boost/geometry/core/tags.hpp>
  20. #include <boost/geometry/views/detail/indexed_point_view.hpp>
  21. #include <boost/geometry/algorithms/detail/convert_point_to_point.hpp>
  22. #include <boost/geometry/algorithms/detail/normalize.hpp>
  23. #include <boost/geometry/algorithms/detail/envelope/transform_units.hpp>
  24. #include <boost/geometry/algorithms/dispatch/envelope.hpp>
  25. #include <boost/geometry/strategies/envelope.hpp>
  26. namespace boost { namespace geometry
  27. {
  28. #ifndef DOXYGEN_NO_DETAIL
  29. namespace detail { namespace envelope
  30. {
  31. template
  32. <
  33. std::size_t Index,
  34. std::size_t DimensionCount
  35. >
  36. struct envelope_indexed_box_on_spheroid
  37. {
  38. template <typename BoxIn, typename BoxOut>
  39. static inline void apply(BoxIn const& box_in, BoxOut& mbr)
  40. {
  41. // transform() does not work with boxes of dimension higher
  42. // than 2; to account for such boxes we transform the min/max
  43. // points of the boxes using the indexed_point_view
  44. detail::indexed_point_view<BoxIn const, Index> box_in_corner(box_in);
  45. detail::indexed_point_view<BoxOut, Index> mbr_corner(mbr);
  46. // first transform the units
  47. transform_units(box_in_corner, mbr_corner);
  48. // now transform the remaining coordinates
  49. detail::conversion::point_to_point
  50. <
  51. detail::indexed_point_view<BoxIn const, Index>,
  52. detail::indexed_point_view<BoxOut, Index>,
  53. 2,
  54. DimensionCount
  55. >::apply(box_in_corner, mbr_corner);
  56. }
  57. };
  58. }} // namespace detail::envelope
  59. #endif // DOXYGEN_NO_DETAIL
  60. namespace strategy { namespace envelope
  61. {
  62. struct spherical_box
  63. {
  64. template <typename BoxIn, typename BoxOut>
  65. static inline void apply(BoxIn const& box_in, BoxOut& mbr)
  66. {
  67. BoxIn box_in_normalized = box_in;
  68. if (!is_inverse_spheroidal_coordinates(box_in))
  69. {
  70. strategy::normalize::spherical_box::apply(box_in, box_in_normalized);
  71. }
  72. geometry::detail::envelope::envelope_indexed_box_on_spheroid
  73. <
  74. min_corner, dimension<BoxIn>::value
  75. >::apply(box_in_normalized, mbr);
  76. geometry::detail::envelope::envelope_indexed_box_on_spheroid
  77. <
  78. max_corner, dimension<BoxIn>::value
  79. >::apply(box_in_normalized, mbr);
  80. }
  81. };
  82. #ifndef DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  83. namespace services
  84. {
  85. template <typename CalculationType>
  86. struct default_strategy<box_tag, spherical_equatorial_tag, CalculationType>
  87. {
  88. typedef strategy::envelope::spherical_box type;
  89. };
  90. template <typename CalculationType>
  91. struct default_strategy<box_tag, spherical_polar_tag, CalculationType>
  92. {
  93. typedef strategy::envelope::spherical_box type;
  94. };
  95. template <typename CalculationType>
  96. struct default_strategy<box_tag, geographic_tag, CalculationType>
  97. {
  98. typedef strategy::envelope::spherical_box type;
  99. };
  100. }
  101. #endif // DOXYGEN_NO_STRATEGY_SPECIALIZATIONS
  102. }} // namespace strategy::envelope
  103. }} // namespace boost::geometry
  104. #endif // BOOST_GEOMETRY_STRATEGIES_SPHERICAL_ENVELOPE_BOX_HPP